lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Thu, 8 Oct 2020 23:57:13 +0530 From: Harshal Chaudhari <harshalchau04@...il.com> To: gregkh@...uxfoundation.org Cc: arnd@...db.de, sudipm.mukherjee@...il.com, linux-kernel@...r.kernel.org, harshalchau04@...il.com Subject: [PATCH] char: ppdev: check if ioctl argument is present and valid Checking the argument passed to the ioctl is valid or not. if not then return -EINVAL. Signed-off-by: Harshal Chaudhari <harshalchau04@...il.com> --- drivers/char/ppdev.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 38b46c7d1737..001392980202 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -354,7 +354,7 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg) unsigned int minor = iminor(file_inode(file)); struct pp_struct *pp = file->private_data; struct parport *port; - void __user *argp = (void __user *)arg; + void __user *argp = NULL; struct ieee1284_info *info; unsigned char reg; unsigned char mask; @@ -364,6 +364,16 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct timespec64 ts; int ret; + if (_IOC_TYPE(cmd) != PP_IOCTL) + return -ENOTTY; + + /* check if ioctl argument is present and valid */ + if (_IOC_DIR(cmd) != _IOC_NONE) { + argp = (void __user *)arg; + if (!argp) + return -EINVAL; + } + /* First handle the cases that don't take arguments. */ switch (cmd) { case PPCLAIM: -- 2.17.1
Powered by blists - more mailing lists