diff options
author | Oliver Hartkopp <socketcan@hartkopp.net> | 2022-03-16 19:42:57 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-04-08 15:40:21 +0300 |
commit | f402c498651993de361f349ac0cedb9f8622319f (patch) | |
tree | e21e53349079c7211c1677d23cdaabee9b35f757 /net/can | |
parent | 8a9d996d4edd1fb28dd87a82ec40740de847ce9b (diff) | |
download | linux-f402c498651993de361f349ac0cedb9f8622319f.tar.xz |
can: isotp: return -EADDRNOTAVAIL when reading from unbound socket
[ Upstream commit 30ffd5332e06316bd69a654c06aa033872979b7c ]
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: e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol")
Link: https://github.com/linux-can/can-utils/issues/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>
Diffstat (limited to 'net/can')
-rw-r--r-- | net/can/isotp.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/net/can/isotp.c b/net/can/isotp.c index 88388ac30aa6..aad4ca62c9fd 100644 --- a/net/can/isotp.c +++ b/net/can/isotp.c @@ -1003,12 +1003,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; |