Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4981905pxu; Tue, 22 Dec 2020 05:48:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDczSM6kxoV7+lk6LF0uZEB6CYdm5mwojB2NTqKJMKL+jfw5sVHhKdebqWKvrolAn+AINk X-Received: by 2002:a17:906:9382:: with SMTP id l2mr20387831ejx.162.1608644884793; Tue, 22 Dec 2020 05:48:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608644884; cv=none; d=google.com; s=arc-20160816; b=n/L1AuzO9QrsCHqTl6cF1dE4DaDea3ltDIpOlCzcIZdLgImRhxM6t8G8kKOwk++XHz k7CVB7GmNebzzMcNEpRR/1YCyR2Rtf3iEBxjcut9XXajZ0AjDAWeYIa8jTQ5Ft9LwQ8l 27yOre/AoEN7iNKiZtwkI/Xq9tkDy3Sh6+jU3eE/M+GFLfRuZZfGVNlP1kWoYde6nxkI 89VuDVhiRKlXb2SwGoEN3Eimi+YVAZbBfDGTttVHP2jFvFhCNzJB8TMQ2ymjD9IrowjA 11pA7G1MP8N1/4EpC1Ga2TyyXNbc4trdnmKryjv1iVDkwAkbMpuGUA2aJ+RHstX64N1e RdEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=lMxMpM9gZvpn6EIaKXhcYM+HSFE4AssFRbZccZ3ke70=; b=TCpunKCSZkfWtGVUPClV9pwhG1P4Da0y1EbQYERXWZW/dQJXGk6BQh6QCBqwEQh9Z5 nfvD1lc1PUzMQjJvDzvy2UrbPVPQqEXCjqJy6baSma8aBnF1d7MMlg4xeEDHjudtuxKd MYj59nZ2nxdOww+b56aW0v0ZYHjxOODD/UXDiD7AmUquVFexwo9kE9aaeNRRqSxU88QT QhHzlcn+JI+nrnxxWr9eeTSVUhE1diDbPTtq5042AvbueQohU/UJdO5CMaG+gWUAv84y MTm8oP64EzYgZcL6ZEAlxqTZgRmwiSpVxk8vsD7Y9S+2Lwvi1cRswlO9g4GBuAel7v86 fcmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si10412211ejh.224.2020.12.22.05.47.41; Tue, 22 Dec 2020 05:48:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727227AbgLVNp5 (ORCPT + 99 others); Tue, 22 Dec 2020 08:45:57 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:10065 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726903AbgLVNp5 (ORCPT ); Tue, 22 Dec 2020 08:45:57 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4D0cy65Bv6zLxlQ; Tue, 22 Dec 2020 21:44:14 +0800 (CST) Received: from [10.67.102.197] (10.67.102.197) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Tue, 22 Dec 2020 21:45:03 +0800 Subject: Re: [PATCH] powerpc:Don't print raw EIP/LR hex values in dump_stack() and show_regs() To: Segher Boessenkool , David Laight CC: Christophe Leroy , "ravi.bangoria@linux.ibm.com" , "mikey@neuling.org" , "yanaijie@huawei.com" , "haren@linux.ibm.com" , "linux-kernel@vger.kernel.org" , "npiggin@gmail.com" , "wangle6@huawei.com" , "paulus@samba.org" , "aneesh.kumar@linux.ibm.com" , "linuxppc-dev@lists.ozlabs.org" References: <20201221032758.12143-1-nixiaoming@huawei.com> <2279fc96-1f10-0c3f-64d9-734f18758620@csgroup.eu> <20201221163130.GZ2672@gate.crashing.org> <20201221171228.GA2672@gate.crashing.org> From: Xiaoming Ni Message-ID: <9b874bd4-9ac8-eb94-8432-8d6193c3feaf@huawei.com> Date: Tue, 22 Dec 2020 21:45:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.0.1 MIME-Version: 1.0 In-Reply-To: <20201221171228.GA2672@gate.crashing.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.102.197] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/12/22 1:12, Segher Boessenkool wrote: > On Mon, Dec 21, 2020 at 04:42:23PM +0000, David Laight wrote: >> From: Segher Boessenkool >>> Sent: 21 December 2020 16:32 >>> >>> On Mon, Dec 21, 2020 at 04:17:21PM +0100, Christophe Leroy wrote: >>>> Le 21/12/2020 à 04:27, Xiaoming Ni a écrit : >>>>> Since the commit 2b0e86cc5de6 ("powerpc/fsl_booke/32: implement KASLR >>>>> infrastructure"), the powerpc system is ready to support KASLR. >>>>> To reduces the risk of invalidating address randomization, don't print the >>>>> EIP/LR hex values in dump_stack() and show_regs(). >>> >>>> I think your change is not enough to hide EIP address, see below a dump >>>> with you patch, you get "Faulting instruction address: 0xc03a0c14" >>> >>> As far as I can see the patch does nothing to the GPR printout. Often >>> GPRs contain code addresses. As one example, the LR is moved via a GPR >>> (often GPR0, but not always) for storing on the stack. >>> >>> So this needs more work. >> >> If the dump_stack() is from an oops you need the real EIP value >> on order to stand any chance of making headway. > > Or at least the function name + offset, yes. > When the system is healthy, only symbols and offsets are printed, Output address and symbol + offset when the system is dying Does this meet both debugging and security requirements? For example: +static void __show_regs_ip_lr(const char *flag, unsigned long addr) +{ + if (system_going_down()) { /* panic oops reboot */ + pr_cont("%s["REG"] %pS", flag, addr, (void *)addr); + } else { + pr_cont("%s%pS", flag, (void *)addr); + } +} + static void __show_regs(struct pt_regs *regs) { int i, trap; - printk("NIP: "REG" LR: "REG" CTR: "REG"\n", - regs->nip, regs->link, regs->ctr); + __show_regs_ip_lr("NIP: ", regs->nip); + __show_regs_ip_lr(" LR: ", regs->link); + pr_cont(" CTR: "REG"\n", regs->ctr); printk("REGS: %px TRAP: %04lx %s (%s)\n", regs, regs->trap, print_tainted(), init_utsname()->release); printk("MSR: "REG" ", regs->msr); >> Otherwise you might just as well just print 'borked - tough luck'. > > Yes. ASLR is a house of cards. But that isn't constructive wrt this > patch :-) > > > Segher > . > Thanks Xiaoming Ni