From patchwork Mon Sep 23 14:19:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 13809670 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 0EDB3CF9C72 for ; Mon, 23 Sep 2024 14:20:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93F1B6B0093; Mon, 23 Sep 2024 10:20:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F15A6B0095; Mon, 23 Sep 2024 10:20:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B8346B0096; Mon, 23 Sep 2024 10:20:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6063A6B0093 for ; Mon, 23 Sep 2024 10:20:14 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0922E1C6873 for ; Mon, 23 Sep 2024 14:20:14 +0000 (UTC) X-FDA: 82596212748.22.82B613A Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf12.hostedemail.com (Postfix) with ESMTP id 4F3734000B for ; Mon, 23 Sep 2024 14:20:12 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of vincenzo.frascino@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727101094; 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; bh=kbveDqJoVu08CXYmp8kmYr5W1Ok5zBD419JjfEoW+L0=; b=5VW+N1VeJquXTGIs1NQ+LTv6rVrIcYrPw9iVukvL7JgE/V1Ig8Bu/1/WayKBcqr9ehpsyG CgsayjX9Dih2Ze/2vXpEqvs2+4F+M9yHcdRaiokXgtrhGPOMf5HsGcbwsoRygZkOQIG8n9 C5qU6OD/gAZosdtV49v2wqPJk49NUxI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727101094; a=rsa-sha256; cv=none; b=BgpPeGcig8aNvdqOffNGgVbb+I9GOmAeS6MFwLByALTBogNkzeISIVRAJZmPvUUKXSAmgi 0gt5+GerBHte5uZjzgV910CXx1BD1ZR/JgOCx0uE/lBYX1VOiM/RSuXYJJa5Lr7mOaOL39 pvuoRvotvSJ4a4asgO2ofdTL3l1Od3Q= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of vincenzo.frascino@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 21AD6FEC; Mon, 23 Sep 2024 07:20:41 -0700 (PDT) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 37AEC3F64C; Mon, 23 Sep 2024 07:20:09 -0700 (PDT) From: Vincenzo Frascino To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Cc: Vincenzo Frascino , Andy Lutomirski , Thomas Gleixner , "Jason A . Donenfeld" , Christophe Leroy , Michael Ellerman , Nicholas Piggin , Naveen N Rao , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Theodore Ts'o , Arnd Bergmann , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Subject: [PATCH v2 8/8] vdso: Modify getrandom to include the correct namespace. Date: Mon, 23 Sep 2024 15:19:43 +0100 Message-Id: <20240923141943.133551-9-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240923141943.133551-1-vincenzo.frascino@arm.com> References: <20240923141943.133551-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 X-Stat-Signature: 8f45e5obe43q4zendc8wh456dohs68z6 X-Rspamd-Queue-Id: 4F3734000B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727101212-175777 X-HE-Meta: U2FsdGVkX1+dFU2pa+dTwkuy/ufhSVsNRcYmuzOr7kwfBPKa+uKYPh1qSI8T1e+o7RCOwm3StQj54G/M8H0STiyAfUC5FMzOHXAWWAl5yfES1QvMkowQhiGZeqREgVUiS6VXF8nDOZSQ5T5y+PVbF4CC8e0UpOuZxy1QkhwKN/eRAp5kCq4rux9CklN4pgN3O7LmR+Tc9Ld60vLW5T2xuhQOybOJydAmKj3fTWtH9IPnMNYS2GGTbXWnmwGVYcckLGHiD+KTBFNvda3+pW2Tq1TCiQxJkFGA95CZwHEdPjqrha4ezFXOoEF/F+cMAWW20ZVDHpECm0BodJM2wdqjjXo1MFti+uofNCIUHIRbXyhTLGq+Rv4lcRzBydkHD1HhmbgboqhiJh9JiPHeNOol9VvS5o6gEP2VpaFUwbHd+r4LRpygadQCdOzd/jYauhLux6S5XLYc6OV2xYvKGNbAY/GyEoyt9BCJNMV2Ipru6FliR+k7P38rTKoLIl0eHpNjS9kvJyOj0iBcE0BbLAQ2SZf+hUT+ksckYqbc38qPkV+76V9EnXoQaWqPLUl3vjMl1OwGv2fY4b0RhMz/QpALo+w7G2nmS4SJMpJ9d0qOn0ErrnwHtngzDPcXE6zme6gVZ2IfvM1zeCcle280iX+g4hNWtqg9ZLpLPBeVmJaXy2nWdjOXiGww8Jkp6yZFai4ugS9WCfGQeP4rAhND+UApYQnuAPH258YHcy37SM+y7XWwMkNxC1qOEGa3ZbsWhNmy48uILWKFrSFEiZ+iHy4TmE53ZhKcUB8McSiQuC5WLiGafvzCneGIp+zYsPjv46wCGLFk0Og72NmItlCZ5wZFwGSZm5GGDwbcawc+DKmjmWymhSGmVRC+UirNTE4THiQLJabARXe4PVvb8Yp5WHp+bmip5/a+AGHEDwWM8oDNuTDxcEMr+Ok15UB2iA6ftTMhvRTTjmNH+9XU2ep+dvt gM/9aRPZ A7kkpdeA/JuC00tttk3Zb9/TfgggEqAH1kaj74C3MUpvuhUN7ZYWyyIfGnMiZwVWzLxDaPDQAsqNS2lYwkF9Uh0zt1wQ0JS/MXkKd0pyUuNQsZwbVz6UTamKk6JUwJse3HcjOFFz4Dx4mGrzRKE+ddM6gB2ehEF9BCo79KD2VoNuXu+4CDBUZW0XL1v73HVtdlP4Ueb+rNTgIpF6BVFL5tpKBh01aehlVuZQ24HQp7HAt5WQYiU1pc4jiRpdfUlWhREJXqSQWz5WaBNE= 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: The VDSO implementation includes headers from outside of the vdso/ namespace. Modify getrandom to take advantage of the refactoring done in the previous patches and to include only the vdso/ namespace. Cc: Andy Lutomirski Cc: Thomas Gleixner Cc: Jason A. Donenfeld Signed-off-by: Vincenzo Frascino --- include/vdso/datapage.h | 1 + lib/vdso/getrandom.c | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h index b7d6c71f20c1..127f0c51bf01 100644 --- a/include/vdso/datapage.h +++ b/include/vdso/datapage.h @@ -5,6 +5,7 @@ #ifndef __ASSEMBLY__ #include +#include #include #include #include diff --git a/lib/vdso/getrandom.c b/lib/vdso/getrandom.c index 938ca539aaa6..e15d3cf768c9 100644 --- a/lib/vdso/getrandom.c +++ b/lib/vdso/getrandom.c @@ -3,19 +3,19 @@ * Copyright (C) 2022-2024 Jason A. Donenfeld . All Rights Reserved. */ -#include -#include #include #include #include -#include -#include -#include +#include +#include -#undef PAGE_SIZE -#undef PAGE_MASK -#define PAGE_SIZE (1UL << CONFIG_PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE - 1)) +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x)) +#endif + +#ifndef min_t +#define min_t(type,a,b) ((type)(a) < (type)(b) ? (type)(a) : (type)(b)) +#endif #define MEMCPY_AND_ZERO_SRC(type, dst, src, len) do { \ while (len >= sizeof(type)) { \ @@ -79,8 +79,8 @@ __cvdso_getrandom_data(const struct vdso_rng_data *rng_info, void *buffer, size_ if (unlikely(opaque_len == ~0UL && !buffer && !len && !flags)) { struct vgetrandom_opaque_params *params = opaque_state; params->size_of_opaque_state = sizeof(*state); - params->mmap_prot = PROT_READ | PROT_WRITE; - params->mmap_flags = MAP_DROPPABLE | MAP_ANONYMOUS; + params->mmap_prot = VDSO_MMAP_PROT; + params->mmap_flags = VDSO_MMAP_FLAGS; for (size_t i = 0; i < ARRAY_SIZE(params->reserved); ++i) params->reserved[i] = 0; return 0;