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 D1CF9C04A94 for ; Mon, 14 Aug 2023 17:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231429AbjHNRwi (ORCPT ); Mon, 14 Aug 2023 13:52:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231356AbjHNRwH (ORCPT ); Mon, 14 Aug 2023 13:52:07 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 935CF124 for ; Mon, 14 Aug 2023 10:52:06 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-4103393a459so30873001cf.0 for ; Mon, 14 Aug 2023 10:52:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1692035525; x=1692640325; 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=t1hvwKn0H2/PSZbR/GuIJU8CyNs4zCnJXFN0bPnDDdo=; b=WqkPJVkEzuJiuWpVE0xvrcozBY6JRrVXbB15phXMk0uV2pBPmu5MxooBqyy4BoTlZe F1guXaemacE9gvxE2gszsGmpQ0/9y+xXNY8lmigpX73Ev797+3wjgFcciGhpUIrhtg5a EdsWWn5R0nyka0voliDSW35s6leLT93sIhtjsfMZKBH+bW48AMzarHiVDi/dMd4W9c+N ZFXbBCt7swL8urtEBQLlIpm/qmW3nEYHGPamzgpZH0+SmsXKweJ4yDZwtdvc/KIwbpOz qDTSe1T5c2S7YXCoqgRXJ03L82/rQM6kshsuAc7lc36XK+kDptFa55Inz33tG/Y26yAW aDxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692035525; x=1692640325; 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=t1hvwKn0H2/PSZbR/GuIJU8CyNs4zCnJXFN0bPnDDdo=; b=S7jemDf23wpevmZCnqcz8g+YNb4XokU0Ib0wB125Evh8Am/6/XWtK3AV6/e1EPUbXL Thsx1nqMwzPhccHo2iAm5ngHFXdlsiTyIeoZhTfpCI497sTgFxHsLKFQTPCxEDwcwphj +vUyfXB3LRolCTBdhrP8B2NEjhe4Ah/N8fNS05gxHBtKTBuNMtgze6oWILTZIKWqjt73 rzqfg/ZQqualBAtXIJr0plHRscXqPVNiH+6/K0EQX8OEpdFDzaFkfG9VNxdhSf3lG0pI joiQkVNL04BG0dKJ4XxiCVWqZ/26e6u3ic8KHPJlF9jqwiBVQbhUWfNHe/fWwQcWs09i krlw== X-Gm-Message-State: AOJu0YxrRKFvcBhZAzp6SAuh0jUNgNoKyGyVwe9zPzul5sGUvgbOlzaD 6NIc4zDm3DPD7wzRi92I6dkQ3A== X-Google-Smtp-Source: AGHT+IHtvhyjY1M4UiRth3J5O18+VLDvzJc4L+UzfAki1qDfw/nksYwiXhRbm5fSVj+QoTS+yY0ZQA== X-Received: by 2002:a05:622a:552:b0:40f:fe6b:6b5b with SMTP id m18-20020a05622a055200b0040ffe6b6b5bmr15011085qtx.66.1692035525779; Mon, 14 Aug 2023 10:52:05 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id pc5-20020a05620a840500b0076d0312b8basm3147781qkn.131.2023.08.14.10.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 10:52:05 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qVbjY-0070E4-Di; Mon, 14 Aug 2023 14:52:04 -0300 Date: Mon, 14 Aug 2023 14:52:04 -0300 From: Jason Gunthorpe To: Stefan Hajnoczi Cc: kvm@vger.kernel.org, "Tian, Kevin" , linux-kernel@vger.kernel.org, Alex Williamson Subject: Re: [PATCH 3/4] vfio: use __aligned_u64 in struct vfio_iommu_type1_info Message-ID: References: <20230809210248.2898981-1-stefanha@redhat.com> <20230809210248.2898981-4-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230809210248.2898981-4-stefanha@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 09, 2023 at 05:02:47PM -0400, Stefan Hajnoczi wrote: > The memory layout of struct vfio_iommu_type1_info 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). > > Suggested-by: Jason Gunthorpe > Signed-off-by: Stefan Hajnoczi > --- > include/uapi/linux/vfio.h | 3 ++- > drivers/vfio/vfio_iommu_type1.c | 11 ++--------- > 2 files changed, 4 insertions(+), 10 deletions(-) Reviewed-by: Jason Gunthorpe Jason