From patchwork Tue Apr 21 08:17:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zong Li X-Patchwork-Id: 11500787 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66B531392 for ; Tue, 21 Apr 2020 08:17:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 33A6C2073A for ; Tue, 21 Apr 2020 08:17:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="cj0aBop9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33A6C2073A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2DD6B8E0006; Tue, 21 Apr 2020 04:17:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2B3F18E0003; Tue, 21 Apr 2020 04:17:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F1D98E0006; Tue, 21 Apr 2020 04:17:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id 0BC228E0003 for ; Tue, 21 Apr 2020 04:17:30 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AE05C40C7 for ; Tue, 21 Apr 2020 08:17:29 +0000 (UTC) X-FDA: 76731157818.24.game65_731a72808013 X-Spam-Summary: 2,0,0,925e2fc728ba4906,d41d8cd98f00b204,zong.li@sifive.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1534:1541:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2894:3138:3139:3140:3141:3142:3353:3865:3866:3867:3870:3871:3872:3874:4605:5007:6261:6653:6737:10004:11026:11473:11658:11914:12043:12048:12291:12296:12297:12517:12519:12555:12683:12895:13069:13095:13311:13357:13894:14096:14110:14181:14384:14394:14721:21080:21433:21444:21451:21627:21939:30054:30070,0,RBL:209.85.210.193:@sifive.com:.lbl8.mailshell.net-62.2.0.100 66.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: game65_731a72808013 X-Filterd-Recvd-Size: 4927 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 21 Apr 2020 08:17:29 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id x15so2010163pfa.1 for ; Tue, 21 Apr 2020 01:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qCOK+HxEBj2bh5BFlG2zt/46BhY0DW9NF3gypZJ6i18=; b=cj0aBop907dm+mkl5z5Mfm3dfJHK382iyGGadBdhXTU4SezE2MCsVNmjWKHydO1MeY hFpq9McPFpfy4rmx7G+Ad1j8hWL2TnkmF0IkMCtKAGmpU+zQZ6aqaTdmOppP8E8jMoFd Fk88jdQI+8R4LkqajRqwVMi8EwnmwqLx6QnbQ8a9F0T2Mu69VHyd9ana73iFO3tfR1QY WOG8lsevniXIBle/Wpw32M1HPnUM/cXVhVfyULOzUIUxNwMYRjXLGcKHakrVVhIkdCst HcA/EUYHskjCRFk4RGeoZHsmrSkm/oL6EadoBmaeDy9n6/Ei3y51wlw/4DW50BwDLHDj 41mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qCOK+HxEBj2bh5BFlG2zt/46BhY0DW9NF3gypZJ6i18=; b=PHTKSEqLutAdV+JfyUSysoynz034r9YvjJfi6cvjhSG5hCjXeIqcmnJJIdEsobSLYD 2Wibrq2WDV800J1QLQXDD+9fV4Bbz+WanEFBVZqIWmfy/qKJpahnAoSHn7rRu/EaejXq hldRb5HL987nfUX/2nH/gqjCRkEMh+hdoXl4u1+FTufmTlF5bBoDsTmCQX8WgEnt/g4r nBXAfA1jBeFqRLwY5EYklLjr7UUBVkYPcBSDA8rwoHBEoGfqcLyvz68LyIWuxlLIpvaF EykwOrBxA7OEMTXjxvey0RltyermIcaGh6CsPM8pLUlY9BRcodim78yCGIzop2723n5z H6Ww== X-Gm-Message-State: AGi0Pua6Rq+89l/C04zOHHrt06fmnaVy24VQN6h7v1/bnMaBGGF9iS0Y 6ystm5CcSjwD5djBhQVi6ziItA== X-Google-Smtp-Source: APiQypLl5oCj7vFGv7zZNaxGJsgDSRmBearvlFa0TCQKMUrRrSskifrV8HFOIzfmSxRHB+7OBiCjMA== X-Received: by 2002:a62:18c8:: with SMTP id 191mr21232603pfy.255.1587457048276; Tue, 21 Apr 2020 01:17:28 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id v9sm1610067pju.3.2020.04.21.01.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 01:17:27 -0700 (PDT) From: Zong Li To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, linux-riscv@lists.infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org Cc: Zong Li Subject: [PATCH 1/4] mm: add DEBUG_WX support Date: Tue, 21 Apr 2020 16:17:12 +0800 Message-Id: <23980cd0f0e5d79e24a92169116407c75bcc650d.1587455584.git.zong.li@sifive.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Some architectures support DEBUG_WX function, it's verbatim from each others. Extract to mm/Kconfig.debug for shared use. Signed-off-by: Zong Li Suggested-by: Palmer Dabbelt --- mm/Kconfig.debug | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug index 0271b22e063f..077458ad968d 100644 --- a/mm/Kconfig.debug +++ b/mm/Kconfig.debug @@ -118,6 +118,39 @@ config DEBUG_RODATA_TEST ---help--- This option enables a testcase for the setting rodata read-only. +config ARCH_HAS_DEBUG_WX + bool + +config DEBUG_WX + bool "Warn on W+X mappings at boot" + depends on ARCH_HAS_DEBUG_WX + select PTDUMP_CORE + help + Generate a warning if any W+X mappings are found at boot. + + This is useful for discovering cases where the kernel is leaving + W+X mappings after applying NX, as such mappings are a security risk. + This check also includes UXN, which should be set on all kernel + mappings. + + Look for a message in dmesg output like this: + + /mm: Checked W+X mappings: passed, no W+X pages found. + + or like this, if the check failed: + + /mm: Checked W+X mappings: failed, W+X pages found. + + Note that even if the check fails, your kernel is possibly + still fine, as W+X mappings are not a security hole in + themselves, what they do is that they make the exploitation + of other unfixed kernel bugs easier. + + There is no runtime or memory usage effect of this option + once the kernel has booted up - it's a one time check. + + If in doubt, say "Y". + config GENERIC_PTDUMP bool From patchwork Tue Apr 21 08:17:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zong Li X-Patchwork-Id: 11500789 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE8991575 for ; Tue, 21 Apr 2020 08:17:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BB01E20B1F for ; Tue, 21 Apr 2020 08:17:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="JRJeJlPb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB01E20B1F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C04778E0007; Tue, 21 Apr 2020 04:17:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BDB718E0003; Tue, 21 Apr 2020 04:17:32 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACA198E0007; Tue, 21 Apr 2020 04:17:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id 9A96C8E0003 for ; Tue, 21 Apr 2020 04:17:32 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 61280181AEF07 for ; Tue, 21 Apr 2020 08:17:32 +0000 (UTC) X-FDA: 76731157944.02.moon57_79193f201319 X-Spam-Summary: 2,0,0,b55ff89f37e2245c,d41d8cd98f00b204,zong.li@sifive.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3868:4250:4321:4605:5007:6261:6653:6737:7875:9036:10004:11026:11473:11657:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12895:12986:13069:13311:13357:13894:14096:14181:14384:14394:14721:14877:21080:21444:21451:21627:30054:30070,0,RBL:209.85.216.67:@sifive.com:.lbl8.mailshell.net-66.100.201.201 62.2.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: moon57_79193f201319 X-Filterd-Recvd-Size: 4940 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Tue, 21 Apr 2020 08:17:31 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id a7so1056954pju.2 for ; Tue, 21 Apr 2020 01:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x1q1dIc4oOXMLuGJhmG405YIgkstM/KJ0hlFL0aEcs0=; b=JRJeJlPbvECowqMMqAqWbzZ8nqW0b1fVx207l4nQs0G9+u8AyrE8inMOe8Uu+Z6mGj oEOZzr8Klh+dWRbsfgOaINRJsKMd/aRX3NBYE5XqzRJkaxfMatym5xIbV3ooZL9jnaaM +HNfMZHP/TNdCf+PfqN1VPRK3J4JEGjE/ewraiaQV5Hg6+Ddm8v+G1yXlEhe/L1wUJsC baY1iJBav4DXjyhX63v9oHhvFi0vhSpYSODaovIkLUeCbp0OKzfU1xWU0XnbBOC1jzjx sc81wyIHXiBh5pXITuvhWZg3AI1x327mOGasYIohrkBPXI/7uBC/YKfXZ3fW0DizX8rC IIvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x1q1dIc4oOXMLuGJhmG405YIgkstM/KJ0hlFL0aEcs0=; b=hdzAPinQ2NM8DYCmY2rEJ+hWsMLNlQ8Zun56h2Q8oIL0jpa20qEms6Pwm3O+5jpCoi Br43UCW6rjewQobwzj3bgiNnhsKyK7U525h6K4KNB6CVecG6bt0bfh1Q6Rg6Petn+T0L Sou665ZjXW4mXSQk2xjMx2NAWTb8a8e8qAA5tbqt3LA3mek4HkHgcKdM61GQK893CF9I /H5igCeqBqQAy3JBQHGZmdC5myX3nAl2t1kINq17qz6EXZwy3pIRP5sTOig3/99WXxEv phP2sKHbFi7GsgvqQ35x4W6WFTU1AiGkUCQDn6JKJfqeMTSBYxqwMEawMwQOLGxFK5Ry RxYQ== X-Gm-Message-State: AGi0PuatWHKiM7tqOyeQeCMSJvhi5I0c4S005H38s9Dzwesa4hlbf6Fp ThYf7zDCD+Z9kDAbwlVW2DCmgx+nyT4= X-Google-Smtp-Source: APiQypJ6TDv1BUeEjsdzkZkCUKbnTrPG7TD+P1kqLfxoAk/M5KRTxIjpkFX2KILsnIQRT2ae8Ou8Jw== X-Received: by 2002:a17:90a:1da6:: with SMTP id v35mr4465596pjv.44.1587457051158; Tue, 21 Apr 2020 01:17:31 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id v9sm1610067pju.3.2020.04.21.01.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 01:17:30 -0700 (PDT) From: Zong Li To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, linux-riscv@lists.infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org Cc: Zong Li Subject: [PATCH 2/4] riscv: support DEBUG_WX Date: Tue, 21 Apr 2020 16:17:13 +0800 Message-Id: <282e266311bced080bc6f7c255b92f87c1eb65d6.1587455584.git.zong.li@sifive.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Support DEBUG_WX to check whether there are mapping with write and execute permission at the same time. Signed-off-by: Zong Li --- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/ptdump.h | 6 ++++++ arch/riscv/mm/init.c | 3 +++ 3 files changed, 10 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 62f7bfeb709e..612bf0a258d0 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -68,6 +68,7 @@ config RISCV select ARCH_HAS_GCOV_PROFILE_ALL select HAVE_COPY_THREAD_TLS select HAVE_ARCH_KASAN if MMU && 64BIT + select ARCH_HAS_DEBUG_WX config ARCH_MMAP_RND_BITS_MIN default 18 if 64BIT diff --git a/arch/riscv/include/asm/ptdump.h b/arch/riscv/include/asm/ptdump.h index e29af7191909..eb2a1cc5f22c 100644 --- a/arch/riscv/include/asm/ptdump.h +++ b/arch/riscv/include/asm/ptdump.h @@ -8,4 +8,10 @@ void ptdump_check_wx(void); +#ifdef CONFIG_DEBUG_WX +#define debug_checkwx() ptdump_check_wx() +#else +#define debug_checkwx() do { } while (0) +#endif + #endif /* _ASM_RISCV_PTDUMP_H */ diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index b55be44ff9bd..86606e4d1860 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "../kernel/head.h" @@ -529,6 +530,8 @@ void mark_rodata_ro(void) set_memory_ro(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT); set_memory_nx(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT); set_memory_nx(data_start, (max_low - data_start) >> PAGE_SHIFT); + + debug_checkwx(); } #endif From patchwork Tue Apr 21 08:17:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zong Li X-Patchwork-Id: 11500791 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2EB81575 for ; Tue, 21 Apr 2020 08:17:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9FFED2098B for ; Tue, 21 Apr 2020 08:17:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="d1EGEWeH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FFED2098B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8CF958E0008; Tue, 21 Apr 2020 04:17:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 87F648E0003; Tue, 21 Apr 2020 04:17:35 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7966B8E0008; Tue, 21 Apr 2020 04:17:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id 675768E0003 for ; Tue, 21 Apr 2020 04:17:35 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2E56D3D19 for ; Tue, 21 Apr 2020 08:17:35 +0000 (UTC) X-FDA: 76731158070.10.bear38_7fa7ce1fd22f X-Spam-Summary: 2,0,0,12e3cf071992a914,d41d8cd98f00b204,zong.li@sifive.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2894:3138:3139:3140:3141:3142:3353:3865:3866:3867:3870:3871:3872:3874:4250:4321:4605:5007:6261:6653:6737:7903:9592:10004:11026:11232:11473:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12694:12737:12895:13095:13894:14096:14181:14394:14721:21080:21433:21444:21451:21627:21939:30054:30070,0,RBL:209.85.216.66:@sifive.com:.lbl8.mailshell.net-66.100.201.201 62.2.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: bear38_7fa7ce1fd22f X-Filterd-Recvd-Size: 5306 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Tue, 21 Apr 2020 08:17:34 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id t9so1062407pjw.0 for ; Tue, 21 Apr 2020 01:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ESIASWIVcw318N0kQ2X0Oi3Z+uroC+zqbTtsgDKDwxc=; b=d1EGEWeHYHIQOJqJjvQeV7F5XbEP5dKBW7WEsc7KqFePlpur3HEhURVt2nLAxU8R+t LZja7jNyrv/MqDehV+bIv3O2awu6Vc6wo5ja/99Fg3/zkOA/b8rUd12iwLrEVBqYNlL8 LTf7evXymEDmOXlZdm6r9x20Y2/6tY/73gMtdIWA1Ts91bYya8o7iZL7Qbyo1a9l5cHq Mb2NIZKnrqizgtSPU1Euc0ALQsGOdKx8TVzUdXCIOumRJtoGHAnWec62IkND8QTrmOQM nPH12sz33bLqzDbK623zAsgvXfGv/SPO4JkjRvc6iRfRE03SIsd9LDw4+o2qcXqrSP8N SPpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ESIASWIVcw318N0kQ2X0Oi3Z+uroC+zqbTtsgDKDwxc=; b=atyEC4FtYbs4c4YgJI+FlQyiodNDRZCuS7lWedwmAd0MoQBcXfqKtFUCOQZuklE5dE vYPEtFvVTnNwc7mdtmRCMc7CQk/nKW7TingQelKSK8JLqQYH1UWQ3mkiy2f9U4WZrY1t 8xDZd5ChJUNy8La88cWCMsV0xwaYvIU18NEDFPQ22zkwkV/+N/j/NJHaY+4599AYweMP cyPwnNe5mH4wd4LMyjUWrIAuNdP7NAKnP13sNPPWmIlKfrapTMtZO6+HVx+aMXMfqtjM AybM/WjKjg1BdM9eqFXZKzoKQPbKTi5Wj3nl8x7AT0+2dSbePHd7afOuMGB8MgJ+SWEC rzog== X-Gm-Message-State: AGi0PuafDgIrogMW/7m+cHE2JeKcCtvZ9Z1sbCg3o8ciUPs/woPFkpX0 jqSTEZzixCOYvS6fUbtDXZbMAA== X-Google-Smtp-Source: APiQypI7y+F6n5TeayUTsoUy+jp+f5r/1IV7aARGN/1mj8/tNHv7iVWTrDqjni/i9mOVUg3YAWeuFQ== X-Received: by 2002:a17:90a:7e4:: with SMTP id m91mr4322055pjm.155.1587457053972; Tue, 21 Apr 2020 01:17:33 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id v9sm1610067pju.3.2020.04.21.01.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 01:17:33 -0700 (PDT) From: Zong Li To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, linux-riscv@lists.infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org Cc: Zong Li Subject: [PATCH 3/4] x86: mm: use ARCH_HAS_DEBUG_WX instead of arch defined Date: Tue, 21 Apr 2020 16:17:14 +0800 Message-Id: <430736828d149df3f5b462d291e845ec690e0141.1587455584.git.zong.li@sifive.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Extract DEBUG_WX to mm/Kconfig.debug for shared use. Change to use ARCH_HAS_DEBUG_WX instead of DEBUG_WX defined by arch port. Signed-off-by: Zong Li --- arch/x86/Kconfig | 1 + arch/x86/Kconfig.debug | 27 --------------------------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 1d6104ea8af0..310a49ee3c25 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -80,6 +80,7 @@ config X86 select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE select ARCH_HAS_SYSCALL_WRAPPER select ARCH_HAS_UBSAN_SANITIZE_ALL + select ARCH_HAS_DEBUG_WX select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI select ARCH_MIGHT_HAVE_PC_PARPORT diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug index 2e74690b028a..de1846ed41b3 100644 --- a/arch/x86/Kconfig.debug +++ b/arch/x86/Kconfig.debug @@ -72,33 +72,6 @@ config EFI_PGT_DUMP issues with the mapping of the EFI runtime regions into that table. -config DEBUG_WX - bool "Warn on W+X mappings at boot" - select PTDUMP_CORE - ---help--- - Generate a warning if any W+X mappings are found at boot. - - This is useful for discovering cases where the kernel is leaving - W+X mappings after applying NX, as such mappings are a security risk. - - Look for a message in dmesg output like this: - - x86/mm: Checked W+X mappings: passed, no W+X pages found. - - or like this, if the check failed: - - x86/mm: Checked W+X mappings: FAILED, W+X pages found. - - Note that even if the check fails, your kernel is possibly - still fine, as W+X mappings are not a security hole in - themselves, what they do is that they make the exploitation - of other unfixed kernel bugs easier. - - There is no runtime or memory usage effect of this option - once the kernel has booted up - it's a one time check. - - If in doubt, say "Y". - config DOUBLEFAULT default y bool "Enable doublefault exception handler" if EXPERT && X86_32 From patchwork Tue Apr 21 08:17:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zong Li X-Patchwork-Id: 11500793 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDD201392 for ; Tue, 21 Apr 2020 08:17:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AA7D92098B for ; Tue, 21 Apr 2020 08:17:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="VzMHbZmG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA7D92098B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A081C8E0009; Tue, 21 Apr 2020 04:17:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9DEA58E0003; Tue, 21 Apr 2020 04:17:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91B8A8E0009; Tue, 21 Apr 2020 04:17:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0026.hostedemail.com [216.40.44.26]) by kanga.kvack.org (Postfix) with ESMTP id 79C4D8E0003 for ; Tue, 21 Apr 2020 04:17:38 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 274D6181AEF07 for ; Tue, 21 Apr 2020 08:17:38 +0000 (UTC) X-FDA: 76731158196.26.crowd20_869c3a3a6956 X-Spam-Summary: 2,0,0,fc38db61e33df859,d41d8cd98f00b204,zong.li@sifive.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:2894:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:4605:5007:6261:6653:6737:7903:9592:10004:11026:11232:11473:11658:11914:12048:12296:12297:12438:12517:12519:12555:12895:12986:13095:13894:14096:14181:14394:14721:21080:21433:21444:21451:21627:21939:21990:30054:30070,0,RBL:209.85.215.194:@sifive.com:.lbl8.mailshell.net-66.100.201.201 62.2.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: crowd20_869c3a3a6956 X-Filterd-Recvd-Size: 5378 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 21 Apr 2020 08:17:37 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id q18so2895363pgm.11 for ; Tue, 21 Apr 2020 01:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R51EKoGdprYIzq4mz86f7ksK2LhT5dJfZ4/kQMPqWXU=; b=VzMHbZmGtC1cli7/MzDUNjXVYWUl1NxixqtpJm0/9P/EzaLVRa8g8WgYud0Qm6Rchk /0trL5SM2/Zrj2mYcg8pq0A+qXdeLRNhfMiAZsy5X8Q7FkKkUcxE3FT4l8B0EtAmdA+a qWQTbQU8+OIZBMPZCnCgj1bgpLATeorKYHYYWZhPAzfAJg7qSDI1mvGlLkPsXDXc0xmQ nHxUsek7TS8kNEMxedKCaVU/PPk6efmG7yA1N7bxrcxILkRxr4XHk7vAf799he9GgfVg ZXr8nDGGsq+0uBoSEWHxoMPWrO9TNXqLg4+rs5s/lfX6Mf18km5fSJ2iKKhhbu7/Mopp enAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R51EKoGdprYIzq4mz86f7ksK2LhT5dJfZ4/kQMPqWXU=; b=pW4VsXphOoEXdPKWKatr+sn2jsmwzU3dV0P0EHYeod4A3SmGWSpiFG3qf90bTfNX4n LYav6YKj9YmA7xOQbMEMdIhDInuXK7JhnJsepmlQToLrgr9xSY4ZyspFic564DTl4kL9 3r5VD29eZGjAuxHBDA/JR0FDQ7jVxC/9H9ie64vvAV5FllUqxfMQVO9ijNkxEO0Yh/0V 5bWeypyhO9i28SouvE6EairI7ZPem/IO061NVqRWXpv7ekDGssGqaig+d+MgWbbAMwHF nnQSUFbtxnP8B6nEox5pIFIbyXUXHxu2hiouPyXUpSuOvi9mFbVOa9nw5sajC4q6NRbM IhJQ== X-Gm-Message-State: AGi0PubRVyXL1ET0xKA1aOdusbuVcbWHwgqUwPCkdXKYr8cF9VVVPV6z XTM6qh/RySAtS5egPck3JZSs8g== X-Google-Smtp-Source: APiQypJD+fzqoCjmoNF33zw6GUvSp1zVm+GJEMjBcSfH6XjMDUyeBTOm2mgFujSrzxWUd3wuELt89Q== X-Received: by 2002:a63:4e21:: with SMTP id c33mr21379911pgb.305.1587457056828; Tue, 21 Apr 2020 01:17:36 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id v9sm1610067pju.3.2020.04.21.01.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 01:17:36 -0700 (PDT) From: Zong Li To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, linux-riscv@lists.infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org Cc: Zong Li Subject: [PATCH 4/4] arm64: mm: use ARCH_HAS_DEBUG_WX instead of arch defined Date: Tue, 21 Apr 2020 16:17:15 +0800 Message-Id: X-Mailer: git-send-email 2.26.1 In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Extract DEBUG_WX to mm/Kconfig.debug for shared use. Change to use ARCH_HAS_DEBUG_WX instead of DEBUG_WX defined by arch port. Signed-off-by: Zong Li Acked-by: Will Deacon --- arch/arm64/Kconfig | 1 + arch/arm64/Kconfig.debug | 29 ----------------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 40fb05d96c60..a16e2ce80854 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -9,6 +9,7 @@ config ARM64 select ACPI_MCFG if (ACPI && PCI) select ACPI_SPCR_TABLE if ACPI select ACPI_PPTT if ACPI + select ARCH_HAS_DEBUG_WX select ARCH_HAS_DEBUG_VIRTUAL select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_DMA_PREP_COHERENT diff --git a/arch/arm64/Kconfig.debug b/arch/arm64/Kconfig.debug index a1efa246c9ed..cdf7ec0b975e 100644 --- a/arch/arm64/Kconfig.debug +++ b/arch/arm64/Kconfig.debug @@ -23,35 +23,6 @@ config ARM64_RANDOMIZE_TEXT_OFFSET of TEXT_OFFSET and platforms must not require a specific value. -config DEBUG_WX - bool "Warn on W+X mappings at boot" - select PTDUMP_CORE - ---help--- - Generate a warning if any W+X mappings are found at boot. - - This is useful for discovering cases where the kernel is leaving - W+X mappings after applying NX, as such mappings are a security risk. - This check also includes UXN, which should be set on all kernel - mappings. - - Look for a message in dmesg output like this: - - arm64/mm: Checked W+X mappings: passed, no W+X pages found. - - or like this, if the check failed: - - arm64/mm: Checked W+X mappings: FAILED, W+X pages found. - - Note that even if the check fails, your kernel is possibly - still fine, as W+X mappings are not a security hole in - themselves, what they do is that they make the exploitation - of other unfixed kernel bugs easier. - - There is no runtime or memory usage effect of this option - once the kernel has booted up - it's a one time check. - - If in doubt, say "Y". - config DEBUG_EFI depends on EFI && DEBUG_INFO bool "UEFI debugging"