From: Oliver Hartkopp <socketcan@hartkopp.net>
To: linux-can@vger.kernel.org
Cc: Oliver Hartkopp <socketcan@hartkopp.net>, stable@vger.kernel.org
Subject: [PATCH v8 5/7] can: isotp: check the return values of can_rx_register() in isotp_bind()
Date: Fri, 23 Oct 2026 14:17:59 +0200 [thread overview]
Message-ID: <20261023121801.3052075-6-socketcan@hartkopp.net> (raw)
In-Reply-To: <20261023121801.3052075-1-socketcan@hartkopp.net>
isotp_bind() ignores the return values of can_rx_register() for the RX
and the echo receiver and binds the socket anyway. When a receiver can
not be allocated, bind() succeeds without this receiver, so the socket
does not receive frames or its transmissions time out. isotp_release()
and isotp_notify() later try to remove the missing receiver, which
triggers the "receive list entry not found" warning in
can_rx_unregister().
As the device has been checked before and RTNL prevents a namespace
change during bind(), only -ENOMEM can be returned here.
Check the return values, remove an already registered RX receiver when
the echo receiver can not be registered and return the error.
Fixes: e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol")
Cc: stable@vger.kernel.org
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
---
net/can/isotp.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/net/can/isotp.c b/net/can/isotp.c
index 1a272ce6a2bd..da80ef606ce0 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -1622,20 +1622,29 @@ static int isotp_bind(struct socket *sock, struct sockaddr_unsized *uaddr, int l
if (!(dev->flags & IFF_UP))
notify_enetdown = 1;
ifindex = dev->ifindex;
- if (isotp_register_rxid(so))
- can_rx_register(net, dev, rx_id, SINGLE_MASK(rx_id),
- isotp_rcv, sk, sock_i_ino(sk), sk);
+ if (isotp_register_rxid(so)) {
+ err = can_rx_register(net, dev, rx_id, SINGLE_MASK(rx_id),
+ isotp_rcv, sk, sock_i_ino(sk), sk);
+ if (err)
+ goto out_put_dev;
+ }
/* no consecutive frame echo skb in flight */
WRITE_ONCE(so->cfecho, 0);
/* register for echo skb's */
- can_rx_register(net, dev, tx_id, SINGLE_MASK(tx_id),
- isotp_rcv_echo, sk, sock_i_ino(sk), sk);
+ err = can_rx_register(net, dev, tx_id, SINGLE_MASK(tx_id),
+ isotp_rcv_echo, sk, sock_i_ino(sk), sk);
+ if (err) {
+ if (isotp_register_rxid(so))
+ can_rx_unregister(net, dev, rx_id, SINGLE_MASK(rx_id),
+ isotp_rcv, sk);
+ goto out_put_dev;
+ }
/* switch to new settings */
so->ifindex = ifindex;
so->rxid = rx_id;
so->txid = tx_id;
--
2.43.0
next prev parent reply other threads:[~2026-10-23 12:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 12:17 [PATCH v8 0/7] can: protect the receive lists with a per-device lock Oliver Hartkopp
2026-10-23 12:17 ` [PATCH v8 1/7] can: proc: reset pkg_stats atomics individually Oliver Hartkopp
2026-10-23 12:17 ` [PATCH v8 2/7] can: proc: skip stats calculation after reset in can_stat_update() Oliver Hartkopp
2026-10-23 12:17 ` [PATCH v8 3/7] can: proc: remove pointers from CAN specific proc output Oliver Hartkopp
2026-10-23 12:17 ` [PATCH v8 4/7] can: replace ARPHRD_CAN type checks with can_get_ml_priv() Oliver Hartkopp
2026-10-23 12:17 ` Oliver Hartkopp [this message]
2026-10-23 12:18 ` [PATCH v8 6/7] can: protect the receive lists with a per-device lock Oliver Hartkopp
2026-10-23 12:18 ` [PATCH v8 7/7] can: raw, isotp: copy socket options outside of lock_sock() Oliver Hartkopp
2026-10-25 11:28 ` [PATCH v8 0/7] can: protect the receive lists with a per-device lock Marc Kleine-Budde
2026-10-25 18:55 ` Oliver Hartkopp
2026-10-25 19:06 ` Marc Kleine-Budde
2026-10-25 19:16 ` Oliver Hartkopp
2026-10-25 19:19 ` Marc Kleine-Budde
2026-10-25 19:22 ` Oliver Hartkopp
2026-10-25 19:43 ` Marc Kleine-Budde
2026-10-25 19:51 ` Oliver Hartkopp
2026-10-25 20:01 ` Marc Kleine-Budde
2026-10-25 20:02 ` Marc Kleine-Budde
2026-10-25 11:43 ` Oliver Hartkopp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261023121801.3052075-6-socketcan@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=linux-can@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.