cifs: fix CIFS_ENUMERATE_SNAPSHOTS oops
authorDavid Disseldorp <ddiss@suse.de>
Wed, 3 May 2017 15:39:08 +0000 (17:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 May 2017 12:28:40 +0000 (14:28 +0200)
commit 6026685de33b0db5b2b6b0e9b41b3a1a3261033c upstream.

As with 618763958b22, an open directory may have a NULL private_data
pointer prior to readdir. CIFS_ENUMERATE_SNAPSHOTS must check for this
before dereference.

Fixes: 834170c85978 ("Enable previous version support")
Signed-off-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/cifs/ioctl.c

index 0015287..b52b7ff 100644 (file)
@@ -268,6 +268,8 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
                        rc = smb_mnt_get_fsinfo(xid, tcon, (void __user *)arg);
                        break;
                case CIFS_ENUMERATE_SNAPSHOTS:
+                       if (pSMBFile == NULL)
+                               break;
                        if (arg == 0) {
                                rc = -EINVAL;
                                goto cifs_ioc_exit;