[PATCH OLK-5.10] dma-buf: insert memory barrier before updating num_fences

From: Hyejeong Choi <hjeong.choi@samsung.com> mainline inclusion from mainline-v6.12-rc1 commit 72c7d62583ebce7baeb61acce6057c361f73be4a category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/ICJTDA CVE: CVE-2025-38095 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- smp_store_mb() inserts memory barrier after storing operation. It is different with what the comment is originally aiming so Null pointer dereference can be happened if memory update is reordered. Signed-off-by: Hyejeong Choi <hjeong.choi@samsung.com> Fixes: a590d0fdbaa5 ("dma-buf: Update reservation shared_count after adding the new fence") CC: stable@vger.kernel.org Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://lore.kernel.org/r/20250513020638.GA2329653@au1-maretx-p37.eng.sarc.s... Signed-off-by: Christian König <christian.koenig@amd.com> Conflicts: drivers/dma-buf/dma-resv.c [Context conflict] Signed-off-by: Bowen You <youbowen2@huawei.com> --- drivers/dma-buf/dma-resv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 1187e5e80ede..3ab9caee6527 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -290,8 +290,9 @@ void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence) replace: RCU_INIT_POINTER(fobj->shared[i], fence); - /* pointer update must be visible before we extend the shared_count */ - smp_store_mb(fobj->shared_count, count); + /* fence update must be visible before we extend the num_fences */ + smp_wmb(); + fobj->shared_count = count; write_seqcount_end(&obj->seq); dma_fence_put(old); -- 2.34.1

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/16965 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/5MB... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/16965 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/5MB...
participants (2)
-
Bowen You
-
patchwork bot