All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Heiko Carstens <hca@linux.ibm.com>
Cc: Alexandra Winter <wintera@linux.ibm.com>,
	Thorsten Winkler <twinkler@linux.ibm.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	netdev@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH net-next] s390: ism: Pass string literal as format argument of dev_set_name()
Date: Thu, 24 Apr 2025 17:28:05 +0100	[thread overview]
Message-ID: <20250424162805.GI3042781@horms.kernel.org> (raw)
In-Reply-To: <20250417110814.12521Bf4-hca@linux.ibm.com>

On Thu, Apr 17, 2025 at 01:08:14PM +0200, Heiko Carstens wrote:
> On Thu, Apr 17, 2025 at 11:28:23AM +0100, Simon Horman wrote:
> > GCC 14.2.0 reports that passing a non-string literal as the
> > format argument of dev_set_name() is potentially insecure.
> > 
> > drivers/s390/net/ism_drv.c: In function 'ism_probe':
> > drivers/s390/net/ism_drv.c:615:2: warning: format not a string literal and no format arguments [-Wformat-security]
> >   615 |  dev_set_name(&ism->dev, dev_name(&pdev->dev));
> >       |  ^~~~~~~~~~~~
> > 
> > It seems to me that as pdev is a PCIE device then the dev_name
> > call above should always return the device's BDF, e.g. 00:12.0.
> > That this should not contain format escape sequences. And thus
> > the current usage is safe.
> > 
> > But, it seems better to be safe than sorry. And, as a bonus, compiler
> > output becomes less verbose by addressing this issue.
> > 
> > Compile tested only.
> > No functional change intended.
> > 
> > Signed-off-by: Simon Horman <horms@kernel.org>
> > ---
> >  drivers/s390/net/ism_drv.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> It might make sense to say that -Wformat-security was explicitly enabled in
> order to trigger this (probably with KCFLAGS=-Wformat-security ?), since this
> warning is by default disabled.
> 
> Just mentioning this, since I was wondering why I haven't seen this.

Thanks Heiko,

Yes, you are right on both counts. I should have mentioned this.
And I did compile with KCFLAGS=-Wformat-security.

  reply	other threads:[~2025-04-24 16:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-17 10:28 [PATCH net-next] s390: ism: Pass string literal as format argument of dev_set_name() Simon Horman
2025-04-17 11:08 ` Heiko Carstens
2025-04-24 16:28   ` Simon Horman [this message]
2025-04-22  9:10 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250424162805.GI3042781@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=borntraeger@linux.ibm.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=svens@linux.ibm.com \
    --cc=twinkler@linux.ibm.com \
    --cc=wintera@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.