Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] can: gw: reject frame format changes in UID updates
@ 2026-12-03  2:30 Hungyu Lin
  2026-12-03  2:33 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Hungyu Lin @ 2026-12-03  2:30 UTC (permalink / raw)
  To: socketcan, mkl; +Cc: linux-can, netdev

An existing gateway job keeps its original flags when its modifications
are replaced by a UID update. cgw_parse_attr() selects modification
functions using the flags from the update request. Changing
CGW_FLAGS_CAN_FD therefore installs CAN FD data operations on a
Classical CAN job. A CAN FD data modification can then touch 64 data
bytes on a frame that only carries 8.

Reject UID updates that change the CAN FD frame-format flag while leaving
updates to the other flags as before.

Fixes: 456a8a646b25 ("can: gw: add support for CAN FD frames")
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
 net/can/gw.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/can/gw.c b/net/can/gw.c
index 8a5327d8a00e8..ff2542f388b66 100644
--- a/net/can/gw.c
+++ b/net/can/gw.c
@@ -1122,8 +1122,9 @@ static int cgw_create_job(struct sk_buff *skb,  struct nlmsghdr *nlh,
 			if (old_cf->uid != mod->uid)
 				continue;
 
-			/* interfaces & filters must be identical */
-			if (memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw))) {
+			/* interfaces, filters and frame format must be identical */
+			if (((gwj->flags ^ r->flags) & CGW_FLAGS_CAN_FD) ||
+			    memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw))) {
 				err = -EINVAL;
 				goto out_free_cf;
 			}
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-03  2:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  2:30 [PATCH net-next] can: gw: reject frame format changes in UID updates Hungyu Lin
2026-12-03  2:33 ` netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox