mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.4 01/38] locks: Fix UBSAN undefined behaviour in flock64_to_posix_lock
@ 2020-12-23  2:24 Sasha Levin
  2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 02/38] tomoyo: fix clang pointer arithmetic warning Sasha Levin
                   ` (36 more replies)
  0 siblings, 37 replies; 40+ messages in thread
From: Sasha Levin @ 2020-12-23  2:24 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Luo Meng, Jeff Layton, Sasha Levin, linux-fsdevel

From: Luo Meng <luomeng12@huawei.com>

[ Upstream commit 16238415eb9886328a89fe7a3cb0b88c7335fe16 ]

When the sum of fl->fl_start and l->l_len overflows,
UBSAN shows the following warning:

UBSAN: Undefined behaviour in fs/locks.c:482:29
signed integer overflow: 2 + 9223372036854775806
cannot be represented in type 'long long int'
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0xe4/0x14e lib/dump_stack.c:118
 ubsan_epilogue+0xe/0x81 lib/ubsan.c:161
 handle_overflow+0x193/0x1e2 lib/ubsan.c:192
 flock64_to_posix_lock fs/locks.c:482 [inline]
 flock_to_posix_lock+0x595/0x690 fs/locks.c:515
 fcntl_setlk+0xf3/0xa90 fs/locks.c:2262
 do_fcntl+0x456/0xf60 fs/fcntl.c:387
 __do_sys_fcntl fs/fcntl.c:483 [inline]
 __se_sys_fcntl fs/fcntl.c:468 [inline]
 __x64_sys_fcntl+0x12d/0x180 fs/fcntl.c:468
 do_syscall_64+0xc8/0x5a0 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Fix it by parenthesizing 'l->l_len - 1'.

Signed-off-by: Luo Meng <luomeng12@huawei.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/locks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/locks.c b/fs/locks.c
index 2c8e1e429cf7e..5cb012e4a2fc4 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -434,7 +434,7 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
 	if (l->l_len > 0) {
 		if (l->l_len - 1 > OFFSET_MAX - fl->fl_start)
 			return -EOVERFLOW;
-		fl->fl_end = fl->fl_start + l->l_len - 1;
+		fl->fl_end = fl->fl_start + (l->l_len - 1);
 
 	} else if (l->l_len < 0) {
 		if (fl->fl_start + l->l_len < 0)
-- 
2.27.0


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2020-12-23 14:15 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-23  2:24 [PATCH AUTOSEL 4.4 01/38] locks: Fix UBSAN undefined behaviour in flock64_to_posix_lock Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 02/38] tomoyo: fix clang pointer arithmetic warning Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 03/38] staging: wimax: depends on NET Sasha Levin
2020-12-23  2:38   ` Jakub Kicinski
2020-12-23 14:14     ` Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 04/38] scsi: pm80xx: Avoid busywait in FW ready check Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 05/38] scsi: pm80xx: Fix pm8001_mpi_get_nvmd_resp() race condition Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 06/38] staging: rtl8192u: fix wrong judgement in rtl8192_rx_isr Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 07/38] mips: ar7: add missing iounmap() on error in ar7_gpio_init Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 08/38] locktorture: Prevent hangs for invalid arguments Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 09/38] rcutorture: " Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 10/38] drm: panel: simple: add missing platform_driver_unregister() in panel_simple_init Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 11/38] Bluetooth: hidp: use correct wait queue when removing ctrl_wait Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 12/38] net: skb_vlan_untag(): don't reset transport offset if set by GRO layer Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 13/38] MIPS: BMC47xx: fix kconfig dependency bug for BCM47XX_SSB Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 14/38] jfs: Fix memleak in dbAdjCtl Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 15/38] media: zr364xx: propagate errors from zr364xx_start_readpipe() Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 16/38] media: isif: reset global state Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 17/38] mmc: tmio: do not print real IOMEM pointer Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 18/38] ARM: OMAP2+: Fix memleak in omap2xxx_clkt_vps_init Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 19/38] tick/broadcast: Serialize access to tick_next_period Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 20/38] ALSA: usb-audio: Don't call usb_set_interface() at trigger callback Sasha Levin
2020-12-23  2:24 ` [PATCH AUTOSEL 4.4 21/38] rxrpc: Don't leak the service-side session key to userspace Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 22/38] ARM: dts: hisilicon: fix errors detected by snps-dw-apb-uart.yaml Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 23/38] ARM: dts: hisilicon: fix errors detected by usb yaml Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 24/38] ARM: dts: hisilicon: fix errors detected by simple-bus.yaml Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 25/38] brcmsmac: ampdu: Check BA window size before checking block ack Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 26/38] iommu/tegra-smmu: Expand mutex protection range Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 27/38] crypto: qce - Fix SHA result buffer corruption issues Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 28/38] media: gp8psk: initialize stats at power control logic Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 29/38] net/lapb: fix t1 timer handling for LAPB_STATE_0 Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 30/38] x86/mce: Panic for LMCE only if mca_cfg.tolerant < 3 Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 31/38] mwifiex: Fix possible buffer overflows in mwifiex_cmd_802_11_ad_hoc_start Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 32/38] misc: vmw_vmci: fix kernel info-leak by initializing dbells in vmci_ctx_get_chkpt_doorbells() Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 33/38] iwlwifi: trans: consider firmware dead after errors Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 34/38] iwlwifi: add an extra firmware state in the transport Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 35/38] mac80211: disallow band-switch during CSA Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 36/38] mac80211: don't filter out beacons once we start CSA Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 37/38] ALSA: hda/hdmi: packet buffer index must be set before reading value Sasha Levin
2020-12-23  2:25 ` [PATCH AUTOSEL 4.4 38/38] PCI: Add function 1 DMA alias quirk for Marvell 9215 SATA controller Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome