From patchwork Fri Jun 14 18:23:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Xu X-Patchwork-Id: 13699040 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 500ECC27C6E for ; Fri, 14 Jun 2024 18:27:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 195F46B00EA; Fri, 14 Jun 2024 14:27:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 303BC6B0163; Fri, 14 Jun 2024 14:27:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0335A6B0149; Fri, 14 Jun 2024 14:27:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8F8A96B015A for ; Fri, 14 Jun 2024 14:24:04 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 3E699A088A for ; Fri, 14 Jun 2024 18:24:04 +0000 (UTC) X-FDA: 82230318408.06.84BC990 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf26.hostedemail.com (Postfix) with ESMTP id 6120914001E for ; Fri, 14 Jun 2024 18:24:02 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=W1CuEotf; spf=pass (imf26.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.216.48 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718389440; a=rsa-sha256; cv=none; b=CdsUgacMOfUCsVEn8haY3fK1PzVke0YvvAvCXAH8zBP4xNvaliX07MhoTg+K018woeEZ1b /Q/5VAzrSAxqLU/hiu03l303kTtvWRDFisXDRDvDnAQzShCN2+A8ziam4ZfDHdAiLKrQt6 kjMSdt7q4GUazmvux22/THdAm+1MVsI= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=W1CuEotf; spf=pass (imf26.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.216.48 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=1718389440; 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=CVHZFIyiPWaIjhxXT8vFMd23GY5cZ8Wtr6v4ExnEFT4=; b=kGS9A1srzctiIg6bL6YzRIyQDyBhG4DN35uyJ3ZroAqOVq84yzomDzceh58Vdtg2MjBo5v uz32B+UBfqpwkjz7miAvp+sWdoheXV3d5goQDZGxfLJ0f3hjxF4Du8GU9YMhlnqncIPNsB bF8xCYLlg58WeI0jPQNiu73Rw9C5rrE= Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2bfff08fc29so2110453a91.1 for ; Fri, 14 Jun 2024 11:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718389441; x=1718994241; 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=CVHZFIyiPWaIjhxXT8vFMd23GY5cZ8Wtr6v4ExnEFT4=; b=W1CuEotfClu9/Ho6p5Q8fokGsBKgswXsCg9yschN+SbCUpo2TnTU/7sczh8vwxQ2Nk 0yCErnYX3pT8tHoPSTH6B4+PpLiGaDTgmXdwg6JJh5fY9Yl5cIQL/Dctv1qBOPXAVRuV D4nkb6Z2Q1VpKHQChaSMoTyf56SE5s0ZqXotU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718389441; x=1718994241; 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=CVHZFIyiPWaIjhxXT8vFMd23GY5cZ8Wtr6v4ExnEFT4=; b=r6NoztDSDjTYWKcDcWA82ZyvLjS0H6ttuTPdaNngk8gdpPK1eTRy4AoNzuR/vFsiXz /WDnAqO6IY12qm9pmjCKZ+qL0nvwKfv6hGXsZMlMZX2mW1N7JXtDjqtk4S/BmHDkRT24 8th9L9t8gagsI0/joQcN6e91RctYNvhKZVQpIXeVhVE+O3iJoMc9cOMbQLMMkffVte5T 9C3UttG760z3yBC7hrIZu7lyTuJzvx5xCSdMrNbBRlgDTryTKdIRTepW3mZEWByq5CNh I14//7jmPbTR4jF793ciJnsv/3FL7RYDyxOJJ5zLMY5bTfiLG/95gT49S5goMIgs1dhT qGVQ== X-Forwarded-Encrypted: i=1; AJvYcCXfRUXMvAL5NP/CXsBP347Y5PGDN2vy1lDfW6s3uVNX+ArxDmCbDgkxg8kgExDVHuU7uY1ZHUq8e0Z4LspULQ9c5Ho= X-Gm-Message-State: AOJu0YyvgbzoC7G10efHlqsJPHo6igZHFe/5o7aS53UXddOw7yHFdGmH V7SgOS077HTCE/x54h1GGHuHZ+e7+T2lbAvkO+wK5EFxtrWoeqFCBSUUscXY0g== X-Google-Smtp-Source: AGHT+IHGY+/B1ncUMFBE/3CojUtQT1wv0qbtFEgFQVZatzHMVqfYLbr7b4a6VgXLaakYnYqdtomNQA== X-Received: by 2002:a17:90b:4d8b:b0:2c4:aa67:895c with SMTP id 98e67ed59e1d1-2c4db242648mr3495956a91.17.1718389441185; Fri, 14 Jun 2024 11:24:01 -0700 (PDT) Received: from localhost (213.126.145.34.bc.googleusercontent.com. [34.145.126.213]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2c4c466c3desm4234620a91.46.2024.06.14.11.24.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Jun 2024 11:24:00 -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 v1 1/1] /proc/pid/smaps: add mseal info for vma Date: Fri, 14 Jun 2024 18:23:27 +0000 Message-ID: <20240614182327.752156-2-jeffxu@google.com> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog In-Reply-To: <20240614182327.752156-1-jeffxu@google.com> References: <20240614182327.752156-1-jeffxu@google.com> MIME-Version: 1.0 X-Stat-Signature: 6gie4spokuezzapaxu8b1ytnjwgy6jp9 X-Rspamd-Queue-Id: 6120914001E X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1718389442-607019 X-HE-Meta: U2FsdGVkX1+FOtDgTAAQMKXoeyJpzZ8I7zaNuhMjM/u2S4rmli9t/GyT6pyzZNBy0KMS5XmHkuQ8lx/yD5xBSRJ9S2YvXThL8356HNSQN23ANjYO9BILyijjt/H9qvlt/7w6eofX+OK4TlfiBxTkZ0+IQMviS9OFH6BHQKE+q0QJBKSSfjWNxsLgCYgzohZQv8ng82+v1EiU1kgQsx3WCyFwhX6RPSky/vDJfDpwNG+Bkwg/SiEoKws0D/92SVHSASlsXczMxo9VjWl3WYHbvrucUXf2J3qnIKci5xjGGtg5vechj5hNMduWapn/+4wsP+swZPICZOx4qdA+o5XSVACSN0GomBX7kM4sPeoDDtu8tLEt6Xu80bIBJSAcYADy9P5tnmDKdws13w/adrwtntIurq3khjLVm+PR2PSQaYmxFv86GgkdgyARRn6Ha4P5Z9Ap4rHOPSbBrvKtNdoq0OEkE5PZ5vX4q4ceA7ORLCXP18G70Jm5trAr36hG1XNpxZRV6FhHOgztcaEKim1oV9QoDH4xH8QZ/htvjC7o/46is79E/lUnW8SzqabE/ofp4T+lyoeIwVUyH8PzXtag6T3SzE/t42vDdQpwN0IywdNZarJgPCh++FunC6pPORCAUlW06orLNr/tC6e1LQZ3NyabVb2whMSIW6HKqpyQ2PdBcfo+T6EUOjRsooSSu1Wn2Sa1EA/kOFuUyuaNRtTtRAr2bYkMHa6nuJddd2dsYKYEbPL+qPC+PRW3U4SxxueNhh5hpqE6yUetkmr465AOAJ2Z22svn223Pv0nRhfwIsAdo46kyzKL48+z+1y/kjC2V2j2Ylmpjz6iC1Yms6VIbxWMa6mGscc4Zl5H3EmtMtpWciQ7nZk9VlZyosw6NN278ZohRsBnUOyuh5s7qvMtVhzfDazgtEmkZCasTcmHGJ6CZXByVCHx/wbMy2WZ74fDZ3OqYYNL+FePSvA06Xd Wxx2fpID RcAuLeoNOIaaLZkcE3dKUf4HY9ubHQorYZzqWY11M7rYfbnwEGifsVjAJkZgN3m9LIEBL7FbG6PDzbBwMYmLGpoIalaTkBtHbnrvuB7YD8Q++HRdBZZHisyZRtmIw0atfvlEvAHiHNBEa3RBF9IpcxWhH8Vr3NxQHmmnvlyArwOZ8tdX1XI131inPJjxybYx5gVzdeZ4C5rlyhwT6IHdq5pZuxr5tCNQJ/4OI 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 sp in /proc/pid/smaps to indicate vma is sealed Signed-off-by: Jeff Xu --- 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..400217a1589c 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 + sp sealed page == ======================================= 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..ba2db75ca22a 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)] = "sp", #endif }; size_t i; diff --git a/include/linux/mm.h b/include/linux/mm.h index 587d34879865..8600564898fa 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -314,6 +314,11 @@ extern unsigned int kobjsize(const void *objp); #define VM_NOHUGEPAGE 0x40000000 /* MADV_NOHUGEPAGE marked this vma */ #define VM_MERGEABLE 0x80000000 /* KSM may merge identical pages */ +#ifdef CONFIG_64BIT +/* VM is sealed, in vm_flags */ +#define VM_SEALED _BITUL(63) +#endif + #ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS #define VM_HIGH_ARCH_BIT_0 32 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_BIT_1 33 /* bit only usable on 64-bit architectures */ 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) {