From: sashiko-bot@kernel.org
To: "Filippo Storniolo" <fstornio@redhat.com>
Cc: "Oleksij Rempel" <o.rempel@pengutronix.de>,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
linux-can@vger.kernel.org
Subject: Re: [PATCH can-next v2 3/3] can: add can diag interface
Date: Thu, 06 Aug 2026 13:51:22 +0000 [thread overview]
Message-ID: <20260806135125.343781F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806-feat-can-diag-v2-3-832597ee4cb9@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Netlink UAPI attributes embed binary structures with implicit compiler padding
--
--- Patch [3]: [PATCH can-next v2 3/3] can: add can diag interface ---
commit 98771deaa2e2d4a790b170eb8967f6122234dec8
Author: Filippo Storniolo <fstornio@redhat.com>
can: add can diag interface
This commit adds the can_diag interface for querying CAN sockets from
userspace using the ss tool. It defines the userspace ABI including netlink
request and response structures to expose socket properties.
> diff --git a/include/uapi/linux/can/diag.h b/include/uapi/linux/can/diag.h
> new file mode 100644
> index 0000000000000..7f99f85c42425
> --- /dev/null
> +++ b/include/uapi/linux/can/diag.h
[ ... ]
> +struct can_diag_j1939_addr {
> + __u64 name;
> + __u32 pgn;
> + __u8 addr;
> +};
[Severity: High]
Does this structure introduce implicit compiler padding? With a 64-bit, 32-bit,
and 8-bit field, it appears there are 3 bytes of implicit padding at the end.
This can lead to architecture-dependent layout mismatches in the UAPI.
Additionally, modern Netlink design rules strongly discourage passing binary
structures directly inside attributes. Should these structure members be broken
out into individual Netlink attributes to ensure proper validation and future
extensibility?
> diff --git a/net/can/diag.c b/net/can/diag.c
> new file mode 100644
> index 0000000000000..e9132ba3f8cc5
> --- /dev/null
> +++ b/net/can/diag.c
[ ... ]
> +static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
[ ... ]
> + case CAN_J1939:
> + {
> + struct can_diag_j1939_addr j1939_addr;
> +
> + memset(&j1939_addr, 0, sizeof(j1939_addr));
> +
> + j1939_addr.name = can_addr.can_addr.j1939.name;
> + j1939_addr.pgn = can_addr.can_addr.j1939.pgn;
> + j1939_addr.addr = can_addr.can_addr.j1939.addr;
> +
> + err = nla_put(skb, CAN_DIAG_J1939_ADDR, sizeof(struct can_diag_j1939_addr),
> + &j1939_addr);
> + }
[Severity: High]
Does sending this binary structure directly as a raw attribute prevent proper
validation and extensibility?
Once this ships in a release, the UAPI is frozen and this layout becomes
unfixable. Could this be changed to send the individual fields as separate,
strongly-typed attributes instead of embedding the C structure directly?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260806-feat-can-diag-v2-0-832597ee4cb9@redhat.com?part=3
next prev parent reply other threads:[~2026-08-06 13:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 13:14 [PATCH can-next v2 0/3] Introduce diag support for CAN Filippo Storniolo
2026-08-06 13:14 ` [PATCH can-next v2 1/3] af_can: ensure sk_protocol is always set on socket creation Filippo Storniolo
2026-08-06 13:14 ` [PATCH can-next v2 2/3] af_can: store socket pointers in struct netns_can Filippo Storniolo
2026-08-06 14:16 ` Marc Kleine-Budde
2026-08-06 15:15 ` Oliver Hartkopp
2026-08-06 16:41 ` Marc Kleine-Budde
2026-08-06 13:14 ` [PATCH can-next v2 3/3] can: add can diag interface Filippo Storniolo
2026-08-06 13:51 ` sashiko-bot [this message]
2026-08-06 13:54 ` Marc Kleine-Budde
2026-08-07 15:40 ` Filippo Storniolo
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=20260806135125.343781F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=fstornio@redhat.com \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=sashiko-reviews@lists.linux.dev \
--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