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:   Tue, 19 Feb 2019 13:02:45 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc:     Petr Mladek <pmladek@...e.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        "Tobin C . Harding" <me@...in.cc>, Joe Perches <joe@...ches.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Michal Hocko <mhocko@...e.cz>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v6 8/9] vsprintf: Prevent crash when dereferencing invalid pointers

On Tue, Feb 19, 2019 at 5:35 AM Sergey Senozhatsky
<sergey.senozhatsky.work@...il.com> wrote:
> On (02/08/19 16:23), Petr Mladek wrote:

> Hmm... So the assumption here is that the target buffer always has
> at least strlen("(efault)") bytes and, thus, we always can write the
> error message to it.

Same assumption as for pointers, 8 or 16 bytes. Same will happen if
it's not enough room.

> > +static int check_pointer(char **buf, char *end, const void *ptr,
> > +                          struct printf_spec spec)
> > +{
> > +     const char *err_msg;
> > +
> > +     err_msg = check_pointer_msg(ptr);
> > +     if (err_msg) {
> > +             *buf = string_nocheck(*buf, end, err_msg, spec);
> > +             return -EFAULT;
> > +     }
> > +
> > +     return 0;
> > +}
>
> Suppose in my driver I sprintf() pointers to 4-bytes strings and, thus,
> have only 5 spare bytes in target buffer. But one of the pointers is
> faulty and now sprintf() writes "(efault)" to target buffer which can
> hold only 5 bytes.

And if it's not? You will get in either case incomplete information,
but at least with "(e" (or even "(") you might get a clue that it
errornous conditions.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ