Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp4089lqt; Wed, 5 Jun 2024 15:10:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVHuBJvayQk569VumlR0awPvXmFXYsK2Mi9+a2o+s9draMb2o332SSYqMPUTN4Xp75nWLiMK6xcIbAz614/JZ5zTSqj68nZbfEdzVnOwg== X-Google-Smtp-Source: AGHT+IGH+MVIH40KrzRYNesJefTJ1Tis9tJmu6+6/pCinsqEVMJsSvvKnx78HsNvTmjkUxKsBkgy X-Received: by 2002:a17:902:f689:b0:1f4:508c:af6 with SMTP id d9443c01a7336-1f6a5a5c8a5mr49153185ad.50.1717625410141; Wed, 05 Jun 2024 15:10:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717625410; cv=pass; d=google.com; s=arc-20160816; b=W4IhlsneLJZxY4ASMzYXB/j2a4hcqIZTa2sN4uuFeDf1eSqykQfkR4yrmTv4n1WCKH Kzk/i+vYOwi0m9kpor32JLLSzCnYfU50u7OvWxt6legmGHB5ySofrXskWfwbr+4XGCqn k/rmuXApT8w/GrH4ESOn48IiIertjWwAu5P0IjL+y4va7gp5ua4iLzBm3ZjQcYVj7GtI 8xiiJ2/Cm1u6/iJM1wyAQKcQWYyv5WTHH6f8VoMkQ7aYZOcq1wqd14sgs6SxECJKVVg5 Y96XjolL6ADZ0lo4S3UeaH1sHqUP5gHbBT4OPD+DvkNgX/Uq+29Z2EAvuLjSxNR9ds+l wHoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=c2R7l22UwY9yFUyciye1CZnuK81vaGKmVtMpyhY7fNc=; fh=489zYYBDQ4Dxx4HOOtaU524wYt7mFF65oTmw1KvCx0M=; b=ieeJyGy8ifn193pbVhNqUOEDiXKv1f+ehnygXH9VZss+7Fvb0TeLNSqW8m6Aw/4ymA RiGqvcbf4effk0ynhISDg+aS5RzhFr+LhHar67oDKwtFVQgQocC0jfzekjI48R3yShJ2 jDWWQDU1pR+JrU2q7i5et79Kp5oy78EBYa6i/d6Z7zloc9FGXywu13ELa9zZGNhemFS/ 4HFbM95NuilAHIv57il6bU9bWQKW1mCsxrXvBdSnYNvoBoEKraONkhotsyql9RiYCMbr sTrBq8fTdRjiPVi4E1+d73cTUoW+Ic7utWgScePyEeRmSiUukf/BLbgzpQJDCnET0y1k LUvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=q0vBTPpB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XjjhP+xH; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-crypto+bounces-4768-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4768-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd7f438bsi471395ad.506.2024.06.05.15.10.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 15:10:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4768-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=q0vBTPpB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XjjhP+xH; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-crypto+bounces-4768-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4768-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0E781284CA5 for ; Wed, 5 Jun 2024 22:10:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7AF115FA69; Wed, 5 Jun 2024 22:10:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="q0vBTPpB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="XjjhP+xH" X-Original-To: linux-crypto@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 243C5154BE3; Wed, 5 Jun 2024 22:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717625404; cv=none; b=BZJXu56jn3kFVh0KG6nO6/ur7HUvMOB0xHKhOhusN2dXIRp/pR+/xgg2MQcYYv7GAEtpElLL4zQEAbXINUwe0HDRAVAc/nSdlDTZQcnrU7FN+KZd717Ye0SQjbwUEqnVjRGAogAj8nHZkxwc5jQIA2miPHHlFdsvxgbyQRAKGtg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717625404; c=relaxed/simple; bh=vm8NGhNASzRMkMaOMS4EF7ZBloPunZLMUUGqmPO/lHA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=F2yIw17hWVz4ZxyNeH5mtgg6/ieib2KIEtPSSEf1DZXSukaX80Pbc/KM7UWWiOPxnFiDly5Bwewwun7tuxrjAjzbK5QWTI1Dq9WeReoNB7s+YzgIB0H8EDJ820cTU+vWTtyVQ6wWW8GxFrJMVncOuYRhAG7HO/9z6UmlZzFswq4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=q0vBTPpB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=XjjhP+xH; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1717625401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c2R7l22UwY9yFUyciye1CZnuK81vaGKmVtMpyhY7fNc=; b=q0vBTPpBnwtmF96XmlDkIlLdL9k3q/4F+8KN9VBJYQFohbydX/XM3NqRqDXlXYkzQkBGsh GuhfK8kAFHKTiAhpp3WVibbaC9Dp4eJ5TVuS+MptAv1aG2fpZBaHKFPFIkYXJbdP7qjX/v zj8l0/WtwrhTx+s2B8FYlV2QDERsmXKXZBCrt5g/u9v35jK+8x5T6d3sgeQdNms7l5eqkj XC3f6mMwYOLFeOJIRkyIzn2+phLKa1JxXnfvry9cJbAYpdN7wjo47wxjzoDSYrWNdCkPm5 WulzyYoT4swk4DDfPukQFsPJ/O9ymePIVGRjnhSZFHxNOvpIwoXhZ9Oi3A8v4g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1717625401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c2R7l22UwY9yFUyciye1CZnuK81vaGKmVtMpyhY7fNc=; b=XjjhP+xHuaQz77lvLGuBDqKymLfoK3Trc9n5qavwAXrGCMtMeuaYL36SFUf4DrlDJMYKCP vAg+mTjVrptTHtCg== To: "Jason A. Donenfeld" , linux-kernel@vger.kernel.org, patches@lists.linux.dev Cc: "Jason A. Donenfeld" , linux-crypto@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, Greg Kroah-Hartman , Adhemerval Zanella Netto , Carlos O'Donell , Florian Weimer , Arnd Bergmann , Jann Horn , Christian Brauner , David Hildenbrand Subject: Re: [PATCH v16 4/5] random: introduce generic vDSO getrandom() implementation In-Reply-To: <874ja73xx7.ffs@tglx> References: <874ja73xx7.ffs@tglx> Date: Thu, 06 Jun 2024 00:10:00 +0200 Message-ID: <87v82n2g93.ffs@tglx> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Jason! On Wed, Jun 05 2024 at 23:03, Thomas Gleixner wrote: > On Tue, May 28 2024 at 14:19, Jason A. Donenfeld wrote: >> + */ >> +#ifdef CONFIG_64BIT >> +typedef u64 vdso_kernel_ulong; >> +#else >> +typedef u32 vdso_kernel_ulong; >> +#endif > > All of this is pointless because if a 32-bit application runs on a > 64-bit kernel it has to use the 64-bit 'generation'. So why on earth do > we need magic here for a 32-bit kernel? > > Just use u64 for both and spare all this voodoo. We're seriously not > "optimizing" for 32-bit kernels. All what happens on a 32-bit kernel is that the RNG will store the unsigned long (32bit) generation into a 64bit variable: smp_store_release(&_vdso_rng_data.generation, next_gen + 1); As the upper 32bit are always zero, there is no issue vs. load store tearing at all. So there is zero benefit for this aside of slightly "better" user space code when running on a 32-bit kernel. Who cares? While staring at this I wonder where the corresponding smp_load_acquire() is. I haven't found one in the VDSO code. READ_ONCE() is only equivalent on a few architectures. But, what does that store_release() buy at all? There is zero ordering vs. anything in the kernel and neither against user space. If that smp_store_release() serves a purpose then it really has to be extensively documented especially as the kernel itself simply uses WRITE/READ_ONCE() for base_rng.generation. Thanks, tglx