From patchwork Thu Aug 22 07:13:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13772816 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 0683FC5320E for ; Thu, 22 Aug 2024 07:13:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A6656B02A3; Thu, 22 Aug 2024 03:13:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 82F236B02A5; Thu, 22 Aug 2024 03:13:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A9DA6B02A6; Thu, 22 Aug 2024 03:13:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 464036B02A3 for ; Thu, 22 Aug 2024 03:13:50 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D90C1140486 for ; Thu, 22 Aug 2024 07:13:49 +0000 (UTC) X-FDA: 82479016578.21.3ADD083 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by imf13.hostedemail.com (Postfix) with ESMTP id AC8D72001F for ; Thu, 22 Aug 2024 07:13:47 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724310811; 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=zLsbp86mxniEb3E+YlEDfPU3PdYohETKqxCyxm1NoGA=; b=QaDOFH5T8whMyRZ/09UUmvpa3fdIWeZCTZF9d2F+tb1bi/OEzpAEf5+37Zzpx7uWEgedwi r7vYnNCJLOpTiIVFGBWGDdo5vWumZog1RvC8LHWMKYPC2EaKUQqKj6/8NchB5qaf2SDf6X 5YGxQTFxnFsM0vTTZQDvVpeOmlLjtaY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724310811; a=rsa-sha256; cv=none; b=soTfkBwTE7ZWQ0ikaad7GWlSlm3cdne81aPsGLKScV7858kMn/gSxbiDBkTEQRQELsXN2R BLwbdxLvo523cMiwU3uZ/cgmarL0s+1k81KiNwRqBDRx+OrfFmGVFWAqnIqkBSinZJVK3L GIWsoLqq1boaTXoygEAUGPemMbchByY= Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4WqDvD04KVz9sST; Thu, 22 Aug 2024 09:13:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U1MT9tMdHKEz; Thu, 22 Aug 2024 09:13:27 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4WqDvC6NsKz9sSH; Thu, 22 Aug 2024 09:13:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C8F7C8B763; Thu, 22 Aug 2024 09:13:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id Bo_6-yJM0v5v; Thu, 22 Aug 2024 09:13:27 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (PO16920.IDSI0.si.c-s.fr [192.168.232.181]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C10D08B77E; Thu, 22 Aug 2024 09:13:26 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" , Arnd Bergmann , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Vincenzo Frascino , Shuah Khan Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 05/17] vdso: Avoid call to memset() by getrandom Date: Thu, 22 Aug 2024 09:13:13 +0200 Message-ID: <5deb67090b214f0e6eae96b7c406546d1a16f89b.1724309198.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724310794; l=1449; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=Tu05MKphwEOYciYKJrZW1zS/5ujWTK6L6L6gDjvRdHs=; b=u0fyVWP390/v2lcPCFKdHXUzbaZAGOJ9fxQFiyRBtDUCKlOBBFypazkoFT3x/4k36OQuZN9O+ 8qHLZBslISeCEi/TEk76Xkmo8/onzIZnJ6KuWgXgE5X334zHCd965Tw X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspam-User: X-Stat-Signature: 9kihy5d3qjo6whq6ckx1khhih17uhc5e X-Rspamd-Queue-Id: AC8D72001F X-Rspamd-Server: rspam11 X-HE-Tag: 1724310827-175038 X-HE-Meta: U2FsdGVkX1+qCNYjNNGu+TAW/01m9PTtej5pG0E4xMrO/n5whdkq9v9bLPJK9i8AB6BTnv/DxMC6Zp3ObePoTc8S3oOdp0NFQ43yAREEDcO02xjq6QwBDErL0UIcunR2GDFlNZROUfO2HkTQnNyJkaSGxz0p+B6yMJtAEDhiPy1kJHT5d5ozSMOnxyCTiqIlq/p4rzkAoiTW56eN1a1SSzuKU7lUCeSD4bx6F0JCPgseqGCh7fl9irbdBFRR4XiSs4mh6gJcq/DxkJ4S2EcDGhaum9Xu6RQz8fP1pxmF9OwNlTyXeuyDFsV3SLXyzQGSGvxBaWwIIkw6V23bLd1KPTT+9U6ufs+XZ28gkyjePxxDC5FD+zhTiBHU3ezqAtNdkDegGiaf9QiE4AcF0DvUAcJMoZZy1dx1z1vagHsFUovVoRgQYsjolVtkpkY2u+KSY4gDls6DLr4qrRgMMwwBpvko18WLAX9Xl0f9edBE8tB3Dn2BgaMyWypt5M55Ut6IWM2HPYMG9FpQTo1BJJySY6tLaXAPXGt++OTPyXeVP8bULENLZCRjP0R6CTOdpwUokWLqQWqkoBrzFc+CGZ93fwkT33Cr/pm1vxcCZ2qNmF3CCCnZpR4NIfstmCWtCqXrzX8jEz2jd0deMV2BlMvfqh1L5Gp/Z1FT7GsvB4ec6UiEL4hlCy7GuDp1uk4GBaFS4v2i1dCoXBmKgu8PdduHLuQhnyvJBMaKcZD1JeDgDwflVClQttXwNOjdxjg1GxBlaE6VTGj5FLQ4bd6bTGypmvgozHZJPyEaC1076I4z3hmLP/dMBSg1HthSgDwjKxwKEDzs1tHrPOoh/dpvSwEumZk7WHsnn1EBbWoZdx78EyBJgeaqdK/OvlSfoq6YWDZ2lEmqkCUFm9/P9m+3K/B9juj2PjxQtCFf+0q2HRwVUl8qX5XNHT6GmZeJncEap92iu3OI9kBVm5F05uwuFco Sj2n096r CGjDdUTI30oK++lOnsPF5PNuolWeRd1pmKwLosfF4uIjDxO73gpJtvpJPKCTJ7kT6iTcfwW1yVflEJniFCk6YgQ3fwNlRf2CV7AvPcAJuJaXFhWWDyaS2QkU7SOHdzR0p4Tvo 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: With the current implementation, __cvdso_getrandom_data() calls memset(), which is unexpected in the VDSO. Rewrite opaque data initialisation to avoid memset(). Signed-off-by: Christophe Leroy Acked-by: Ard Biesheuvel --- lib/vdso/getrandom.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/vdso/getrandom.c b/lib/vdso/getrandom.c index cab153c5f9be..4a56f45141b4 100644 --- a/lib/vdso/getrandom.c +++ b/lib/vdso/getrandom.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -74,11 +75,15 @@ __cvdso_getrandom_data(const struct vdso_rng_data *rng_info, void *buffer, size_ u32 counter[2] = { 0 }; if (unlikely(opaque_len == ~0UL && !buffer && !len && !flags)) { - *(struct vgetrandom_opaque_params *)opaque_state = (struct vgetrandom_opaque_params) { - .size_of_opaque_state = sizeof(*state), - .mmap_prot = PROT_READ | PROT_WRITE, - .mmap_flags = MAP_DROPPABLE | MAP_ANONYMOUS - }; + struct vgetrandom_opaque_params *params = opaque_state; + int i; + + params->size_of_opaque_state = sizeof(*state); + params->mmap_prot = PROT_READ | PROT_WRITE; + params->mmap_flags = MAP_DROPPABLE | MAP_ANONYMOUS; + for (i = 0; i < ARRAY_SIZE(params->reserved); i++) + params->reserved[i] = 0; + return 0; }