Linux CAN drivers development
 help / color / mirror / Atom feed
* [PATCH net-next v2] can: gw: reject frame format changes in UID updates
@ 2026-12-04  7:07 Hungyu Lin
  2026-12-04  7:12 ` netdev-bot+sinfo
  2026-12-04  8:25 ` Oliver Hartkopp
  0 siblings, 2 replies; 3+ messages in thread
From: Hungyu Lin @ 2026-12-04  7:07 UTC (permalink / raw)
  To: socketcan, mkl; +Cc: linux-can, netdev

UID updates replace only the modification rules of an existing gateway
job. The job keeps its original flags, while cgw_parse_attr() selects
modification functions using the flags supplied with the update. A
request that changes CGW_FLAGS_CAN_FD can therefore install CAN FD data
operations on a Classical CAN job.

Require all flags to match when updating a job by UID. Changes to the
other flags are equally ineffective because the job keeps its original
settings.

Fixes: 456a8a646b25 ("can: gw: add support for CAN FD frames")
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
Changes in v2:
- Reject changes to all flags, as suggested by Oliver Hartkopp.

 net/can/gw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/can/gw.c b/net/can/gw.c
index 8a5327d8a00e8..14fa2e5ef505c 100644
--- a/net/can/gw.c
+++ b/net/can/gw.c
@@ -1123,7 +1123,8 @@ static int cgw_create_job(struct sk_buff *skb,  struct nlmsghdr *nlh,
 				continue;
 
 			/* interfaces & filters must be identical */
-			if (memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw))) {
+			if (gwj->flags != r->flags ||
+			    memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw))) {
 				err = -EINVAL;
 				goto out_free_cf;
 			}
-- 
2.50.1 (Apple Git-155)


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

* Re: [PATCH net-next v2] can: gw: reject frame format changes in UID updates
  2026-12-04  7:07 [PATCH net-next v2] can: gw: reject frame format changes in UID updates Hungyu Lin
@ 2026-12-04  7:12 ` netdev-bot+sinfo
  2026-12-04  8:25 ` Oliver Hartkopp
  1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-12-04  7:12 UTC (permalink / raw)
  To: Hungyu Lin; +Cc: socketcan, mkl, linux-can, netdev

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

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

* Re: [PATCH net-next v2] can: gw: reject frame format changes in UID updates
  2026-12-04  7:07 [PATCH net-next v2] can: gw: reject frame format changes in UID updates Hungyu Lin
  2026-12-04  7:12 ` netdev-bot+sinfo
@ 2026-12-04  8:25 ` Oliver Hartkopp
  1 sibling, 0 replies; 3+ messages in thread
From: Oliver Hartkopp @ 2026-12-04  8:25 UTC (permalink / raw)
  To: Hungyu Lin, mkl; +Cc: linux-can, netdev

Hello Hungyu,

On 04.12.26 08:07, Hungyu Lin wrote:
> UID updates replace only the modification rules of an existing gateway
> job. The job keeps its original flags, while cgw_parse_attr() selects
> modification functions using the flags supplied with the update. A
> request that changes CGW_FLAGS_CAN_FD can therefore install CAN FD data
> operations on a Classical CAN job.
> 
> Require all flags to match when updating a job by UID. Changes to the
> other flags are equally ineffective because the job keeps its original
> settings.
> 
> Fixes: 456a8a646b25 ("can: gw: add support for CAN FD frames")

Please add

Cc: stable@vger.kernel.org

here.

> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
> ---
> Changes in v2:
> - Reject changes to all flags, as suggested by Oliver Hartkopp.
> 
>   net/can/gw.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/can/gw.c b/net/can/gw.c
> index 8a5327d8a00e8..14fa2e5ef505c 100644
> --- a/net/can/gw.c
> +++ b/net/can/gw.c
> @@ -1123,7 +1123,8 @@ static int cgw_create_job(struct sk_buff *skb,  struct nlmsghdr *nlh,
>   				continue;
>   
>   			/* interfaces & filters must be identical */
> -			if (memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw))) {
> +			if (gwj->flags != r->flags ||
> +			    memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw))) {

I've looked into cgw_remove_job() where limit_hops is also checked to 
identify the gw job:

         if (gwj->flags != r->flags)
                 continue;

         if (gwj->limit_hops != limhops)
                 continue;

Therefore I would suggest to be consistent in the UID update:

	if (gwj->flags != r->flags ||
	    gwj->limit_hops != limhops ||
	    memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw))) {


>   				err = -EINVAL;
>   				goto out_free_cf;
>   			}

Many thanks,
Oliver


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

end of thread, other threads:[~2026-12-04  8:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  7:07 [PATCH net-next v2] can: gw: reject frame format changes in UID updates Hungyu Lin
2026-12-04  7:12 ` netdev-bot+sinfo
2026-12-04  8:25 ` Oliver Hartkopp

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