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: <01039f49e5104f31975999590e6c0a7e@realtek.com>
Date: Wed, 23 Apr 2025 11:53:12 +0000
From: Justin Lai <justinlai0215@...ltek.com>
To: Simon Horman <horms@...nel.org>
CC: "kuba@...nel.org" <kuba@...nel.org>,
        "davem@...emloft.net"
	<davem@...emloft.net>,
        "edumazet@...gle.com" <edumazet@...gle.com>,
        "pabeni@...hat.com" <pabeni@...hat.com>,
        "andrew+netdev@...n.ch"
	<andrew+netdev@...n.ch>,
        "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>,
        "netdev@...r.kernel.org"
	<netdev@...r.kernel.org>,
        Ping-Ke Shih <pkshih@...ltek.com>,
        Larry Chiu
	<larry.chiu@...ltek.com>,
        kernel test robot <lkp@...el.com>
Subject: RE: [PATCH net v3 2/3] rtase: Increase the size of ivec->name

> On Thu, Apr 17, 2025 at 04:56:58PM +0800, Justin Lai wrote:
> > Fix the following compile warning reported by the kernel test robot by
> > increasing the size of ivec->name.
> >
> > drivers/net/ethernet/realtek/rtase/rtase_main.c: In function 'rtase_open':
> > >> drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:52: warning:
> > '%i' directive output may be truncated writing between 1 and 10 bytes
> > into a region of size between 7 and 22 [-Wformat-truncation=]
> >      snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
> >                                                      ^~
> >  drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:45: note:
> >  directive argument in the range [0, 2147483647]
> >      snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
> >                                               ^~~~~~~~~~
> >  drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:4: note:
> >  'snprintf' output between 6 and 30 bytes into a destination of  size
> > 26
> >      snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
> >      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >        tp->dev->name, i);
> >        ~~~~~~~~~~~~~~~~~
> 
> Hi Justin,
> 
> Given that the type of i is u16, it's theoretical range of values is [0, 65536].
> (I expect that in practice the range is significantly smaller.)
> 
> So the string representation of i should fit in the minumum of 7 bytes available
> (only a maximum of 5 are needed).
> 
> And I do notice that newer compilers do not seem to warn about this.
> 
> So I don't really think this needs updating.
> And if so, certainly not as a fix for 'net'.
> 
> Also, as an aside, as i is unsigned, the format specifier really ought to be %u
> instead of %i. Not that it seems to make any difference here given the range of
> values discussed above.
> 
> > Reported-by: kernel test robot <lkp@...el.com>
> > Closes:
> > https://lore.kernel.org/oe-kbuild-all/202503182158.nkAlbJWX-lkp@intel.
> > com/
> > Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this
> > module")
> > Signed-off-by: Justin Lai <justinlai0215@...ltek.com>
> 
> --
> pw-bot: changes-requested

Hi Simon,

Thank you for your reply. I will modify the format specifier to %u.
Since the warning from the kernel test robot is a false positive, I
will not address this warning, meaning I will not increase the size
of ivec->name. This patch will be posted to net-next.

Thanks,
Justin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ