Skip to contentSkip to conversation

RDMA/usnic: Bound buffer size to sizeof(buf) in flowinfo_read()

PATCH Applied Serhat Kumral 3 participants 3 messages Oct 17 – Oct 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/usnic: Bound buffer size to sizeof(buf) in flowinfo_read()

In flowinfo_read(), 'left' tracks the remaining space in the 512-byte stack buffer 'buf', but it is initialized to 'count'.

Initialize 'left' to sizeof(buf) instead of 'count'.

Fixes 9f637f793602 ("IB/usnic: Expose flows via debugfs")

---
found by smatch:
- drivers/infiniband/hw/usnic/usnic_debugfs.c:85 flowinfo_read() error: scnprintf() 'ptr' too small (512 vs 1000000000)

 drivers/infiniband/hw/usnic/usnic_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/usnic/usnic_debugfs.c +1 -1
index 10a8cd5ba076..ece7c6e71499 100644
@@ -76,7 +76,7 @@ static ssize_t flowinfo_read(struct file *f, char __user *data,
 
 	qp_flow = f->private_data;
 	ptr = buf;
-	left = count;
+	left = sizeof(buf);
 
 	if (*ppos > 0)
 		return 0;
Signature · 1 line
2.53.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines

In flowinfo_read(), 'left' tracks the remaining space in the 512-byte stack buffer 'buf', but it is initialized to 'count'.

Initialize 'left' to sizeof(buf) instead of 'count'.

Fixes 9f637f793602 ("IB/usnic: Expose flows via debugfs")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1