Commit d0257e0
RDMA/uverbs: Prevent integer overflow issue
In the expression "cmd.wqe_size * cmd.wr_count", both variables are u32
values that come from the user so the multiplication can lead to integer
wrapping. Then we pass the result to uverbs_request_next_ptr() which also
could potentially wrap. The "cmd.sge_count * sizeof(struct ib_uverbs_sge)"
multiplication can also overflow on 32bit systems although it's fine on
64bit systems.
This patch does two things. First, I've re-arranged the condition in
uverbs_request_next_ptr() so that the use controlled variable "len" is on
one side of the comparison by itself without any math. Then I've modified
all the callers to use size_mul() for the multiplications.
Fixes: 67cdb40 ("[IB] uverbs: Implement more commands")
Cc: [email protected]
Signed-off-by: Dan Carpenter <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Leon Romanovsky <[email protected]>1 parent eb867d7 commit d0257e0
1 file changed
+9
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
2008 | 2008 | | |
2009 | 2009 | | |
2010 | 2010 | | |
2011 | | - | |
| 2011 | + | |
| 2012 | + | |
2012 | 2013 | | |
2013 | 2014 | | |
2014 | | - | |
2015 | | - | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
2016 | 2018 | | |
2017 | 2019 | | |
2018 | 2020 | | |
| |||
2198 | 2200 | | |
2199 | 2201 | | |
2200 | 2202 | | |
2201 | | - | |
| 2203 | + | |
2202 | 2204 | | |
2203 | 2205 | | |
2204 | | - | |
2205 | | - | |
| 2206 | + | |
| 2207 | + | |
2206 | 2208 | | |
2207 | 2209 | | |
2208 | 2210 | | |
| |||
0 commit comments