lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1548218239-31223-1-git-send-email-laoar.shao@gmail.com>
Date:   Wed, 23 Jan 2019 12:37:19 +0800
From:   Yafang Shao <laoar.shao@...il.com>
To:     kafai@...com, brakmo@...com, ast@...nel.org, daniel@...earbox.net
Cc:     netdev@...r.kernel.org, shaoyafang@...iglobal.com,
        Yafang Shao <laoar.shao@...il.com>
Subject: [PATCH v2 bpf] bpf: sock recvbuff must be limited by rmem_max in bpf_setsockopt()

When sock recvbuff is set by bpf_setsockopt(), the value must by limited
by rmem_max.
It is the same with sendbuff.

Fixes: 8c4b4c7e9ff0 ("bpf: Add setsockopt helper function to bpf")
Acked-by: Martin KaFai Lau <kafai@...com>
Acked-by: Lawrence Brakmo <brakmo@...com>
Signed-off-by: Yafang Shao <laoar.shao@...il.com>
---
 net/core/filter.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index 7559d68..7a54dc1 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4112,10 +4112,12 @@ static unsigned long bpf_xdp_copy(void *dst_buff, const void *src_buff,
 		/* Only some socketops are supported */
 		switch (optname) {
 		case SO_RCVBUF:
+			val = min_t(u32, val, sysctl_rmem_max);
 			sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
 			sk->sk_rcvbuf = max_t(int, val * 2, SOCK_MIN_RCVBUF);
 			break;
 		case SO_SNDBUF:
+			val = min_t(u32, val, sysctl_wmem_max);
 			sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
 			sk->sk_sndbuf = max_t(int, val * 2, SOCK_MIN_SNDBUF);
 			break;
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ