public inbox for kernel-hardening@lists.openwall.com
 help / color / mirror / Atom feed
From: Alexander Popov <alex.popov@linux.com>
To: Laura Abbott <labbott@redhat.com>, Kees Cook <keescook@chromium.org>
Cc: kernel-hardening@lists.openwall.com,
	PaX Team <pageexec@freemail.hu>,
	Brad Spengler <spender@grsecurity.net>,
	Ingo Molnar <mingo@kernel.org>, Andy Lutomirski <luto@kernel.org>,
	Tycho Andersen <tycho@tycho.ws>,
	Mark Rutland <mark.rutland@arm.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Borislav Petkov <bp@alien8.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H . Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>, X86 ML <x86@kernel.org>
Subject: [kernel-hardening] Re: [PATCH RFC v6 5/6] fs/proc: Show STACKLEAK metrics in the /proc file system
Date: Fri, 8 Dec 2017 01:58:24 +0300	[thread overview]
Message-ID: <0756b086-6ff8-b505-b638-4fd35d18250d@linux.com> (raw)
In-Reply-To: <37807af6-1743-059c-614a-1328c0c880e4@redhat.com>

On 07.12.2017 02:06, Laura Abbott wrote:
> On 12/06/2017 12:40 PM, Kees Cook wrote:
>> On Wed, Dec 6, 2017 at 11:22 AM, Laura Abbott <labbott@redhat.com> wrote:
>>> On 12/05/2017 03:33 PM, Alexander Popov wrote:
>>>> diff --git a/fs/proc/base.c b/fs/proc/base.c
>>>> index 28fa852..3569446 100644
>>>> --- a/fs/proc/base.c
>>>> +++ b/fs/proc/base.c
>>>> @@ -2884,6 +2884,17 @@ static int proc_pid_patch_state(struct seq_file *m,
>>>> struct pid_namespace *ns,
>>>>    }
>>>>    #endif /* CONFIG_LIVEPATCH */
>>>>    +#ifdef CONFIG_STACKLEAK_METRICS
>>>> +static int proc_lowest_stack(struct seq_file *m, struct pid_namespace
>>>> *ns,
>>>> +                               struct pid *pid, struct task_struct *task)
>>>> +{
>>>> +       seq_printf(m, "prev_lowest_stack: %pK\nlowest_stack: %pK\n",
>>>> +                  (void *)task->thread.prev_lowest_stack,
>>>> +                  (void *)task->thread.lowest_stack);
>>>> +       return 0;
>>>> +}
>>>> +#endif /* CONFIG_STACKLEAK_METRICS */
>>>> +
>>>
>>> This just prints the hashed value with the new pointer leak work.
>>> I don't think we want to print the fprev_lowest_stackully exposed value via %px so
>>> it's not clear how valuable this proc file is now.
>>
>> Maybe print the size, not the location?

Yes, I think I can print: THREAD_SIZE - (addr & (THREAD_SIZE - 1)).
I can call it "stack_depth", do you like it?

N.B. this value is not a really precise stack depth, because:
 - we don't instrument all kernel functions, so a lot of them don't update the
lowest_stack value;
 - prev_lowest_stack is a final point of the poison search in erase_kstack(), it
is not an actual stack depth.

Or should I dwell on the current version and rely on non-zero kptr_restrict?

> Hmmmmm, that starts to overlap with CONFIG_DEBUG_STACK_USAGE.
> That's not a bad thing but it would be good to clarify what
> this is tracking vs. CONFIG_DEBUG_STACK_USAGE.

Thanks, Laura, I didn't know about CONFIG_DEBUG_STACK_USAGE. After testing it I
think that it should remain independent, because:
 - it works on sysrq;
 - it dumps information about all tasks in the system at once;
 - it provides precise information (in contrast to my metrics).

In addition, I guess, modifying sysrq output format might break the workflow of
users, who parse it (but I'm not sure).

Best regards,
Alexander

  reply	other threads:[~2017-12-07 22:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-05 23:33 [kernel-hardening] [PATCH RFC v6 0/6] Introduce the STACKLEAK feature and a test for it Alexander Popov
2017-12-05 23:33 ` [kernel-hardening] [PATCH RFC v6 1/6] x86/entry: Add STACKLEAK erasing the kernel stack at the end of syscalls Alexander Popov
2017-12-08 11:44   ` [kernel-hardening] " Peter Zijlstra
2017-12-08 21:54     ` Alexander Popov
2017-12-11  9:26       ` Peter Zijlstra
2017-12-05 23:33 ` [kernel-hardening] [PATCH RFC v6 2/6] gcc-plugins: Add STACKLEAK plugin for tracking the kernel stack Alexander Popov
2017-12-06 18:57   ` [kernel-hardening] " Laura Abbott
2017-12-07 23:05     ` Alexander Popov
2017-12-12  0:09   ` [kernel-hardening] " Dmitry V. Levin
2017-12-15 15:28     ` Alexander Popov
2017-12-05 23:33 ` [kernel-hardening] [PATCH RFC v6 3/6] x86/entry: Erase kernel stack in syscall_trace_enter() Alexander Popov
2017-12-06 21:12   ` Dmitry V. Levin
2017-12-11 22:38     ` Alexander Popov
2017-12-05 23:33 ` [kernel-hardening] [PATCH RFC v6 4/6] lkdtm: Add a test for STACKLEAK Alexander Popov
2017-12-05 23:33 ` [kernel-hardening] [PATCH RFC v6 5/6] fs/proc: Show STACKLEAK metrics in the /proc file system Alexander Popov
2017-12-06 19:22   ` [kernel-hardening] " Laura Abbott
2017-12-06 20:40     ` Kees Cook
2017-12-06 23:06       ` Laura Abbott
2017-12-07 22:58         ` Alexander Popov [this message]
2017-12-07  7:09     ` Alexander Popov
2017-12-07 20:47       ` Tobin C. Harding
2017-12-05 23:33 ` [kernel-hardening] [PATCH RFC v6 6/6] doc: self-protection: Add information about STACKLEAK feature Alexander Popov

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=0756b086-6ff8-b505-b638-4fd35d18250d@linux.com \
    --to=alex.popov@linux.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=ard.biesheuvel@linaro.org \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=labbott@redhat.com \
    --cc=luto@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=pageexec@freemail.hu \
    --cc=spender@grsecurity.net \
    --cc=tglx@linutronix.de \
    --cc=tycho@tycho.ws \
    --cc=x86@kernel.org \
    /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