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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 20 Jun 2021 14:38:42 +0200
From:   Norbert Slusarek <nslusarek@....net>
To:     netdev@...r.kernel.org
Cc:     ore@...gutronix.de, mkl@...gutronix.de, socketcan@...tkopp.net,
        davem@...emloft.net, kuba@...nel.org, linux-can@...r.kernel.org,
        nslusarek@....net, kernel@...gutronix.de
Subject: [PATCH] can: j1939: prevent allocation of j1939 filter for optlen = 0

If optval != NULL and optlen = 0 are specified for SO_J1939_FILTER in
j1939_sk_setsockopt(), memdup_sockptr() will return ZERO_PTR for 0 size
allocation. The new filter will be mistakenly assigned ZERO_PTR.
This patch checks for optlen != 0 and filter will be assigned NULL
in case of optlen = 0.

Fixes: a7b75c5a8c41 ("net: pass a sockptr_t into ->setsockopt")
Signed-off-by: Norbert Slusarek <nslusarek@....net>

---
 net/can/j1939/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
index 56aa66147d5a..ff20cb629200 100644
--- a/net/can/j1939/socket.c
+++ b/net/can/j1939/socket.c
@@ -673,7 +673,7 @@ static int j1939_sk_setsockopt(struct socket *sock, int level, int optname,

 	switch (optname) {
 	case SO_J1939_FILTER:
-		if (!sockptr_is_null(optval)) {
+		if (!sockptr_is_null(optval) && optlen != 0) {
 			struct j1939_filter *f;
 			int c;

--
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ