From nobody Sun Feb 8 05:59:51 2026 Received: from mail-io1-f73.google.com (mail-io1-f73.google.com [209.85.166.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1DF02FFF84 for ; Fri, 31 Oct 2025 17:06:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761930369; cv=none; b=GcAB49RCkS2d1BcbZ0l8/xaOPC+KvudVvh3DkRmxh726YqNLUIb43Xvztf1WeChffCpn4o2DLkKmxH4i+Xb04qLJpGVg1KRloDwnCKBipwfoqzCe7uK85s/XhyO/8RFfY/S3Ox0Zk0Ybz3lGbvDiNnBEwH9qCbp58S4MnvOKo1E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761930369; c=relaxed/simple; bh=51HoynwOXBBYpmRQlOlZjPk3WwgqcaDPqx5ZdB388U4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=foN1mcNjwINVCB1yItxXLloiqMTnMF5bDY7pKdbS8BGynlZ4lpuaj/Ac9dJLXK4c0qk8ltKxbEhF82B4jbhqrITMc7NfhgJLmpxbGy1sT3PrhNFl7/qa3Rs2ZKJ21yO6b/OTVNFjgO1l9NZTY2BCtWq0I4FLZociH7weqpXUmWs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--rananta.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EEhHOHlF; arc=none smtp.client-ip=209.85.166.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--rananta.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EEhHOHlF" Received: by mail-io1-f73.google.com with SMTP id ca18e2360f4ac-9447edc234fso638653839f.2 for ; Fri, 31 Oct 2025 10:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1761930367; x=1762535167; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ESK5VZc3vh1v+zY2F8OUAm49V9ykNX+vVejA0Uaau+g=; b=EEhHOHlFoK8+f5QyodcEejOWF9NHTz8GF8TlT81bD9LgXer/sYSYtrIqotp8968gu/ Vr2zyOeGfCV8XUZqpl8kxujf4cBo0dQxqGJiMXLdfrEce2J+dvsGlNp5s4ZNpOtorKvB PID+OsnWbrfJzcaRtGja/o61M3yXnTpGltTh4KYhiHj3skAVW+FiFMEp6OGhOIW7fKIr vj2r5dBMsaAGoCR7SrGUQXwnf/jZcWOzoWC7u+a2ynh3rxB2HepvmlzJeEWYqhdIyrJX Ll02J+CrQUkMArgEz9/gI6Tszu5FJ/vpAad4FO7oG4sei7itVOa6hE3YBLFtcbbqfyvB ncjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761930367; x=1762535167; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ESK5VZc3vh1v+zY2F8OUAm49V9ykNX+vVejA0Uaau+g=; b=ezp0jznawfsvtA2tnG4K3it1OPkwaR9cnHoctm95wqJOHXOIXgV4s1tyQQ5iNjkeAY It3aEonAyF2uD7Gp0i82dRubit2s3I8AfyEwEbdX4UefOPQRw2jaFYSK3zykw6Ys5rkG 1Pwc98pnqp3diwIOeKjcF3SeFz23XzakJmP6pgZkvfDBTmvCNrSHvxSA2QBaT4oHLU9p u594Fge8UWl1mp62QeOX4lKZmb4wWo6DMiQQ5lcsylKqWx62rKmJTSwRfFji6qJW5c/Q wp2d7keuTJ/QUNnzRoXoFi2ThCzgD4Fp6gJRy2jctd2Vw5J/UJflNov9AEPfuB3kMEYo lJ5A== X-Forwarded-Encrypted: i=1; AJvYcCVnHwvE74L9xWgKas7O3CcWxdRhA8IzjA05z4a3rjHvegVKVo4+Q0IpZAKDvey+MheowYyJ4cvRq0Q73WI=@vger.kernel.org X-Gm-Message-State: AOJu0YyXy0kG7ZbPYic0s7MPKzy8DiXMK9IvDro3Du1rZaiTI7jCOdBg xAjYi7PTh2sKS+EGzef+8FDSlCjMizHHzJbFivUktAU6NhXJvZzeFZqvYrpG2JfPFQvQOckmxD6 MbKF+qKrdZw== X-Google-Smtp-Source: AGHT+IHDw1+d8/l+qhwB+hEV3+qa8J59RyQJZwYBwBtApzCiM87vIs6ZU3Urpv3R+3PkP8aNHR918I5o62+g X-Received: from iobfp5.prod.google.com ([2002:a05:6602:c85:b0:945:abfb:6eb0]) (user=rananta job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6602:6c0d:b0:943:5917:b6fb with SMTP id ca18e2360f4ac-9482274fc8amr725849839f.0.1761930367031; Fri, 31 Oct 2025 10:06:07 -0700 (PDT) Date: Fri, 31 Oct 2025 17:06:02 +0000 In-Reply-To: <20251031170603.2260022-1-rananta@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251031170603.2260022-1-rananta@google.com> X-Mailer: git-send-email 2.51.1.930.gacf6e81ea2-goog Message-ID: <20251031170603.2260022-2-rananta@google.com> Subject: [PATCH v2 1/2] vfio: Fix ksize arg while copying user struct in vfio_df_ioctl_bind_iommufd() From: Raghavendra Rao Ananta To: Jason Gunthorpe , Alex Williamson , Alex Williamson , Longfang Liu , David Matlack Cc: Josh Hilke , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Raghavendra Rao Ananta , stable@vger.kernel.org, Jason Gunthorpe Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For the cases where user includes a non-zero value in 'token_uuid_ptr' field of 'struct vfio_device_bind_iommufd', the copy_struct_from_user() in vfio_df_ioctl_bind_iommufd() fails with -E2BIG. For the 'minsz' passed, copy_struct_from_user() expects the newly introduced field to be zero-ed, which would be incorrect in this case. Fix this by passing the actual size of the kernel struct. If working with a newer userspace, copy_struct_from_user() would copy the 'token_uuid_ptr' field, and if working with an old userspace, it would zero out this field, thus still retaining backward compatibility. Fixes: 86624ba3b522 ("vfio/pci: Do vf_token checks for VFIO_DEVICE_BIND_IOM= MUFD") Cc: stable@vger.kernel.org Signed-off-by: Raghavendra Rao Ananta Reviewed-by: Jason Gunthorpe --- drivers/vfio/device_cdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vfio/device_cdev.c b/drivers/vfio/device_cdev.c index 480cac3a0c274..8ceca24ac136c 100644 --- a/drivers/vfio/device_cdev.c +++ b/drivers/vfio/device_cdev.c @@ -99,7 +99,7 @@ long vfio_df_ioctl_bind_iommufd(struct vfio_device_file *= df, return ret; if (user_size < minsz) return -EINVAL; - ret =3D copy_struct_from_user(&bind, minsz, arg, user_size); + ret =3D copy_struct_from_user(&bind, sizeof(bind), arg, user_size); if (ret) return ret; =20 --=20 2.51.1.930.gacf6e81ea2-goog From nobody Sun Feb 8 05:59:51 2026 Received: from mail-ot1-f74.google.com (mail-ot1-f74.google.com [209.85.210.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E2993019B1 for ; Fri, 31 Oct 2025 17:06:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761930370; cv=none; b=TuT+F3oiAAzln7CaUbo5IMM8vVZOB5YeruMYm3rRUH0GOOk6FnftAPB9jZWlWTvzcBCD8PbHS3OFnGCU+iNDjpCaAWCw6MOs42hSgcYi3WeW0LeCc2WTvXYDRgRiFyvE8TwLs4ZWiRcY1cYQ3U/CJo7McBwTgWUCZkISgwK3HRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761930370; c=relaxed/simple; bh=QwYo/Yoz+I4T+rZY/7ih9WEmyZPRtgRok11KJciMVYc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=glzCOXrAHYt54hwKrD83jOv3GpdyVMNS8ggnOdIINzGgR+Cikg53NifJnWbqZFDg5eq6Pnmnh7DxwglMt1mMId2p2nKj2WvYAROe/r4LI5XdCfKJEkMBQh5BqYhXw68UjNLX/xmxNmf2tDU6gTpqAsU6g9hGinlWMF4KD9oFIhg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--rananta.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=G9nHaUnf; arc=none smtp.client-ip=209.85.210.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--rananta.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="G9nHaUnf" Received: by mail-ot1-f74.google.com with SMTP id 46e09a7af769-7c3e149a815so4543108a34.1 for ; Fri, 31 Oct 2025 10:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1761930368; x=1762535168; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=OY4ljaKFzmW3A8oE1zEU8ROXOLit9Ajx9xtSY2H7jXY=; b=G9nHaUnfUjt68aiP/CybRo7KmwBmq0K7B4ZpIEJlRCYW7Fps+ADEwraw2+Mk83Wopr //Ba16ZKuIb8LmVrMHN4VGcyZpQ+QKVis+CJxXuAksXD5PhnxTnysN79AZ5k5y6pUxC5 VjNZr9+ciPUxYapnFnKi9VfN0MEgf8xsEstL5fN3GON0O0tt2GnLI8wMSU1bDw41Faz3 QFw4iaUCIHgCgda/+/+nCwfe8erV8dOxdleg+ruabOBCH+vS5axxtU3uWnsOGbYAFogp m2wdvSjAeiy9MUFpg3PXT1UGyhrY74YuHkPEPPOATN2MH+GutjR4HM2HKDuC3wltCpNA +MqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761930368; x=1762535168; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OY4ljaKFzmW3A8oE1zEU8ROXOLit9Ajx9xtSY2H7jXY=; b=ChyVUia1s2Ohv+tv+D39iFCb3Qz3Cvj3dmc3HYC9yBeUioPLIZw2O8gf0YEKgOmavV wzkTY6X56YKYKrbwcMRK5jBLtXiRxXSjWcq5EU3f9cH3d1tZ6OWl8xHbnQW1KEkaC2NA m4LTT2dS9qBaIsg/YF1IUB81CAdSk12+yqYMnBKhAHvmiARRY514D4iKFcwUJIExYNwJ QzR5XKqHteYRB68eFQ2L7iozhJnOnejxq+JbdjbJRDtGYqQVbx7e0rQS2tyHZqZ8Hs8w 6JPTe4PRJGvxkUBr4Hkfs51qPzGJVRyGWo3CxjAtLOvQbXBU4RBxLKjtG5lZcW8r6V6D JdKw== X-Forwarded-Encrypted: i=1; AJvYcCW2sh558mYAyQjVmn2RyWwSM6nbajljwTP6QsurazjFvWndYyRTRVn9IDgPL6z5yhWcEXcZ4gX5P6GeFIg=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2UNDZqenkj+c1Y75bWZMbZSwEu7vRo7wVO0vCqLvNi5ndJ93T cWt6gEBS+KhGJ44nv1mm3Mt+2Ij5K3iHjxNxfDGyDXmCicZbkP8/ztB7kg24i5McvrTogTPD33m BUoGamQlcmA== X-Google-Smtp-Source: AGHT+IEnJVtmijC8TzZF5pGhOrZATGI47Fj98vUFRBqaKlvcaJ3uI54EHz3UXi30/Su9B2TFuWmC2JYVX9kc X-Received: from otar9.prod.google.com ([2002:a05:6830:1c9:b0:7c3:e32e:483d]) (user=rananta job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6830:6110:b0:7b2:8ab:69bd with SMTP id 46e09a7af769-7c696847015mr2109668a34.33.1761930368062; Fri, 31 Oct 2025 10:06:08 -0700 (PDT) Date: Fri, 31 Oct 2025 17:06:03 +0000 In-Reply-To: <20251031170603.2260022-1-rananta@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251031170603.2260022-1-rananta@google.com> X-Mailer: git-send-email 2.51.1.930.gacf6e81ea2-goog Message-ID: <20251031170603.2260022-3-rananta@google.com> Subject: [PATCH v2 2/2] hisi_acc_vfio_pci: Add .match_token_uuid callback in hisi_acc_vfio_pci_migrn_ops From: Raghavendra Rao Ananta To: Jason Gunthorpe , Alex Williamson , Alex Williamson , Longfang Liu , David Matlack Cc: Josh Hilke , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Raghavendra Rao Ananta , stable@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The commit, <86624ba3b522> ("vfio/pci: Do vf_token checks for VFIO_DEVICE_BIND_IOMMUFD") accidentally ignored including the .match_token_uuid callback in the hisi_acc_vfio_pci_migrn_ops struct. Introduce the missed callback here. Fixes: 86624ba3b522 ("vfio/pci: Do vf_token checks for VFIO_DEVICE_BIND_IOM= MUFD") Cc: stable@vger.kernel.org Suggested-by: Longfang Liu Signed-off-by: Raghavendra Rao Ananta Reviewed-by: Jason Gunthorpe Reviewed-by: Longfang Liu --- drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/= pci/hisilicon/hisi_acc_vfio_pci.c index fde33f54e99ec..d07093d7cc3f5 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c @@ -1564,6 +1564,7 @@ static const struct vfio_device_ops hisi_acc_vfio_pci= _migrn_ops =3D { .mmap =3D hisi_acc_vfio_pci_mmap, .request =3D vfio_pci_core_request, .match =3D vfio_pci_core_match, + .match_token_uuid =3D vfio_pci_core_match_token_uuid, .bind_iommufd =3D vfio_iommufd_physical_bind, .unbind_iommufd =3D vfio_iommufd_physical_unbind, .attach_ioas =3D vfio_iommufd_physical_attach_ioas, --=20 2.51.1.930.gacf6e81ea2-goog