* [PATCH can] can: netlink: can_changelink(): allow disabling of automatic restart
@ 2025-10-20 11:34 Marc Kleine-Budde
2025-10-20 15:26 ` Marc Kleine-Budde
0 siblings, 1 reply; 2+ messages in thread
From: Marc Kleine-Budde @ 2025-10-20 11:34 UTC (permalink / raw)
To: Vincent Mailhol
Cc: kernel, linux-can, linux-kernel, stable, Andrei Lalaev,
Marc Kleine-Budde
Since the commit c1f3f9797c1f ("can: netlink: can_changelink(): fix NULL
pointer deref of struct can_priv::do_set_mode"), the automatic restart
delay can only be set for devices that implement the restart handler struct
can_priv::do_set_mode. As it makes no sense to configure a automatic
restart for devices that doesn't support it.
However, since systemd commit 13ce5d4632e3 ("network/can: properly handle
CAN.RestartSec=0") [1], systemd-networkd correctly handles a restart delay
of "0" (i.e. the restart is disabled). Which means that a disabled restart
is always configured in the kernel.
On systems with both changes active this causes that CAN interfaces that
don't implement a restart handler cannot be brought up by systemd-networkd.
Solve this problem by allowing a delay of "0" to be configured, even if the
device does not implement a restart handler.
[1] https://github.com/systemd/systemd/commit/13ce5d4632e395521e6205c954493c7fc1c4c6e0
Cc: stable@vger.kernel.org
Cc: Andrei Lalaev <andrey.lalaev@gmail.com>
Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
Closes: https://lore.kernel.org/all/20251020-certain-arrogant-vole-of-sunshine-141841-mkl@pengutronix.de
Fixes: c1f3f9797c1f ("can: netlink: can_changelink(): fix NULL pointer deref of struct can_priv::do_set_mode")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/dev/netlink.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c
index 0591406b6f32..6f83b87d54fc 100644
--- a/drivers/net/can/dev/netlink.c
+++ b/drivers/net/can/dev/netlink.c
@@ -452,7 +452,9 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
}
if (data[IFLA_CAN_RESTART_MS]) {
- if (!priv->do_set_mode) {
+ unsigned int restart_ms = nla_get_u32(data[IFLA_CAN_RESTART_MS]);
+
+ if (restart_ms != 0 && !priv->do_set_mode) {
NL_SET_ERR_MSG(extack,
"Device doesn't support restart from Bus Off");
return -EOPNOTSUPP;
@@ -461,7 +463,7 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
/* Do not allow changing restart delay while running */
if (dev->flags & IFF_UP)
return -EBUSY;
- priv->restart_ms = nla_get_u32(data[IFLA_CAN_RESTART_MS]);
+ priv->restart_ms = restart_ms;
}
if (data[IFLA_CAN_RESTART]) {
---
base-commit: ffff5c8fc2af2218a3332b3d5b97654599d50cde
change-id: 20251020-netlink-fix-restart-6016f4d93e38
Best regards,
--
Marc Kleine-Budde <mkl@pengutronix.de>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH can] can: netlink: can_changelink(): allow disabling of automatic restart
2025-10-20 11:34 [PATCH can] can: netlink: can_changelink(): allow disabling of automatic restart Marc Kleine-Budde
@ 2025-10-20 15:26 ` Marc Kleine-Budde
0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2025-10-20 15:26 UTC (permalink / raw)
To: Vincent Mailhol; +Cc: kernel, linux-can, linux-kernel, stable, Andrei Lalaev
[-- Attachment #1: Type: text/plain, Size: 1775 bytes --]
On 20.10.2025 13:34:42, Marc Kleine-Budde wrote:
> Since the commit c1f3f9797c1f ("can: netlink: can_changelink(): fix NULL
> pointer deref of struct can_priv::do_set_mode"), the automatic restart
> delay can only be set for devices that implement the restart handler struct
> can_priv::do_set_mode. As it makes no sense to configure a automatic
> restart for devices that doesn't support it.
>
> However, since systemd commit 13ce5d4632e3 ("network/can: properly handle
> CAN.RestartSec=0") [1], systemd-networkd correctly handles a restart delay
> of "0" (i.e. the restart is disabled). Which means that a disabled restart
> is always configured in the kernel.
>
> On systems with both changes active this causes that CAN interfaces that
> don't implement a restart handler cannot be brought up by systemd-networkd.
>
> Solve this problem by allowing a delay of "0" to be configured, even if the
> device does not implement a restart handler.
>
> [1] https://github.com/systemd/systemd/commit/13ce5d4632e395521e6205c954493c7fc1c4c6e0
>
> Cc: stable@vger.kernel.org
> Cc: Andrei Lalaev <andrey.lalaev@gmail.com>
> Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Closes: https://lore.kernel.org/all/20251020-certain-arrogant-vole-of-sunshine-141841-mkl@pengutronix.de
> Fixes: c1f3f9797c1f ("can: netlink: can_changelink(): fix NULL pointer deref of struct can_priv::do_set_mode")
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Applied to linux-can.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-20 15:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-20 11:34 [PATCH can] can: netlink: can_changelink(): allow disabling of automatic restart Marc Kleine-Budde
2025-10-20 15:26 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).