Linux CAN drivers development
 help / color / mirror / Atom feed
From: Hungyu Lin <dennylin0707@gmail.com>
To: socketcan@hartkopp.net, mkl@pengutronix.de
Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH net-next] can: gw: reject frame format changes in UID updates
Date: Thu,  3 Dec 2026 02:30:18 +0000	[thread overview]
Message-ID: <20261203023019.109-1-dennylin0707@gmail.com> (raw)

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)


             reply	other threads:[~2026-12-03  2:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  2:30 Hungyu Lin [this message]
2026-12-03  2:33 ` [PATCH net-next] can: gw: reject frame format changes in UID updates netdev-bot+sinfo

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=20261203023019.109-1-dennylin0707@gmail.com \
    --to=dennylin0707@gmail.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=socketcan@hartkopp.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox