From patchwork Sat Aug 17 00:18:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Falcato X-Patchwork-Id: 13766880 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 CF43DC52D7D for ; Sat, 17 Aug 2024 00:18:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 395A06B03D4; Fri, 16 Aug 2024 20:18:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 343E46B03D6; Fri, 16 Aug 2024 20:18:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 176716B03D7; Fri, 16 Aug 2024 20:18:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E4A696B03D4 for ; Fri, 16 Aug 2024 20:18:50 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 747581603C2 for ; Sat, 17 Aug 2024 00:18:50 +0000 (UTC) X-FDA: 82459826820.22.AFF3670 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by imf20.hostedemail.com (Postfix) with ESMTP id 68D6C1C001D for ; Sat, 17 Aug 2024 00:18:48 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JQEGDNMl; spf=pass (imf20.hostedemail.com: domain of pedro.falcato@gmail.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=pedro.falcato@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723853869; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AVSLpFCNCxLphAVPpePgVTrDRTKaNng95YGqfZlpIJs=; b=E5aouc/qHkk11fLDzX6A+pRt8HGL523dznnM4ym1DsY7EDG2WpLcP9gRU5kts8EW+XoEci FGil/NqKV2qOVa7iKV8WwFkAcxD/0KPDBmgkokyMcDmxPbRyGKWb28DgHbNuu5KMH7klKV pEE+/Vve1sA+M4Li+H1sCPaCyWRaGr8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JQEGDNMl; spf=pass (imf20.hostedemail.com: domain of pedro.falcato@gmail.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=pedro.falcato@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723853869; a=rsa-sha256; cv=none; b=Uc4LAKIdIjEx7pnxpNB5T4K1k6Q3uXgtwW4PHf4zN7WTO8DyOECMHJ9WWovH0HxpIuqSET 1SF4r5hiVME7LClMyUgXcFCMcUP1TyQrlFnrpuslYqzGf3bXpNS971Uzem0KS5ec6VQ0DU +hPYxFH2YZK4yM1SveoaB+ZZyBDUuBk= Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-42816ca797fso18569085e9.2 for ; Fri, 16 Aug 2024 17:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723853927; x=1724458727; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=AVSLpFCNCxLphAVPpePgVTrDRTKaNng95YGqfZlpIJs=; b=JQEGDNMlRuWFJ/TU4AyOlQpl50uS4D6t0gdZ2TQlmjvgfGttdroQsWkTBk1oF/J78i 4vmdLolF5Amg1jW5QdugtNPhLhQWCO1d6OapHvXp4Z2GWj7yrilIYvuCOjTgEpQ1Eg0y VAPKcSMtw5dX+jxH1hFCYrnqOn0t+kfwttlD3DgexaKY3RnIhmW+oOOQgrrVtk7vvzdI HniqKyzjD3ocM2/ONGwHV63jeaIJR9C0Z7hffKyTIzl/oNzIpShZ99fhe9qfgyxcw4eg qxjap5euSzDTuSfcevsJCbsM6oYjOgMceelwwO+RJuRboKi26ZMS7hI4T/mKxlH3OV5k ZLVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723853927; x=1724458727; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AVSLpFCNCxLphAVPpePgVTrDRTKaNng95YGqfZlpIJs=; b=mPnWoI7dwCI+pSas+Su4gFbU4aqKjWxF4eHwsVXVpX+9S3wmWwyXVb3ELOJnPuxgVs 9AmpEXXUv88dCjP+zHLUifMJZBklNUUTXvLQL5wMptCXloaiEf/ZMuknGAhvGK26n4Xc rbtgye5aF6YDHYSJ9hmSwW799eKkTrIW9K7bm9WPZDGZwWDGrkaIXgNfjiLkZvPsAuVs ZEJk1e69kEcwwWXPEc3lBLspksrlMFlwLQOJzKp/hvGooffBgcG07xnvGsudjWsYaeuH SUNFclsGwvOJjBY0UYOFuKgHxmzvwUcyyhJSMZbCbZo2+0STO1AF6iV9voKELYUxoE7y i+Xg== X-Gm-Message-State: AOJu0YzWN9senmvR1vdySsYOewR8WbpTTmYM3bA6YfxYN/p6uH43NYOm mDa/MpMzzequ5XTj1/glelxkWAbMHShh+ixgik26guVt7BzG6Kg2 X-Google-Smtp-Source: AGHT+IEF/45IWEnY8seUwWDHiPQtCFESvI6bebHfacPqy451180xkuSrsBTLSGa9GQqBMGnh8DYNYw== X-Received: by 2002:a05:600c:35c5:b0:428:1a48:d5cf with SMTP id 5b1f17b1804b1-429ed7ba070mr33189155e9.9.1723853925945; Fri, 16 Aug 2024 17:18:45 -0700 (PDT) Received: from [192.168.1.91] ([2001:818:e92f:6400:96b:aa92:afc0:2d3d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429d781047asm104842055e9.0.2024.08.16.17.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 17:18:45 -0700 (PDT) From: Pedro Falcato Date: Sat, 17 Aug 2024 01:18:33 +0100 Subject: [PATCH v3 6/7] mm: Remove can_modify_mm() MIME-Version: 1.0 Message-Id: <20240817-mseal-depessimize-v3-6-d8d2e037df30@gmail.com> References: <20240817-mseal-depessimize-v3-0-d8d2e037df30@gmail.com> In-Reply-To: <20240817-mseal-depessimize-v3-0-d8d2e037df30@gmail.com> To: Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Shuah Khan Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, jeffxu@chromium.org, oliver.sang@intel.com, torvalds@linux-foundation.org, Michael Ellerman , Kees Cook , Pedro Falcato X-Mailer: b4 0.14.1 X-Stat-Signature: ut3ixgcn7pprspckr8563b71yaeerj8z X-Rspam-User: X-Rspamd-Queue-Id: 68D6C1C001D X-Rspamd-Server: rspam02 X-HE-Tag: 1723853928-925784 X-HE-Meta: U2FsdGVkX192+j8QRZageaTnDPSJM9Gb0xeoAkGqr/R9Atl8qJDnakt0wPfYwpTRp9kbHzh8TQmQZKHSP2Yo4OxIcdN90oAv8iTB7cfBukYzlBv2eNdQD/1EyjSu3V9T95Mr/CWW5viVNu2HNB1u1/g8hkctib3XHwpATpZOiXxiRpR/mOqVKw5NQ6xEgv8YcXRgtBjpZ0mp8wByFfrXYwqSR0rNCpEQgia5viuvGf4OzB/MaL8u5/c73rigqQpNN7nrwmEbxY/9Mkh1Lakuau/FVxkGNtFQcpMXN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Gl01unJzFCRH0Rl47iQtThpkd76kT6i/uM5NROhUgvoUByfOJgLEVbZBxiM+iBkCVGuVu99IMyo9HYAYhQFaRO6chXfxdo2jZk6NPSHg4GtNUzWmjbaea4JItujdK+RbJwjoywpbooOyM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000016, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: With no more users in the tree, we can finally remove can_modify_mm(). Signed-off-by: Pedro Falcato Reviewed-by: Liam R. Howlett Reviewed-by: Lorenzo Stoakes --- mm/internal.h | 14 -------------- mm/mseal.c | 21 --------------------- 2 files changed, 35 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 1db320650539..3b738b0ad893 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1361,25 +1361,11 @@ static inline int can_do_mseal(unsigned long flags) return 0; } -bool can_modify_mm(struct mm_struct *mm, unsigned long start, - unsigned long end); #else static inline int can_do_mseal(unsigned long flags) { return -EPERM; } - -static inline bool can_modify_mm(struct mm_struct *mm, unsigned long start, - unsigned long end) -{ - return true; -} - -static inline bool can_modify_mm_madv(struct mm_struct *mm, unsigned long start, - unsigned long end, int behavior) -{ - return true; -} #endif #ifdef CONFIG_SHRINKER_DEBUG diff --git a/mm/mseal.c b/mm/mseal.c index fdd1666344fa..28cd17d7aaf2 100644 --- a/mm/mseal.c +++ b/mm/mseal.c @@ -53,27 +53,6 @@ static bool is_ro_anon(struct vm_area_struct *vma) return false; } -/* - * Check if the vmas of a memory range are allowed to be modified. - * the memory ranger can have a gap (unallocated memory). - * return true, if it is allowed. - */ -bool can_modify_mm(struct mm_struct *mm, unsigned long start, unsigned long end) -{ - struct vm_area_struct *vma; - - VMA_ITERATOR(vmi, mm, start); - - /* going through each vma to check. */ - for_each_vma_range(vmi, vma, end) { - if (unlikely(!can_modify_vma(vma))) - return false; - } - - /* Allow by default. */ - return true; -} - /* * Check if a vma is allowed to be modified by madvise. */