Skip to content

Commit e0b057b

Browse files
Tetsuo Handaxjamesmorris
authored andcommitted
TOMOYO: Fix incomplete read after seek.
Commit f23571e "TOMOYO: Copy directly to userspace buffer." introduced tomoyo_flush() that flushes data to be read as soon as possible. tomoyo_select_domain() (which is called by write()) enqueues data which meant to be read by next read(), but previous read()'s read buffer's size was not cleared. As a result, since 2.6.36, sequence like char *cp = "select global-pid=1\n"; read(fd, buf1, sizeof(buf1)); write(fd, cp, strlen(cp)); read(fd, buf2, sizeof(buf2)); causes enqueued data to be flushed to buf1 rather than buf2. Fix this bug by clearing read buffer's size upon write() request. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
1 parent 6afcb3b commit e0b057b

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎security/tomoyo/common.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,6 +2591,7 @@ ssize_t tomoyo_write_control(struct tomoyo_io_buffer *head,
25912591
return -EFAULT;
25922592
if (mutex_lock_interruptible(&head->io_sem))
25932593
return -EINTR;
2594+
head->read_user_buf_avail = 0;
25942595
idx = tomoyo_read_lock();
25952596
/* Read a line and dispatch it to the policy handler. */
25962597
while (avail_len > 0) {

0 commit comments

Comments
 (0)