From patchwork Fri Dec 6 19:48:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Xu X-Patchwork-Id: 13897671 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 01F9DE7717B for ; Fri, 6 Dec 2024 19:48:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5EA7B6B02DA; Fri, 6 Dec 2024 14:48:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FD076B02DC; Fri, 6 Dec 2024 14:48:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 350BA6B02DD; Fri, 6 Dec 2024 14:48:45 -0500 (EST) 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 0E2D96B02DA for ; Fri, 6 Dec 2024 14:48:45 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C0160AF883 for ; Fri, 6 Dec 2024 19:48:44 +0000 (UTC) X-FDA: 82865571432.11.3E55636 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf17.hostedemail.com (Postfix) with ESMTP id AE55E4000F for ; Fri, 6 Dec 2024 19:48:29 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="M9nTxD4/"; spf=pass (imf17.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.215.178 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=1733514505; 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=dKZgGxt5h33tUs/q9vcvav+JlEm6T9+HGtdqCUo6Cio=; b=ZsQciSx4dhtZl/iaja69h286WP8dupPeQd6X50bhdaAEwNik50n5vs09mZyVj0K7gso4Wb kc2ivi1noBDDxihydYv+O0yKtEDwnc4uKyhY5IUOaVju7mvrw5QGp8PijKJ04aChaPyWEo QTTXiaBHKV/8+8mEW40Z28cmu4ai20M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733514505; a=rsa-sha256; cv=none; b=LcJBCUY6Aq2I5WZiXNTfpo61ieaCNkQyUg17y2yUlYnMwqnDcAypGjGqTkuYQY46SydyFp EXE7qsYmqYW+PVtMMDs0pGeD4jBpfzXlATE6i4qk0NvtSH3au9ZOKX2VHCnYLsLf35A7qA lZBO03EcQv0sxUMw0pgMOemgBQvnWU8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="M9nTxD4/"; spf=pass (imf17.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.215.178 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-7eadb7f77e8so247907a12.1 for ; Fri, 06 Dec 2024 11:48:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733514521; x=1734119321; 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=dKZgGxt5h33tUs/q9vcvav+JlEm6T9+HGtdqCUo6Cio=; b=M9nTxD4/U8CJaQTrg3h3skS2XgDwbNix4p6jn4eGHFCpPRZnamZKPUvH4o9Nbd4uIW baWUuCsZkDqHhZaYpAiPhrwT934xZdAl+ljDVqJYwsMkmnZ9FoAxqrxpvM2StVZBiCwe cMO1+Zh4dPTY9Ju7lUbEu0UAKoX8NVS9uG690= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733514521; x=1734119321; 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=dKZgGxt5h33tUs/q9vcvav+JlEm6T9+HGtdqCUo6Cio=; b=IrsPUFO403LGwnaH1ZiY2r+I3ywlx723QakkPVk5jwi1Hyc5sI0Q96qpLraGZ2zRoA DTjKgtdtWtyHs3nCIkFBP0lIN0L8iOF/PwhvaXSxqoqaT1w/H60WpT7pP5neSosQKRFY P2b4WV9o/dOVOm/e4/GzRoZ5XBUXFqwdcUi4KAR94fK2c/2B/LTXPUZ2b/sWZPLxffe8 Tn7kR8RM1RqyJE2TA1mNZ0a/NYQs+XvIu+zn08/Gbw12uCPw1A2W5Mc8v9hr5H4zGJid fqolrzeY/8a/w/nkWv5s+2HyusBJXhs1Vh0DFFeLXfeanNgbU0ZCU10FHuMofkDvyzjZ ZUjA== X-Forwarded-Encrypted: i=1; AJvYcCXH6CyHFPIT5be6JahaI1gML4Er3Rh0K3ZjGF+JKeaAGhFzg88tTVrZy2+ANUbZDBqwY3HzZw9NqA==@kvack.org X-Gm-Message-State: AOJu0YzlGgBCmpKpfHJ7VXm1DP/pOVwec6AKgsy/phWWEn4wfKbBKbqA nGZeHDCAGCPPb722ARLm69AMpFqAwASkMtV4vBGwSr6aQrozFvrXvEabxQBw2Q7o06kn8v15HZ0 = X-Gm-Gg: ASbGncu45wiFZblWOXptt5yJgCar7D+HEeIGbKGQAkevVMO+q2s7+VDo4+NIpCa4DVn Lm+FgqYhZ1YWpxllbxxc2iCFVB9puLHUxZriuW0dU2etclOiW3bzzBiZIg0CstplHpxAVZg455T M+luDRRip3bZazmoGhkfNphiNLSuM+MpX/gyhXlCSrtB9mHMny7bKWusC5jIoqHAwBRz8mWFPeG tGDPkUmt0GaLWhSL+yfEV8jXbSxfeCVlhw1R2N/PU0hqbQkDq+oCKicdpSQWrpDkDTRFnpMBJ/7 doipk8Gtld0= X-Google-Smtp-Source: AGHT+IHHIPUS+nOwW3qIcBXhQCAbu0RwI1NczWGVxjH2s2mm/k1K5Ni5Cq+mTyAFLJrv08XeLo3oQQ== X-Received: by 2002:a05:6a20:72a3:b0:1d9:71:c23a with SMTP id adf61e73a8af0-1e187158340mr3045518637.10.1733514521497; Fri, 06 Dec 2024 11:48:41 -0800 (PST) Received: from localhost (238.76.127.34.bc.googleusercontent.com. [34.127.76.238]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-725a29c5d77sm3317742b3a.31.2024.12.06.11.48.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Dec 2024 11:48:41 -0800 (PST) From: jeffxu@chromium.org To: akpm@linux-foundation.org, vbabka@suse.cz, lorenzo.stoakes@oracle.com, Liam.Howlett@Oracle.com Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, jorgelo@chromium.org, keescook@chromium.org, pedro.falcato@gmail.com, rdunlap@infradead.org, Jeff Xu Subject: [PATCH v2 1/1] mseal: remove can_do_mseal() Date: Fri, 6 Dec 2024 19:48:39 +0000 Message-ID: <20241206194839.3030596-2-jeffxu@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241206194839.3030596-1-jeffxu@google.com> References: <20241206194839.3030596-1-jeffxu@google.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: AE55E4000F X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: gpbwyjro6n7c4epx4iz9cgb6fe8h8e6n X-HE-Tag: 1733514509-953960 X-HE-Meta: U2FsdGVkX1/urcsS7RhYNw8rj04YPSjhXoaFkrDcb0f8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GDH98bFgVX+mmpOfkIu+dVH70Vsir4cW2jVWL/08XK9FWYgrJo9hqYRvuZpaoW+S88otbVlM9EK+ZtqXi+Nmwm3AyklmjqVM6ClqSMhKgSptC4+o0fkjZ8Q9aHvjRclWYBLM9/m2v35pXMboqcjBUmb2Je6bDgi+fc4yM/SmadM8ItfBB1fII3efKmJiT3/dcTxkyfPSS3wfu+2wdo9xFcYuQWWYYL2Gxibt77UbZ7hX2WHxnWGm5VBxr8PwRDjG9MgcBfbo9bkJaPviehdjEomNO2/1t5DGVz2YhUR3/5iKAyco1Hl41efD0uuxmzMAdxg9CHLhijJt9W2Vv096n+QWO7oCMxGkYmXQ/Cwyw+vAvZ+oCHCWFk0J04fN479eEtD3I0Q9ThzIVACGOiqDf4XYNtBR31ePeVUXj655E0yU= 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 No code logic change. can_do_mseal() is called exclusively by mseal.c, and mseal.c is compiled only when CONFIG_64BIT flag is set in makefile. Therefore, it is unnecessary to have 32 bit stub function in the header file, remove this function and merge the logic into do_mseal(). Link: https://lkml.kernel.org/r/20241206013934.2782793-1-jeffxu@google.com Signed-off-by: Jeff Xu Cc: Jorge Lucangeli Obes Cc: Kees Cook Cc: Liam R. Howlett Cc: Lorenzo Stoakes Cc: Pedro Falcato Cc: Randy Dunlap Cc: Vlastimil Babka Signed-off-by: Andrew Morton Reviewed-by: Lorenzo Stoakes --- mm/internal.h | 16 ---------------- mm/mseal.c | 6 +++--- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 74dc1c48fa31..5e4ef5ce9c0a 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1457,22 +1457,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 -static inline int can_do_mseal(unsigned long flags) -{ - if (flags) - return -EINVAL; - - return 0; -} - -#else -static inline int can_do_mseal(unsigned long flags) -{ - return -EPERM; -} -#endif - #ifdef CONFIG_SHRINKER_DEBUG static inline __printf(2, 0) int shrinker_debugfs_name_alloc( struct shrinker *shrinker, const char *fmt, va_list ap) diff --git a/mm/mseal.c b/mm/mseal.c index 81d6e980e8a9..c27197ac04e8 100644 --- a/mm/mseal.c +++ b/mm/mseal.c @@ -217,9 +217,9 @@ int do_mseal(unsigned long start, size_t len_in, unsigned long flags) unsigned long end; struct mm_struct *mm = current->mm; - ret = can_do_mseal(flags); - if (ret) - return ret; + /* Verify flags not set. */ + if (flags) + return -EINVAL; start = untagged_addr(start); if (!PAGE_ALIGNED(start))