From: Dan Carpenter <dan.carpenter@oracle.com>
To: Saeed Mahameed <saeedm@nvidia.com>, Aya Levin <ayal@nvidia.com>
Cc: Leon Romanovsky <leon@kernel.org>,
Eran Ben Elisha <eranbe@mellanox.com>,
Moshe Shemesh <moshe@mellanox.com>,
Ariel Levkovich <lariel@mellanox.com>,
"Pavel Machek (CIP)" <pavel@denx.de>,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [PATCH mellanox-tree] net/mlx5: prevent an integer underflow in mlx5_perout_configure()
Date: Fri, 19 Feb 2021 12:57:52 +0300 [thread overview]
Message-ID: <YC+LoAcvcQSWLLKX@mwanda> (raw)
The value of "sec" comes from the user. Negative values will lead to
shift wrapping inside the perout_conf_real_time() function and triggger
a UBSan warning.
Add a check and return -EINVAL to prevent that from happening.
Fixes: 432119de33d9 ("net/mlx5: Add cyc2time HW translation mode support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Saeed, I think this goes through your git tree and you will send a pull
request to the networking?
From static analysis. Not tested.
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index b0e129d0f6d8..286824ca62b5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -516,7 +516,7 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp,
nsec = rq->perout.start.nsec;
sec = rq->perout.start.sec;
- if (rt_mode && sec > U32_MAX)
+ if (rt_mode && (sec < 0 || sec > U32_MAX))
return -EINVAL;
time_stamp = rt_mode ? perout_conf_real_time(sec, nsec) :
--
2.30.0
next reply other threads:[~2021-02-19 9:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-19 9:57 Dan Carpenter [this message]
2021-02-21 6:11 ` [PATCH mellanox-tree] net/mlx5: prevent an integer underflow in mlx5_perout_configure() Leon Romanovsky
2021-03-01 10:12 ` Eran Ben Elisha
2021-03-01 10:36 ` Dan Carpenter
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=YC+LoAcvcQSWLLKX@mwanda \
--to=dan.carpenter@oracle.com \
--cc=ayal@nvidia.com \
--cc=eranbe@mellanox.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lariel@mellanox.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=moshe@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=pavel@denx.de \
--cc=saeedm@nvidia.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).