Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH next] RDMA/bnxt_re: Fix buffer overflow in debugfs code
@ 2025-02-07  9:16 Dan Carpenter
  2025-02-08 13:19 ` Selvin Xavier
  2025-02-09  9:58 ` Leon Romanovsky
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-02-07  9:16 UTC (permalink / raw)
  To: Selvin Xavier
  Cc: Kalesh AP, Jason Gunthorpe, Leon Romanovsky, linux-rdma,
	linux-kernel, kernel-janitors

Add some bounds checking to prevent memory corruption in
bnxt_re_cc_config_set().  This is debugfs code so the bug can only be
triggered by root.

Fixes: 656dff55da19 ("RDMA/bnxt_re: Congestion control settings using debugfs hook")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/infiniband/hw/bnxt_re/debugfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/hw/bnxt_re/debugfs.c b/drivers/infiniband/hw/bnxt_re/debugfs.c
index f4dd2fb51867..d7354e7753fe 100644
--- a/drivers/infiniband/hw/bnxt_re/debugfs.c
+++ b/drivers/infiniband/hw/bnxt_re/debugfs.c
@@ -285,6 +285,9 @@ static ssize_t bnxt_re_cc_config_set(struct file *filp, const char __user *buffe
 	u32 val;
 	int rc;
 
+	if (count >= sizeof(buf))
+		return -EINVAL;
+
 	if (copy_from_user(buf, buffer, count))
 		return -EFAULT;
 
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-09  9:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-07  9:16 [PATCH next] RDMA/bnxt_re: Fix buffer overflow in debugfs code Dan Carpenter
2025-02-08 13:19 ` Selvin Xavier
2025-02-09  9:58 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox