Skip to content

Commit

Permalink
can: isotp: check CAN address family in isotp_bind()
Browse files Browse the repository at this point in the history
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: [email protected]
Signed-off-by: Oliver Hartkopp <[email protected]>
Link: https://lore.kernel.org/all/[email protected]
Signed-off-by: Marc Kleine-Budde <[email protected]>
  • Loading branch information
hartkopp authored and marckleinebudde committed Feb 2, 2023
1 parent 2a30b2b commit c6adf65
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/can/isotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,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);
Expand Down

0 comments on commit c6adf65

Please sign in to comment.