lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFfO_h7acCeMO5g-r1ivS_7hiTJaY_TmbyOxRtvz-2+UdmJGag@mail.gmail.com>
Date: Thu, 29 Jan 2026 22:55:41 +0600
From: Dorjoy Chowdhury <dorjoychy111@...il.com>
To: Christian Brauner <brauner@...nel.org>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org, 
	viro@...iv.linux.org.uk, jack@...e.cz, jlayton@...nel.org, 
	chuck.lever@...cle.com, alex.aring@...il.com, arnd@...db.de, 
	adilger@...ger.ca
Subject: Re: [PATCH v3 1/4] open: new O_REGULAR flag support

On Thu, Jan 29, 2026 at 4:49 PM Christian Brauner <brauner@...nel.org> wrote:
>
> On Tue, Jan 27, 2026 at 11:58:17PM +0600, Dorjoy Chowdhury wrote:
> > This flag indicates the path should be opened if it's a regular file.
> > This is useful to write secure programs that want to avoid being tricked
> > into opening device nodes with special semantics while thinking they
> > operate on regular files.
> >
> > A corresponding error code ENOTREG has been introduced. For example, if
> > open is called on path /dev/null with O_REGULAR in the flag param, it
> > will return -ENOTREG.
> >
> > When used in combination with O_CREAT, either the regular file is
> > created, or if the path already exists, it is opened if it's a regular
> > file. Otherwise, -ENOTREG is returned.
> >
> > -EINVAL is returned when O_REGULAR is combined with O_DIRECTORY (not
> > part of O_TMPFILE) because it doesn't make sense to open a path that
> > is both a directory and a regular file.
> >
> > Signed-off-by: Dorjoy Chowdhury <dorjoychy111@...il.com>
> > ---
>
> Yeah, we shouldn't add support for this outside of openat2(). We also
> shouldn't call this OEXT_* or O2_*. Let's just follow the pattern where
> we prefix the flag space with the name of the system call
> OPENAT2_REGULAR.
>

Thanks for the feedback. I agree that OPENAT2_REGULAR is better than
the other OEXT_*/O2_* options. Right now in the patch, the O_REGULAR
took the next slot in all the fcntl files. Should OPENAT2_REGULAR be a
bit outside of the 32bits? That way it won't take any of the regular
O_* bits and we would only need to define it in
include/uapi/asm-generic/fcntl.h file and not need it in
arch/*/fcntl.h files. What do you think?

> There's also no real need to make O_DIRECTORY exclusive with
> OPENAT2_REGULAR. Callers could legimitately want to open a directory or
> regular file but not anything else. If someone wants to operate on a
> whole filesystem tree but only wants to interact with regular files and
> directories and ignore devices, sockets, fifos etc it's very handy to
> just be able to set both in flags.
>
> Frankly, this shouldn't be a flag at all but we already have O_DIRECTORY
> in there so no need to move this into a new field.
>
> Add EFTYPE as the errno code. Some of the bsds including macos already
> have that.

Great suggestion. Will fixup in v4 submission.

Regards,
Dorjoy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ