From mboxrd@z Thu Jan 1 00:00:00 1970 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 08C4DC021A0 for ; Thu, 13 Feb 2025 22:00:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CBFD6B0093; Thu, 13 Feb 2025 17:00:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 67A2E6B0095; Thu, 13 Feb 2025 17:00:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51A73280001; Thu, 13 Feb 2025 17:00:37 -0500 (EST) 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 34A2E6B0093 for ; Thu, 13 Feb 2025 17:00:37 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B4D55161791 for ; Thu, 13 Feb 2025 22:00:36 +0000 (UTC) X-FDA: 83116291272.15.2F4BA9A Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) by imf22.hostedemail.com (Postfix) with ESMTP id BB9A2C0004 for ; Thu, 13 Feb 2025 22:00:34 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Pkd2gQLh; spf=pass (imf22.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.167.181 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=1739484034; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=lVDdJuGJBV06FhLssYXV1tVqu4QAOw03JY046Cqka88=; b=sd5hHw8Rqn3pL2LtF66EAw7B20Oh8VQy7bpDipVO5HY20YrZ832T67B1yquuXJB/TacXup dwYkwkELEfvgRbBjNn8XC2ULhIKvdb/IGsJbbYKmc6+XK3cN0H2zWsEZ36+fAP1wx2M7/n EnmYKE/3RUhbngl1GrN2TkEK8crGamg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Pkd2gQLh; spf=pass (imf22.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.167.181 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=1739484034; a=rsa-sha256; cv=none; b=metvrlvQNAlgRQRfTLQZVw43ZxhMNwX7AzNG1xI7cXbjdQLAb+KFQDNJDPYbg+hNWLg9t/ gZ5dUTB2fhVaWKcQ3ZpsLeFAPvTe/GR1QqrbiesF+D0xOJ3HS10VoeeQ08KSeNlBxxCJ4+ bLpBR+FQca8yf+OV4sBHkQwmRKj9Alc= Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3f3d8c0a2edso37760b6e.0 for ; Thu, 13 Feb 2025 14:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1739484033; x=1740088833; darn=kvack.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lVDdJuGJBV06FhLssYXV1tVqu4QAOw03JY046Cqka88=; b=Pkd2gQLhOW7DY4Jsnj0k375L7TQ4G6s0P0xSO62lz/rFerfNKPsADs7tigHvXfR1c9 5Y+drISUunVLw1qYvm0yt8FHRHDezeDSNR5xBl6CLhVKHwEa8i/rLnWvSa2rP3qquig4 VwoezfNfMefWdehOUOGKBSIt+sJcwiMJWkvno= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739484033; x=1740088833; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lVDdJuGJBV06FhLssYXV1tVqu4QAOw03JY046Cqka88=; b=MesulMFcMCp07EcSEsbnx8nuZeAqry/IGAU2aoEtHRbnAaDujNnKKorhMfm//MTb4O xyeDJiWamoZPD0ciG4LcsEGDXZ8orajZcJauXpeBP//+2IZ6llXlfGkewXt/V8f0xQgY JNYff6yoKEOTJA1/tHMwhrPElcWvFSebCJfjmcF8AHh2k4jmRVyUTMWty67VJjlpfEsf vJ4eeFr3aVOh9ZrboSPSWBiKo9u3AONFmO1z6S6zz9wJNGeTiZWGngXywIDsiCZ0wEvx titMW8Ddzc71y09jcGgMmQeeTGnNARTTshV+kJZQf09MgtpkktiMfZTuXWf67Dy7FxfR WkvQ== X-Forwarded-Encrypted: i=1; AJvYcCVhTTMvNnMp3rT4536ko7tXoOI7/mR3mGAdbv4OsA2txktbQrIGtYX3XKEJHlRry+sX+YhyZc2LNg==@kvack.org X-Gm-Message-State: AOJu0Yxe/o+mxgy/o8BUnuTDwYnuOaHJHg/gUfxZLLMcfPAOjrm/qFls 66TqtJATOVflsQJchZp3BF+cyjjYjlQy+F0OGsHaCgzjgT5FSyIW6xBRlUCGuemlisDDGppWFJ6 aYNGsJuGnESj+/aGkr6q/nvwHu4+pTx2nFYTR X-Gm-Gg: ASbGnctN840EJskwLcpPxeBw5eAQHYVI4Upnjz3j+zBJAj0oqBDMtko1qLOclgkxt9G WibfFO0ttDJ85QdIAQbDmVMHYyxQMiF3h8ixbw3Hm9Tn0bRCmKwSpo+FjkqLtz1MBMds5z56e+Q B3KBC4tGxyAMDeyT+S2ar8mx9tTWeZqQ== X-Google-Smtp-Source: AGHT+IFZ89lyjLhjthMWsh+Xv4yhuWhXx7WGtpO3v2Lf/Ol2MmQBmeBdIvJLJQo6cKuEv712+t/jVH0mS+/lu/S260g= X-Received: by 2002:a05:6808:1b1f:b0:3eb:9107:ee76 with SMTP id 5614622812f47-3f3e1a4eee0mr102943b6e.7.1739484033654; Thu, 13 Feb 2025 14:00:33 -0800 (PST) MIME-Version: 1.0 References: <20250212032155.1276806-1-jeffxu@google.com> <20250212032155.1276806-2-jeffxu@google.com> <66q7feybn3q2vuam72uwmai322jdx3jtv2m5xmh75l6w6etqiv@knpsyh3o627k> <202502131142.F5EE115C3A@keescook> In-Reply-To: From: Jeff Xu Date: Thu, 13 Feb 2025 14:00:22 -0800 X-Gm-Features: AWEUYZlJg0Av8eErqyHIPSk3VZi3rcP5H9jYN8zDMf2Bq0g8eCVrgdxuS5QpM8M Message-ID: Subject: Re: [RFC PATCH v5 1/7] mseal, system mappings: kernel config and header change To: "Liam R. Howlett" , Kees Cook , Jeff Xu , akpm@linux-foundation.org, jannh@google.com, torvalds@linux-foundation.org, vbabka@suse.cz, lorenzo.stoakes@oracle.com, adhemerval.zanella@linaro.org, oleg@redhat.com, avagin@gmail.com, benjamin@sipsolutions.net, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, jorgelo@chromium.org, sroettger@google.com, hch@lst.de, ojeda@kernel.org, thomas.weissschuh@linutronix.de, adobriyan@gmail.com, johannes@sipsolutions.net, pedro.falcato@gmail.com, hca@linux.ibm.com, willy@infradead.org, anna-maria@linutronix.de, mark.rutland@arm.com, linus.walleij@linaro.org, Jason@zx2c4.com, deller@gmx.de, rdunlap@infradead.org, davem@davemloft.net, peterx@redhat.com, f.fainelli@gmail.com, gerg@kernel.org, dave.hansen@linux.intel.com, mingo@kernel.org, ardb@kernel.org, mhocko@suse.com, 42.hyeyoo@gmail.com, peterz@infradead.org, ardb@google.com, enh@google.com, rientjes@google.com, groeck@chromium.org, mpe@ellerman.id.au, aleksandr.mikhalitsyn@canonical.com, mike.rapoport@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: BB9A2C0004 X-Stat-Signature: k4wdmysbrcq91kpw9zhbpw1thy7qqr11 X-Rspam-User: X-HE-Tag: 1739484034-682783 X-HE-Meta: U2FsdGVkX18F7Bj1MOXgybNB5S0WpdjBwP1yGcdkUcwzO2ibL0KdsZChVMxkYbMpPBwRcdZeVd7kDx0eg11rOLzA/M5dqTqE1doM3NAskCMMTyjzsUmZGe12jr01fVO/qvjKCx6YH+0TLYLAwTVUtHv6lTfNpQ3NlVx2p18vePMTZ5vx9d6/81AGVDBOa+mBtVLAp9iPA9wed0v44AL9p0kgIb7xQ/HnPiT5w/6Cg6/cpEJPusjneCqkbZUgCq0U3t+IDj88/gKJkXQr0MWJrnDGA/VZJoxdyeBPSTHl++g/YYWWMZT03zEp6/eNuKNLN+vVIo9ZUgis5pjHZx/LGrZGYFNgMkweBUYKH/WgKUwtISoIA+GdWYpCtgYKW7GX3mIAbkAm5b4WfI6iyEQboZQXVE761lFJBsj/2KzqNQiXPSfH1RNkEcYVuv5k016qCmXw+lN1Txf7WVM3cEHxzD1EldmDZd80bOoTXl/ffY8EnELA683sqmyFg01aX6a/KyNa7GymLm7Zc7ZZMMQpshtKC/w4p78sjrJunTG9V6iiPQVYUOZ4Bu6rwJJQ8Xzkev3JIc+p7cykj48iuOvu8UZiIjgPXzE8SnkvbyvYHx7dcFAteR7Acv/Xmg3blKjLxhmW20JypjvlIDT7nZ6+iWa329vczAr26jZCZyM8R2FRgeCJzxWEYdtWRwZZ/cZtSiPSv/Xm9u9bmBEuxwJRA/1OPZJCicHIi4eDHyDO2EgXWT3E4S/zHlEEncQ9xVvJvQk/IXDN660X0K1jY4t7AnxDZ+aUwrppgvgUjZDT/cjb5HoKYP2SofoxbC2ON+L+xe90vPunPm7p6XQ0EmXpWJOduoxHWRp5oqGpxJrdz09PIoS0unjA5r1iVdPX8GoQf/yCgYXZTW+bx2TefAGqT//JTCTU3hI0Mz/KUtDxtTXy7p3Ah556ZkYwrPaG4dPLPjkJb5glN+9KKlsXQW2 reOCQAwj i9b0w403K7OGtKGHNezwoQnqppkVSolwuuP99HmsDiwyd38VCgxgjyjp0guQqLxGaSDyXq5DCm6o5b9d1XISmEeI2F/XXMgTf8zsGYixNwuZ9gnNWK7TbWEQp6rWLdSuIso0M6T9jwmQWh4rW0fEq6cvkzJuzQPaojMLetvxnCTpIW9zZS7R1RNm1nkE6OYjsozHAHPQAao7cIxnI58bGxC0hNrjyZgXgOVAxgCmRVEHKUwCkpCa9xk2uzrBj/PZDkR653iR0eMDN/OJ9fzLRUX2aF8IMgfvJvbULS95a2h2RhgI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000073, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Feb 13, 2025 at 12:54=E2=80=AFPM Liam R. Howlett wrote: > > > > > > > > VM_SEALED isn't defined in 32-bit systems, and mseal.c isn't part o= f > > > > the build. This is intentional. Any 32-bit code trying to use the > > > > sealing function or the VM_SEALED flag will immediately fail > > > > compilation. This makes it easier to identify incorrect usage. > > > > > > So you are against using the #define because the VM_SYSTEM_SEAL will = be > > > defined, even though it will be VM_NONE? This is no worse than a > > > function that returns 0, and it aligns better with what we have today= in > > > that it can be put in the list of other flags. > > > > When I was reading through all of this and considering the history of > > its development goals, it strikes me that a function is easier for the > > future if/when this can be made a boot-time setting. > > > > Reworking this change to function as a boot-time parameter, or whatever, > would not be a significant amount of work, if/when the time comes. > Since we don't know what the future holds, it it unnecessary to engineer > in a potential change for a future version when the change is easy > enough to make later and keep the code cleaner now. > Sure, I will put the function in mm.h for this patch. We can find a proper place when it is time to implement the boot-time parameter change. The call stack for sealing system mapping is something like below: install_special_mapping (mm/mmap.c) map_vdso (arch/x86/entry/vdso/vma.c) load_elf_binary (fs/binfmt_elf.c) load_misc_binary (fs/binfmt_misc.c) bprm_execve (fs/exec.c) do_execveat_common __x64_sys_execve do_syscall_64 IMO, there's a clear divide between the API implementer and the API user. mm and mm.h are the providers, offering the core mm functionality through APIs/data structures like install_special_mapping(). The exe layer (bprm_execve, map_vdso, etc) is the consumer of the install_special_mapping. The logic related to checking if sealing system mapping is enabled belongs to the exe layer. > > > If mm maintainers prefer a #define for now, that's fine of course. The > > value of VM_SYSTEM_SEAL can be VM_NONE on 32-bit. > > Thanks. I think having a flag with VM_NONE on 32-bit is just as sane as > a "flags |=3D system_seal()" call that unconditionally returns 0 on > 32-bit. > Consider the case below in src/third_party/kernel/v6.6/fs/proc/task_mmu.c, #ifdef CONFIG_64BIT [ilog2(VM_SEALED)] =3D "sl", #endif If #ifdef CONFIG_64BIT is missing, it won't be detected during compile time= . Setting VM_SEALED to VM_NONE could simplify the coding in some cases (get/set case), but it might make other cases error prone. I would prefer to not have VM_SEALED for 32 bit. -Jeff