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: <YNXG472lXPHlbuCF@kroah.com>
Date:   Fri, 25 Jun 2021 14:06:59 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Borislav Petkov <bp@...en8.de>
Cc:     x86@...nel.org, Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org
Subject: Re: [RESEND PATCH] x86/tools/relocs: add __printf attribute to die()

On Thu, Jun 24, 2021 at 02:32:43PM +0200, Borislav Petkov wrote:
> On Thu, Jun 24, 2021 at 01:58:03PM +0200, Greg Kroah-Hartman wrote:
> > There are a number of printf "mismatches" in the use of die() in
> > x86/tools/relocs.c.  Fix them up and add the printf attribute to the
> > reloc.h header file to prevent them from ever coming back.
> > 
> > Cc: Thomas Gleixner <tglx@...utronix.de>
> > Cc: Ingo Molnar <mingo@...hat.com>
> > Cc: Borislav Petkov <bp@...en8.de>
> > Cc: "H. Peter Anvin" <hpa@...or.com>
> > Cc: linux-kernel@...r.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> > ---
> >  arch/x86/tools/relocs.c | 21 +++++++++++----------
> >  arch/x86/tools/relocs.h |  1 +
> >  2 files changed, 12 insertions(+), 10 deletions(-)
> > 
> > Originally sent back in Feb, but it seems to have been missed:
> > 	https://lore.kernel.org/r/20210227095356.603513-1-gregkh@linuxfoundation.org
> > 
> > 
> > diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
> > index ce7188cbdae5..c3105a8c6cde 100644
> > --- a/arch/x86/tools/relocs.c
> > +++ b/arch/x86/tools/relocs.c
> > @@ -389,7 +389,8 @@ static void read_ehdr(FILE *fp)
> >  		Elf_Shdr shdr;
> >  
> >  		if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0)
> > -			die("Seek to %d failed: %s\n", ehdr.e_shoff, strerror(errno));
> > +			die("Seek to %d failed: %s\n",
> > +			    (int)ehdr.e_shoff, strerror(errno));
> 
> Instead of casting all those, I think you should use %zu as, apparently,
> we're using unsigned types for Elf{32,64}_Off and Elf{32,64}_Xword, etc.

Ah, that does not work, I tried it and I get:

arch/x86/tools/relocs.c: In function ‘read_ehdr’:
arch/x86/tools/relocs.c:392:40: warning: format ‘%zu’ expects argument of type ‘size_t’, but argument 2 has type ‘Elf32_Off’ {aka ‘unsigned int’} [-Wformat=]
  392 |                         die("Seek to %zu failed: %s\n",
      |                                      ~~^
      |                                        |
      |                                        long unsigned int
      |                                      %u
  393 |                             ehdr.e_shoff, strerror(errno));
      |                             ~~~~~~~~~~~~
      |                                 |
      |                                 Elf32_Off {aka unsigned int}

Casting seems to be the only way to make this "quiet" that I can tell.

Unless someone else has a good idea?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ