From patchwork Sat Sep 16 02:18:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13388082 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3D66CD37B2 for ; Sat, 16 Sep 2023 02:19:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236419AbjIPCTS (ORCPT ); Fri, 15 Sep 2023 22:19:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231585AbjIPCSs (ORCPT ); Fri, 15 Sep 2023 22:18:48 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25FD2173C for ; Fri, 15 Sep 2023 19:18:43 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-577fb90bb76so1508409a12.2 for ; Fri, 15 Sep 2023 19:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694830722; x=1695435522; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lNAcEM45JnuCfTSJI3E/dx3IgazeK//Dr+dUsENW/9I=; b=dErwtPH2G7abDL5kB5qiGhpulzgA5oK2y0zkfp9GNJk4LH2sASgp46k9IgrS/USCvW o314qKE6fVK4/+0TrC7RogNKAno77k86WiE1r30sveWDMrNlrsYdbWQ7FGvXKTdhJ7pq 9WqeFwo3BBWBE6YLyYcn3/2H4u8e8GWwI9LL8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694830722; x=1695435522; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lNAcEM45JnuCfTSJI3E/dx3IgazeK//Dr+dUsENW/9I=; b=Sg04Gb7UPQWTUTnKIQfYf24enlDoDCg8RNsl9Vb8FmpdGTZODvbUIWZN5ilhYebTyS QZNIH6RpVrYYbzR5gBc22F95YcUb7/FQcEAilad/+iDriruNaBwxALJRf5cUeCSKOXvq DEtlWeA7nXcs1OSmI/9CIdwUmQaFEt0evx9FtD6ZGOA0EqEKGd7NlLJRPZ6oRxS5hUOc CkMZM7w+IZeFR+s/TOtUtyp0V08LaVGT8lxqJ+KYKvr5lY9pgfKvC16F1NLgZvaUwXuw 9ZEx4ssBMWdpjeHh4yZqD3o+8dO5DQtrHm+jmZJbyjECYCyVhZinKnifTxffWuqtoJpt z24A== X-Gm-Message-State: AOJu0Ywuksqu3FDmGAB6fZ3bGNxZIntDazOfoDo7sKorovD5/ftZ9OXe oB6+lULQwqJG8MoYZRdX/28NGw== X-Google-Smtp-Source: AGHT+IHGflPojIWFVtfNOoBI/mmU5yo4NTnIHWbhbq4XOzjG2hmoFQfv/CUSUlzb4Q2BjUy9ltgeBw== X-Received: by 2002:a05:6a20:3206:b0:15a:58c8:b10f with SMTP id hl6-20020a056a20320600b0015a58c8b10fmr2994151pzc.43.1694830722637; Fri, 15 Sep 2023 19:18:42 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id p4-20020a170902a40400b001b03a1a3151sm4116061plq.70.2023.09.15.19.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 19:18:41 -0700 (PDT) From: Kees Cook To: Matteo Rizzo Cc: Kees Cook , Jann Horn , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] x86/mm/dump_pagetables: Add SLAB_VIRTUAL knowledge Date: Fri, 15 Sep 2023 19:18:39 -0700 Message-Id: <20230916021835.never.147-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1869; i=keescook@chromium.org; h=from:subject:message-id; bh=HmsovkvkpuwppfIJaKsY4lAxAF0+pyYONDwvgfgBOPE=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBRB/T8jhFzJbx6o5pyHiafrDVYrG9hl2ENXaj 1vL0IdviLGJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQUQfwAKCRCJcvTf3G3A JmvID/9kiQNsFcjzH+6NwX2OKRtQtlFTPX4yZBTLdnCSlSxoiZOn1Um7n4ushYsTSH9QPZ2ddwb ZO0VP2CD4+wb17Lra8vU4oBGVa7Qou3CMDgsmY29UzQAgJMybMY2IA7PK6tsbotWnW9A0fD50ux yzmULaSqemZOWBFAe7ahP5HoWMdrmi45KP/vnhSAJbiTrIYUBueQQectsRg2UEufA3kpMGFpyRc vuRQVGyTzX6c/w7jLd9IP06ww2nvV9deNlrTD0khFfDrR40jbKZ4YkHRuiS7DD9fDvuRKMAU0QX FkOWDs7Mvx/UO44vjmmLT6g9/T/temLWY4ud/DGWD2mZm7FD6wmCKCxFTgzKQSD/P90lhr9o217 rOulVz8VirrktInFxsA3t0ODzZpdyyMk3w48IOt+uXWi/Z3Ql8D3303wxw5XbNpSiFk9AwGhagg vx238fBXuPczyRGAzINKeLr/5u5vt8ErQmw1Tzij2Ph1UOVzGUwyDTTFTd9FP0HMDN+XqFG8T3B kE4REF5HqLOMJLVDOJjHJLpRnDkuO6gOMeLnoX+JEpJByYJex8wltdRkjYGRjh14psEpBsZaAU5 MCc6f8enuWqjL04mNW/SYQfAfq8gqQ/h/i1Pz8/vZB3hAMqTbLsopoZ2D7u1Mx7xr2jlhk/qqJh lchwYnO C2pRB0MQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Add the markings for the SLAB_VIRTUAL area. Cc: Matteo Rizzo Cc: Jann Horn Cc: Dave Hansen Cc: Andy Lutomirski Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: x86@kernel.org Cc: "H. Peter Anvin" Signed-off-by: Kees Cook --- This is on top of the SLAB_VIRTUAL series: https://lore.kernel.org/all/20230915105933.495735-11-matteorizzo@google.com/ Feel free to collapse this into the x86 patch from the above series. FYI, as expected, the kernel page table entries get way longer with SLAB_VIRTUAL. :) Without SLAB_VIRTUAL: # wc -l /sys/kernel/debug/page_tables/kernel 1501 /sys/kernel/debug/page_tables/kernel With SLAB_VIRTUAL: # wc -l /sys/kernel/debug/page_tables/kernel 7549 /sys/kernel/debug/page_tables/kernel --- arch/x86/mm/dump_pagetables.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index e1b599ecbbc2..b1fa68669e61 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -64,6 +64,9 @@ enum address_markers_idx { KASAN_SHADOW_END_NR, #endif CPU_ENTRY_AREA_NR, +#ifdef CONFIG_SLAB_VIRTUAL + SLAB_AREA_NR, +#endif #ifdef CONFIG_X86_ESPFIX64 ESPFIX_START_NR, #endif @@ -95,6 +98,9 @@ static struct addr_marker address_markers[] = { [LDT_NR] = { 0UL, "LDT remap" }, #endif [CPU_ENTRY_AREA_NR] = { CPU_ENTRY_AREA_BASE,"CPU entry Area" }, +#ifdef CONFIG_SLAB_VIRTUAL + [SLAB_AREA_NR] = { SLAB_BASE_ADDR, "Slab Area" }, +#endif #ifdef CONFIG_X86_ESPFIX64 [ESPFIX_START_NR] = { ESPFIX_BASE_ADDR, "ESPfix Area", 16 }, #endif