linux/drivers/iommu/intel
Seyediman Seyedarab 3a5394b3b0 iommu/vt-d: Replace snprintf with scnprintf in dmar_latency_snapshot()
[ Upstream commit 75c02a0376 ]

snprintf() returns the number of bytes that would have been written, not
the number actually written. Using this for offset tracking can cause
buffer overruns if truncation occurs.

Replace snprintf() with scnprintf() to ensure the offset stays within
bounds.

Since scnprintf() never returns a negative value, and zero is not possible
in this context because 'bytes' starts at 0 and 'size - bytes' is
DEBUG_BUFFER_SIZE in the first call, which is large enough to hold the
string literals used, the return value is always positive. An integer
overflow is also completely out of reach here due to the small and fixed
buffer size. The error check in latency_show_one() is therefore
unnecessary. Remove it and make dmar_latency_snapshot() return void.

Signed-off-by: Seyediman Seyedarab <ImanDevel@gmail.com>
Link: https://lore.kernel.org/r/20250731225048.131364-1-ImanDevel@gmail.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-11-13 15:34:27 -05:00
..
cache.c iommu/vt-d: Fix qi_batch NULL pointer with nested parent domain 2024-12-19 18:13:06 +01:00
cap_audit.c iommu/vt-d: Remove virtual command interface 2023-03-31 10:03:21 +02:00
cap_audit.h iommu/vt-d: Check FL and SL capability sanity in scalable mode 2021-10-18 12:31:48 +02:00
debugfs.c iommu/vt-d: Replace snprintf with scnprintf in dmar_latency_snapshot() 2025-11-13 15:34:27 -05:00
dmar.c iommu/vt-d: Fix suspicious RCU usage 2025-03-07 18:25:42 +01:00
iommu.c iommu/vt-d: Avoid use of NULL after WARN_ON_ONCE 2025-11-02 22:15:23 +09:00
iommu.h iommu/vt-d: Disallow dirty tracking if incoherent page walk 2025-10-15 12:00:17 +02:00
irq_remapping.c iommu/vt-d: Wire up irq_ack() to irq_move_irq() for posted MSIs 2025-04-20 10:15:48 +02:00
Kconfig dma-mapping: direct calls for dma-iommu 2024-08-22 06:18:11 +02:00
Makefile iommu/vt-d: Add cache tag assignment interface 2024-04-26 11:57:40 +02:00
nested.c iommu/vt-d: Restore context entry setup order for aliased devices 2025-06-27 11:11:21 +01:00
pasid.c Merge branches 'fixes', 'arm/smmu', 'intel/vt-d', 'amd/amd-vi' and 'core' into next 2024-09-13 12:53:05 +02:00
pasid.h iommu/vt-d: Remove control over Execute-Requested requests 2024-07-03 16:39:26 +01:00
perf.c iommu/vt-d: Replace snprintf with scnprintf in dmar_latency_snapshot() 2025-11-13 15:34:27 -05:00
perf.h iommu/vt-d: Replace snprintf with scnprintf in dmar_latency_snapshot() 2025-11-13 15:34:27 -05:00
perfmon.c iommu/vt-d: Clean up cpumask and hotplug for perfmon 2024-09-10 11:44:13 +02:00
perfmon.h iommu/vt-d: Add IOMMU perfmon support 2023-02-03 11:06:06 +01:00
svm.c iommu/vt-d: Add qi_batch for dmar_domain 2024-09-02 18:15:02 +02:00
trace.c iommu/vt-d: Move trace/events/intel_iommu.h under iommu 2022-07-15 10:21:28 +02:00
trace.h tracing/treewide: Remove second parameter of __assign_str() 2024-05-22 20:14:47 -04:00