From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758054AbcHYVHx (ORCPT ); Thu, 25 Aug 2016 17:07:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48238 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755466AbcHYVHU (ORCPT ); Thu, 25 Aug 2016 17:07:20 -0400 Date: Thu, 25 Aug 2016 16:07:16 -0500 From: Josh Poimboeuf To: Kees Cook Cc: Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , the arch/x86 maintainers , Linux Kernel Mailing List , Andy Lutomirski , Steven Rostedt , Brian Gerst , Frederic Weisbecker , Byungchul Park , Nilay Vaish Subject: Re: [PATCH 3/6] x86/dumpstack: make printk_stack_address() more generally useful Message-ID: <20160825210716.e3p42qm5k4yd3cqb@treble> References: <9fbe0db05bacf66d337c162edbf61450d0cff1e2.1472057064.git.jpoimboe@redhat.com> <20160824182220.GB10153@twins.programming.kicks-ass.net> <20160824193707.qw7vii3l4ggcfl6d@treble> <20160825174904.vfam55lpo7geczqf@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 25 Aug 2016 21:07:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 25, 2016 at 04:41:29PM -0400, Kees Cook wrote: > On Thu, Aug 25, 2016 at 1:49 PM, Josh Poimboeuf wrote: > > On Wed, Aug 24, 2016 at 02:37:07PM -0500, Josh Poimboeuf wrote: > >> On Wed, Aug 24, 2016 at 02:37:21PM -0400, Linus Torvalds wrote: > >> > On Wed, Aug 24, 2016 at 2:22 PM, Peter Zijlstra wrote: > >> > > > >> > > I actively disable KASLR on my dev box and feed these hex numbers into > >> > > addr2line -ie vmlinux to find where in the function we are. > >> > > > >> > > Having the option to make %pB generate them works for me. > >> > > >> > Yeah, considering that this is the only place this is used, changing > >> > %pB sounds quite reasonable. > >> > >> There's now another use of '%pB' in proc_pid_stack() in the tip tree: I > >> changed it to '%pB' from '%pS'. But I think the modified '%pB' would > >> work there as well. > >> > >> > We could perhaps make %pB show the hex numbers and address (so pB > >> > would expand to "[] symbolname".if > >> > > >> > (a) not randomizing (so the hex numbers _may_ be useful) > >> > > >> > (b) kptr_restrict is 0 (so the hex numbers are "safe" in the dmesg) > >> > > >> > and fall back to just the symbolic name if either of those aren't true? > >> > >> Do we really need to check for both? '%pK' only checks kptr_restrict. > >> I'd think we should be consistent with that. And maybe there are some > >> scenarios where the actual text addresses provide useful debug > >> information if KASLR is enabled and kptr_restrict is zero. > > > > So I was looking at implementing this, and I noticed that '%pK' prints > > "pK-error" if it's called from interrupt context when kptr_restrict==1. > > Because checking CAP_SYSLOG would be meaningless in that case. > > > > I don't really understand the point of the "pK-error" thing. Any reason > > why we can't print zero, i.e., just degrade the kptr_restrict from 1 to > > 2 in an interrupt? > > > > That would make the '%pK' code simpler and usable from interrupt > > context. Also it would make its behavior consistent with the proposed > > '%pB' changes, and the kptr_restrict code could be shared between '%pK' > > and '%pB'. > > > > Kess (or others), any objections if I make that change? Ahem, Kees, sorry :-) > I don't mind this becoming "0" on error. I suspect the rationale was > to make it a discoverable condition and to avoid confusion. > > As far as expanding the usage, I'm still in favor, though there is > work planned to make kptr_restrict go away in favor of having > blacklisted destination buffers, etc. I'm hoping to have this as part > of the continuing usercopy hardening work. > > Regardless, aren't these values being written to dmesg buffer? > Traditionally we've not bothered censoring values that go there, as > "dmesg_restrict" exists to protect those contents. Ah, the plot thickens. I didn't know about 'dmesg_restrict'. So I guess we don't have to restrict the stack dump addresses after all, since the entire dmesg buffer is protected by syslog()? If so, I'm thinking that expanding '%pB' wouldn't be worthwhile after all, because its two users would have two different requirements for printing the address: /proc//stack needs to use kptr_restrict but the unwinder doesn't. In which case I think the current code is fine. -- Josh