From: Dan Carpenter <dan.carpenter@oracle.com>
To: Wu Hao <hao.wu@intel.com>, Xu Yilun <yilun.xu@intel.com>
Cc: Tom Rix <trix@redhat.com>, Moritz Fischer <mdf@kernel.org>,
Luwei Kang <luwei.kang@intel.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
linux-fpga@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] fpga: prevent integer overflow in dfl_feature_ioctl_set_irq()
Date: Thu, 1 Sep 2022 08:18:45 +0300 [thread overview]
Message-ID: <YxBAtYCM38dM7yzI@kili> (raw)
The "hdr.count * sizeof(s32)" multiplication can overflow on 32 bit
systems leading to memory corruption. Use array_size() to fix that.
Fixes: 322b598be4d9 ("fpga: dfl: introduce interrupt trigger setting API")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/fpga/dfl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index 5498bc337f8b..b9aae85ba930 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -1866,7 +1866,7 @@ long dfl_feature_ioctl_set_irq(struct platform_device *pdev,
return -EINVAL;
fds = memdup_user((void __user *)(arg + sizeof(hdr)),
- hdr.count * sizeof(s32));
+ array_size(hdr.count, sizeof(s32)));
if (IS_ERR(fds))
return PTR_ERR(fds);
--
2.35.1
next reply other threads:[~2022-09-01 5:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 5:18 Dan Carpenter [this message]
2022-09-03 17:52 ` [PATCH] fpga: prevent integer overflow in dfl_feature_ioctl_set_irq() Xu Yilun
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=YxBAtYCM38dM7yzI@kili \
--to=dan.carpenter@oracle.com \
--cc=hao.wu@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-fpga@vger.kernel.org \
--cc=luwei.kang@intel.com \
--cc=mdf@kernel.org \
--cc=mtosatti@redhat.com \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.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;
as well as URLs for NNTP newsgroup(s).