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 E5DB2C433FE for ; Thu, 6 Oct 2022 17:24:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 600186B0072; Thu, 6 Oct 2022 13:24:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 587EB6B0073; Thu, 6 Oct 2022 13:24:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B38C8E0001; Thu, 6 Oct 2022 13:24:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 166566B0072 for ; Thu, 6 Oct 2022 13:24:54 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5CABB4113F for ; Thu, 6 Oct 2022 17:24:51 +0000 (UTC) X-FDA: 79991199582.26.02902BB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id DD6B51C001E for ; Thu, 6 Oct 2022 17:24:49 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 06A9861A38 for ; Thu, 6 Oct 2022 17:24:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C480C43141 for ; Thu, 6 Oct 2022 17:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1665077083; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hw+hnIMvKUNp0lwyCAgNJh72KYkKEhg87FRQTBs88Es=; b=POjrwExNl+YXOaE1lio2t2OoJfp8Pmah83jSwtmwy+a2nmIcgGjbJmUmksnkg0epw22VVq tGGHYs/cXqxakaG1JY+AKcIhkDIqLD1VU/xPH1+NYYAgl3bbbwTmxU3VYrpCk1M4Y+6MDS 6kdK5f+OZLONIyv9rAEIsa1XZ5KZlTQ= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 39ff1862 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Thu, 6 Oct 2022 17:24:42 +0000 (UTC) Received: by mail-oo1-f49.google.com with SMTP id x6-20020a4ac586000000b0047f8cc6dbe4so1882202oop.3 for ; Thu, 06 Oct 2022 10:24:41 -0700 (PDT) X-Gm-Message-State: ACrzQf08KWYsu7tT9y2lqWKvk14GNO4Kt99qFl5e4+aRh+uOoye3ouNk EN7eLnsp4XL5vNAFteyv1oTFh5c1nJhlPCLk9Ac= X-Google-Smtp-Source: AMsMyM5KG2gwBNORWG5lbntrblDeF/IiEaNCtjq1xHSusLtpHfgrAAJFtzxp/82W985F9k39J/OxSFTwH+6dW+Mrfqw= X-Received: by 2002:ab0:6cb0:0:b0:3d7:1184:847f with SMTP id j16-20020ab06cb0000000b003d71184847fmr777504uaa.49.1665077067240; Thu, 06 Oct 2022 10:24:27 -0700 (PDT) MIME-Version: 1.0 References: <20221006165346.73159-1-Jason@zx2c4.com> <20221006165346.73159-4-Jason@zx2c4.com> <848ed24c-13ef-6c38-fd13-639b33809194@csgroup.eu> In-Reply-To: <848ed24c-13ef-6c38-fd13-639b33809194@csgroup.eu> From: "Jason A. Donenfeld" Date: Thu, 6 Oct 2022 11:24:16 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 3/5] treewide: use get_random_u32() when possible To: Christophe Leroy Cc: "linux-kernel@vger.kernel.org" , "patches@lists.linux.dev" , Andreas Noever , Andrew Morton , Andy Shevchenko , Borislav Petkov , Catalin Marinas , =?UTF-8?Q?Christoph_B=C3=B6hmwalder?= , Christoph Hellwig , Daniel Borkmann , Dave Airlie , Dave Hansen , "David S . Miller" , Eric Dumazet , Florian Westphal , Greg Kroah-Hartman , "H . Peter Anvin" , Heiko Carstens , Helge Deller , Herbert Xu , Huacai Chen , Hugh Dickins , Jakub Kicinski , "James E . J . Bottomley" , Jan Kara , Jason Gunthorpe , Jens Axboe , Johannes Berg , Jonathan Corbet , Jozsef Kadlecsik , KP Singh , Kees Cook , Marco Elver , Mauro Carvalho Chehab , Michael Ellerman , Pablo Neira Ayuso , Paolo Abeni , Peter Zijlstra , Richard Weinberger , Russell King , "Theodore Ts'o" , Thomas Bogendoerfer , Thomas Gleixner , Thomas Graf , Ulf Hansson , Vignesh Raghavendra , WANG Xuerui , Will Deacon , Yury Norov , "dri-devel@lists.freedesktop.org" , "kasan-dev@googlegroups.com" , "kernel-janitors@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-block@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "linux-doc@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-media@vger.kernel.org" , "linux-mips@vger.kernel.org" , "linux-mm@kvack.org" , "linux-mmc@vger.kernel.org" , "linux-mtd@lists.infradead.org" , "linux-nvme@lists.infradead.org" , "linux-parisc@vger.kernel.org" , "linux-rdma@vger.kernel.org" , "linux-s390@vger.kernel.org" , "linux-um@lists.infradead.org" , "linux-usb@vger.kernel.org" , "linux-wireless@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "loongarch@lists.linux.dev" , "netdev@vger.kernel.org" , "sparclinux@vger.kernel.org" , "x86@kernel.org" , =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , Chuck Lever , Jan Kara Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665077090; 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=hw+hnIMvKUNp0lwyCAgNJh72KYkKEhg87FRQTBs88Es=; b=dJ7CDwXjCXYKUxHE/b+gefgz+vpyM42CKrrHgjOIPJSQmxW1Oq90hDgyiPzg95X8etKb3f WV1V5qByNs388iPr05MDo1dCn5sPxnRsn+ME1F1G2oql6rXDbLqEkRfZPxs3thiLac1YBu 1e/679/nqH5yDd6XnynW+CKkc5d1eK8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=POjrwExN; dmarc=pass (policy=quarantine) header.from=zx2c4.com; spf=pass (imf18.hostedemail.com: domain of "SRS0=tIOp=2H=zx2c4.com=Jason@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=tIOp=2H=zx2c4.com=Jason@kernel.org" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665077090; a=rsa-sha256; cv=none; b=xWXnmQhq+J6ppfJiGtAOXvM+W9q1v/yTtnHri2Jn/H7ebBf5XjG1gXa/O8sb97C4p7LSQS hViNvc3c4ou2RRAtoK8mZp4JsuBvYRr7kXFPpB8eARSYi8X0+LFhtjvuXC1kjmxsGCW0Hg i/2y+LY9llFT7Y8z8dYu52cv5rP45TI= X-Rspamd-Queue-Id: DD6B51C001E Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=POjrwExN; dmarc=pass (policy=quarantine) header.from=zx2c4.com; spf=pass (imf18.hostedemail.com: domain of "SRS0=tIOp=2H=zx2c4.com=Jason@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=tIOp=2H=zx2c4.com=Jason@kernel.org" X-Rspam-User: X-Rspamd-Server: rspam10 X-Stat-Signature: uwkgmdncj8tofjgrkxonwmmssd88o8m1 X-HE-Tag: 1665077089-762201 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: Hi Christophe, On Thu, Oct 6, 2022 at 11:21 AM Christophe Leroy wrote: > Le 06/10/2022 =C3=A0 18:53, Jason A. Donenfeld a =C3=A9crit : > > The prandom_u32() function has been a deprecated inline wrapper around > > get_random_u32() for several releases now, and compiles down to the > > exact same code. Replace the deprecated wrapper with a direct call to > > the real function. The same also applies to get_random_int(), which is > > just a wrapper around get_random_u32(). > > > > Reviewed-by: Kees Cook > > Acked-by: Toke H=C3=B8iland-J=C3=B8rgensen # for sch_cak= e > > Acked-by: Chuck Lever # for nfsd > > Reviewed-by: Jan Kara # for ext4 > > Signed-off-by: Jason A. Donenfeld > > --- > > > diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/proces= s.c > > index 0fbda89cd1bb..9c4c15afbbe8 100644 > > --- a/arch/powerpc/kernel/process.c > > +++ b/arch/powerpc/kernel/process.c > > @@ -2308,6 +2308,6 @@ void notrace __ppc64_runlatch_off(void) > > unsigned long arch_align_stack(unsigned long sp) > > { > > if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_s= pace) > > - sp -=3D get_random_int() & ~PAGE_MASK; > > + sp -=3D get_random_u32() & ~PAGE_MASK; > > return sp & ~0xf; > > Isn't that a candidate for prandom_u32_max() ? > > Note that sp is deemed to be 16 bytes aligned at all time. Yes, probably. It seemed non-trivial to think about, so I didn't. But let's see here... maybe it's not too bad: If PAGE_MASK is always ~(PAGE_SIZE-1), then ~PAGE_MASK is (PAGE_SIZE-1), so prandom_u32_max(PAGE_SIZE) should yield the same thing? Is that accurate? And holds across platforms (this comes up a few places)? If so, I'll do that for a v4. Jason