public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vfs: added better file aio_read aio_write operations presence check
@ 2008-09-16  9:29 Marco Stornelli
  2008-09-16 11:03 ` Manish Katiyar
  2008-09-16 16:36 ` Christoph Hellwig
  0 siblings, 2 replies; 7+ messages in thread
From: Marco Stornelli @ 2008-09-16  9:29 UTC (permalink / raw)
  To: viro, linux-fsdevel; +Cc: linux-kernel

From: Marco Stornelli <marco.stornelli@gmail.com>

If a filesystem in the file operations specifies for read and write operations only do_sync_read and do_sync_write without 
init aio_read and aio_write, there will be a kernel oops, because the vfs code check the presence of (to read for example)
read OR aio_read method, then it calls read if it's pointer is not null. It's not sufficient because if the read function is 
actually a do_sync_read, it calls aio_read but without checking the presence. I think a BUG_ON check can be more useful.
Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
---

--- linux-2.6.26.5/fs/read_write.c.orig	2008-08-20 20:11:37.000000000 +0200
+++ linux-2.6.26.5/fs/read_write.c	2008-09-16 11:01:13.000000000 +0200
@@ -240,6 +240,7 @@ ssize_t do_sync_read(struct file *filp,
 	kiocb.ki_pos = *ppos;
 	kiocb.ki_left = len;
 
+	BUG_ON(!filp->f_op->aio_read);
 	for (;;) {
 		ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
 		if (ret != -EIOCBRETRY)
@@ -295,6 +296,7 @@ ssize_t do_sync_write(struct file *filp,
 	kiocb.ki_pos = *ppos;
 	kiocb.ki_left = len;
 
+	BUG_ON(!filp->f_op->aio_write);
 	for (;;) {
 		ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
 		if (ret != -EIOCBRETRY)


^ permalink raw reply	[flat|nested] 7+ messages in thread
[parent not found: <bcF2N-29W-1@gated-at.bofh.it>]

end of thread, other threads:[~2008-09-16 16:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-16  9:29 [PATCH] vfs: added better file aio_read aio_write operations presence check Marco Stornelli
2008-09-16 11:03 ` Manish Katiyar
2008-09-16 11:13   ` Marco Stornelli
2008-09-16 11:31     ` Manish Katiyar
2008-09-16 16:36 ` Christoph Hellwig
     [not found] <bcF2N-29W-1@gated-at.bofh.it>
     [not found] ` <bcGBv-4eJ-1@gated-at.bofh.it>
2008-09-16 15:36   ` Bodo Eggert
2008-09-16 15:41     ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox