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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250512222011.57059-1-kuniyu@amazon.com>
Date: Mon, 12 May 2025 15:20:09 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <willemdebruijn.kernel@...il.com>
CC: <brauner@...nel.org>, <davem@...emloft.net>, <edumazet@...gle.com>,
	<horms@...nel.org>, <kuba@...nel.org>, <kuni1840@...il.com>,
	<kuniyu@...zon.com>, <netdev@...r.kernel.org>, <pabeni@...hat.com>,
	<willemb@...gle.com>
Subject: Re: [PATCH v2 net-next 6/9] af_unix: Move SOCK_PASS{CRED,PIDFD,SEC} to struct sock.

From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
Date: Mon, 12 May 2025 15:20:54 -0400
> Kuniyuki Iwashima wrote:
> > As explained in the next patch, SO_PASSRIGHTS would have a problem
> > if we assigned a corresponding bit to socket->flags, so it must be
> > managed in struct sock.
> > 
> > Mixing socket->flags and sk->sk_flags for similar options will look
> > confusing, and sk->sk_flags does not have enough space on 32bit system.
> > 
> > Also, as mentioned in commit 16e572626961 ("af_unix: dont send
> > SCM_CREDENTIALS by default"), SOCK_PASSCRED and SOCK_PASSPID handling
> > is known to be slow, and managing the flags in struct socket cannot
> > avoid that for embryo sockets.
> > 
> > Let's move SOCK_PASS{CRED,PIDFD,SEC} to struct sock.
> > 
> > While at it, other SOCK_XXX flags in net.h are grouped as enum.
> > 
> > Signed-off-by: Kuniyuki Iwashima <kuniyu@...zon.com>
> 
> > diff --git a/net/core/sock.c b/net/core/sock.c
> > index 1ab59efbafc5..9540cbe3d83e 100644
> > --- a/net/core/sock.c
> > +++ b/net/core/sock.c
> > @@ -1224,19 +1224,19 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
> >  		if (!sk_may_scm_recv(sk))
> >  			return -EOPNOTSUPP;
> >  
> > -		assign_bit(SOCK_PASSSEC, &sock->flags, valbool);
> > +		sk->sk_scm_security = valbool;
> 
> Is it safe to switch from atomic to non-atomic updates?
> 
> Reads and writes can race. Especially given that these are bit stores, so RMW.

Exactly, will move them down after sockopt_lock_sock().

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ