iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommufd/driver: Fix counter initialization for counted_by annotation
@ 2025-11-11  9:01 Gustavo A. R. Silva
  2025-11-11 18:53 ` Nicolin Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2025-11-11  9:01 UTC (permalink / raw)
  To: Jason Gunthorpe, Kevin Tian, Joerg Roedel, Will Deacon,
	Robin Murphy, Lu Baolu, Nicolin Chen
  Cc: iommu, linux-kernel, Gustavo A. R. Silva, linux-hardening

One of the requirements for counted_by annotations is that the counter
member must be initialized before the first reference to the
flexible-array member.

Move the vevent->data_len = data_len; initialization to before the
first access to flexible array vevent->event_data.

Cc: stable@vger.kernel.org
Fixes: e8e1ef9b77a7 ("iommufd/viommu: Add iommufd_viommu_report_event helper")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/iommu/iommufd/driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/iommufd/driver.c b/drivers/iommu/iommufd/driver.c
index 6f1010da221c..21d4a35538f6 100644
--- a/drivers/iommu/iommufd/driver.c
+++ b/drivers/iommu/iommufd/driver.c
@@ -161,8 +161,8 @@ int iommufd_viommu_report_event(struct iommufd_viommu *viommu,
 		vevent = &veventq->lost_events_header;
 		goto out_set_header;
 	}
-	memcpy(vevent->event_data, event_data, data_len);
 	vevent->data_len = data_len;
+	memcpy(vevent->event_data, event_data, data_len);
 	veventq->num_events++;
 
 out_set_header:
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommufd/driver: Fix counter initialization for counted_by annotation
  2025-11-11  9:01 [PATCH] iommufd/driver: Fix counter initialization for counted_by annotation Gustavo A. R. Silva
@ 2025-11-11 18:53 ` Nicolin Chen
  2025-11-17  7:10 ` Tian, Kevin
  2025-11-21 19:43 ` Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolin Chen @ 2025-11-11 18:53 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Jason Gunthorpe, Kevin Tian, Joerg Roedel, Will Deacon,
	Robin Murphy, Lu Baolu, iommu, linux-kernel, linux-hardening

On Tue, Nov 11, 2025 at 06:01:24PM +0900, Gustavo A. R. Silva wrote:
> One of the requirements for counted_by annotations is that the counter
> member must be initialized before the first reference to the
> flexible-array member.
> 
> Move the vevent->data_len = data_len; initialization to before the
> first access to flexible array vevent->event_data.
> 
> Cc: stable@vger.kernel.org
> Fixes: e8e1ef9b77a7 ("iommufd/viommu: Add iommufd_viommu_report_event helper")
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
 
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] iommufd/driver: Fix counter initialization for counted_by annotation
  2025-11-11  9:01 [PATCH] iommufd/driver: Fix counter initialization for counted_by annotation Gustavo A. R. Silva
  2025-11-11 18:53 ` Nicolin Chen
@ 2025-11-17  7:10 ` Tian, Kevin
  2025-11-21 19:43 ` Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Tian, Kevin @ 2025-11-17  7:10 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Jason Gunthorpe, Joerg Roedel, Will Deacon,
	Robin Murphy, Lu Baolu, Nicolin Chen
  Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org

> From: Gustavo A. R. Silva <gustavoars@kernel.org>
> Sent: Tuesday, November 11, 2025 5:01 PM
> 
> One of the requirements for counted_by annotations is that the counter
> member must be initialized before the first reference to the
> flexible-array member.
> 
> Move the vevent->data_len = data_len; initialization to before the
> first access to flexible array vevent->event_data.
> 
> Cc: stable@vger.kernel.org
> Fixes: e8e1ef9b77a7 ("iommufd/viommu: Add
> iommufd_viommu_report_event helper")
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommufd/driver: Fix counter initialization for counted_by annotation
  2025-11-11  9:01 [PATCH] iommufd/driver: Fix counter initialization for counted_by annotation Gustavo A. R. Silva
  2025-11-11 18:53 ` Nicolin Chen
  2025-11-17  7:10 ` Tian, Kevin
@ 2025-11-21 19:43 ` Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2025-11-21 19:43 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Kevin Tian, Joerg Roedel, Will Deacon, Robin Murphy, Lu Baolu,
	Nicolin Chen, iommu, linux-kernel, linux-hardening

On Tue, Nov 11, 2025 at 06:01:24PM +0900, Gustavo A. R. Silva wrote:
> One of the requirements for counted_by annotations is that the counter
> member must be initialized before the first reference to the
> flexible-array member.
> 
> Move the vevent->data_len = data_len; initialization to before the
> first access to flexible array vevent->event_data.
> 
> Cc: stable@vger.kernel.org
> Fixes: e8e1ef9b77a7 ("iommufd/viommu: Add iommufd_viommu_report_event helper")
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
>  drivers/iommu/iommufd/driver.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-21 19:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-11  9:01 [PATCH] iommufd/driver: Fix counter initialization for counted_by annotation Gustavo A. R. Silva
2025-11-11 18:53 ` Nicolin Chen
2025-11-17  7:10 ` Tian, Kevin
2025-11-21 19:43 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).