Received: by 10.192.165.148 with SMTP id m20csp131132imm; Tue, 1 May 2018 19:21:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrNUj+e/kcdrFyuyC4eU7VF5Xq+5CnXus5KNHGLCARtoPg8IUKcf+10YIJkHTl51rglHAc/ X-Received: by 2002:a63:7a43:: with SMTP id j3-v6mr14567577pgn.172.1525227691885; Tue, 01 May 2018 19:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525227691; cv=none; d=google.com; s=arc-20160816; b=wEJtt8h/d1tiFu7UwwtIVNk6bptZEC321GYrNs0MffAp/v3BKdSYEEgeMklCb+w+q3 c3sgXNfkWEcaNpJLHNQ68VzhS1b9CZBUxe4zstUW1TGD7F8tlBmuFoueK2TBD/MygVjQ KKMhdw4YkyIS3miTNY+I2RjntBg8XYGRMSYx3MlIS6i5yijjRzvtoSxRL59DhB/KhMnr JVgQqKHH+Da9X17XPSJz95tfsMWorNETnyDyCym+Px9QhhoiqDmSi7aqTwX1naLFMnAL fINcNuD8/F2vdvavx8y/L4KP4WSpJqTbJEo8pTOQWDswePrMBIF7tE4ZQtAgQIyFrdsT gRNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=Yu45mQ3V8+IKRQsPov+O9cWL9SPnklwVhOYUoS20l6o=; b=Aefq2Be0liDBS2lxWpG4vOR4pxs9cGXzpmWsSTwJfA0s0I0J1UtwMG8NA3mu9cjMU/ bdmVkwTwJKNEMRTdDmEE/G+i6+g5s1SbpDrQ8Ubb4v1DC8xQ6mFv9VmSvEwOePvjwsUa D7JuZNz3EN7RdFlwWi8/y/GmhNTDdaPf3p9eTmnwyB+rWlq6Sj9K41C9sv8dRBkZIoJJ IObW4gvSlrTAq+k+nbEH++HIbHdN2Hla+T204AGEhx53mWX9O57rI9cEMADe1PaWqjTm JeYa9XYnvpZZsPigH0UT4myu+cYjxsNboRRltoq5Sw0g8kfwsrII+Qu9NTeIO+h8Fzmr xBug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=CwreXqv0; dkim=fail header.i=@chromium.org header.s=google header.b=DF2DIJGb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q16-v6si1810156pgc.635.2018.05.01.19.21.17; Tue, 01 May 2018 19:21:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=CwreXqv0; dkim=fail header.i=@chromium.org header.s=google header.b=DF2DIJGb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751214AbeEBCUw (ORCPT + 99 others); Tue, 1 May 2018 22:20:52 -0400 Received: from mail-ua0-f193.google.com ([209.85.217.193]:40958 "EHLO mail-ua0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945AbeEBCUu (ORCPT ); Tue, 1 May 2018 22:20:50 -0400 Received: by mail-ua0-f193.google.com with SMTP id g9so8492003uak.7 for ; Tue, 01 May 2018 19:20:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Yu45mQ3V8+IKRQsPov+O9cWL9SPnklwVhOYUoS20l6o=; b=CwreXqv0G67akUR0yu7ltHuCOhaH2/YBDLbRruIaQdHM02zO7wtsjyLknF6CChs+Cb Z3WB3w3rFG0IA1tFqiqkKPwGzynLF1mDjcS/GU1n4sP/u8OeraSNXJfdrHx2Uz2MNFkg YPHwt+OHn7xYoj3j/eoIU5CossGgVvlqg/wzIofyCbCt96QxF3d/6/2DzPw68ancC6gt 2XU8BWtp45tPocFnrjt4Ru9ro96v7KmORkyrukPUiBFIGd4YBOh54Inpfq95lv7UcGe9 54I4nRQb4AhhsLdrV74oMW3YNfxvFpntDb68Qhqnk2a8AyT+75e1TbCIAkGaoizwE0Mr S1zQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Yu45mQ3V8+IKRQsPov+O9cWL9SPnklwVhOYUoS20l6o=; b=DF2DIJGbPuQfSX+oyshlYvUBZWN8LKCkoSX0zbRg0imSDmAFCzQdxJpT5sdFk+ru3e Vj7CIUxDxeeCkRFfcG8jKVojBNuxwousmcsltBd5KYIY2IzrGevxGvckgEDqMYBfAmV0 HwxQgPbXDmmu9t0dpAkoUl0Q528DCDByQrn6A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Yu45mQ3V8+IKRQsPov+O9cWL9SPnklwVhOYUoS20l6o=; b=dDblEIqnFxzWNtJaeX0ynU8ahUilnlv4xpgau5hhdkjC3pgWw8gzpmyap69yjtpMDa n/FTACVNB4e5dFyR7q9Of6RwQZEodLuJFS7aS4LP71rSALo1yxq9LHlDJ0oY8r+YC2Hc uGkN3wC96eXv09JMen4o5W0USNocySxVNxkJp/PSBbaEBw88Dwf+3IYu6JZki4l1Pgy/ FIegaD9oMmcBG16DKjNMLxC4apl1xl+Rn2RJjF/CxIoeiknC8uCTk4a75q4+hABXaIH5 XeT1FvlKGld6C87DCzqi2VzOpa6DaowVgrdVzn5drRvtZU/cQv+VMC5nc3vm5OQXNV/b QzIQ== X-Gm-Message-State: ALQs6tD32AeoCp0wzQDFDK7GbJYrfCaCHQbLrGJjTLwqYswqSJHPtqPP 50tIzz1wyX4OHrnkkmsaYjYo6I3GPoo+cYp4xe2N6zBxAU0= X-Received: by 10.176.76.226 with SMTP id e34mr16879317uag.0.1525227649014; Tue, 01 May 2018 19:20:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.11.209 with HTTP; Tue, 1 May 2018 19:20:48 -0700 (PDT) In-Reply-To: <20180418071436.21392-1-tmricht@linux.ibm.com> References: <20180418071436.21392-1-tmricht@linux.ibm.com> From: Kees Cook Date: Tue, 1 May 2018 19:20:48 -0700 X-Google-Sender-Auth: 8p3jXzqf796h4b78XW5HVQqz-lI Message-ID: Subject: Re: [PATCH v3] module: Fix display of wrong module .text address To: Thomas Richter Cc: Jessica Yu , Linus Torvalds , LKML , Christian Borntraeger , Martin Schwidefsky , brueckner@linux.vnet.ibm.com, Heiko Carstens , Peter Zijlstra , Arnaldo Carvalho de Melo , "Tobin C. Harding" , "# 3.4.x" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 18, 2018 at 12:14 AM, Thomas Richter wrote: > Reading file /proc/modules shows the correct address: > [root@s35lp76 ~]# cat /proc/modules | egrep '^qeth_l2' > qeth_l2 94208 1 - Live 0x000003ff80401000 > > and reading file /sys/module/qeth_l2/sections/.text > [root@s35lp76 ~]# cat /sys/module/qeth_l2/sections/.text > 0x0000000018ea8363 > displays a random address. > > This breaks the perf tool which uses this address on s390 > to calculate start of .text section in memory. > > Fix this by printing the correct (unhashed) address. > > Thanks to Jessica Yu for helping on this. > > Fixes: ef0010a30935 ("vsprintf: don't use 'restricted_pointer()' when not restricting") > Cc: # v4.15+ > Suggested-by: Linus Torvalds > Signed-off-by: Thomas Richter > Cc: Jessica Yu > --- > kernel/module.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/kernel/module.c b/kernel/module.c > index a6e43a5806a1..40b42000bd80 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -1472,7 +1472,8 @@ static ssize_t module_sect_show(struct module_attribute *mattr, > { > struct module_sect_attr *sattr = > container_of(mattr, struct module_sect_attr, mattr); > - return sprintf(buf, "0x%pK\n", (void *)sattr->address); > + return sprintf(buf, "0x%px\n", kptr_restrict < 2 ? > + (void *)sattr->address : NULL); Errr... this looks reversed to me. I would expect: "kptr_restrict < 2 ? NULL : (void *)sattr->address" -Kees -- Kees Cook Pixel Security