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
stable inclusion
from stable-v5.10.110
commit f402c498651993de361f349ac0cedb9f8622319f
bugzilla: https://gitee.com/openeuler/kernel/issues/I574AL

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f402c498651993de361f349ac0cedb9f8622319f

--------------------------------

[ 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/[email protected]
Suggested-by: Derek Will <[email protected]>
Signed-off-by: Oliver Hartkopp <[email protected]>
Signed-off-by: Marc Kleine-Budde <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Yu Liao <[email protected]>
Reviewed-by: Wei Li <[email protected]>
Signed-off-by: Zheng Zengkai <[email protected]>
  • Loading branch information
hartkopp authored and Zhengzengkai committed Jul 5, 2022
1 parent 0768115 commit 7f0d279
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/can/isotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7f0d279

Please sign in to comment.