[PATCH] vfs: added better file aio_read aio_write operations presence check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Marco Stornelli <marco.stornelli@xxxxxxxxx>

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@xxxxxxxxx>
---

--- 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)

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux