2014-04-23 13:46:44

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH 0/2] fs/ext4: fix for aio_write related kernel crash in linux-next

Hi,

This might be already fixed.
I have noticed that with linux-next the kernel crashes when trying to use ext4
as rootfs.

Regards,
Peter
---
Peter Ujfalusi (2):
fs: read_write: Check ->aio_write in __kernel_write() and vfs_write()
ext4: Fix up the .write callback to use new_sync_write

fs/ext4/file.c | 2 +-
fs/read_write.c | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)

--
1.9.2


2014-04-23 13:46:56

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH 1/2] fs: read_write: Check ->aio_write in __kernel_write() and vfs_write()

Do similar checks as it has been done in vfs_read for the aio_write
callback.
ext4 for example does not provide aio_write callback causing NULL pointer
dereference in do_sync_write() without this check.

Signed-off-by: Peter Ujfalusi <[email protected]>
---
fs/read_write.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index b6336a54f70d..009d8542a889 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -500,8 +500,10 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
count = MAX_RW_COUNT;
if (file->f_op->write)
ret = file->f_op->write(file, p, count, pos);
- else
+ else if (file->f_op->aio_write)
ret = do_sync_write(file, p, count, pos);
+ else
+ ret = new_sync_write(file, p, count, pos);
set_fs(old_fs);
if (ret > 0) {
fsnotify_modify(file);
@@ -528,8 +530,10 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
file_start_write(file);
if (file->f_op->write)
ret = file->f_op->write(file, buf, count, pos);
- else
+ else if (file->f_op->aio_write)
ret = do_sync_write(file, buf, count, pos);
+ else
+ ret = new_sync_write(file, buf, count, pos);
if (ret > 0) {
fsnotify_modify(file);
add_wchar(current, ret);
--
1.9.2


2014-04-23 13:46:46

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH 2/2] ext4: Fix up the .write callback to use new_sync_write

Other filesystems has been updated but ext4 has been left out and since
ext4 does not provide aio_write callback we have kernel crash in
do_sync_write()

Signed-off-by: Peter Ujfalusi <[email protected]>
---
fs/ext4/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index f48a1c2838b6..708aad768199 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -587,7 +587,7 @@ loff_t ext4_llseek(struct file *file, loff_t offset, int whence)
const struct file_operations ext4_file_operations = {
.llseek = ext4_llseek,
.read = new_sync_read,
- .write = do_sync_write,
+ .write = new_sync_write,
.read_iter = generic_file_read_iter,
.write_iter = ext4_file_write_iter,
.unlocked_ioctl = ext4_ioctl,
--
1.9.2