summaryrefslogtreecommitdiff
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorCunhao Lu <1579567540@qq.com>2026-07-31 17:45:02 +0800
committerMarc Kleine-Budde <mkl@pengutronix.de>2026-11-03 19:54:28 +0100
commitb4ebcbbf66ba6c5816dfe229effb4641c46e4b4c (patch)
tree5d46fac7d68e6db9e097e2f4e9eb72081ddf483c /include/uapi/linux
parentd4b616a38118e81cfb206babd052db260d7abf6c (diff)
can: dev: can_put_echo_skb(): free skb on invalid echo index
can_put_echo_skb() consumes the skb on all paths except when the echo index is out of bounds. This leaves ownership with the caller on -EINVAL, unlike the other error paths, and can leak the skb if the caller expects consistent semantics. Free the skb before returning -EINVAL so that all return paths consume it. Fixes: 6411959c10fe ("can: dev: can_put_echo_skb(): don't crash kernel if can_priv::echo_skb is accessed out of bounds") Cc: stable@vger.kernel.org Reviewed-by: Vincent Mailhol <mailhol@kernel.org> Signed-off-by: Cunhao Lu <1579567540@qq.com> Link: https://patch.msgid.link/tencent_683AA16E643DE00211CD2FB62991264DC605@qq.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- FAQ: Q: `can_skb_init_valid()` directly modifies `skb->data` without checking if the SKB is cloned or shared. Is this violating SKB shared buffer rules and causing data corruption? A: The finding about can_skb_init_valid() modifying skb->data on a potentially shared buffer is not relevant for this (correct) patch. The FDF-flag write in can_skb_init_valid() only matters for PF_PACKET use: PF_CAN allocators already set CANFD_FDF. The write exists to normalize frames for PF_PACKET observers (tcpdump/Wireshark) so they can distinguish classic CAN from CAN FD at the netdev level, and to compensate for PF_PACKET senders that omit the bit. That normalization is functionally required. The shared-buffer concern only becomes realistic through a specific chain: a PF_PACKET sender injects a CANFD-sized frame, the CAN driver's loopback puts an echo skb back into can_rcv(), and cgw (without modfuncs) clones it for forwarding to another interface. Only on that second can_skb_init_valid() call is the skb cloned. By then the bit was already set on the exclusive skb during the initial xmit path, so the flags |= CANFD_FDF write is strictly idempotent for any parallel consumer of the shared buffer - no memory-safety or information-disclosure consequence. It's a formal violation of the skb sharing rules without an observable effect, so the current code can stay as-is. Link: https://lore.kernel.org/all/54a3cc01-abcf-4a33-b932-39bb1f68cdd5@hartkopp.net/ [mkl: convert Oliver's mail to FAQ section]
Diffstat (limited to 'include/uapi/linux')
0 files changed, 0 insertions, 0 deletions