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]
Message-ID: <CAGXu5jJZ3WY1cTCZc6QJtyE+FkVV-XBaQGqszHW1K52e_qAKvA@mail.gmail.com>
Date:	Wed, 11 Sep 2013 12:26:00 -0700
From:	Kees Cook <keescook@...omium.org>
To:	Dan Carpenter <dan.carpenter@...cle.com>
Cc:	devel@...verdev.osuosl.org, Lidza Louina <lidza.louina@...il.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Joe Perches <joe@...ches.com>,
	Tushar Behera <tushar.behera@...aro.org>
Subject: Re: [PATCH] staging: dgnc: fix potential format string flaw

On Wed, Sep 11, 2013 at 12:22 PM, Dan Carpenter
<dan.carpenter@...cle.com> wrote:
> On Wed, Sep 11, 2013 at 11:19:11AM -0700, Kees Cook wrote:
>> On Wed, Sep 11, 2013 at 2:31 AM, Dan Carpenter <dan.carpenter@...cle.com> wrote:
>> > On Tue, Sep 10, 2013 at 10:19:17PM -0700, Kees Cook wrote:
>> >> In the former case, format characters will get processed by the
>> >> sprintf logic. In the latter, they are printed as-is. In this specific
>> >> case, if there was a way to inject strings like "ohai %n" into the
>> >> msgbuf string, the former would actually attempt to resolve the %n. In
>> >> the simple case, this could lead to Oopses, and in the unlucky case,
>> >> it could allow arbitrary memory writing and execution control.
>> >>
>> >> http://en.wikipedia.org/wiki/Uncontrolled_format_string
>> >
>> > The kernel ignores %n so hopefully it can't actually write to memory.
>>
>> I wish! This is not the case, though. See FORMAT_TYPE_NRCHARS in
>> lib/vsprintf.c's vsnprintf().
>>
>> $ git grep '%n' | wc -l
>> 111
>>
>
> Hm...  That's unfortunate.  The comments were shifted around so it says
> it's ignored but it's not.

Outside of scanf, there are very few uses, though:

$ git grep %n | grep print
...
net/phonet/socket.c:            seq_printf(seq, "%s%n", "pt  loc  rem
rs st tx_queue rx_queue "
net/phonet/socket.c:            seq_printf(seq, "%s%n", "rs   uid inode", &len);
net/phonet/socket.c:            seq_printf(seq, "%02X %5u %lu%n",
net/sctp/objcnt.c:      seq_printf(seq, "%s: %d%n", sctp_dbg_objcnt[i].label,

-Kees

-- 
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ