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 E22CBC04FDF for ; Mon, 14 Aug 2023 17:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231491AbjHNRwl (ORCPT ); Mon, 14 Aug 2023 13:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231682AbjHNRwa (ORCPT ); Mon, 14 Aug 2023 13:52:30 -0400 Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAB0C172C for ; Mon, 14 Aug 2023 10:52:19 -0700 (PDT) Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-56dd69cbb18so3174611eaf.2 for ; Mon, 14 Aug 2023 10:52:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1692035539; x=1692640339; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=uPVktipHR+zcbSodfTpb3XBmJmcoL0W6CfGs9OCLYNE=; b=mVDtQzd8MHNyxorFjlWbKe61eqmNhOA9pfMOqHFa7Ec/bADYHlcuoS5/OHt0VCnTOx NaJAl4w3FAiUFmZt6cu2m+AtARGcXFC94dOXLMn30mQ1+d+w/Alum0xRKCvtCIrrBgcu HeICg4DGbZ6hvV3HN6b73hJDu9i0bUCX2NLxgVIhDdYESPyR6olqbtV3wgWHw4jX+YRy +JYdx+NsrzhaJHbKOoJKfV0XDn7g9rRQFhCTowzdUxywaAY6E01N/gzjj/xHxqCOt0+V ZRuPyA7bnfzeQFUhQ3Y3NNo4pWWoME3TrkXJcE2OLQ+ef5M8EY1uidlLu8EGWprUK3oP rHtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692035539; x=1692640339; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uPVktipHR+zcbSodfTpb3XBmJmcoL0W6CfGs9OCLYNE=; b=EJm6AnDLQZruGSOhCmd7T/jx7bD3faj+3Tod3CD8KQb6WpVI0uJlHllRuAD8QqHaV3 +5Zq5DitWQDY7BTLRn7PtuJVV6nRlkFMQy9ivv1Wu9MFlcObQpottmoPV5lkEvrpTZKf Ei1jjTBgwTPvW3FMBdpKFoSrROXzoiTktKJmu9QXeKgenmw69IBzwjN9pkr6t+GlMGxJ F4uMsdoaaQ0l7WVjqggL+xisazHA3s7YxVhHUcq+EeHPtJDQiHr5rF+4OEkdw59ozRK7 lYbUT/GgPyogmOHPzVtRZ9ha6rQ0uJBjQpyIy3SljRNgIqps0nvFyc3MkVYrk+PIifaO wPfg== X-Gm-Message-State: AOJu0YzGUgDKAggbZwiVJcv9vUZzQw5EgALi87z1WqBAJWvIv+2z9/O1 Mu16tRfyOkgwrEOv6vRWP0/Uu7RO1y1m+0OcMsU= X-Google-Smtp-Source: AGHT+IHOhOpWvPjOGvkcdFMoAbgFEcs4qtjnrZmuX8GY0VlauHTC8TNCRgC7r3FFsu0oet1AEAb/zQ== X-Received: by 2002:a05:6358:8a7:b0:13a:4855:d8f0 with SMTP id m39-20020a05635808a700b0013a4855d8f0mr6962015rwj.5.1692035539024; Mon, 14 Aug 2023 10:52:19 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id w6-20020ac87186000000b00403e80cad67sm3256843qto.41.2023.08.14.10.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 10:52:18 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qVbjl-0070EN-Sw; Mon, 14 Aug 2023 14:52:17 -0300 Date: Mon, 14 Aug 2023 14:52:17 -0300 From: Jason Gunthorpe To: Stefan Hajnoczi Cc: kvm@vger.kernel.org, "Tian, Kevin" , linux-kernel@vger.kernel.org, Alex Williamson Subject: Re: [PATCH 4/4] vfio: use __aligned_u64 in struct vfio_device_ioeventfd Message-ID: References: <20230809210248.2898981-1-stefanha@redhat.com> <20230809210248.2898981-5-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230809210248.2898981-5-stefanha@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 09, 2023 at 05:02:48PM -0400, Stefan Hajnoczi wrote: > The memory layout of struct vfio_device_ioeventfd is > architecture-dependent due to a u64 field and a struct size that is not > a multiple of 8 bytes: > - On x86_64 the struct size is padded to a multiple of 8 bytes. > - On x32 the struct size is only a multiple of 4 bytes, not 8. > - Other architectures may vary. > > Use __aligned_u64 to make memory layout consistent. This reduces the > chance of holes that result in an information leak and the chance that > 32-bit userspace on a 64-bit kernel breakage. > > This patch increases the struct size on x32 but this is safe because of > the struct's argsz field. The kernel may grow the struct as long as it > still supports smaller argsz values from userspace (e.g. applications > compiled against older kernel headers). > > The code that uses struct vfio_device_ioeventfd already works correctly > when the struct size grows, so only the struct definition needs to be > changed. > > Suggested-by: Jason Gunthorpe > Signed-off-by: Stefan Hajnoczi > --- > include/uapi/linux/vfio.h | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) Reviewed-by: Jason Gunthorpe Jason