From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Sam P <sam@bynar.io>, netdev@vger.kernel.org
Cc: mkl@pengutronix.de, linux-kernel@vger.kernel.org,
linux-can@vger.kernel.org
Subject: Re: [PATCH net] can: raw: fix ro->uniq use-after-free in raw_rcv()
Date: Wed, 8 Apr 2026 21:31:00 +0200 [thread overview]
Message-ID: <0bfd04db-ae11-4a2c-9d3d-40d0a86bf4a2@hartkopp.net> (raw)
In-Reply-To: <430cc8b9-21f0-4954-ae36-ec5e63f3ef9d@bynar.io>
On 08.04.26 19:22, Sam P wrote:
> On 08/04/2026 17:28, Oliver Hartkopp wrote:
>>
>> Can you tell why you preferred the destructor solution now?
>
> Thank you :) I preferred the destructor solution as it seemed to match
> the socket lifetime model better and I wasn't sure if the blocking sync
> in the raw_release() was too heavy-handed for this specific issue, given
> raw_release() already holds rtnl_lock() and lock_sock(sk). That said,
> I'm happy to defer to your experience if the sync fix is better suited,
> I have tested both of them.
Thanks. I think rtnl_lock() really might create a performance impact to
other networking code when syncronize_rcu() waits for its grace period.
>> And if I see it correctly the UAF problem might also show up with the
>> kfree(ro->filter) statement we can see at the beginning of the above
>> patch.
>>
>> So either free_percpu(ro->uniq) and kfree(ro->filter) should be
>> handled after the finalized synchronize_rcu() process, right?
>
> ro->filter isn't accessed in the racey raw_rcv() path as far as I can
> tell, and I don't *think* there are other racey paths but it wouldn't
> hurt to handle it just in-case. I think this would be simple with the
> synchronize_rcu() patch, as you mentioned, but I'm not sure with the
> destructor.
ro->filter contains all the CAN_RAW specific CAN ID filters and is
allocated if more than the single default filter is required.
It is last used in the raw_disable_allfilters() above.
So after the good discussion I tend to your original approach with the
destructor ;-)
Will add my Acked-by: to the original posted patch.
Many thanks,
Oliver
next prev parent reply other threads:[~2026-04-08 19:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 14:30 [PATCH net] can: raw: fix ro->uniq use-after-free in raw_rcv() Sam P
2026-04-08 16:28 ` Oliver Hartkopp
2026-04-08 17:22 ` Sam P
2026-04-08 19:31 ` Oliver Hartkopp [this message]
2026-04-08 19:32 ` Oliver Hartkopp
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=0bfd04db-ae11-4a2c-9d3d-40d0a86bf4a2@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=sam@bynar.io \
/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