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: <20240116150950.5f444a04@gandalf.local.home>
Date: Tue, 16 Jan 2024 15:09:50 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc: nathanl@...ux.ibm.com, Kees Cook <keescook@...omium.org>,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH] seq_buf: make DECLARE_SEQ_BUF() usable

On Tue, 16 Jan 2024 20:40:29 +0100
Christophe JAILLET <christophe.jaillet@...adoo.fr> wrote:

> Le 16/01/2024 à 15:09, Nathan Lynch via B4 Relay a écrit :
> > From: Nathan Lynch <nathanl@...ux.ibm.com>
> > 
> > Using the address operator on the array doesn't work:
> > 
> > /include/linux/seq_buf.h:27:27: error: initialization of ‘char *’
> >    from incompatible pointer type ‘char (*)[128]’
> >    [-Werror=incompatible-pointer-types]
> >     27 |                 .buffer = &__ ## NAME ## _buffer,       \
> >        |                           ^
> > 
> > Apart from fixing that, we can improve DECLARE_SEQ_BUF() by using a
> > compound literal to define the buffer array without attaching a name
> > to it. This makes the macro a single statement, allowing constructs
> > such as:
> > 
> >    static DECLARE_SEQ_BUF(my_seq_buf, MYSB_SIZE);
> > 
> > to work as intended.
> > 
> > Signed-off-by: Nathan Lynch <nathanl@...ux.ibm.com>
> > Fixes: dcc4e5728eea ("seq_buf: Introduce DECLARE_SEQ_BUF and seq_buf_str()")
> > ---
> >   include/linux/seq_buf.h | 3 +--
> >   1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h
> > index 5fb1f12c33f9..c44f4b47b945 100644
> > --- a/include/linux/seq_buf.h
> > +++ b/include/linux/seq_buf.h
> > @@ -22,9 +22,8 @@ struct seq_buf {
> >   };
> >   
> >   #define DECLARE_SEQ_BUF(NAME, SIZE)			\
> > -	char __ ## NAME ## _buffer[SIZE] = "";		\
> >   	struct seq_buf NAME = {				\
> > -		.buffer = &__ ## NAME ## _buffer,	\
> > +		.buffer = (char[SIZE]) { 0 },		\
> >   		.size = SIZE,				\
> >   	}  
> 
> Hi,
> 
> just removing the & in ".buffer = __ ## NAME ## _buffer, \" also works IIRC.
> 
> See [1], which unfortunately has been unnoticed.
> 
> CJ
> 
> 
> [1]: 
> https://lore.kernel.org/all/2a534333-b5f6-4b1d-b4b8-a1a71f91c3ff@wanadoo.fr/

I guess I missed that.

But it still doesn't fix this case:

 static DECLARE_SEQ_BUF(my_seq_buf, MYSB_SIZE);

Which this patch does.


-- Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ