public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <jbottomley@parallels.com>
To: "hch@infradead.org" <hch@infradead.org>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"kbuild-all@01.org" <kbuild-all@01.org>,
	"fengguang.wu@intel.com" <fengguang.wu@intel.com>,
	"hare@suse.de" <hare@suse.de>
Subject: Re: [linux-devel:devel-lkp-ib03-powerpc-201501140043 30/31] drivers/scsi/scsi_logging.c:254:3: error: format not a string literal and no format arguments
Date: Wed, 14 Jan 2015 15:26:22 +0000	[thread overview]
Message-ID: <1421249215.2083.7.camel@parallels.com> (raw)
In-Reply-To: <20150114094043.GA21820@infradead.org>

On Wed, 2015-01-14 at 01:40 -0800, Christoph Hellwig wrote:
> On Tue, Jan 13, 2015 at 05:30:20PM +0000, James Bottomley wrote:
> > Just for everyone's sake the problem is printk format strings (and all
> > the things that indirect there, like pr_xxx and dev_printk).  We must
> > never pass a mutable string directly to printk because of the mayhem
> > that would result if its contents were altered by the user (because some
> > of the things we do in string format parsing are very dangerous), making
> > this a potential security issue.  Only ever pass static strings (in the
> > ro section) to printk formats.
> > 
> > So this is wrong:
> > 
> > dev_printk(KERN_INFO, dev, logbuf);
> > 
> > This is correct:
> > 
> > dev_printk(KERN_INFO, dev, "%s", logbuf);
> 
> In this case the logbug comes from actually doing just that string
> formatting earlier in the function, so it practice it's harmles.

However, it's a wrong pattern which we need to avoid.  Otherwise we get
one patch every few months "fixing" it and a couple of annoyed emails
from security people who re-did the analysis.

> It would be useful to have a dev_puts to avoid that reinterpretation again,
> though.

I'm fairly certain, given a lot of what has gone on in our string
processors that dev_puts() would get implemented via dev_printk ...

James


      reply	other threads:[~2015-01-14 15:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201501140133.IhMp3BqI%fengguang.wu@intel.com>
2015-01-13 17:30 ` [linux-devel:devel-lkp-ib03-powerpc-201501140043 30/31] drivers/scsi/scsi_logging.c:254:3: error: format not a string literal and no format arguments James Bottomley
2015-01-14  9:40   ` Christoph Hellwig
2015-01-14 15:26     ` James Bottomley [this message]

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=1421249215.2083.7.camel@parallels.com \
    --to=jbottomley@parallels.com \
    --cc=fengguang.wu@intel.com \
    --cc=hare@suse.de \
    --cc=hch@infradead.org \
    --cc=kbuild-all@01.org \
    --cc=linux-scsi@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox