public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tycho Andersen <tycho@docker.com>
To: "Tobin C. Harding" <me@tobin.cc>
Cc: kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org
Subject: Re: [kernel-hardening] [PATCH] lib/vsprintf: add default case to 'i' specifier
Date: Mon, 9 Oct 2017 09:16:09 -0600	[thread overview]
Message-ID: <20171009151609.xcfushhda2mfc3ff@smitten> (raw)
In-Reply-To: <1507517945-27155-1-git-send-email-me@tobin.cc>

On Mon, Oct 09, 2017 at 01:59:05PM +1100, Tobin C. Harding wrote:
> %pi leaks kernel addresses if incorrectly specified.
> 
> Currently the printk specifier %pi (%pI) contains a switch statement
> without a default clause. The %pi specifier requires a subsequent
> character (4, 6, or S) controlling the output. If the specifier is
> incomplete the switch statement will fall through and print the variable
> argument address in hex instead of the value of the argument (as an IP
> address).
> 
> If uncaught this leaks kernel addresses into dmesg. We can return an
> error string to make the bug visible and stop addresses leaking.
> 
> Add a default clause returning an error string, stops leaking addresses
> and makes the buggy code

...? :)

> Signed-off-by: Tobin C. Harding <me@tobin.cc>
> ---
>  lib/vsprintf.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 86c3385b9eb3..155702f05b14 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1775,6 +1775,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
>  			default:
>  				return string(buf, end, "(invalid address)", spec);
>  			}}
> +		default:

Maybe a WARN(1, "invalid pointer format")? That way it'll be easy for
people to figure out where to fix.

Cheers,

Tycho

> +			return string(buf, end, "(invalid specifier, form: %pi4)", spec);
>  		}
>  		break;
>  	case 'E':
> -- 
> 2.7.4
> 

  reply	other threads:[~2017-10-09 15:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-09  2:59 [PATCH] lib/vsprintf: add default case to 'i' specifier Tobin C. Harding
2017-10-09 15:16 ` Tycho Andersen [this message]
2017-10-09 21:27   ` [kernel-hardening] " Tobin C. Harding
2017-10-10  7:09 ` Joe Perches
2017-10-10 21:47   ` Tobin C. Harding

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=20171009151609.xcfushhda2mfc3ff@smitten \
    --to=tycho@docker.com \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@tobin.cc \
    /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