lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_5E4637BE7BC1256D39C73ADCA118BD908507@qq.com>
Date: Tue,  9 Jul 2024 16:32:48 +0800
From: Yangyu Chen <cyy@...self.name>
To: iommu@...ts.linux.dev
Cc: linux-kernel@...r.kernel.org,
	Christoph Hellwig <hch@....de>,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	Robin Murphy <robin.murphy@....com>,
	Yangyu Chen <cyy@...self.name>
Subject: [PATCH -fixes] dma-direct: only reference arch_dma_set_uncached symbol when usable

The arch_dma_set_uncached symbol is only used when the architecture
provides it. However, many architectures do not provide it, and the
code currently relies on compiler optimization to cut the unnecessary
code. When the compiler fails to optimize it, the code will reference
the symbol and cause a link error. I found this bug when developing
some new extensions for RISC-V on LLVM.

This patch adds a check to avoid the reference to the symbol when it is
not provided.

Signed-off-by: Yangyu Chen <cyy@...self.name>
---
 kernel/dma/direct.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 4d543b1e9d57..cdf3616a6def 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -293,9 +293,14 @@ void *dma_direct_alloc(struct device *dev, size_t size,
 
 	if (set_uncached) {
 		arch_dma_prep_coherent(page, size);
+#ifdef CONFIG_ARCH_HAS_DMA_SET_UNCACHED
 		ret = arch_dma_set_uncached(ret, size);
 		if (IS_ERR(ret))
 			goto out_encrypt_pages;
+#else
+		dev_err_once(dev, "BUG: set_uncached set but arch doesn't have dma_set_uncached\n");
+		goto out_encrypt_pages;
+#endif
 	}
 
 	*dma_handle = phys_to_dma_direct(dev, page_to_phys(page));
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ