Message ID | 20231016143828.647848-7-jeffxu@chromium.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 9042FCDB465 for <linux-mm@archiver.kernel.org>; Mon, 16 Oct 2023 14:39:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D3DE8E0003; Mon, 16 Oct 2023 10:39:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2581C8E0001; Mon, 16 Oct 2023 10:39:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05D088E0003; Mon, 16 Oct 2023 10:39:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DF9208E0001 for <linux-mm@kvack.org>; Mon, 16 Oct 2023 10:39:07 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A7EFA409A2 for <linux-mm@kvack.org>; Mon, 16 Oct 2023 14:39:07 +0000 (UTC) X-FDA: 81351581934.29.C4C560D Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf17.hostedemail.com (Postfix) with ESMTP id E09D240026 for <linux-mm@kvack.org>; Mon, 16 Oct 2023 14:39:05 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=UIQJSIwE; spf=pass (imf17.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.215.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=1697467145; 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=+0Sn/gKJWR6siX+0KJWM5lAESAe3sWf60qybDDt1Pys=; b=FEv/+1OIj/iGKP7EvGPgT0tTfneCA2B+CU3VD9obLz3iW7sw/YAREffWb0KJQxUdXeG0H3 OP7QPkxP+jgdE3XW00fQ4tsjodCvVxs2Jhcm7n6Ffyl8wbR41gYJQCPmwrLDZCTABeG/// pHCueBCnH3rrHQQii/GdYxI1lRboSRw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697467145; a=rsa-sha256; cv=none; b=IrMLXKYiCXXIaKPDHkBf001KZE2FRZ01W4blKzUvkDIa9yUmvHjZvJ+ol9aHbIOnA8Y8nh GIB72VQindYQ/GAWVROUlDRdsGksy95Z0bXqNG7CyScT/9qlijq9P6FGjAUXcYQed2oJqt 5kBMeTDD/1gc9Gnt93ac9a0PpG4vt+A= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=UIQJSIwE; spf=pass (imf17.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.215.180 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-584a761b301so3374765a12.3 for <linux-mm@kvack.org>; Mon, 16 Oct 2023 07:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1697467145; x=1698071945; 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=+0Sn/gKJWR6siX+0KJWM5lAESAe3sWf60qybDDt1Pys=; b=UIQJSIwESUj8f36Oz+4wv5Ux1ZP+BGDSsRO+luklo546YiEoJs/mkScUGRDvqDk1zQ 3Fs+0DBChVJ4EBw+tLDGjrwjTLK1OtFDI3z2HogZDlkJ4VGxjJGEqyVP8UVuZ0T8o2F9 U6Ih8z+fAYrTomqv1ePCpjR7zTAGgUdBST/JA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697467145; x=1698071945; 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=+0Sn/gKJWR6siX+0KJWM5lAESAe3sWf60qybDDt1Pys=; b=ClxtL2PSP+9WlRQ2woCadb/qBhhUpkmpbWD/tLcBGlG1MSH8qD0DdIeAl/bSkAHQ8J 1WPOY8K94/S6pJHiYzjDEODfe2tFSYRHvN91I3K9b6/ZUHDXPfbc8Nq83B+FOVGzXDE+ wAdJKwsf8IstMewSZ0MmHapr70v/1/Y+6VX6qkpaB7mINmvV/QrsMO/XyejsdERWtQyU nHa9T0TW9T2YqJHlGMR/ygOQ4Tg3eg5JdylMXZac1Tmf04owgcyQM2EdIdGdvGiUi5gX FiJACHYg2uWnyOVr8MYAHaKM7JAo41EVTJECrqpqvoLx6zui/g5Ai2f9BuIk+Su6YsUA AbIw== X-Gm-Message-State: AOJu0YzdH76QfaKU9PF6+TnDtNZLNGWGTt3lzjPT+JafvPSxbGylu4Sl tU5ryUL2xtsQHP66cNfB0xN8yg== X-Google-Smtp-Source: AGHT+IHQKvwpFIbGSIva7hn5sjCBlscbClIlMg0fHg4jXNaku6Zt8hbJMcw6wC8Uuvj5QeuKGPqvTA== X-Received: by 2002:a17:90b:1fc6:b0:27d:4283:b8a2 with SMTP id st6-20020a17090b1fc600b0027d4283b8a2mr7510538pjb.14.1697467144783; Mon, 16 Oct 2023 07:39:04 -0700 (PDT) Received: from localhost (9.184.168.34.bc.googleusercontent.com. [34.168.184.9]) by smtp.gmail.com with UTF8SMTPSA id nh24-20020a17090b365800b0026f39c90111sm5008030pjb.20.2023.10.16.07.39.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Oct 2023 07:39:04 -0700 (PDT) From: jeffxu@chromium.org To: akpm@linux-foundation.org, keescook@chromium.org, sroettger@google.com Cc: jeffxu@google.com, jorgelo@chromium.org, groeck@chromium.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, jannh@google.com, surenb@google.com, alex.sierra@amd.com, apopple@nvidia.com, aneesh.kumar@linux.ibm.com, axelrasmussen@google.com, ben@decadent.org.uk, catalin.marinas@arm.com, david@redhat.com, dwmw@amazon.co.uk, ying.huang@intel.com, hughd@google.com, joey.gouly@arm.com, corbet@lwn.net, wangkefeng.wang@huawei.com, Liam.Howlett@oracle.com, torvalds@linux-foundation.org, lstoakes@gmail.com, willy@infradead.org, mawupeng1@huawei.com, linmiaohe@huawei.com, namit@vmware.com, peterx@redhat.com, peterz@infradead.org, ryan.roberts@arm.com, shr@devkernel.io, vbabka@suse.cz, xiujianfeng@huawei.com, yu.ma@intel.com, zhangpeng362@huawei.com, dave.hansen@intel.com, luto@kernel.org, linux-hardening@vger.kernel.org Subject: [RFC PATCH v1 6/8] mseal mremap Date: Mon, 16 Oct 2023 14:38:25 +0000 Message-ID: <20231016143828.647848-7-jeffxu@chromium.org> X-Mailer: git-send-email 2.42.0.655.g421f12c284-goog In-Reply-To: <20231016143828.647848-1-jeffxu@chromium.org> References: <20231016143828.647848-1-jeffxu@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E09D240026 X-Rspam-User: X-Stat-Signature: gfyfhihsymwcxkkwm7j7go9yj1emp1gn X-Rspamd-Server: rspam03 X-HE-Tag: 1697467145-870285 X-HE-Meta: U2FsdGVkX18SxpGHGpLT6YgurRJide9oetH4bM5SUEwL0vbDQcUONgWjQw3qNV9voJ4iybhh3djyBaguFdJAvSvEyCrh6fHYmx9Rh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LCovBTz02BQghaB1G1z/XaRdNpidVelKfWgAO4R4Z0uz3Ji5lfaV0QyU5b/BT72KHjM1nhl0KEzfIxVHtLq5B8KJN3HINAX01novKsPOJk8M2SB38xbXMsjBj 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: <linux-mm.kvack.org> |
Series |
Introduce mseal() syscall
|
expand
|
diff --git a/mm/mremap.c b/mm/mremap.c index e43f9ceaa29d..2288f9d0b126 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -836,7 +836,15 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len, if ((mm->map_count + 2) >= sysctl_max_map_count - 3) return -ENOMEM; + if (!can_modify_mm(mm, addr, addr + old_len, MM_ACTION_MREMAP, + ON_BEHALF_OF_USERSPACE)) + return -EACCES; + if (flags & MREMAP_FIXED) { + if (!can_modify_mm(mm, new_addr, new_addr + new_len, + MM_ACTION_MREMAP, ON_BEHALF_OF_USERSPACE)) + return -EACCES; + ret = do_munmap(mm, new_addr, new_len, uf_unmap_early); if (ret) goto out; @@ -995,6 +1003,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, goto out; } + if (!can_modify_mm(mm, addr, addr + old_len, MM_ACTION_MREMAP, + ON_BEHALF_OF_USERSPACE)) { + ret = -EACCES; + goto out; + } + /* * Always allow a shrinking remap: that just unmaps * the unnecessary pages..