summaryrefslogtreecommitdiffstats
path: root/net/can
diff options
context:
space:
mode:
authorOliver Hartkopp <socketcan@hartkopp.net>2023-01-04 21:18:44 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-10 09:33:51 +0100
commit9427584c2f153d0677ef3bad6f44028c60d728c4 (patch)
tree02f796c406c9019f959072757d90c3ca3dabefa0 /net/can
parent3b26e45ce1e156559ff72dcaa15f9e7d99c60497 (diff)
downloadlinux-stable-9427584c2f153d0677ef3bad6f44028c60d728c4.tar.gz
linux-stable-9427584c2f153d0677ef3bad6f44028c60d728c4.tar.bz2
linux-stable-9427584c2f153d0677ef3bad6f44028c60d728c4.zip
can: isotp: check CAN address family in isotp_bind()
[ Upstream commit c6adf659a8ba85913e16a571d5a9bcd17d3d1234 ] Add missing check to block non-AF_CAN binds. Syzbot created some code which matched the right sockaddr struct size but used AF_XDP (0x2C) instead of AF_CAN (0x1D) in the address family field: bind$xdp(r2, &(0x7f0000000540)={0x2c, 0x0, r4, 0x0, r2}, 0x10) ^^^^ This has no funtional impact but the userspace should be notified about the wrong address family field content. Link: https://syzkaller.appspot.com/text?tag=CrashLog&x=11ff9d8c480000 Reported-by: syzbot+5aed6c3aaba661f5b917@syzkaller.appspotmail.com Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/all/20230104201844.13168-1-socketcan@hartkopp.net Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/can')
-rw-r--r--net/can/isotp.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/can/isotp.c b/net/can/isotp.c
index fc81d77724a1..9bc344851704 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -1220,6 +1220,9 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len)
if (len < ISOTP_MIN_NAMELEN)
return -EINVAL;
+ if (addr->can_family != AF_CAN)
+ return -EINVAL;
+
/* sanitize tx CAN identifier */
if (tx_id & CAN_EFF_FLAG)
tx_id &= (CAN_EFF_FLAG | CAN_EFF_MASK);