Linux CAN drivers development
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Vincent Mailhol <mailhol@kernel.org>
Cc: linux-can@vger.kernel.org, Eulgyu Kim <eulgyukim@snu.ac.kr>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: Re: [PATCH] can: raw: add locking for raw flags bitfield
Date: Wed, 6 May 2026 13:54:23 +0200	[thread overview]
Message-ID: <9110e56c-42e7-4299-963e-2e42f73b0eff@hartkopp.net> (raw)
In-Reply-To: <CAMZ6RqJdF4xit5xvpGy6P9Nkenh6PT0meVpcL3UYZKx01yfQAg@mail.gmail.com>

Hello Vincent!

On 06.05.26 12:22, Vincent Mailhol wrote:
> On Mon. 4 May 2026 at 13:31, Oliver Hartkopp <socketcan@hartkopp.net> wrote:
>> With commit 890e5198a6e5 ("can: raw: use bitfields to store flags in
>> struct raw_sock") the formerly separate integer values have been integrated
>> into a single bitfield. This led to a read-modify-write operation when
>> changing a flag in raw_setsockopt() which now needs a locking to prevent
>> concurrent access.
>>
>> Instead of adding a lock/unlock hell in each of the flag manipulations this
>> patch introduces a wrapper for a new raw_setsockopt_locked() function
>> analogue to the isotp_setsockopt[_locked]() approach in net/can/isotp.c
>>
>> Fixes: 890e5198a6e5 ("can: raw: use bitfields to store flags in struct raw_sock")
> 
> Arg, that's my patch, sorry for that!

No problem. I did realize this either o_O

>> Reported-by: Eulgyu Kim <eulgyukim@snu.ac.kr>
> 
> Maybe add a link to the report?
> 
> Link: https://lore.kernel.org/linux-can/20260503112200.22727-1-eulgyukim@snu.ac.kr/

Good idea. In fact checkpatch.pl said "Reported-by: should be 
immediately followed by Closes: with a URL to the report"

So it should be

Closes: 
https://lore.kernel.org/linux-can/20260503112200.22727-1-eulgyukim@snu.ac.kr/

>> Tested-by: Eulgyu Kim <eulgyukim@snu.ac.kr>
>> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
> 
> I was able to trigger the bug locally using Eulgyu minimum reproducer
> and I can confirm that the issue is correctly resolved by this patch.
> I also think that globally holding the lock simplifies the logic. I
> tried to think if there were any alternatives (like
> READ_ONCE()/WRITE_ONCE() or atomic types) but none of these seem
> applicable here.
> 
> Reviewed-by: Vincent Mailhol <mailhol@kernel.org>
> Tested-by: Vincent Mailhol <mailhol@kernel.org>

Thanks Vincent!

Best regards,
Oliver

  reply	other threads:[~2026-05-06 12:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-04 11:19 [PATCH] can: raw: add locking for raw flags bitfield Oliver Hartkopp
2026-05-06 10:22 ` Vincent Mailhol
2026-05-06 11:54   ` Oliver Hartkopp [this message]
2026-05-06 12:43 ` Marc Kleine-Budde

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=9110e56c-42e7-4299-963e-2e42f73b0eff@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=eulgyukim@snu.ac.kr \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    /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