All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rohit Sarkar <rohitsarkar5398@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: devel@driverdev.osuosl.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	kernel-janitors@vger.kernel.org,
	"Tobias Büttner" <tobias.buettner@fau.de>,
	"Eric Anholt" <eric@anholt.net>,
	"Stefan Wahren" <wahrenst@gmx.net>,
	"Dominic Braun" <inf.braun@fau.de>,
	linux-rpi-kernel@lists.infradead.org
Subject: Re: [PATCH] staging: vhciq_core: replace snprintf with scnprintf
Date: Wed, 11 Sep 2019 15:15:00 +0000	[thread overview]
Message-ID: <20190911150300.GA12027@SARKAR> (raw)
In-Reply-To: <20190911144312.GL15977@kadam>

On Wed, Sep 11, 2019 at 05:46:12PM +0300, Dan Carpenter wrote:
> On Wed, Sep 11, 2019 at 07:55:43PM +0530, Rohit Sarkar wrote:
> > On Wed, Sep 11, 2019 at 04:17:25PM +0200, Stefan Wahren wrote:
> > > Hi Rohit,
> > > 
> > > On 11.09.19 15:51, Rohit Sarkar wrote:
> > > > When the number of bytes to be printed exceeds the limit snprintf
> > > > returns the number of bytes that would have been printed (if there was
> > > > no truncation). This might cause issues, hence use scnprintf which
> > > > returns the actual number of bytes printed to buffer always
> > > >
> > > > Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
> > > thanks for your patch. Did you test your change on the Raspberry Pi?
> > 
> > Hey Stefan,
> > No I haven't done so as I thought this is a generic change?
> > Will that be necessary?
> 
> No.  It's not required.  The patch is easy to audit and clearly
> harmless.
> 
> The question would be does it actually fix a bug?  I looked at it and
> some of the strings are definitely a bit long.  The longest one I saw
> was:
> 	"  Slots: %d available (%d data), %d recyclable, %d stalls (%d data)",
> 	123456789 123456789 123456789 123456789 123456789 123456789 123456789
> 
> If you get a lot of stalls, then that looks like it could lead to a
> read overflow (an information leak).  Either way this does make the
> code a bit easier to audit so it seems like a nice cleanup.  Next time
> though, I really would prefer if you put this sort analysis in your
> commit message so I can just glance over it.  (I'm lazy).
> 
> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> regards,
> dan carpenter

Hey Dan,
Thanks for reviewing this :)
I will make sure to add some analysis the next time I do a clean up like
this.

There are a lot of usages of "snprintf" throughout the staging
directory (315 to be exact)
Would it be worthwhile to find ones that may cause an information leak
and replace them with "scnprintf"?
Thanks,
Rohit

  reply	other threads:[~2019-09-11 15:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11 13:51 [PATCH] staging: vhciq_core: replace snprintf with scnprintf Rohit Sarkar
2019-09-11 14:17 ` Stefan Wahren
2019-09-11 14:37   ` Rohit Sarkar
2019-09-11 14:46     ` Dan Carpenter
2019-09-11 15:15       ` Rohit Sarkar [this message]
2019-09-11 17:24         ` Dan Carpenter
2019-09-11 17:50           ` Rohit Sarkar

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=20190911150300.GA12027@SARKAR \
    --to=rohitsarkar5398@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=eric@anholt.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=inf.braun@fau.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=tobias.buettner@fau.de \
    --cc=wahrenst@gmx.net \
    /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.