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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44E24C4332F for ; Wed, 30 Nov 2022 15:13:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229514AbiK3PNW (ORCPT ); Wed, 30 Nov 2022 10:13:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiK3PNV (ORCPT ); Wed, 30 Nov 2022 10:13:21 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9934C18B0D; Wed, 30 Nov 2022 07:13:18 -0800 (PST) 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 sin.source.kernel.org (Postfix) with ESMTPS id AC4ADCE1928; Wed, 30 Nov 2022 15:13:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EA45C433D6; Wed, 30 Nov 2022 15:13:14 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="fAVgMKq6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1669821191; 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=7ehcLEnrmYdooboo6C8RqDRNIDhpqFZtLvwqVG7Hw+8=; b=fAVgMKq6Riw/gzU9p3R+4uU7gWKsb4jXNlxQZhG6hZCQjaFHhkn57SCWHgkLuSJlissX9/ pI83l41q3tknVyPf0sb3Qb59pF4wYDgWLHucwUe+9bk5J6kENcDVprNaqabdY1KwYMdg3S 0cNjoAQJfonLpTbw9oebQAOyYGIar0k= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id fd6b750a (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 30 Nov 2022 15:13:11 +0000 (UTC) Received: by mail-vs1-f48.google.com with SMTP id i2so17572823vsc.1; Wed, 30 Nov 2022 07:13:10 -0800 (PST) X-Gm-Message-State: ANoB5pmQUP4bD6ze5BieyRCw9293s7F4OyQ0ev/VoG3r9Vb6SX9/YA8U yqTealCvr0M49KeoUSqikHjlmbfIt8rTABdNWnk= X-Google-Smtp-Source: AA0mqf6Yl/T+OAmoD0yazsnLCOATWbsGEI4/bldaoexY6SLa+x8gkonaehR/KkIlFpsUee1zbzFLip7zOgDwOVo3DmU= X-Received: by 2002:a67:f54e:0:b0:3b0:4e31:10f7 with SMTP id z14-20020a67f54e000000b003b04e3110f7mr24842897vsn.73.1669821189935; Wed, 30 Nov 2022 07:13:09 -0800 (PST) MIME-Version: 1.0 References: <20221129210639.42233-1-Jason@zx2c4.com> <20221129210639.42233-4-Jason@zx2c4.com> <878rjs7mcx.fsf@oldenburg.str.redhat.com> <16ec2a7a-c469-4732-aeca-e74a9fb88d3e@app.fastmail.com> In-Reply-To: <16ec2a7a-c469-4732-aeca-e74a9fb88d3e@app.fastmail.com> From: "Jason A. Donenfeld" Date: Wed, 30 Nov 2022 16:12:58 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v10 3/4] random: introduce generic vDSO getrandom() implementation To: Arnd Bergmann Cc: Florian Weimer , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Thomas Gleixner , linux-crypto@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, Greg Kroah-Hartman , Adhemerval Zanella Netto , "Carlos O'Donell" , Christian Brauner Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org Hi Arnd, On Wed, Nov 30, 2022 at 4:07 PM Arnd Bergmann wrote: > > +#ifdef CONFIG_64BIT > > +typedef u64 vdso_kernel_ulong; > > +#else > > +typedef u32 vdso_kernel_ulong; > > +#endif > > This does not address the ABI concern: to allow 32-bit and 64-bit > tasks to share the same data page, it has to be the same width on > both, either u32 or 64, but not depending on a configuration > option. I think it does address the issue. CONFIG_64BIT is a .config setting, not a compiler-derived setting. So a 64-bit kernel will get a u64 in kernel mode, and then it will get a u64 for the 64-bit vdso usermode compile, and finally it will get a u64 for the 32-bit vdso usermode compile. So in all three cases, the size is the same. > > struct vdso_rng_data { > > vdso_kernel_ulong generation; > > bool is_ready; > > }; > > There is another problem with this: you have implicit padding > in the structure because the two members have different size > and alignment requirements. The easiest fix is to make them > both u64, or you could have a u32 is_ready and an explit u32 > for the padding. There's padding at the end of the structure, yes. But both `generation` and `is_ready` will be at the same offset. If the structure grows, then sure, that'll have to be taken into account. But that's not a problem because this is a private implementation detail between the vdso code and the kernel. Jason