From patchwork Fri Jun 14 23:20:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Xu X-Patchwork-Id: 13699164 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A9A3C27C6E for ; Fri, 14 Jun 2024 23:22:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3B2E6B017F; Fri, 14 Jun 2024 19:22:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 594EF6B0182; Fri, 14 Jun 2024 19:22:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A812A6B017F; Fri, 14 Jun 2024 19:22:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3B85D6B0196 for ; Fri, 14 Jun 2024 19:20:24 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C3EBEC034A for ; Fri, 14 Jun 2024 23:20:23 +0000 (UTC) X-FDA: 82231065126.29.66DEFFE Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf18.hostedemail.com (Postfix) with ESMTP id 03F771C0004 for ; Fri, 14 Jun 2024 23:20:21 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=kZcOS46N; spf=pass (imf18.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.210.180 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718407219; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5sKXX4VALlpzvd31iPrb4eMztLZWEFkwR52gFSz74AM=; b=FoEdbtDJMV1yWDo6JnKfq8iDDCUjd3cmVL5Fd7jDqavng6m4ysRL4ZmPFLx0fVPCiOs93A U7KS+YqHJGpvvdZJ5pT+e6RkACDrdgdjLqbMrULZ2gfJCpeQaipvHPnD0QpXSsf1Rm8T5b GaE98grcbuOKX/uCgPARw9ItBfTL/G4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718407219; a=rsa-sha256; cv=none; b=FoayVw3Zn+IJlL48kthle/ZkOxY1BSrosGRjvr2TVW9wbJ6npepKjjdDqaD07ClfoN25oE ALgICkYn854uFbw2y9mAzHYXQzR7/mzZxOHWPHUQELRlhjiZtFGqeQYqwlBmaNEeOfprHx bueS9oC4RdgPCdzP49x+308/yjmtjt0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=kZcOS46N; spf=pass (imf18.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.210.180 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-705c7e2d31cso2489157b3a.3 for ; Fri, 14 Jun 2024 16:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718407221; x=1719012021; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5sKXX4VALlpzvd31iPrb4eMztLZWEFkwR52gFSz74AM=; b=kZcOS46N4iCKg8SiHlfZiNszo2R5NSdOOWHk5gAgSnBDVhbtBc6PgfZb57nU+fp/iO ud+OCc5ayjel4DQ4UYidv/YzmEryuVeEUckGcVI0ozH5QtoR/wTIfQNnKAT3hKtrdNlY YGzLIv3RrCw52sYBG3SorSsz0UDvSqZLkzgpw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718407221; x=1719012021; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5sKXX4VALlpzvd31iPrb4eMztLZWEFkwR52gFSz74AM=; b=PRk9d3dU/U5KYTLKSE493R4Gi+Q+zopFDYGYXy37PA1LPQPFdR7k5qI13B4q2lUV35 PhbRYrDPR+HoXrxrGuHDHvBREV6JuwLv4gMoSL/UXmmW1BKEowWPzsZ5m47bNFrFaOEv AXCsusYTwWDMQ3iow0i7A6ohBZBbamn1UlvuKAW8CdI2hGU2yjH8kxFigBwWl541JtFe t7vJ69IHZL07fuu3bOvqx2RVM4Hrq1ERMreDprRH1lGBTsqbvHcPxM3sK9ZkO9ZOiFLK rnShmEj0Y9A1Fuaao+EZ9zgSfryCEWTITjq7aIDJ6ZhmEnczko7Qcrt1lKypmTJJsrEY j7xQ== X-Forwarded-Encrypted: i=1; AJvYcCUAxuHhFFnEcN0znJ5S1rb5I4vTxHlQ1vFLH7W0gFhBNrmdXdl8TEDzca437cA0hxcVJ6JLVkOf0ruxv8Sub0R5yIU= X-Gm-Message-State: AOJu0Yw7tA5i+yJ00giy4ES2wZVZ+VIplAMLoHhosgsPDeYSLdjA6+Y1 3PBjm21sVlhKa6eYP9tQU5LSTmg2z0AEk7YrZsn/6T/qIlnlydGDBvD4g5F0AQ== X-Google-Smtp-Source: AGHT+IEaKtIKsVDOYcOmB47qgVisOpqhdKsdmoxHcr8Lwv42IwYY08IPuEJQDEoV3VsClwjTqs1o7g== X-Received: by 2002:a05:6a00:1888:b0:704:b8c0:42ed with SMTP id d2e1a72fcca58-705d7144e01mr4910662b3a.9.1718407220764; Fri, 14 Jun 2024 16:20:20 -0700 (PDT) Received: from localhost (213.126.145.34.bc.googleusercontent.com. [34.145.126.213]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-6fee39bb90dsm2698718a12.77.2024.06.14.16.20.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Jun 2024 16:20:20 -0700 (PDT) From: jeffxu@chromium.org To: akpm@linux-foundation.org, jannh@google.com, sroettger@google.com, rdunlap@infradead.org, david@redhat.com, adhemerval.zanella@linaro.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, jorgelo@chromium.org, keescook@chromium.org, Jeff Xu Subject: [PATCH v2 1/1] /proc/pid/smaps: add mseal info for vma Date: Fri, 14 Jun 2024 23:20:14 +0000 Message-ID: <20240614232014.806352-2-jeffxu@google.com> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog In-Reply-To: <20240614232014.806352-1-jeffxu@google.com> References: <20240614232014.806352-1-jeffxu@google.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 03F771C0004 X-Stat-Signature: z1o7p9jz9oefywt7ty7gk5tpqz5w8teu X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718407221-189738 X-HE-Meta: U2FsdGVkX18zNb99VSVGq8nlbClk1pS0N+fpkmrOqquhC2RpxEKQPxEsFWDtW87Vr5PspKorcbqB0DHQLTuMeZJwPiS/QczLy0+uQLLqfUdcUDhTeWcfV84hIKVoYMBh0ZH83JCf0NdXyOLxP38qp2tRfFlxETQhHYN8T6ET7Pc5DRqwcMu0Gkk+ycgNDIJpRg65OF0RSVe3/4Qoknsb5g6yuWmlj1YnEK4+LLxXlQplYN63OJyTNuCsuSh1y2ahgLTIEvkFdoP3F8SKTkI/kW2jMQidXUGlI30tmGo7ZZbJmP0o5bwiI2F3uyREM93hOTDIZFuLwa6rkqugu9yrnQ+rAz0OdAcf12jew4gxsAi5m0XXYGBqz6Wi6paC4b6i8T7OS/EIgbkv3ObvoczqOW/QJLM0imMl2dCYeLrwvuY8wLjh6abtF79u7ZByebSUwxhw9EWS6dPK0qmGuSZJd/drpBS51956fcoGldNdZoRFbS0c19B7w+yDYu2sw8AtUvd2pM91j/3C68dkb95FDK5mQYKHFr2qk2Pg1lYOOhdy3xzzB9DNHEKLYyYdiMM8juBmZ3Gkbqs1olnk4N/RcSRN5xlAvpb64QjgocnYTwtfbwvDmiEsjhJEJZHuw1MxYLQgaPACNi8Wys7Zm+NVRc7l5mkZHlHULxWItgLTf8TmBeNrqPtrUpymV2ZmSE3GlnS52ymROWizeqPkWMg6OXEyZeOEPHZaZodlIg8dpim5PhnDZWdA/Ndw4fMqM12cjbvB02AgWmsw98t6FL+SbY5/0H2BTeGepkkw3h3bnhk25ESqPOc0JnoFp9IHOxvvsDYKSNI+uo9q9YqMGLmo3in+RKnwzw3fYavPdhNbu1TfyW+joAM82ioqdncQ4EXbo63eYX4Y6IgsGRXMFrCmtPX0dJOORUl1p7mBb/UXP8Z9+UeFwD7h/o4ewvSwi08SpLyslU5qWH3oz/Mz5L/ gbpj+XRO /9eFESq9k1h0GrRKw9OTXnzV5EgGNcrxrgZ9oD4Iw6PQueJQ5P3xToiPLn6yW4lAhgdpIpj5v2Kx4A6ptbdO/jNRx7uJ6zqMwIejUTkOXaQm5Lmmmm8D6nlLRSKzYQLk6YXM1N/8OC7VDvqNKIad59u6t2lfVIVWrclPCstmFXKTNoATpGvPo3eTMbP0fljkm4Tuqb8FFgBzRpP2hmfoOw702oGsrVAPrDHL7 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: List-Subscribe: List-Unsubscribe: From: Jeff Xu Add sl in /proc/pid/smaps to indicate vma is sealed Signed-off-by: Jeff Xu Acked-by: David Hildenbrand --- Documentation/filesystems/proc.rst | 1 + fs/proc/task_mmu.c | 3 +++ include/linux/mm.h | 5 +++++ mm/internal.h | 5 ----- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 7c3a565ffbef..82d142de3461 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -571,6 +571,7 @@ encoded manner. The codes are the following: um userfaultfd missing tracking uw userfaultfd wr-protect tracking ss shadow stack page + sl sealed == ======================================= Note that there is no guarantee that every flag and associated mnemonic will diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 6ed1f56b32b4..93fb2c61b154 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -711,6 +711,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */ #ifdef CONFIG_X86_USER_SHADOW_STACK [ilog2(VM_SHADOW_STACK)] = "ss", +#endif +#ifdef CONFIG_64BIT + [ilog2(VM_SEALED)] = "sl", #endif }; size_t i; diff --git a/include/linux/mm.h b/include/linux/mm.h index 587d34879865..84c4cc7354b4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -406,6 +406,11 @@ extern unsigned int kobjsize(const void *objp); #define VM_ALLOW_ANY_UNCACHED VM_NONE #endif +#ifdef CONFIG_64BIT +/* VM is sealed, in vm_flags */ +#define VM_SEALED _BITUL(63) +#endif + /* Bits set in the VMA until the stack is in its final location */ #define VM_STACK_INCOMPLETE_SETUP (VM_RAND_READ | VM_SEQ_READ | VM_STACK_EARLY) diff --git a/mm/internal.h b/mm/internal.h index fd68c43664d5..72f7c110d563 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1509,11 +1509,6 @@ void __meminit __init_single_page(struct page *page, unsigned long pfn, unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg, int priority); -#ifdef CONFIG_64BIT -/* VM is sealed, in vm_flags */ -#define VM_SEALED _BITUL(63) -#endif - #ifdef CONFIG_64BIT static inline int can_do_mseal(unsigned long flags) {