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] [day] [month] [year] [list]
Message-ID: <202504071136.73E5C22D0B@keescook>
Date: Mon, 7 Apr 2025 11:37:54 -0700
From: Kees Cook <kees@...nel.org>
To: James Bottomley <James.Bottomley@...senpartnership.com>
Cc: Jack Wang <jinpu.wang@...ud.ionos.com>,
	"Martin K. Petersen" <martin.petersen@...cle.com>,
	linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-hardening@...r.kernel.org
Subject: Re: [PATCH] scsi: pm80xx: Add __nonstring annotations for
 unterminated strings

On Mon, Mar 10, 2025 at 06:38:01PM -0400, James Bottomley wrote:
> On Mon, 2025-03-10 at 15:25 -0700, Kees Cook wrote:
> > When a character array without a terminating NUL character has a
> > static
> > initializer, GCC 15's -Wunterminated-string-initialization will only
> > warn if the array lacks the "nonstring" attribute[1]. Mark the arrays
> > with __nonstring to and correctly identify the char array as "not a C
> > string" and thereby eliminate the warning.
> > 
> > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178 [1]
> > Cc: Jack Wang <jinpu.wang@...ud.ionos.com>
> > Cc: "James E.J. Bottomley" <James.Bottomley@...senPartnership.com>
> > Cc: "Martin K. Petersen" <martin.petersen@...cle.com>
> > Cc: linux-scsi@...r.kernel.org
> > Signed-off-by: Kees Cook <kees@...nel.org>
> > ---
> >  drivers/scsi/pm8001/pm8001_ctl.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/scsi/pm8001/pm8001_ctl.c
> > b/drivers/scsi/pm8001/pm8001_ctl.c
> > index 85ff95c6543a..7618f9cc9986 100644
> > --- a/drivers/scsi/pm8001/pm8001_ctl.c
> > +++ b/drivers/scsi/pm8001/pm8001_ctl.c
> > @@ -644,7 +644,7 @@ static DEVICE_ATTR(gsm_log, S_IRUGO,
> > pm8001_ctl_gsm_log_show, NULL);
> >  #define FLASH_CMD_SET_NVMD    0x02
> >  
> >  struct flash_command {
> > -     u8      command[8];
> > +     u8      command[8] __nonstring;
> 
> This looks a bit suboptimal ... is there anywhere in the kernel u8[] is
> actually used for real strings?  In which case it would seem the better
> place to put the annotation is in the typedef for u8 arrays.

I answered this in a merged thread[1]. Can this get picked up?

Thanks!

-Kees

[1] https://lore.kernel.org/lkml/202503111520.CF7527A@keescook/

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ