Commit 1b93ae64cabe5e28dd5a1f35f96f938ca4f6ae20
1 parent
6732badee0
Exists in
master
and in
7 other branches
[NET]: Validate socket filters against BPF_MAXINSNS in one spot.
Currently the checks are scattered all over and this leads to inconsistencies and even cases where the check is not made. Based upon a patch from Kris Katterjohn. Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 2 changed files with 2 additions and 5 deletions Side-by-side Diff
drivers/net/ppp_generic.c
net/core/filter.c
... | ... | @@ -293,7 +293,7 @@ |
293 | 293 | struct sock_filter *ftest; |
294 | 294 | int pc; |
295 | 295 | |
296 | - if (((unsigned int)flen >= (~0U / sizeof(struct sock_filter))) || flen == 0) | |
296 | + if (flen == 0 || flen > BPF_MAXINSNS) | |
297 | 297 | return -EINVAL; |
298 | 298 | |
299 | 299 | /* check the filter code now */ |
... | ... | @@ -360,7 +360,7 @@ |
360 | 360 | int err; |
361 | 361 | |
362 | 362 | /* Make sure new filter is there and in the right amounts. */ |
363 | - if (fprog->filter == NULL || fprog->len > BPF_MAXINSNS) | |
363 | + if (fprog->filter == NULL) | |
364 | 364 | return -EINVAL; |
365 | 365 | |
366 | 366 | fp = sock_kmalloc(sk, fsize+sizeof(*fp), GFP_KERNEL); |