History

cgroup: Zero sized write should be no-op

Do not report failure on zero sized writes, and handle them as no-op. There's issues for example in case of writev() when there's iovec containing zero buffer as a first one. It's expected writev() on below example to successfully perform the write to specified writable cgroup file expecting integer value, and to return 2. For now it's returning value -1, and skipping the write: int writetest(int fd) { const char *buf1 = ""; const char *buf2 = "1\n"; struct iovec iov[2] = { { .iov_base = (void*)buf1, .iov_len = 0 }, { .iov_base = (void*)buf2, .iov_len = 2 } }; return writev(fd, iov, 2); } This patch fixes the issue by checking if there's nothing to write, and handling the write as no-op by just returning 0.

Jouni Roivas committed 6 years ago

Commit 65026da1 parent 95d32511 file · +3 −0Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/cgroup/cgroup.c+3−0
@@ -3681,6 +3681,9 @@ static ssize_t cgroup_file_write(struct kernfs_open_file *of, char *buf, · 3680 unmodified lines
3681 struct cgroup_subsys_state *css;3681 struct cgroup_subsys_state *css;
3682 int ret;3682 int ret;
3683 3683
3684 if (!nbytes)
3685 return 0;
3686
3684 /*3687 /*
3685 * If namespaces are delegation boundaries, disallow writes to3688 * If namespaces are delegation boundaries, disallow writes to
3686 * files in an non-init namespace root from inside the namespace3689 * files in an non-init namespace root from inside the namespace

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t