All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: william.c.roberts@intel.com
Cc: kernel-hardening@lists.openwall.com, corbet@lwn.net,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] printk: introduce kptr_restrict level 3
Date: Wed, 05 Oct 2016 22:52:39 +0200	[thread overview]
Message-ID: <87eg3umsbs.fsf@rasmusvillemoes.dk> (raw)
In-Reply-To: <1475690686-16138-1-git-send-email-william.c.roberts@intel.com> (william c. roberts's message of "Wed, 5 Oct 2016 14:04:46 -0400")

On Wed, Oct 05 2016, william.c.roberts@intel.com wrote:

> From: William Roberts <william.c.roberts@intel.com>
>
> Some out-of-tree modules do not use %pK and just use %p, as it's
> the common C paradigm for printing pointers. Because of this,
> kptr_restrict has no affect on the output and thus, no way to
> contain the kernel address leak.
>
> Introduce kptr_restrict level 3 that causes the kernel to
> treat %p as if it was %pK and thus always prints zeros.
>
> Sample Output:
> kptr_restrict == 2:
> p: 00000000604369f4
> pK: 0000000000000000
>
> kptr_restrict == 3:
> p: 0000000000000000
> pK: 0000000000000000
>
> Signed-off-by: William Roberts <william.c.roberts@intel.com>
> ---
>  Documentation/sysctl/kernel.txt |   3 ++
>  kernel/sysctl.c                 |   3 +-
>  lib/vsprintf.c                  | 107 ++++++++++++++++++++++++----------------

That's a lot of changed lines. Why isn't this just

--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1719,6 +1719,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
        case 'G':
                return flags_string(buf, end, ptr, fmt);
        }
+       if (kptr_restrict == 3)
+               ptr = NULL;
        spec.flags |= SMALL;
        if (spec.field_width == -1) {
                spec.field_width = default_width;

?

WARNING: multiple messages have this Message-ID (diff)
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: william.c.roberts@intel.com
Cc: kernel-hardening@lists.openwall.com, corbet@lwn.net,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [kernel-hardening] Re: [PATCH] printk: introduce kptr_restrict level 3
Date: Wed, 05 Oct 2016 22:52:39 +0200	[thread overview]
Message-ID: <87eg3umsbs.fsf@rasmusvillemoes.dk> (raw)
In-Reply-To: <1475690686-16138-1-git-send-email-william.c.roberts@intel.com> (william c. roberts's message of "Wed, 5 Oct 2016 14:04:46 -0400")

On Wed, Oct 05 2016, william.c.roberts@intel.com wrote:

> From: William Roberts <william.c.roberts@intel.com>
>
> Some out-of-tree modules do not use %pK and just use %p, as it's
> the common C paradigm for printing pointers. Because of this,
> kptr_restrict has no affect on the output and thus, no way to
> contain the kernel address leak.
>
> Introduce kptr_restrict level 3 that causes the kernel to
> treat %p as if it was %pK and thus always prints zeros.
>
> Sample Output:
> kptr_restrict == 2:
> p: 00000000604369f4
> pK: 0000000000000000
>
> kptr_restrict == 3:
> p: 0000000000000000
> pK: 0000000000000000
>
> Signed-off-by: William Roberts <william.c.roberts@intel.com>
> ---
>  Documentation/sysctl/kernel.txt |   3 ++
>  kernel/sysctl.c                 |   3 +-
>  lib/vsprintf.c                  | 107 ++++++++++++++++++++++++----------------

That's a lot of changed lines. Why isn't this just

--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1719,6 +1719,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
        case 'G':
                return flags_string(buf, end, ptr, fmt);
        }
+       if (kptr_restrict == 3)
+               ptr = NULL;
        spec.flags |= SMALL;
        if (spec.field_width == -1) {
                spec.field_width = default_width;

?

  parent reply	other threads:[~2016-10-05 20:52 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05 18:04 [PATCH] printk: introduce kptr_restrict level 3 william.c.roberts
2016-10-05 18:04 ` [kernel-hardening] " william.c.roberts
2016-10-05 19:34 ` Kees Cook
2016-10-05 19:34   ` [kernel-hardening] " Kees Cook
2016-10-06 13:17   ` Roberts, William C
2016-10-06 13:17     ` [kernel-hardening] " Roberts, William C
2016-10-06 15:18   ` Roberts, William C
2016-10-06 21:04     ` [kernel-hardening] " Kees Cook
2016-10-07 14:19       ` [kernel-hardening] " Roberts, William C
2016-10-07 14:29         ` Jann Horn
2016-10-07 15:05           ` Roberts, William C
2016-10-07 15:15             ` Jann Horn
2016-10-07 19:12           ` Kees Cook
2016-10-11 18:11             ` Roberts, William C
2016-10-05 20:52 ` Rasmus Villemoes [this message]
2016-10-05 20:52   ` [kernel-hardening] " Rasmus Villemoes
2016-10-06 13:23   ` Roberts, William C
2016-10-06 13:23     ` [kernel-hardening] " Roberts, William C
2016-10-06 13:31 ` Christoph Hellwig
2016-10-06 13:31   ` [kernel-hardening] " Christoph Hellwig
2016-10-06 13:47   ` Roberts, William C
2016-10-06 13:47     ` [kernel-hardening] " Roberts, William C
2016-10-06 13:56     ` Christoph Hellwig
2016-10-06 13:56       ` [kernel-hardening] " Christoph Hellwig
2016-10-06 14:59       ` Roberts, William C
2016-10-06 14:59         ` [kernel-hardening] " Roberts, William C
2016-10-06 21:00       ` Kees Cook
2016-10-06 21:00         ` [kernel-hardening] " Kees Cook
2016-10-06 21:19         ` Joe Perches
2016-10-06 21:19           ` [kernel-hardening] " Joe Perches
2016-10-06 21:25           ` Kees Cook
2016-10-06 21:25             ` [kernel-hardening] " Kees Cook
2016-10-07 14:21         ` Roberts, William C
2016-10-07 14:21           ` [kernel-hardening] " Roberts, William C
2016-10-06 14:05     ` Jann Horn
2016-10-06 14:05       ` Jann Horn
2016-10-06 14:46       ` Jann Horn
2016-10-06 14:46         ` Jann Horn
2016-10-07 11:52       ` Jann Horn
2016-10-07 11:52         ` Jann Horn

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=87eg3umsbs.fsf@rasmusvillemoes.dk \
    --to=linux@rasmusvillemoes.dk \
    --cc=corbet@lwn.net \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=william.c.roberts@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.