From: Dorinda Bassey <dbassey@redhat.com>
To: mvaralar@redhat.com, virtualization@lists.linux.dev,
linux-can@vger.kernel.org
Cc: dbassey@redhat.com, harald.mommer@oss.qualcomm.com,
mkl@pengutronix.de, mailhol@kernel.org, mst@redhat.com,
jasowang@redhat.com, xuanzhuo@linux.alibaba.com,
eperezma@redhat.com, mikhail.golubev-ciuchea@oss.qualcomm.com,
sgarzare@redhat.com, francesco@valla.it
Subject: Re: [PATCH v13] can: virtio: Add virtio CAN driver
Date: Thu, 2 Apr 2026 11:52:43 +0200 [thread overview]
Message-ID: <20260402095243.647258-1-dbassey@redhat.com> (raw)
In-Reply-To: <acLNB9PYmJ9L0Wvc@fedora>
Hi Matias,
I've been testing PATCH v13 of the virtio CAN driver and encountered a
FORTIFY_SOURCE panic when transmitting frames:
sh-5.3# cansend can0 123#DEADBEEF
[ 51.700501] Kernel BUG at __fortify_panic+0x9/0xb [verbose debug info unavailable]
[ 51.700798] Oops: invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
[ 51.700881] CPU: 2 UID: 0 PID: 374 Comm: cansend Tainted: G W 6.12.76 #1
[ 51.701070] Tainted: [W]=WARN
[ 51.701143] RIP: 0010:__fortify_panic+0x9/0xb
[ 51.701212] Code: 01 00 00 e9 58 7e c2 ff cc cc cc cc cc cc cc cc cc 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
90 40 0f b6 ff e8 57 a9 c2 ff <0f> 0b 48 8b 54 24 08 48 8b 74 24 10 4c 8d 44 24 1d 4c 89 e1 48 c7
[ 51.701406] RSP: 0018:ffffc900001ffb10 EFLAGS: 00010246
[ 51.701454] RAX: 0000000000000000 RBX: ffff888100ea8780 RCX: 0000000000000003
[ 51.701530] RDX: 0000000000000000 RSI: ffffc900001ff9b8 RDI: 0000000000000001
[ 51.701625] RBP: 0000000000000000 R08: 0000000000000000 R09: 00000000fffffbff
[ 51.701700] R10: ffffffff82239ee0 R11: ffffc900001ff9b0 R12: ffff888100ea8000
[ 51.701789] R13: ffff888100817200 R14: ffff88810037cda0 R15: ffffc900001ffb48
[ 51.701866] FS: 00007f7c4cda3740(0000) GS:ffff88812bd00000(0000) knlGS:0000000000000000
[ 51.701948] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 51.702007] CR2: 00007f7c4ceffdc0 CR3: 0000000100d12000 CR4: 0000000000350eb0
[ 51.702072] Call Trace:
[ 51.702105] <TASK>
[ 51.702126] ? virtio_can_start_xmit.cold+0x2b/0x4d
[ 51.702171] ? srso_alias_return_thunk+0x5/0xfbef5
The issue is in virtio_can_start_xmit() where can_tx_msg->tx_out.length
is set AFTER memcpy(can_tx_msg->tx_out.sdu, ...). Since sdu[] uses
__counted_by_le(length), FORTIFY_SOURCE sees length=0 during the copy
and panics.
The fix is to set length before the memcpy:
diff --git a/drivers/net/can/virtio_can.c b/drivers/net/can/virtio_can.c
index xxx..yyy 100644
--- a/drivers/net/can/virtio_can.c
+++ b/drivers/net/can/virtio_can.c
@@ -308,6 +308,7 @@ static netdev_tx_t virtio_can_start_xmit(struct sk_buff *skb,
can_tx_msg->tx_out.msg_type = cpu_to_le16(VIRTIO_CAN_TX);
+ can_tx_msg->tx_out.length = cpu_to_le16(cf->len);
can_flags = 0;
if (cf->can_id & CAN_EFF_FLAG) {
@@ -322,7 +323,6 @@ static netdev_tx_t virtio_can_start_xmit(struct sk_buff *skb,
can_flags |= VIRTIO_CAN_FLAGS_FD;
can_tx_msg->tx_out.flags = cpu_to_le32(can_flags);
- can_tx_msg->tx_out.length = cpu_to_le16(cf->len);
sg_init_one(&sg_out, &can_tx_msg->tx_out, hdr_size + cf->len);
Tested with vhost-device-can backend, and it works correctly after this fix.
Thanks,
Dorinda Bassey
next prev parent reply other threads:[~2026-04-02 9:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 17:36 [PATCH v13] can: virtio: Add virtio CAN driver Matias Ezequiel Vara Larsen
2026-03-23 10:36 ` Marc Kleine-Budde
2026-03-24 17:42 ` Matias Ezequiel Vara Larsen
2026-04-02 9:52 ` Dorinda Bassey [this message]
2026-04-07 8:36 ` Matias Ezequiel Vara Larsen
2026-04-07 13:48 ` Matias Ezequiel Vara Larsen
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=20260402095243.647258-1-dbassey@redhat.com \
--to=dbassey@redhat.com \
--cc=eperezma@redhat.com \
--cc=francesco@valla.it \
--cc=harald.mommer@oss.qualcomm.com \
--cc=jasowang@redhat.com \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mikhail.golubev-ciuchea@oss.qualcomm.com \
--cc=mkl@pengutronix.de \
--cc=mst@redhat.com \
--cc=mvaralar@redhat.com \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/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