From: Qinglang Miao <miaoqinglang@huawei.com>
To: Vineeth Vijayan <vneethv@linux.ibm.com>,
Peter Oberparleiter <oberpar@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>
Cc: <linux-s390@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Qinglang Miao" <miaoqinglang@huawei.com>
Subject: [PATCH] s390: cmf: fix use-after-free in enable_cmf
Date: Fri, 20 Nov 2020 15:48:50 +0800 [thread overview]
Message-ID: <20201120074850.31609-1-miaoqinglang@huawei.com> (raw)
kfree(cdev) is called in put_device in the error branch. So that
device_unlock(&cdev->dev) would raise a use-after-free bug. In fact,
there's no need to call device_unlock after put_device.
Fix it by adding simply return after put_device.
Fixes: a6ef15652d26 ("s390/cio: fix use after free in cmb processing")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
drivers/s390/cio/cmf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 72dd2471e..e95ca476f 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -1149,9 +1149,12 @@ int enable_cmf(struct ccw_device *cdev)
sysfs_remove_group(&cdev->dev.kobj, cmbops->attr_group);
cmbops->free(cdev);
}
+
out:
- if (ret)
+ if (ret) {
put_device(&cdev->dev);
+ return ret;
+ }
out_unlock:
device_unlock(&cdev->dev);
return ret;
--
2.23.0
next reply other threads:[~2020-11-20 7:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 7:48 Qinglang Miao [this message]
2020-11-20 8:00 ` Cornelia Huck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201120074850.31609-1-miaoqinglang@huawei.com \
--to=miaoqinglang@huawei.com \
--cc=borntraeger@de.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=oberpar@linux.ibm.com \
--cc=vneethv@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®