linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Kees Cook <keescook@chromium.org>, Willy Tarreau <w@1wt.eu>
Cc: Silvio Cesare <silvio.cesare@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Liam Girdwood <liam.r.girdwood@linux.intel.com>,
	Jie Yang <yang.jie@linux.intel.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Will Deacon <will.deacon@arm.com>, Greg KH <greg@kroah.com>
Subject: Re: [PATCH 6/8] ASoC: intel: skylake: change snprintf to scnprintf for possible overflow
Date: Wed, 16 Jan 2019 13:35:51 -0600	[thread overview]
Message-ID: <ce0fca46-ff5e-beb3-5318-3a7c1e6da0e8@linux.intel.com> (raw)
In-Reply-To: <CAGXu5j+LvQsLSO+TtVr5hrUTYHA0Hqrc=pxPMv++erySJ8pV7g@mail.gmail.com>


>> diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
>> index 5d7ac2ee7a3c..bb28db734fb7 100644
>> --- a/sound/soc/intel/skylake/skl-debug.c
>> +++ b/sound/soc/intel/skylake/skl-debug.c
>> @@ -43,7 +43,7 @@ static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,
>>          ssize_t ret = 0;
>>
>>          for (i = 0; i < max_pin; i++)
>> -               ret += snprintf(buf + size, MOD_BUF - size,
>> +               ret += scnprintf(buf + size, MOD_BUF - size,
>>                                  "%s %d\n\tModule %d\n\tInstance %d\n\t"
>>                                  "In-used %s\n\tType %s\n"
>>                                  "\tState %d\n\tIndex %d\n",
>>
> While working on a Coccinelle script to find more cases of this, I
> noticed that this code is buggy: it keeps overwriting the same
> position in the buf string: "buf + size" and don't take "ret" into
> account at all. This needs to be:
>
> ret += scnprintf(buf + size + ret, MOD_BUF - size - ret,

Thanks for the sighting. Indeed this looks like a bug, all other calls 
to snprintf use "ret" to modify the destination/length.

The only explanation I have for it not being noticed earlier is that 
it's possibly not used - a 5mn test on 2 machines show the loop is 
actually not run (max_pin == 0).

It'll take me a bit of time to figure out what exactly this routine is 
supposed to do, maybe we should do the cross-tree change first?

-Pierre


  reply	other threads:[~2019-01-16 19:35 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-12 15:28 [PATCH 1/8] lkdtm: change snprintf to scnprintf for possible overflow Willy Tarreau
2019-01-12 15:28 ` [PATCH 2/8] libertas: " Willy Tarreau
2019-01-15  1:09   ` Kees Cook
2019-01-15  5:55   ` Kalle Valo
2019-01-15 20:35     ` Willy Tarreau
2019-01-16 16:40       ` Kalle Valo
2019-01-16 17:02         ` Willy Tarreau
2019-01-12 15:28 ` [PATCH 3/8] ocfs2: " Willy Tarreau
2019-01-15  1:14   ` Kees Cook
2019-01-12 15:28 ` [PATCH 4/8] ASoC: " Willy Tarreau
2019-01-15  1:13   ` Kees Cook
2019-01-15  1:25   ` Nicolin Chen
2019-01-15  3:18     ` Willy Tarreau
2019-01-12 15:28 ` [PATCH 5/8] scsi: lpfc: " Willy Tarreau
2019-01-15  1:15   ` Kees Cook
2019-01-15 22:41     ` James Smart
2019-03-20 17:39       ` Greg KH
2019-03-20 20:27         ` James Smart
2019-03-21  0:41         ` James Smart
2019-01-12 15:28 ` [PATCH 6/8] ASoC: intel: skylake: " Willy Tarreau
2019-01-15  1:12   ` Kees Cook
2019-01-16 18:41   ` Kees Cook
2019-01-16 19:35     ` Pierre-Louis Bossart [this message]
2019-01-16 19:51       ` Kees Cook
2019-01-12 15:28 ` [PATCH 7/8] ASoC: dapm: " Willy Tarreau
2019-01-14 14:56   ` Mark Brown
2019-01-15  3:16     ` Willy Tarreau
2019-01-15 15:44       ` Mark Brown
2019-01-15 15:55         ` Willy Tarreau
2019-01-12 15:28 ` [PATCH 8/8] spi: dw: " Willy Tarreau
2019-01-15  1:09   ` Kees Cook
2019-01-15  1:02 ` [PATCH 1/8] lkdtm: " Kees Cook
2019-01-15  1:07   ` Kees Cook
2019-01-15  3:12   ` Willy Tarreau
2019-01-15 20:47 ` Kees Cook
2019-01-18 13:06   ` Greg KH

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=ce0fca46-ff5e-beb3-5318-3a7c1e6da0e8@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=dan.carpenter@oracle.com \
    --cc=greg@kroah.com \
    --cc=keescook@chromium.org \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=silvio.cesare@gmail.com \
    --cc=w@1wt.eu \
    --cc=will.deacon@arm.com \
    --cc=yang.jie@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).