Skip to content

Commit 866a357

Browse files
lrq-maxgregkh
authored andcommitted
iommu/intel: Fix out-of-bounds memset in dmar_latency_disable()
[ Upstream commit 754f8ef ] dmar_latency_disable() intends to zero out only the single latency_statistic entry for the given type, but the memset size was computed as sizeof(*lstat) * DMAR_LATENCY_NUM, which clears the entire array starting from &lstat[type]. When type > 0, this writes beyond the end of the allocated array, corrupting adjacent memory. Fix by using sizeof(*lstat) to clear only the target entry. Fixes: 55ee5e6 ("iommu/vt-d: Add common code for dmar latency performance monitors") Signed-off-by: Li RongQing <lirongqing@baidu.com> Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent abe5d79 commit 866a357

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/iommu/intel/perf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void dmar_latency_disable(struct intel_iommu *iommu, enum latency_type type)
6363
return;
6464

6565
spin_lock_irqsave(&latency_lock, flags);
66-
memset(&lstat[type], 0, sizeof(*lstat) * DMAR_LATENCY_NUM);
66+
memset(&lstat[type], 0, sizeof(*lstat));
6767
spin_unlock_irqrestore(&latency_lock, flags);
6868
}
6969

0 commit comments

Comments
 (0)