All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] FS: Fixed buffer overflow issue in seq_read()
@ 2013-11-19  0:18 Charley (Hao Chuan) Chu
  2013-11-19  0:38 ` Linus Torvalds
  2013-11-19  1:20 ` Al Viro
  0 siblings, 2 replies; 8+ messages in thread
From: Charley (Hao Chuan) Chu @ 2013-11-19  0:18 UTC (permalink / raw)
  To: linux-fsdevel@vger.kernel.org, Alexander Viro
  Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org

The buffer count is not initialized when a new buffer is allocated. 

It cause kernel crash with "Unable to handle kernel paging
request..." error in __copy_to_user_std(). It happens when a 
memory allocation failure in the while(1)-loop, which left the 
buffer count (m->count) is larger than buffer size 
(m->size).  

This patch is currently against a linux 3.12 kernel

Signed-off-by: Charley Chu charley.chu@broadcom.com
---
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 1cd2388..480a341 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -191,6 +191,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
 
        /* grab buffer if we didn't have one */
        if (!m->buf) {
+               m->count = m->from = 0;
                m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
                if (!m->buf)
                        goto Enomem;




^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-11-19 21:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-19  0:18 [PATCH] FS: Fixed buffer overflow issue in seq_read() Charley (Hao Chuan) Chu
2013-11-19  0:38 ` Linus Torvalds
2013-11-19  1:26   ` Al Viro
2013-11-19  1:20 ` Al Viro
2013-11-19  3:13   ` Linus Torvalds
2013-11-19  3:28     ` Al Viro
2013-11-19  3:33       ` Linus Torvalds
2013-11-19 21:22     ` Charley (Hao Chuan) Chu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.