From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thomas Gleixner <tglx@linutronix.de>, Stephen Rothwell <sfr@canb.auug.org.au>, Sasha Levin <sashal@kernel.org>, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 28/31] ARM: futex: Address build warning Date: Thu, 14 May 2020 14:54:10 -0400 [thread overview] Message-ID: <20200514185413.20755-28-sashal@kernel.org> (raw) In-Reply-To: <20200514185413.20755-1-sashal@kernel.org> From: Thomas Gleixner <tglx@linutronix.de> [ Upstream commit 8101b5a1531f3390b3a69fa7934c70a8fd6566ad ] Stephen reported the following build warning on a ARM multi_v7_defconfig build with GCC 9.2.1: kernel/futex.c: In function 'do_futex': kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized] 1676 | return oldval == cmparg; | ~~~~~~~^~~~~~~~~ kernel/futex.c:1652:6: note: 'oldval' was declared here 1652 | int oldval, ret; | ^~~~~~ introduced by commit a08971e9488d ("futex: arch_futex_atomic_op_inuser() calling conventions change"). While that change should not make any difference it confuses GCC which fails to work out that oldval is not referenced when the return value is not zero. GCC fails to properly analyze arch_futex_atomic_op_inuser(). It's not the early return, the issue is with the assembly macros. GCC fails to detect that those either set 'ret' to 0 and set oldval or set 'ret' to -EFAULT which makes oldval uninteresting. The store to the callsite supplied oldval pointer is conditional on ret == 0. The straight forward way to solve this is to make the store unconditional. Aside of addressing the build warning this makes sense anyway because it removes the conditional from the fastpath. In the error case the stored value is uninteresting and the extra store does not matter at all. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lkml.kernel.org/r/87pncao2ph.fsf@nanos.tec.linutronix.de Signed-off-by: Sasha Levin <sashal@kernel.org> --- arch/arm/include/asm/futex.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h index ffebe7b7a5b74..91ca80035fc42 100644 --- a/arch/arm/include/asm/futex.h +++ b/arch/arm/include/asm/futex.h @@ -163,8 +163,13 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) preempt_enable(); #endif - if (!ret) - *oval = oldval; + /* + * Store unconditionally. If ret != 0 the extra store is the least + * of the worries but GCC cannot figure out that __futex_atomic_op() + * is either setting ret to -EFAULT or storing the old value in + * oldval which results in a uninitialized warning at the call site. + */ + *oval = oldval; return ret; } -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sasha Levin <sashal@kernel.org>, Stephen Rothwell <sfr@canb.auug.org.au>, Thomas Gleixner <tglx@linutronix.de>, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 28/31] ARM: futex: Address build warning Date: Thu, 14 May 2020 14:54:10 -0400 [thread overview] Message-ID: <20200514185413.20755-28-sashal@kernel.org> (raw) In-Reply-To: <20200514185413.20755-1-sashal@kernel.org> From: Thomas Gleixner <tglx@linutronix.de> [ Upstream commit 8101b5a1531f3390b3a69fa7934c70a8fd6566ad ] Stephen reported the following build warning on a ARM multi_v7_defconfig build with GCC 9.2.1: kernel/futex.c: In function 'do_futex': kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized] 1676 | return oldval == cmparg; | ~~~~~~~^~~~~~~~~ kernel/futex.c:1652:6: note: 'oldval' was declared here 1652 | int oldval, ret; | ^~~~~~ introduced by commit a08971e9488d ("futex: arch_futex_atomic_op_inuser() calling conventions change"). While that change should not make any difference it confuses GCC which fails to work out that oldval is not referenced when the return value is not zero. GCC fails to properly analyze arch_futex_atomic_op_inuser(). It's not the early return, the issue is with the assembly macros. GCC fails to detect that those either set 'ret' to 0 and set oldval or set 'ret' to -EFAULT which makes oldval uninteresting. The store to the callsite supplied oldval pointer is conditional on ret == 0. The straight forward way to solve this is to make the store unconditional. Aside of addressing the build warning this makes sense anyway because it removes the conditional from the fastpath. In the error case the stored value is uninteresting and the extra store does not matter at all. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lkml.kernel.org/r/87pncao2ph.fsf@nanos.tec.linutronix.de Signed-off-by: Sasha Levin <sashal@kernel.org> --- arch/arm/include/asm/futex.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h index ffebe7b7a5b74..91ca80035fc42 100644 --- a/arch/arm/include/asm/futex.h +++ b/arch/arm/include/asm/futex.h @@ -163,8 +163,13 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) preempt_enable(); #endif - if (!ret) - *oval = oldval; + /* + * Store unconditionally. If ret != 0 the extra store is the least + * of the worries but GCC cannot figure out that __futex_atomic_op() + * is either setting ret to -EFAULT or storing the old value in + * oldval which results in a uninitialized warning at the call site. + */ + *oval = oldval; return ret; } -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-05-14 18:55 UTC|newest] Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-14 18:53 [PATCH AUTOSEL 4.19 01/31] Makefile: disallow data races on gcc-10 as well Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 02/31] gcc-common.h: Update for GCC 10 Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 03/31] HID: multitouch: add eGalaxTouch P80H84 support Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 04/31] HID: alps: Add AUI1657 device ID Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 05/31] HID: alps: ALPS_1657 is too specific; use U1_UNICORN_LEGACY instead Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 06/31] phy: tegra: Select USB_COMMON for usb_get_maximum_speed() Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 07/31] scsi: qla2xxx: Fix hang when issuing nvme disconnect-all in NPIV Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 08/31] scsi: qla2xxx: Delete all sessions before unregister local nvme port Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 09/31] configfs: fix config_item refcnt leak in configfs_rmdir() Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 10/31] vhost/vsock: fix packet delivery order to monitoring devices Sasha Levin 2020-05-14 18:53 ` Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 11/31] aquantia: Fix the media type of AQC100 ethernet controller in the driver Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 12/31] net/sonic: Fix a resource leak in an error handling path in 'jazz_sonic_probe()' Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 13/31] most: core: use function subsys_initcall() Sasha Levin 2020-05-14 18:53 ` Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 14/31] component: Silence bind error on -EPROBE_DEFER Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 15/31] scsi: ibmvscsi: Fix WARN_ON during event pool release Sasha Levin 2020-05-14 18:53 ` Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 16/31] HID: i2c-hid: reset Synaptics SYNA2393 on resume Sasha Levin 2020-05-14 18:53 ` [PATCH AUTOSEL 4.19 17/31] soc: qcom: ipa: IPA endpoints Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 18/31] net: ipa: fix a bug in ipa_endpoint_stop() Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 19/31] net: moxa: Fix a potential double 'free_irq()' Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 20/31] x86/apic: Move TSC deadline timer debug printk Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 21/31] gtp: set NLM_F_MULTI flag in gtp_genl_dump_pdp() Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 22/31] virtio-blk: handle block_device_operations callbacks after hot unplug Sasha Levin 2020-05-14 18:54 ` Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 23/31] HID: quirks: Add HID_QUIRK_NO_INIT_REPORTS quirk for Dell K12A keyboard-dock Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 24/31] ceph: fix double unlock in handle_cap_export() Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 25/31] stmmac: fix pointer check after utilization in stmmac_interrupt Sasha Levin 2020-05-14 18:54 ` Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 26/31] USB: core: Fix misleading driver bug report Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 27/31] platform/x86: asus-nb-wmi: Do not load on Asus T100TA and T200TA Sasha Levin 2020-05-14 18:54 ` Sasha Levin [this message] 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 28/31] ARM: futex: Address build warning Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 29/31] crypto: lrw - simplify error handling in create() Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 30/31] crypto: xts - simplify error handling in ->create() Sasha Levin 2020-05-14 18:54 ` [PATCH AUTOSEL 4.19 31/31] gcc-10: avoid shadowing standard library 'free()' in crypto Sasha Levin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200514185413.20755-28-sashal@kernel.org \ --to=sashal@kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=sfr@canb.auug.org.au \ --cc=stable@vger.kernel.org \ --cc=tglx@linutronix.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.