RDMA/usnic: Bound buffer size to sizeof(buf) in flowinfo_read()
Subsystems (2)
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'.
---
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
@@ -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
[email protected]
AI reviewSashiko 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")Signed-off-by Serhat Kumral <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Leon Romanovsky
AppliedQuoted 4 lines · Serhat Kumral
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'.
Applied, thanks!
[1/1] RDMA/usnic: Bound buffer size to sizeof(buf) in flowinfo_read()
https://git.kernel.org/rdma/rdma/c/9dd8b9a337af84
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>