projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a5bebc4
)
bpf: Fix SO_RCVBUF/SO_SNDBUF handling in _bpf_setsockopt().
author
Kuniyuki Iwashima
<kuniyu@amazon.co.jp>
Tue, 4 Jan 2022 01:31:48 +0000
(10:31 +0900)
committer
Alexei Starovoitov
<ast@kernel.org>
Wed, 5 Jan 2022 22:15:42 +0000
(14:15 -0800)
The commit
4057765f2dee
("sock: consistent handling of extreme
SO_SNDBUF/SO_RCVBUF values") added a change to prevent underflow
in setsockopt() around SO_SNDBUF/SO_RCVBUF.
This patch adds the same change to _bpf_setsockopt().
Fixes: 4057765f2dee ("sock: consistent handling of extreme SO_SNDBUF/SO_RCVBUF values")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link:
https://lore.kernel.org/bpf/20220104013153.97906-2-kuniyu@amazon.co.jp
net/core/filter.c
patch
|
blob
|
history
diff --git
a/net/core/filter.c
b/net/core/filter.c
index 606ab5a98a1af4a57bf6260051dca010c7a2c146..368fe28c8dc6e04a61082d49bed116107a5b846e 100644
(file)
--- a/
net/core/filter.c
+++ b/
net/core/filter.c
@@
-4741,12
+4741,14
@@
static int _bpf_setsockopt(struct sock *sk, int level, int optname,
switch (optname) {
case SO_RCVBUF:
val = min_t(u32, val, sysctl_rmem_max);
+ val = min_t(int, val, INT_MAX / 2);
sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
WRITE_ONCE(sk->sk_rcvbuf,
max_t(int, val * 2, SOCK_MIN_RCVBUF));
break;
case SO_SNDBUF:
val = min_t(u32, val, sysctl_wmem_max);
+ val = min_t(int, val, INT_MAX / 2);
sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
WRITE_ONCE(sk->sk_sndbuf,
max_t(int, val * 2, SOCK_MIN_SNDBUF));