From e27a011ac06d8844d9ddbfb93ecb9d0965dd9f6a Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Fri, 29 Mar 2013 15:22:21 +0400 Subject: [PATCH] LU-3066 llite: fix crash in fdatasync(directory) kernel NULL pointer dereference for fdatasync(directory) fd = open("/mnt/lustre", O_RDONLY|O_NONBLOCK|O_DIRECTORY); fdatasync(fd); close(fd); Signed-off-by: Dmitry Eremin Change-Id: Ib14b25d1694131e1a65373654008b7f337ce959e Reviewed-on: http://review.whamcloud.com/5886 Tested-by: Hudson Reviewed-by: Faccini Bruno Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/llite/file.c | 8 ++++---- lustre/tests/sanity.sh | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index bd0e91f..fe4f03c 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2417,15 +2417,15 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, */ #ifdef HAVE_FILE_FSYNC_4ARGS -int ll_fsync(struct file *file, loff_t start, loff_t end, int data) +int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) { struct dentry *dentry = file->f_dentry; #elif defined(HAVE_FILE_FSYNC_2ARGS) -int ll_fsync(struct file *file, int data) +int ll_fsync(struct file *file, int datasync) { struct dentry *dentry = file->f_dentry; #else -int ll_fsync(struct file *file, struct dentry *dentry, int data) +int ll_fsync(struct file *file, struct dentry *dentry, int datasync) { #endif struct inode *inode = dentry->d_inode; @@ -2469,7 +2469,7 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data) if (!err) ptlrpc_req_finished(req); - if (data) { + if (datasync && S_ISREG(inode->i_mode)) { struct ll_file_data *fd = LUSTRE_FPRIVATE(file); err = cl_sync_file_range(inode, 0, OBD_OBJECT_EOF, diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index ae3151f..7685c77 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -6982,6 +6982,15 @@ test_118l() } run_test 118l "fsync dir =========" +test_118m() # LU-3066 +{ + [ $PARALLEL == "yes" ] && skip "skip parallel run" && return + test_mkdir -p $DIR/$tdir + $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed" + rm -rf $DIR/$tdir +} +run_test 118m "fdatasync dir =========" + [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT test_119a() # bug 11737 -- 1.8.3.1