Received: by 10.192.165.156 with SMTP id m28csp242627imm; Tue, 17 Apr 2018 09:22:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+1s3zT2nBteBcdsWy58HZZikaMjEvWQ5zRhXax9REWDmTlYtd9HOOLD0TZlaMJ2EWS3tCy X-Received: by 2002:a17:902:30f:: with SMTP id 15-v6mr2616685pld.365.1523982171871; Tue, 17 Apr 2018 09:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523982171; cv=none; d=google.com; s=arc-20160816; b=OLMYnfgv4JATfc06A2aoxEAutlEp8zaC//2EHuZ5Gt1DE6sbK17jWLQGGLvo43lxSO msd1VfxrH/8r08IBOKt/1Rz4kPZExp3cR97JnI6W+P4Y2UrRy+MJ/JafPyAEwepEC+yj UU7/dJOIBZLn8hMiWHYb8av8PJ626caTsNY8kwRmeee0XoCSnMruHJnwm83LHU5QNfIK fVLxAYBhJfqsajbhaTWR+fsdmBcYcYEY+5CcU1nT4hZlr7CLiaGuLZdi9wP+ltYR8tHH Fy5fwgp5DfUYNTxqIu3pCWDspjSEr1hdZFyfjUDSFg3Q24vcEYoxRrY/AeYaBfWlJGa7 kZEg== 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=lPlqPwI3aaz4hWWHr5T97YHMfo6cUpQZfVL7b7pJaSQ=; b=iCxb4dlqCNoa63IsRwpmW46U05w3ITlaCxr8h5C4CZM8pgfjG2QRSnRCK/OV+6xKfd QqCrx065P+g5lLtAS6244D8lIg61hw7i2cghvjQu5XV7bEgGxcds4Yvm0m39XgTYNzyR gtip0x9dZwbyfTQ3taj3Nh3O8Ma941ZSJ0W3J64eRp6HnIe+xdsnwbrXPeFatBv73rQV E9PWOYgBvqUnbe5y9txBqLr7vx4etToNGlQxPmTzxp7i0ehx7ZqJc3zE4AOFtrRV2qhG /jdA7nCg3xenAi3mnxh1aWllvt4+unO+tuOrlpl4gSSorIyodsnJnoRgiZwUZt7Yo4gT TOTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=tgI3znu0; dkim=fail header.i=@chromium.org header.s=google header.b=m/ijypuN; 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 f4-v6si9661238plf.543.2018.04.17.09.22.37; Tue, 17 Apr 2018 09:22:51 -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=tgI3znu0; dkim=fail header.i=@chromium.org header.s=google header.b=m/ijypuN; 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 S1755873AbeDQQUU (ORCPT + 99 others); Tue, 17 Apr 2018 12:20:20 -0400 Received: from mail-vk0-f66.google.com ([209.85.213.66]:47062 "EHLO mail-vk0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755813AbeDQQKV (ORCPT ); Tue, 17 Apr 2018 12:10:21 -0400 Received: by mail-vk0-f66.google.com with SMTP id v205so12166833vkv.13 for ; Tue, 17 Apr 2018 09:10:21 -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=lPlqPwI3aaz4hWWHr5T97YHMfo6cUpQZfVL7b7pJaSQ=; b=tgI3znu0I3hkOvsdo/6mKtplI3ASCCqzJaESZJdJUUlOB5zrW+PIYNuGFcuRyyrS0W u8PReE08xs6UIDWaQCy/LGbbO4t3uQZ//8fWz/OboVpa/Cgw3WawjoFbtyjFuc8BnDeR hMjXbg1w0yggigXFIjWDN6FMw82iufn4l4FAzDpxT/i2sLb120ySLFQ+hyXVuScas8gK H0/tt5BXSQ5SYLb6FrrHtb48fKFhGhsqY214+7qOD2E5shaToyDgaBqU3Au2b7anGuL4 mokONBtyN5KLzi3U/UPLPf2n2ydICA06j0FvPVRzgHNt67JzntpL7pAeIS2C/KEw8rK4 V48Q== 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=lPlqPwI3aaz4hWWHr5T97YHMfo6cUpQZfVL7b7pJaSQ=; b=m/ijypuNcCZCHSEoDp1TkYZT+qDJ+EO9zZq6IR0enGKza0G4WsbWpomeBcxiGomzFh rIiEP/qsDi/tSOmUl1QI01/sdbvbnMUhH9qX+juev2gAS0IHzc1FbVdwmwJfEtlOVwc4 IMJ30/ILMJpSrMY4nvKGKSIUJVnGzujz9HKl8= 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=lPlqPwI3aaz4hWWHr5T97YHMfo6cUpQZfVL7b7pJaSQ=; b=GrVJDtUm5+7WvlZvGrsH2DZJXy/WFG/pYPb+ynq68bHGH30oGBT5HwTgdL+9bsnbYD 5N4nh6KvvaPmeSi7+qm3WTaP7YoqcIqwJMndGQgHBhptfSqPV/Js6v6v89rkubcuB/rc nQF1NWfXjKTNERUobNEcVov8F8Nf+MRV93/1Qq72JCle5NZTIxPns0TS4UUMFpSgPlLu UV6jLZaQ9uWd3dFITp6cYCBEclDWQAydnZhpEOuWvK4SvIGB/Kv3nqaVLgETfLjjewX4 de17UEg9S5KPgIASIHq5GiAM1jA9CffACBi3GhKgFk3iiI8U4BV7GN33s1WPgo2FzQQo JBGw== X-Gm-Message-State: ALQs6tD+0XxIqyW0mgIlxcwo/sHSs+hiq4310u9jEP07EpWDJzI0OADl uR8jOrM461rQs/d1Htz7+Uuad9uvxIaskw/LPkG/yg== X-Received: by 10.31.148.135 with SMTP id w129mr1890566vkd.7.1523981420261; Tue, 17 Apr 2018 09:10:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.164.81 with HTTP; Tue, 17 Apr 2018 09:10:19 -0700 (PDT) In-Reply-To: References: <20180417082054.26978-1-tmricht@linux.ibm.com> From: Kees Cook Date: Tue, 17 Apr 2018 09:10:19 -0700 X-Google-Sender-Auth: KEKmz8j8si55kJ0WjB-gaZZVBfw Message-ID: Subject: Re: [PATCH] modules: Fix display of wrong module .text address To: Christian Borntraeger Cc: Thomas Richter , Jessica Yu , Linus Torvalds , LKML , Martin Schwidefsky , brueckner@linux.vnet.ibm.com, Heiko Carstens , Peter Zijlstra , Arnaldo Carvalho de Melo , "Tobin C. Harding" 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 Tue, Apr 17, 2018 at 1:24 AM, Christian Borntraeger wrote: > > > On 04/17/2018 10:20 AM, Thomas Richter wrote: >> In kernel v4.16.0 the module .text address is displayed >> wrong when using /sys/module/*/sections/.text file. >> Commit ef0010a30935 ("vsprintf: don't use 'restricted_pointer()' when >> not restricting") >> is the first bad commit. >> >> Here is the issue, using module qeth_l2 on s390 which is the >> ethernet device driver: >> >> [root@s35lp76 ~]# lsmod >> Module Size Used by >> qeth_l2 94208 1 >> ... >> >> [root@s35lp76 ~]# cat /proc/modules | egrep '^qeth_l2' >> qeth_l2 94208 1 - Live 0x000003ff80401000 >> ^ This is the correct address in memory >> [root@s35lp76 ~]# cat /sys/module/qeth_l2/sections/.text >> 0x0000000018ea8363 <---- This is a wrong address >> [root@s35lp76 ~]# >> >> 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. >> >> Suggested-by: Linus Torvalds >> Signed-off-by: Thomas Richter >> Cc: Jessica Yu > > CC stable? > >> --- >> kernel/module.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/kernel/module.c b/kernel/module.c >> index a6e43a5806a1..77ab7211ddef 100644 >> --- a/kernel/module.c >> +++ b/kernel/module.c >> @@ -1472,7 +1472,7 @@ 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, "%#lx\n", kptr_restrict < 2 ? sattr->address : 0); Can we use %px instead, just to make the hash-bypass reports easier to grep for? -Kees >> } >> >> static void free_sect_attrs(struct module_sect_attrs *sect_attrs) >> > -- Kees Cook Pixel Security