Skip to content

Commit

Permalink
can: isotp: return -EADDRNOTAVAIL when reading from unbound socket
Browse files Browse the repository at this point in the history
[ Upstream commit 30ffd53 ]

When reading from an unbound can-isotp socket the syscall blocked
indefinitely. As unbound sockets (without given CAN address information)
do not make sense anyway we directly return -EADDRNOTAVAIL on read()
analogue to the known behavior from sendmsg().

Fixes: e057dd3 ("can: add ISO 15765-2:2016 transport protocol")
Link: linux-can/can-utils#349
Link: https://lore.kernel.org/all/20220316164258.54155-2-socketcan@hartkopp.net
Suggested-by: Derek Will <derekrobertwill@gmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
hartkopp authored and gregkh committed Apr 8, 2022
1 parent 10cdfbc commit 1866771
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/can/isotp.c
Expand Up @@ -1005,12 +1005,16 @@ static int isotp_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
{
struct sock *sk = sock->sk;
struct sk_buff *skb;
struct isotp_sock *so = isotp_sk(sk);
int err = 0;
int noblock;

noblock = flags & MSG_DONTWAIT;
flags &= ~MSG_DONTWAIT;

if (!so->bound)
return -EADDRNOTAVAIL;

skb = skb_recv_datagram(sk, flags, noblock, &err);
if (!skb)
return err;
Expand Down

0 comments on commit 1866771

Please sign in to comment.