Commit 4cdcdbe
i2c: designware: Remove i2c_dw_remove_lock_support()
When building certain configurations with CONFIG_FINEIBT=y after
commit 894af4a ("objtool: Validate kCFI calls"), there is a
warning due to an indirect call in dw_i2c_plat_remove():
$ cat allno.config
CONFIG_ACPI=y
CONFIG_CFI=y
CONFIG_COMMON_CLK=y
CONFIG_CPU_MITIGATIONS=y
CONFIG_I2C=y
CONFIG_I2C_DESIGNWARE_BAYTRAIL=y
CONFIG_I2C_DESIGNWARE_CORE=y
CONFIG_I2C_DESIGNWARE_PLATFORM=y
CONFIG_IOSF_MBI=y
CONFIG_MITIGATION_RETPOLINE=y
CONFIG_MODULES=y
CONFIG_PCI=y
CONFIG_X86_KERNEL_IBT=y
$ make -skj"$(nproc)" ARCH=x86_64 LLVM=1 clean allnoconfig vmlinux
vmlinux.o: warning: objtool: dw_i2c_plat_remove+0x3c: no-cfi indirect call!
With this configuration, i2c_dw_semaphore_cb_table has the BAYTRAIL
member and the sentinel (i.e., 2 members), both of which have an
implicit
.remove = NULL,
so Clang effectively turns i2c_dw_remove_lock_support(), which is later
inlined into dw_i2c_plat_remove(), into:
static void i2c_dw_remove_lock_support(struct dw_i2c_dev *dev)
{
if (dev->semaphore_idx > 2)
(*NULL)(dev):
}
which is not necessarily problematic from a logic perspective (as the
code was not bounds checking semaphore_idx so an out of bounds index
could already crash) but objtool's new __nocfi indirect call checking
trips over Clang dropping the kCFI setup from a known NULL indirect
call.
While it would be possible to fix this by transforming the initial check
into
if (dev->semaphore_idx < 0 || dev->semaphore_idx >= ARRAY_SIZE(i2c_dw_semaphore_cb_table))
the remove member is unused after commit 440da73 ("i2c: designware:
Use PCI PSP driver for communication"), so i2c_dw_remove_lock_support()
can be removed altogether, as it will never actually do anything.
Closes: ClangBuiltLinux#2133
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Reviewed-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20251013-dw_i2c_plat_remove-avoid-objtool-no-cfi-warning-v1-1-8cc4842967bf@kernel.org1 parent dcb6fa3 commit 4cdcdbe
2 files changed
Lines changed: 0 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
333 | | - | |
334 | 333 | | |
335 | 334 | | |
336 | 335 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | 200 | | |
210 | 201 | | |
211 | 202 | | |
| |||
339 | 330 | | |
340 | 331 | | |
341 | 332 | | |
342 | | - | |
343 | | - | |
344 | 333 | | |
345 | 334 | | |
346 | 335 | | |
| |||
0 commit comments