In the kernel implementation that handles the fcntl()
system call on a pipe, there's:
/*
* If trying to increase the pipe capacity, check that an
* unprivileged user is not trying to exceed various limits
* (soft limit check here, hard limit check just below).
* Decreasing the pipe capacity is always permitted, even
* if the user is currently over a limit.
*/
if (nr_slots > pipe->max_usage &&
size > pipe_max_size && !capable(CAP_SYS_RESOURCE))
return -EPERM;
user_bufs = account_pipe_buffers(pipe->user, pipe->nr_accounted, nr_slots);
if (nr_slots > pipe->max_usage &&
(too_many_pipe_buffers_hard(user_bufs) ||
too_many_pipe_buffers_soft(user_bufs)) &&
pipe_is_unprivileged_user()) {
ret = -EPERM;
goto out_revert_acct;
}
Those EPERM
s correspond to the "operation not permitted"
errors that you're seeing.
I think it's likely you're hitting an unprivileged user resource limit. You can do a man 7 pipe
and search for /proc file
for the details, but here's a quick summary:
/proc/sys/fs/pipe-max-size (since Linux 2.6.35)
The maximum size (in bytes) of individual pipes that can
be set by users without the CAP_SYS_RESOURCE capability.
/proc/sys/fs/pipe-user-pages-hard (since Linux 4.5)
The hard limit on the total size (in pages) of all pipes
created or set by a single unprivileged user (i.e., one
with neither the CAP_SYS_RESOURCE nor the CAP_SYS_ADMIN
capability).
/proc/sys/fs/pipe-user-pages-soft (since Linux 4.5)
The soft limit on the total size (in pages) of all pipes
created or set by a single unprivileged user (i.e., one
with neither the CAP_SYS_RESOURCE nor the CAP_SYS_ADMIN
capability).