Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bdle6p2ohjckvb7wwwquj27wen65zzzz73eqahbuntfdf7xquu@5yaobuvf6yos>
Date: Mon, 17 Feb 2025 16:08:02 +0100
From: Alejandro Colomar <alx@...nel.org>
To: Rich Felker <dalias@...c.org>
Cc: libc-help@...rceware.org, linux-man@...r.kernel.org, 
	Karlson2k <k2k@...od.ru>, Tobias Stoeckmann <tobias@...eckmann.org>, 
	Serge Hallyn <serge@...lyn.com>, Iker Pedrosa <ipedrosa@...hat.com>, musl@...ts.openwall.com
Subject: Re: Re: [shadow-maint/shadow] Add cheap defense mechanisms
 (PR #1171)

Hi Rich,

On Mon, Feb 17, 2025 at 09:44:58AM -0500, Rich Felker wrote:
> It's in the latest POSIX and we have supported it for a long time as
> POSIX-future (since 2012/release 0.9.7).

Thanks!  That agrees with my own research.

> > > Isn't it safe to use constructs like 
> > > ``` C
> > > shadow = fopen (SGROUP_FILE, "re");
> > > if (NULL == shadow )
> > >   shadow = fopen (SGROUP_FILE, "r");
> > > ```
> > > ?
> 
> Unfortunately this doesn't work because it's UB to pass any modes but
> the standards-specified ones.

Makes sense.  Thanks!

> In any case use of fopen is just gratuitously bad for software that
> targets POSIX. The right way to do things is a two-step open+fdopen.
> This avoids needing to depend on new features to open and lets you use
> all the modern open flags, openat if needed, etc.

Hmmm, thanks for the idea!  This code is old, so we didn't actually
write it; we only added 'e' recently to it.  If we need to write new
code, I'll take into consideration doing that as a two-step process,
maybe adding a wrapper around that process.


Have a lovely day!
Alex

> P.S. Had to omit shadow-utils <~hallyn/shadow@...ts.sr.ht> from CC
> because my mail software rejects / in an address... gotta fix that.
> Apologies.

No problem.  Thanks!

-- 
<https://www.alejandro-colomar.es/>

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.