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]
Date:   Wed, 16 Jan 2019 11:51:58 -0800
From:   Kees Cook <keescook@...omium.org>
To:     Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
Cc:     Willy Tarreau <w@....eu>, Silvio Cesare <silvio.cesare@...il.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Liam Girdwood <liam.r.girdwood@...ux.intel.com>,
        Jie Yang <yang.jie@...ux.intel.com>,
        Dan Carpenter <dan.carpenter@...cle.com>,
        Will Deacon <will.deacon@....com>, Greg KH <greg@...ah.com>
Subject: Re: [PATCH 6/8] ASoC: intel: skylake: change snprintf to scnprintf
 for possible overflow

On Wed, Jan 16, 2019 at 11:35 AM Pierre-Louis Bossart
<pierre-louis.bossart@...ux.intel.com> wrote:
>
>
> >> 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?

Sounds good to me. These patches are direct at maintainers, so please
apply at will. :)

Thanks!

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ