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]
Date:   Wed, 19 Jul 2023 10:30:17 -0700
From:   Kuniyuki Iwashima <kuniyu@...zon.com>
To:     <leitao@...ian.org>
CC:     <alexander@...alicyn.com>, <ast@...nel.org>, <davem@...emloft.net>,
        <dhowells@...hat.com>, <edumazet@...gle.com>,
        <kernelxing@...cent.com>, <kuba@...nel.org>, <kuniyu@...zon.com>,
        <leit@...a.com>, <linux-kernel@...r.kernel.org>,
        <lucien.xin@...il.com>, <martin.lau@...nel.org>,
        <netdev@...r.kernel.org>, <pabeni@...hat.com>
Subject: Re: [PATCH net-next] net: Use _K_SS_MAXSIZE instead of absolute value

From: Breno Leitao <leitao@...ian.org>
Date: Wed, 19 Jul 2023 10:18:49 -0700
> On Wed, Jul 19, 2023 at 10:04:45AM -0700, Kuniyuki Iwashima wrote:
> > From: Breno Leitao <leitao@...ian.org>
> > Date: Wed, 19 Jul 2023 01:44:12 -0700
> > > Looking at sk_getsockopt function, it is unclear why 128 is a magical
> > > number.
> > > 
> > > Use the proper macro, so it becomes clear to understand what the value
> > > mean, and get a reference where it is coming from (user-exported API).
> > > 
> > > Signed-off-by: Breno Leitao <leitao@...ian.org>
> > > ---
> > >  net/core/sock.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/net/core/sock.c b/net/core/sock.c
> > > index 9370fd50aa2c..58b6f00197d6 100644
> > > --- a/net/core/sock.c
> > > +++ b/net/core/sock.c
> > > @@ -1815,7 +1815,7 @@ int sk_getsockopt(struct sock *sk, int level, int optname,
> > >  
> > >  	case SO_PEERNAME:
> > >  	{
> > > -		char address[128];
> > > +		char address[_K_SS_MAXSIZE];
> > 
> > I guess you saw a bug caught by the fortified memcpy(), but this
> > doesn't fix it properly.
> 
> Not really, in fact. I was reading this code, and I found this
> discussion a while ago, where I got the idea:
> 
> https://lore.kernel.org/lkml/20140930.005925.995989898229686123.davem@davemloft.net/

I got it, but I prefer using struct sockaddr_storage as done in
other places.

  $ grep -rn sockaddr_storage net/

Also, there would be some situations where we must cast each
family-specific address back to sockaddr_storage for fortified
library.

Then, it makes more sense to use sockaddr_storage rather than
_K_SS_MAXSIZE.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ