autofs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH upstream] KASAN: slab-out-of-bounds Read in getname_kernel
@ 2018-07-01 22:04 tomas
  2018-07-02  1:10 ` Ian Kent
  0 siblings, 1 reply; 10+ messages in thread
From: tomas @ 2018-07-01 22:04 UTC (permalink / raw)
  To: raven, autofs; +Cc: linux-kernel, syzkaller

Hi,

I've looked into this issue found by Syzbot and I made a patch:

https://syzkaller.appspot.com/bug?id=d03abd8b42847f7f69b1d1d7f97208ae425b1163


The autofs subsystem does not check that the "path" parameter is present
within the "param" struct passed by the userspace in case the
AUTOFS_DEV_IOCTL_OPENMOUNT_CMD command is passed. Indeed, it assumes a
path is always provided (though a path is not always present, as per how
the struct is defined:
https://github.com/torvalds/linux/blob/master/include/uapi/linux/auto_dev-ioctl.h#L89).
Skipping the check provokes an oob read in "strlen", called by
"getname_kernel", in turn called by the autofs to assess the length of
the non-existing path.

To solve it, modify the "validate_dev_ioctl" function to check also that
a path has been provided if the command is AUTOFS_DEV_IOCTL_OPENMOUNT_CMD.


--- b/fs/autofs/dev-ioctl.c    2018-07-01 23:10:16.059728621 +0200
+++ a/fs/autofs/dev-ioctl.c    2018-07-01 23:10:24.311792133 +0200
@@ -136,6 +136,9 @@ static int validate_dev_ioctl(int cmd, s
             goto out;
         }
     }
+    /* AUTOFS_DEV_IOCTL_OPENMOUNT_CMD without path */
+    else if(_IOC_NR(cmd) == AUTOFS_DEV_IOCTL_OPENMOUNT_CMD)
+        return -EINVAL;
 
     err = 0;
 out:


Tested and solves the issue on Linus' main git tree.

Tomas



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-07-03  6:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-01 22:04 [PATCH upstream] KASAN: slab-out-of-bounds Read in getname_kernel tomas
2018-07-02  1:10 ` Ian Kent
2018-07-02  1:42   ` Ian Kent
2018-07-02  8:31     ` tomas
2018-07-02 10:20       ` Ian Kent
2018-07-02 11:55         ` tomas
2018-07-02 12:15           ` Dmitry Vyukov
2018-07-03  1:34             ` Ian Kent
2018-07-03  5:48               ` Dmitry Vyukov
2018-07-03  6:40                 ` Ian Kent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).