|
|
3acf2d4 |
From 86e5aca7fa2927060839f3e3b40c8bd65a7e8d1e Mon Sep 17 00:00:00 2001
|
|
|
3acf2d4 |
From: Gen Zhang <blackgod016574@gmail.com>
|
|
|
3acf2d4 |
Date: Thu, 30 May 2019 09:10:30 +0800
|
|
|
3acf2d4 |
Subject: scsi: mpt3sas_ctl: fix double-fetch bug in _ctl_ioctl_main()
|
|
|
3acf2d4 |
|
|
|
3acf2d4 |
In _ctl_ioctl_main(), 'ioctl_header' is fetched the first time from
|
|
|
3acf2d4 |
userspace. 'ioctl_header.ioc_number' is then checked. The legal result is
|
|
|
3acf2d4 |
saved to 'ioc'. Then, in condition MPT3COMMAND, the whole struct is fetched
|
|
|
3acf2d4 |
again from the userspace. Then _ctl_do_mpt_command() is called, 'ioc' and
|
|
|
3acf2d4 |
'karg' as inputs.
|
|
|
3acf2d4 |
|
|
|
3acf2d4 |
However, a malicious user can change the 'ioc_number' between the two
|
|
|
3acf2d4 |
fetches, which will cause a potential security issues. Moreover, a
|
|
|
3acf2d4 |
malicious user can provide a valid 'ioc_number' to pass the check in first
|
|
|
3acf2d4 |
fetch, and then modify it in the second fetch.
|
|
|
3acf2d4 |
|
|
|
3acf2d4 |
To fix this, we need to recheck the 'ioc_number' in the second fetch.
|
|
|
3acf2d4 |
|
|
|
3acf2d4 |
Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
|
|
|
3acf2d4 |
Acked-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
|
|
|
3acf2d4 |
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
|
|
|
3acf2d4 |
---
|
|
|
3acf2d4 |
drivers/scsi/mpt3sas/mpt3sas_ctl.c | 4 ++++
|
|
|
3acf2d4 |
1 file changed, 4 insertions(+)
|
|
|
3acf2d4 |
|
|
|
3acf2d4 |
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
|
|
|
3acf2d4 |
index b2bb47c14d35..5181c03e82a6 100644
|
|
|
3acf2d4 |
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
|
|
|
3acf2d4 |
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
|
|
|
3acf2d4 |
@@ -2319,6 +2319,10 @@ _ctl_ioctl_main(struct file *file, unsigned int cmd, void __user *arg,
|
|
|
3acf2d4 |
break;
|
|
|
3acf2d4 |
}
|
|
|
3acf2d4 |
|
|
|
3acf2d4 |
+ if (karg.hdr.ioc_number != ioctl_header.ioc_number) {
|
|
|
3acf2d4 |
+ ret = -EINVAL;
|
|
|
3acf2d4 |
+ break;
|
|
|
3acf2d4 |
+ }
|
|
|
3acf2d4 |
if (_IOC_SIZE(cmd) == sizeof(struct mpt3_ioctl_command)) {
|
|
|
3acf2d4 |
uarg = arg;
|
|
|
3acf2d4 |
ret = _ctl_do_mpt_command(ioc, karg, &uarg->mf);
|
|
|
3acf2d4 |
--
|
|
|
3acf2d4 |
cgit 1.2-0.3.lf.el7
|
|
|
3acf2d4 |
|