From: Christian Borntraeger <borntraeger@linux.ibm.com>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>, vneethv@linux.ibm.com
Cc: oberpar@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com,
agordeev@linux.ibm.com, svens@linux.ibm.com,
linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
Abaci Robot <abaci@linux.alibaba.com>
Subject: Re: [PATCH] s390/chsc: Switch over to memdup_user()
Date: Tue, 17 Jan 2023 08:37:39 +0100 [thread overview]
Message-ID: <41023c65-16db-5f8b-c2d9-c794b3536896@linux.ibm.com> (raw)
In-Reply-To: <20230117060443.62153-1-jiapeng.chong@linux.alibaba.com>
Am 17.01.23 um 07:04 schrieb Jiapeng Chong:
> Use memdup_user rather than duplicating its implementation, this is a
> little bit restricted to reduce false positives.
>
> ./drivers/s390/cio/chsc_sch.c:703:7-14: WARNING opportunity for memdup_user.
>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3785
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
> drivers/s390/cio/chsc_sch.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c
> index 180ab899289c..097769a955c3 100644
> --- a/drivers/s390/cio/chsc_sch.c
> +++ b/drivers/s390/cio/chsc_sch.c
> @@ -700,15 +700,11 @@ static int chsc_ioctl_conf_comp_list(void __user *user_ccl)
> sccl_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
> if (!sccl_area)
> return -ENOMEM;
> - ccl = kzalloc(sizeof(*ccl), GFP_KERNEL);
> - if (!ccl) {
> - ret = -ENOMEM;
> - goto out_free;
> - }
> - if (copy_from_user(ccl, user_ccl, sizeof(*ccl))) {
> - ret = -EFAULT;
> - goto out_free;
> - }
> +
> + ccl = memdup_user(user_ccl, sizeof(*ccl));
> + if (IS_ERR(ccl))
> + return PTR_ERR(ccl);
The old code did free sccl_area your code does not.
> +
> sccl_area->request.length = 0x0020;
> sccl_area->request.code = 0x0030;
> sccl_area->fmt = ccl->req.fmt;
prev parent reply other threads:[~2023-01-17 7:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 6:04 [PATCH] s390/chsc: Switch over to memdup_user() Jiapeng Chong
2023-01-17 7:37 ` Christian Borntraeger [this message]
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=41023c65-16db-5f8b-c2d9-c794b3536896@linux.ibm.com \
--to=borntraeger@linux.ibm.com \
--cc=abaci@linux.alibaba.com \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=jiapeng.chong@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=oberpar@linux.ibm.com \
--cc=svens@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