All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Thomas Gleixner <tglx@linutronix.de>,
	David Laight <david.laight.linux@gmail.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] fs: Replace user_access_{begin/end} by scoped user access
Date: Wed, 18 Mar 2026 13:29:07 +0100	[thread overview]
Message-ID: <e19d7d3f-d2f3-4bb0-be4d-af2679673f68@kernel.org> (raw)
In-Reply-To: <CAHk-=whFS7D1M4=cMi9cR06Uoxr1QeM8HUtRB6V3cQth=QNoXg@mail.gmail.com>



Le 16/03/2026 à 18:12, Linus Torvalds a écrit :
> On Mon, 16 Mar 2026 at 01:53, Christophe Leroy (CS GROUP)
> <chleroy@kernel.org> wrote:
>>
>> -       if (!user_write_access_begin(dirent,
>> -                       (unsigned long)(dirent->d_name + namlen + 1) -
>> -                               (unsigned long)dirent))
>> -               goto efault;
> 
> This was already pretty unreadable (my bad), but..
> 
>> +       scoped_user_write_access_size(dirent, (unsigned long)(dirent->d_name + namlen + 1) -
>> +                                             (unsigned long)dirent, efault) {
> 
> .. in my opinion, this is even worse. It's a 90+ character long line
> (or something), *and* it continues on the next line.
> 
> Yes, yes, the old code was disgusting too, but when changing it for
> something that is supposed to be easier to read, please let's make it
> *really* easier to read.
> 
> (And yes, there's another case of this same pattern a bit later).

The other pattern looks similar but is not exactly the same.

> 
> Adding a helper inline function like dirent_size() might do it. And I
> think it might as well be cleaned up while at it, and make it be
> something like
> 
>      static inline size_t dirent_size(int namelen)
>      {
>          return offsetof(struct linux_dirent, d_name) + namelen + 1;
>      }
> 

...

> 
> Hmm? Can you do at least that dirent_size() kind of cleanup?

Thanks for the suggestion.

I went for a local var alternative, see v4. A helper would be of no help 
as the two patterns are not exactly the same:

	size_t size = offsetof(struct old_linux_dirent, d_name) + namlen + 1;

	size_t size = offsetof(struct compat_old_linux_dirent, d_name) + namlen 
+ 1;


Christophe

  parent reply	other threads:[~2026-03-18 12:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16  8:52 [PATCH v3] fs: Replace user_access_{begin/end} by scoped user access Christophe Leroy (CS GROUP)
2026-03-16 17:12 ` Linus Torvalds
2026-03-16 23:19   ` David Laight
2026-03-18 12:29   ` Christophe Leroy (CS GROUP) [this message]
2026-03-18 15:49     ` Linus Torvalds
2026-03-18 15:53       ` Linus Torvalds
2026-03-18 22:35         ` David Laight
2026-03-24 11:42         ` Christophe Leroy (CS GROUP)

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=e19d7d3f-d2f3-4bb0-be4d-af2679673f68@kernel.org \
    --to=chleroy@kernel.org \
    --cc=brauner@kernel.org \
    --cc=david.laight.linux@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.