Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 8 Dec 2017 01:58:24 +0300
From: Alexander Popov <alex.popov@...ux.com>
To: Laura Abbott <labbott@...hat.com>, Kees Cook <keescook@...omium.org>
Cc: kernel-hardening@...ts.openwall.com, PaX Team <pageexec@...email.hu>,
 Brad Spengler <spender@...ecurity.net>, Ingo Molnar <mingo@...nel.org>,
 Andy Lutomirski <luto@...nel.org>, Tycho Andersen <tycho@...ho.ws>,
 Mark Rutland <mark.rutland@....com>,
 Ard Biesheuvel <ard.biesheuvel@...aro.org>, Borislav Petkov <bp@...en8.de>,
 Thomas Gleixner <tglx@...utronix.de>, "H . Peter Anvin" <hpa@...or.com>,
 Peter Zijlstra <a.p.zijlstra@...llo.nl>, X86 ML <x86@...nel.org>
Subject: Re: [PATCH RFC v6 5/6] fs/proc: Show STACKLEAK metrics in the /proc
 file system

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@...hat.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

Powered by blists - more mailing lists

Your e-mail address:

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