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 9F408C021B2 for ; Tue, 25 Feb 2025 22:38:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 284EB280003; Tue, 25 Feb 2025 17:38:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 23458280001; Tue, 25 Feb 2025 17:38:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D516280003; Tue, 25 Feb 2025 17:38:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E2CFF280001 for ; Tue, 25 Feb 2025 17:38:00 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 86E85140496 for ; Tue, 25 Feb 2025 22:38:00 +0000 (UTC) X-FDA: 83159931120.21.7FD28C1 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) by imf25.hostedemail.com (Postfix) with ESMTP id AC625A0007 for ; Tue, 25 Feb 2025 22:37:58 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=c30EnOoC; spf=pass (imf25.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.210.41 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=1740523078; 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=TM09Vy3kN6bqyw39MdyhtNezW+WJUnfi9H/ALFTk9Q8=; b=zgQFj/WfH0zaeDYVpu3oHDQiZyUQJMeWMWuLVzdBgIajkXp+b78WqA5HMHjlof5aOEearS 47CJMdXXGhYL555zuvkUkyquBpDOxw8q4w6AxuYax6vEL8OoFhEM5bA7p9AwKnnma6arQk puaolRGRRy706DrfCD88U+kV0Wh1VxE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=c30EnOoC; spf=pass (imf25.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.210.41 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=1740523078; a=rsa-sha256; cv=none; b=NFpUKPd9BfKY9sKjtxsVnOhRh77X7R5j4PYPfDcCKUhu9S1PS222UuDS0G2Bq8T1OD/QCv 4nvqxYHX0nEIZwgM4Y+q9a1RVSXWrOv1sRnBMwkJ3c7uBJbaiRttBnFgKj4JnbR0v1/+7h 5FcKW2IGg0s1mzMc9igjaKHeSiF7XUI= Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-724daedf8c3so1567737a34.3 for ; Tue, 25 Feb 2025 14:37:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1740523078; x=1741127878; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TM09Vy3kN6bqyw39MdyhtNezW+WJUnfi9H/ALFTk9Q8=; b=c30EnOoCzCizDdquocx19XdckVbbAXLXjmp9xFcv2MmMIJ5n+sJ/Z6eoWZUFWgl+Fv fdu9wyt7oB0W9uRsbeHPwl3vRrHzL+1ilIBuVm9WIhnU5hqZ8Z8fNQ+h4xjTQ6pjH8Sh d8pbOQBmsOYu3jOuZpJ1j6VgcgZNoYiyMGWcs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740523078; x=1741127878; h=content-transfer-encoding:cc: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=TM09Vy3kN6bqyw39MdyhtNezW+WJUnfi9H/ALFTk9Q8=; b=KiWM58DBpVMdeB9+5m75kYreRQv4D6MPVL3Im7dusznLcRmE6xO4hMyOp91r9mias0 6+AAOylB8ouVUdDlh41LtnxcWKwtYiJPVwkywsTsRzavpm0l8FZBpdSSZJX9tUx0V/NU shGkaoPooFqj+JNsmkUs2Npq9axPgT5eus3MrAOPdE4aqCH+sP4zmbFB9zBk6n70FCMV 8+zzxmALfJqNdigqxOr2ZB1NjcxPAX8+b4BzyH3H7T21hVsVmK6biCOhvNAdNQ4mY4V0 RNOy0iyi53I32d3qogiMIQdobHmvqkI9IXxenHnF0DwHRiBf800X8f3JUqBxrafdg22W RBjA== X-Forwarded-Encrypted: i=1; AJvYcCWgicNtsfTCszIs5w5VR3YZK77O65Psj9J8OpHSz2yDzJOYhxVSgn/UePOJPBT5kMgcBGNYrugCIA==@kvack.org X-Gm-Message-State: AOJu0Yx6mfjohS7pEhohyAD2WEOYdC73mv0zEch7fZy9BuiDNvkBwbRG eb1xxxrK+KlB45McHTCd5wBWe83YtfGljwyry5KN1T8pJ+4eGzi8CictZ2bT//wD7ul/6TJpFoW /KH1FSGqw1oi/lPvgN4jmkAxRb3LpxJfSoTf6 X-Gm-Gg: ASbGncuHwz0lIr2ic42JCRsvn3jNyCXPhyX8wb2wFmRUupOQafgZWCgEsOM8nXvL7tb dcMUP1Ljrj9h09cFKbkbxzqYiPshw4ugDZYi5Q1UoC8W84NW/W66/tBGt1bz2Lftsd8hZ+S0hFB ocFMQZHS1CvxAykQKcWCLQ4d51f1rydGI6Y/g= X-Google-Smtp-Source: AGHT+IEpcvXgYiPClCySX5ynQ10F8Hy35U+lAZUo00/td8VvueGsr0yfG4XsKHGe1Drl9rCIX+ro1GOLwaDthyw6wO4= X-Received: by 2002:a05:6830:3106:b0:727:2b73:cbb7 with SMTP id 46e09a7af769-7274c257d4emr4278353a34.4.1740523077707; Tue, 25 Feb 2025 14:37:57 -0800 (PST) MIME-Version: 1.0 References: <20250224225246.3712295-1-jeffxu@google.com> <20250224225246.3712295-3-jeffxu@google.com> In-Reply-To: From: Jeff Xu Date: Tue, 25 Feb 2025 14:37:46 -0800 X-Gm-Features: AQ5f1JoKtUHhlK-Y7z-DtFO5DD67q41dfSZq435LKdak_34AMb1q5CdQGGx9fmY Message-ID: Subject: Re: [PATCH v7 2/7] selftests: x86: test_mremap_vdso: skip if vdso is msealed To: Lorenzo Stoakes Cc: akpm@linux-foundation.org, keescook@chromium.org, jannh@google.com, torvalds@linux-foundation.org, vbabka@suse.cz, Liam.Howlett@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, Kees Cook Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: AC625A0007 X-Stat-Signature: w7dma9skooxyf837zzxy4nzsz67j9hrj X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1740523078-477934 X-HE-Meta: U2FsdGVkX1/54S7+1mR4qrIxT1TZKejy6jI9zCe1LSNfwCesz6O+S3BSrDxklNuNkNlL/TfTNOgdP21GKPqSQM5HYYvjL4efprp2A67uVlJDlscYx1hgddpFpnGMzQWT44njF5mhvIlthA8ART0uWemk0/HxsU+K6PsTSOE6S0aKU8LwE7D+QsZRySGc38+Xq5sY2PAB8Qe/YsypohV3xNLC4OWl8hC6sCo06OkKbU30ehbiHFiaQnnShh/bR7+bFP4IbwgIkOuASTdlI6OOeXnJnq9Ncc5R5dPnTV7HpODudzQmZCk9G7sii6cZpIHg2SaTvBlOcJzIQe6H8BVHarvDcxMvYpcclxNBKxOeVcHDFQoCttoS2JUeF6od9mJWu4I+KiukPKWhRt+Zr4ommXBDqBrfHyoIluljJXu0k0czOotRBW9Dle8qkU2BV6l/JsYkPIi81TuW04WVeINpB6fZ8XV2GjVsRjmJEgcwsHLM0q4KgTwzqK8Z49TSf4KpJylk0mWj/gzbsq01NoXTOlyPafA1zIdm9AIHdoGN2PUGZ30WDYSW+Moay5FD1eCmIgFzIpBpNAeeyZccfTABeS0u/SeMDxchXiMlnkNNLtBc0LoVqQLKY2qgHeE/un0eWkC5jwD3XTCgzB24pRUGs5P2qMq5g39m9b7MX1Dt5tLEEWuAXKghZYTh5jrB/+14BTPUUyoftsjDkUxx7Eejh2e5NFRo5PP8e8gPvsXghDTid4Yz5TScEzs2bk0//0tzzuknKHDp1iorZFoPqDIorSx8PKW5TlCBmv5pzYkg/xXHoBo72rxsm8sjaqXBey4idmJdruZlN10vZetSDOYx2Y3SWpTlVpoR7MoIaJs/9BgHLr4L3LWWal4DhF+Kxc3RaK1DqrUBpJpWFdUG+YYxK1KYjr1lI6OgQW9QgCfm0o1QxJtG6nGlCeyykXndxKn7AOc+DnKuuTKc/G9yyjL hvtvEy9B LZoWegbHPK0blFbmH8Bs/YhorWoYftlTbgqW3Xpet0JWx5VOJ8/fqiUO1Wu0tc0o3ILZVn7ocMpIqa/0A6pH08lgoWWDWiVmgqlR/v8Qt17IncBgtwwfZ2RUlUbv3YMW378sEZKG42KeZNimtYUhFVJVX7I2MBgOXMH9KXEItC35pZYBTjGa8Tu7pfB+9D1AWwSIMghD/fb/MetnVk/oSISWmkM1Qs70A5EMYG+5lvcm9t9XhK3JiFA3j5OOpFnB8fbu45PNiFqGM7WB3bbNsIA4GrLz8fhYE8wWKPzJ7x1xQPmVmv6FkNPq6vRGJooR8wVJD2ga5XecccsczPYj9TL5Un5WHUJMEoarRCWnfGsKBjXQoRnCvx5YiWdvyiKa1BXda 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: On Mon, Feb 24, 2025 at 10:15=E2=80=AFPM Lorenzo Stoakes wrote: > > On Mon, Feb 24, 2025 at 10:52:41PM +0000, jeffxu@chromium.org wrote: > > From: Jeff Xu > > > > Add code to detect if the vdso is memory sealed, skip the test > > if it is. > > I feel this is a little succinct of a commit message, but I guess it gets= to the > heart of what you're doing here. > > Fundamentally I mean it makes sense, but I'm concerned that x86 has a tes= t > -expliictly checking- whether mremap() of VDSO is possible - are there ca= ses > where x86 might want to do this internal to the kernel? > > I guess not since this is essentially a userland self test and probably > asserting you can do this in the way rr, etc. do. > > > > > Signed-off-by: Jeff Xu > > Reviewed-by: Kees Cook > > Anyway, this aside, this looks fine, aside from nit below, so: > > Reviewed-by: Lorenzo Stoakes > > > --- > > .../testing/selftests/x86/test_mremap_vdso.c | 43 +++++++++++++++++++ > > 1 file changed, 43 insertions(+) > > > > diff --git a/tools/testing/selftests/x86/test_mremap_vdso.c b/tools/tes= ting/selftests/x86/test_mremap_vdso.c > > index d53959e03593..94bee6e0c813 100644 > > --- a/tools/testing/selftests/x86/test_mremap_vdso.c > > +++ b/tools/testing/selftests/x86/test_mremap_vdso.c > > @@ -14,6 +14,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -55,13 +56,55 @@ static int try_to_remap(void *vdso_addr, unsigned l= ong size) > > > > } > > > > +#define VDSO_NAME "[vdso]" > > +#define VMFLAGS "VmFlags:" > > +#define MSEAL_FLAGS "sl" > > +#define MAX_LINE_LEN 512 > > + > > +bool vdso_sealed(FILE *maps) > > Should be static? > sure. > > +{ > > + char line[MAX_LINE_LEN]; > > + bool has_vdso =3D false; > > + > > + while (fgets(line, sizeof(line), maps)) { > > + if (strstr(line, VDSO_NAME)) > > + has_vdso =3D true; > > + > > + if (has_vdso && !strncmp(line, VMFLAGS, strlen(VMFLAGS)))= { > > + if (strstr(line, MSEAL_FLAGS)) > > + return true; > > + > > + return false; > > + } > > + } > > + > > + return false; > > +} > > + > > int main(int argc, char **argv, char **envp) > > { > > pid_t child; > > + FILE *maps; > > > > ksft_print_header(); > > ksft_set_plan(1); > > > > + maps =3D fopen("/proc/self/smaps", "r"); > > + if (!maps) { > > + ksft_test_result_skip( > > + "Could not open /proc/self/smaps, errno=3D%d\n", > > + errno); > > + > > + return 0; > > + } > > + > > + if (vdso_sealed(maps)) { > > + ksft_test_result_skip("vdso is sealed\n"); > > + return 0; > > + } > > + > > + fclose(maps); > > + > > child =3D fork(); > > if (child =3D=3D -1) > > ksft_exit_fail_msg("failed to fork (%d): %m\n", errno); > > -- > > 2.48.1.658.g4767266eb4-goog > >