Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 24 Jul 2019 10:08:57 -0700
From: Linus Torvalds <>
To: Rasmus Villemoes <>
Cc: Yann Droneaud <>, David Laight <>, 
	Joe Perches <>, 
	"" <>, Jonathan Corbet <>, 
	Stephen Kitt <>, Kees Cook <>, 
	Nitin Gote <>, "" <>, 
	"" <>, 
	Andrew Morton <>
Subject: Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms

On Wed, Jul 24, 2019 at 6:09 AM Rasmus Villemoes
<> wrote:
> The kernel's snprintf() does not behave in a non-standard way, at least
> not with respect to its return value.

Note that the kernels snprintf() *does* very much protect against the
overflow case - not by changing the return value, but simply by having

        /* Reject out-of-range values early.  Large positive sizes are
           used for unknown buffer sizes. */
        if (WARN_ON_ONCE(size > INT_MAX))
                return 0;

at the very top.

So you can't actually overflow in the kernel by using the repeated

        offset += vsnprintf( .. size - offset ..);


Yes, it's the wrong thing to do, but it is still _safe_.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.