From: Mateusz Guzik <mjguzik(a)gmail.com>
[ Upstream commit 0d196e7589cefe207d5d41f37a0a28a1fdeeb7c6 ]
Both i_mode and noexec checks wrapped in WARN_ON stem from an artifact
of the previous implementation. They used to legitimately check for the
condition, but that got moved up in two commits:
633fb6ac3980 ("exec: move S_ISREG() check earlier")
0fd338b2d2cd ("exec: move path_noexec() check earlier")
Instead of being removed said checks are WARN_ON'ed instead, which
has some debug value.
However, the spurious path_noexec check is racy, resulting in
unwarranted warnings should someone race with setting the noexec flag.
One can note there is more to perm-checking whether execve is allowed
and none of the conditions are guaranteed to still hold after they were
tested for.
Additionally this does not validate whether the code path did any perm
checking to begin with -- it will pass if the inode happens to be
regular.
Keep the redundant path_noexec() check even though it's mindless
nonsense checking for guarantee that isn't given so drop the WARN.
Reword the commentary and do small tidy ups while here.
Signed-off-by: Mateusz Guzik <mjguzik(a)gmail.com>
Link: https://lore.kernel.org/r/20240805131721.765484-1-mjguzik@gmail.com
[brauner: keep redundant path_noexec() check]
Signed-off-by: Christian Brauner <brauner(a)kernel.org>
[cascardo: keep exit label and use it]
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo(a)igalia.com>
---
fs/exec.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index 6e5324c7e9b6..7144c541818f 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -144,13 +144,11 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
goto out;
/*
- * may_open() has already checked for this, so it should be
- * impossible to trip now. But we need to be extra cautious
- * and check again at the very end too.
+ * Check do_open_execat() for an explanation.
*/
error = -EACCES;
- if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode) ||
- path_noexec(&file->f_path)))
+ if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode)) ||
+ path_noexec(&file->f_path))
goto exit;
fsnotify_open(file);
@@ -919,16 +917,16 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
file = do_filp_open(fd, name, &open_exec_flags);
if (IS_ERR(file))
- goto out;
+ return file;
/*
- * may_open() has already checked for this, so it should be
- * impossible to trip now. But we need to be extra cautious
- * and check again at the very end too.
+ * In the past the regular type check was here. It moved to may_open() in
+ * 633fb6ac3980 ("exec: move S_ISREG() check earlier"). Since then it is
+ * an invariant that all non-regular files error out before we get here.
*/
err = -EACCES;
- if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode) ||
- path_noexec(&file->f_path)))
+ if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode)) ||
+ path_noexec(&file->f_path))
goto exit;
err = deny_write_access(file);
@@ -938,7 +936,6 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
if (name->name[0] != '\0')
fsnotify_open(file);
-out:
return file;
exit:
--
2.34.1
From: Mateusz Guzik <mjguzik(a)gmail.com>
[ Upstream commit 0d196e7589cefe207d5d41f37a0a28a1fdeeb7c6 ]
Both i_mode and noexec checks wrapped in WARN_ON stem from an artifact
of the previous implementation. They used to legitimately check for the
condition, but that got moved up in two commits:
633fb6ac3980 ("exec: move S_ISREG() check earlier")
0fd338b2d2cd ("exec: move path_noexec() check earlier")
Instead of being removed said checks are WARN_ON'ed instead, which
has some debug value.
However, the spurious path_noexec check is racy, resulting in
unwarranted warnings should someone race with setting the noexec flag.
One can note there is more to perm-checking whether execve is allowed
and none of the conditions are guaranteed to still hold after they were
tested for.
Additionally this does not validate whether the code path did any perm
checking to begin with -- it will pass if the inode happens to be
regular.
Keep the redundant path_noexec() check even though it's mindless
nonsense checking for guarantee that isn't given so drop the WARN.
Reword the commentary and do small tidy ups while here.
Signed-off-by: Mateusz Guzik <mjguzik(a)gmail.com>
Link: https://lore.kernel.org/r/20240805131721.765484-1-mjguzik@gmail.com
[brauner: keep redundant path_noexec() check]
Signed-off-by: Christian Brauner <brauner(a)kernel.org>
[cascardo: keep exit label and use it]
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo(a)igalia.com>
---
fs/exec.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index 26f0b79cb4f9..8395e7ff7b94 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -142,13 +142,11 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
goto out;
/*
- * may_open() has already checked for this, so it should be
- * impossible to trip now. But we need to be extra cautious
- * and check again at the very end too.
+ * Check do_open_execat() for an explanation.
*/
error = -EACCES;
- if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode) ||
- path_noexec(&file->f_path)))
+ if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode)) ||
+ path_noexec(&file->f_path))
goto exit;
fsnotify_open(file);
@@ -919,16 +917,16 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
file = do_filp_open(fd, name, &open_exec_flags);
if (IS_ERR(file))
- goto out;
+ return file;
/*
- * may_open() has already checked for this, so it should be
- * impossible to trip now. But we need to be extra cautious
- * and check again at the very end too.
+ * In the past the regular type check was here. It moved to may_open() in
+ * 633fb6ac3980 ("exec: move S_ISREG() check earlier"). Since then it is
+ * an invariant that all non-regular files error out before we get here.
*/
err = -EACCES;
- if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode) ||
- path_noexec(&file->f_path)))
+ if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode)) ||
+ path_noexec(&file->f_path))
goto exit;
err = deny_write_access(file);
@@ -938,7 +936,6 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
if (name->name[0] != '\0')
fsnotify_open(file);
-out:
return file;
exit:
--
2.34.1
From: Mateusz Guzik <mjguzik(a)gmail.com>
[ Upstream commit 0d196e7589cefe207d5d41f37a0a28a1fdeeb7c6 ]
Both i_mode and noexec checks wrapped in WARN_ON stem from an artifact
of the previous implementation. They used to legitimately check for the
condition, but that got moved up in two commits:
633fb6ac3980 ("exec: move S_ISREG() check earlier")
0fd338b2d2cd ("exec: move path_noexec() check earlier")
Instead of being removed said checks are WARN_ON'ed instead, which
has some debug value.
However, the spurious path_noexec check is racy, resulting in
unwarranted warnings should someone race with setting the noexec flag.
One can note there is more to perm-checking whether execve is allowed
and none of the conditions are guaranteed to still hold after they were
tested for.
Additionally this does not validate whether the code path did any perm
checking to begin with -- it will pass if the inode happens to be
regular.
Keep the redundant path_noexec() check even though it's mindless
nonsense checking for guarantee that isn't given so drop the WARN.
Reword the commentary and do small tidy ups while here.
Signed-off-by: Mateusz Guzik <mjguzik(a)gmail.com>
Link: https://lore.kernel.org/r/20240805131721.765484-1-mjguzik@gmail.com
[brauner: keep redundant path_noexec() check]
Signed-off-by: Christian Brauner <brauner(a)kernel.org>
[cascardo: keep exit label and use it]
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo(a)igalia.com>
---
fs/exec.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index 65d3ebc24fd3..a42c9b8b070d 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -141,13 +141,11 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
goto out;
/*
- * may_open() has already checked for this, so it should be
- * impossible to trip now. But we need to be extra cautious
- * and check again at the very end too.
+ * Check do_open_execat() for an explanation.
*/
error = -EACCES;
- if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode) ||
- path_noexec(&file->f_path)))
+ if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode)) ||
+ path_noexec(&file->f_path))
goto exit;
fsnotify_open(file);
@@ -927,16 +925,16 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
file = do_filp_open(fd, name, &open_exec_flags);
if (IS_ERR(file))
- goto out;
+ return file;
/*
- * may_open() has already checked for this, so it should be
- * impossible to trip now. But we need to be extra cautious
- * and check again at the very end too.
+ * In the past the regular type check was here. It moved to may_open() in
+ * 633fb6ac3980 ("exec: move S_ISREG() check earlier"). Since then it is
+ * an invariant that all non-regular files error out before we get here.
*/
err = -EACCES;
- if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode) ||
- path_noexec(&file->f_path)))
+ if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode)) ||
+ path_noexec(&file->f_path))
goto exit;
err = deny_write_access(file);
@@ -946,7 +944,6 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
if (name->name[0] != '\0')
fsnotify_open(file);
-out:
return file;
exit:
--
2.34.1
From: Mateusz Guzik <mjguzik(a)gmail.com>
[ Upstream commit 0d196e7589cefe207d5d41f37a0a28a1fdeeb7c6 ]
Both i_mode and noexec checks wrapped in WARN_ON stem from an artifact
of the previous implementation. They used to legitimately check for the
condition, but that got moved up in two commits:
633fb6ac3980 ("exec: move S_ISREG() check earlier")
0fd338b2d2cd ("exec: move path_noexec() check earlier")
Instead of being removed said checks are WARN_ON'ed instead, which
has some debug value.
However, the spurious path_noexec check is racy, resulting in
unwarranted warnings should someone race with setting the noexec flag.
One can note there is more to perm-checking whether execve is allowed
and none of the conditions are guaranteed to still hold after they were
tested for.
Additionally this does not validate whether the code path did any perm
checking to begin with -- it will pass if the inode happens to be
regular.
Keep the redundant path_noexec() check even though it's mindless
nonsense checking for guarantee that isn't given so drop the WARN.
Reword the commentary and do small tidy ups while here.
Signed-off-by: Mateusz Guzik <mjguzik(a)gmail.com>
Link: https://lore.kernel.org/r/20240805131721.765484-1-mjguzik@gmail.com
[brauner: keep redundant path_noexec() check]
Signed-off-by: Christian Brauner <brauner(a)kernel.org>
[cascardo: keep exit label and use it]
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo(a)igalia.com>
---
fs/exec.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index f49b352a6032..7776209d98c1 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -143,13 +143,11 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
goto out;
/*
- * may_open() has already checked for this, so it should be
- * impossible to trip now. But we need to be extra cautious
- * and check again at the very end too.
+ * Check do_open_execat() for an explanation.
*/
error = -EACCES;
- if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode) ||
- path_noexec(&file->f_path)))
+ if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode)) ||
+ path_noexec(&file->f_path))
goto exit;
error = -ENOEXEC;
@@ -925,23 +923,22 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
file = do_filp_open(fd, name, &open_exec_flags);
if (IS_ERR(file))
- goto out;
+ return file;
/*
- * may_open() has already checked for this, so it should be
- * impossible to trip now. But we need to be extra cautious
- * and check again at the very end too.
+ * In the past the regular type check was here. It moved to may_open() in
+ * 633fb6ac3980 ("exec: move S_ISREG() check earlier"). Since then it is
+ * an invariant that all non-regular files error out before we get here.
*/
err = -EACCES;
- if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode) ||
- path_noexec(&file->f_path)))
+ if (WARN_ON_ONCE(!S_ISREG(file_inode(file)->i_mode)) ||
+ path_noexec(&file->f_path))
goto exit;
err = deny_write_access(file);
if (err)
goto exit;
-out:
return file;
exit:
--
2.34.1
This is the start of the stable review cycle for the 5.15.169 release.
There are 82 patches in this series, all will be posted as a response
to this one. If anyone has any issues with these being applied, please
let me know.
Responses should be made by Wed, 23 Oct 2024 10:22:25 +0000.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.169-r…
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.15.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 5.15.169-rc1
Vasiliy Kovalev <kovalev(a)altlinux.org>
ALSA: hda/conexant - Use cached pin control for Node 0x1d on HP EliteOne 1000 G2
Aneesh Kumar K.V <aneesh.kumar(a)linux.ibm.com>
powerpc/mm: Always update max/min_low_pfn in mem_topology_setup()
Ryusuke Konishi <konishi.ryusuke(a)gmail.com>
nilfs2: propagate directory read errors from nilfs_find_entry()
Paolo Abeni <pabeni(a)redhat.com>
mptcp: prevent MPC handshake on port-based signal endpoints
Matthieu Baerts (NGI0) <matttbe(a)kernel.org>
mptcp: pm: fix UaF read in mptcp_pm_nl_rm_addr_or_subflow
Matthieu Baerts (NGI0) <matttbe(a)kernel.org>
mptcp: fallback when MPTCP opts are dropped after 1st data
Paolo Abeni <pabeni(a)redhat.com>
tcp: fix mptcp DSS corruption due to large pmtu xmit
Paolo Abeni <pabeni(a)redhat.com>
mptcp: handle consistently DSS corruption
Geliang Tang <geliang.tang(a)suse.com>
mptcp: track and update contiguous data status
Marc Zyngier <maz(a)kernel.org>
irqchip/gic-v4: Don't allow a VMOVP on a dying VPE
Sergey Matsievskiy <matsievskiysv(a)gmail.com>
pinctrl: ocelot: fix system hang on level based interrupts
Pawan Gupta <pawan.kumar.gupta(a)linux.intel.com>
x86/entry_32: Clear CPU buffers after register restore in NMI return
Pawan Gupta <pawan.kumar.gupta(a)linux.intel.com>
x86/entry_32: Do not clobber user EFLAGS.ZF
Zhang Rui <rui.zhang(a)intel.com>
x86/apic: Always explicitly disarm TSC-deadline timer
Nathan Chancellor <nathan(a)kernel.org>
x86/resctrl: Annotate get_mem_config() functions as __init
Takashi Iwai <tiwai(a)suse.de>
parport: Proper fix for array out-of-bounds access
Daniele Palmas <dnlplm(a)gmail.com>
USB: serial: option: add Telit FN920C04 MBIM compositions
Benjamin B. Frost <benjamin(a)geanix.com>
USB: serial: option: add support for Quectel EG916Q-GL
Mathias Nyman <mathias.nyman(a)linux.intel.com>
xhci: Mitigate failed set dequeue pointer commands
Mathias Nyman <mathias.nyman(a)linux.intel.com>
xhci: Fix incorrect stream context type macro
Luiz Augusto von Dentz <luiz.von.dentz(a)intel.com>
Bluetooth: btusb: Fix regression with fake CSR controllers 0a12:0001
Aaron Thompson <dev(a)aaront.org>
Bluetooth: Remove debugfs directory on module init failure
Javier Carrasco <javier.carrasco.cruz(a)gmail.com>
iio: adc: ti-ads124s08: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig
Javier Carrasco <javier.carrasco.cruz(a)gmail.com>
iio: proximity: mb1232: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig
Emil Gedenryd <emil.gedenryd(a)axis.com>
iio: light: opt3001: add missing full-scale range value
Javier Carrasco <javier.carrasco.cruz(a)gmail.com>
iio: light: veml6030: fix IIO device retrieval from embedded device
Javier Carrasco <javier.carrasco.cruz(a)gmail.com>
iio: light: veml6030: fix ALS sensor resolution
Christophe JAILLET <christophe.jaillet(a)wanadoo.fr>
iio: hid-sensors: Fix an error handling path in _hid_sensor_set_report_latency()
Javier Carrasco <javier.carrasco.cruz(a)gmail.com>
iio: adc: ti-ads8688: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig
Javier Carrasco <javier.carrasco.cruz(a)gmail.com>
iio: dac: stm32-dac-core: add missing select REGMAP_MMIO in Kconfig
Javier Carrasco <javier.carrasco.cruz(a)gmail.com>
iio: dac: ltc1660: add missing select REGMAP_SPI in Kconfig
Javier Carrasco <javier.carrasco.cruz(a)gmail.com>
iio: dac: ad5770r: add missing select REGMAP_SPI in Kconfig
Nikolay Kuratov <kniv(a)yandex-team.ru>
drm/vmwgfx: Handle surface check failure correctly
Ville Syrjälä <ville.syrjala(a)linux.intel.com>
drm/radeon: Fix encoder->possible_clones
Jens Axboe <axboe(a)kernel.dk>
io_uring/sqpoll: close race on waiting for sqring entries
Omar Sandoval <osandov(a)fb.com>
blk-rq-qos: fix crash on rq_qos_wait vs. rq_qos_wake_function race
Johannes Wikner <kwikner(a)ethz.ch>
x86/bugs: Do not use UNTRAIN_RET with IBPB on entry
Johannes Wikner <kwikner(a)ethz.ch>
x86/bugs: Skip RSB fill at VMEXIT
Johannes Wikner <kwikner(a)ethz.ch>
x86/entry: Have entry_ibpb() invalidate return predictions
Johannes Wikner <kwikner(a)ethz.ch>
x86/cpufeatures: Add a IBPB_NO_RET BUG flag
Jim Mattson <jmattson(a)google.com>
x86/cpufeatures: Define X86_FEATURE_AMD_IBPB_RET
Michael Mueller <mimu(a)linux.ibm.com>
KVM: s390: Change virtual to physical address access in diag 0x258 handler
Thomas Weißschuh <thomas.weissschuh(a)linutronix.de>
s390/sclp_vt220: Convert newlines to CRLF instead of LFCR
Lu Baolu <baolu.lu(a)linux.intel.com>
iommu/vt-d: Fix incorrect pci_for_each_dma_alias() for non-PCI devices
Felix Moessbauer <felix.moessbauer(a)siemens.com>
io_uring/sqpoll: do not put cpumask on stack
Jens Axboe <axboe(a)kernel.dk>
io_uring/sqpoll: retain test for whether the CPU is valid
Felix Moessbauer <felix.moessbauer(a)siemens.com>
io_uring/sqpoll: do not allow pinning outside of cpuset
Wachowski, Karol <karol.wachowski(a)intel.com>
drm/shmem-helper: Fix BUG_ON() on mmap(PROT_WRITE, MAP_PRIVATE)
Breno Leitao <leitao(a)debian.org>
KVM: Fix a data race on last_boosted_vcpu in kvm_vcpu_on_spin()
Mikulas Patocka <mpatocka(a)redhat.com>
dm-crypt, dm-verity: disable tasklets
Johannes Berg <johannes.berg(a)intel.com>
wifi: mac80211: fix potential key use-after-free
Patrick Roy <roypat(a)amazon.co.uk>
secretmem: disable memfd_secret() if arch cannot set direct map
Liu Shixin <liushixin2(a)huawei.com>
mm/swapfile: skip HugeTLB pages for unuse_vma
OGAWA Hirofumi <hirofumi(a)mail.parknet.co.jp>
fat: fix uninitialized variable
Nianyao Tang <tangnianyao(a)huawei.com>
irqchip/gic-v3-its: Fix VSYNC referencing an unmapped VPE on GIC v4.1
Oleksij Rempel <linux(a)rempel-privat.de>
net: macb: Avoid 20s boot delay by skipping MDIO bus registration for fixed-link PHY
Mark Rutland <mark.rutland(a)arm.com>
arm64: probes: Fix simulate_ldr*_literal()
Mark Rutland <mark.rutland(a)arm.com>
arm64: probes: Remove broken LDR (literal) uprobe support
Jinjie Ruan <ruanjinjie(a)huawei.com>
posix-clock: Fix missing timespec64 check in pc_clock_settime()
Wei Fang <wei.fang(a)nxp.com>
net: enetc: add missing static descriptor and inline keyword
Wei Fang <wei.fang(a)nxp.com>
net: enetc: remove xdp_drops statistic from enetc_xdp_drop()
Jan Kara <jack(a)suse.cz>
udf: Fix bogus checksum computation in udf_rename()
Jan Kara <jack(a)suse.cz>
udf: Don't return bh from udf_expand_dir_adinicb()
Jan Kara <jack(a)suse.cz>
udf: Handle error when expanding directory
Jan Kara <jack(a)suse.cz>
udf: Remove old directory iteration code
Jan Kara <jack(a)suse.cz>
udf: Convert udf_link() to new directory iteration code
Jan Kara <jack(a)suse.cz>
udf: Convert udf_mkdir() to new directory iteration code
Jan Kara <jack(a)suse.cz>
udf: Convert udf_add_nondir() to new directory iteration
Jan Kara <jack(a)suse.cz>
udf: Implement adding of dir entries using new iteration code
Jan Kara <jack(a)suse.cz>
udf: Convert udf_unlink() to new directory iteration code
Jan Kara <jack(a)suse.cz>
udf: Convert udf_rmdir() to new directory iteration code
Jan Kara <jack(a)suse.cz>
udf: Convert empty_dir() to new directory iteration code
Jan Kara <jack(a)suse.cz>
udf: Convert udf_get_parent() to new directory iteration code
Jan Kara <jack(a)suse.cz>
udf: Convert udf_lookup() to use new directory iteration code
Jan Kara <jack(a)suse.cz>
udf: Convert udf_readdir() to new directory iteration
Jan Kara <jack(a)suse.cz>
udf: Convert udf_rename() to new directory iteration code
Jan Kara <jack(a)suse.cz>
udf: Provide function to mark entry as deleted using new directory iteration code
Jan Kara <jack(a)suse.cz>
udf: Implement searching for directory entry using new iteration code
Jan Kara <jack(a)suse.cz>
udf: Move udf_expand_dir_adinicb() to its callsite
Jan Kara <jack(a)suse.cz>
udf: Convert udf_expand_dir_adinicb() to new directory iteration
Jan Kara <jack(a)suse.cz>
udf: New directory iteration code
Vasiliy Kovalev <kovalev(a)altlinux.org>
ALSA: hda/conexant - Fix audio routing for HP EliteOne 1000 G2
-------------
Diffstat:
Makefile | 4 +-
arch/arm64/kernel/probes/decode-insn.c | 16 +-
arch/arm64/kernel/probes/simulate-insn.c | 18 +-
arch/powerpc/mm/numa.c | 6 +-
arch/s390/kvm/diag.c | 2 +-
arch/x86/entry/entry.S | 5 +
arch/x86/entry/entry_32.S | 6 +-
arch/x86/include/asm/cpufeatures.h | 4 +-
arch/x86/kernel/apic/apic.c | 14 +-
arch/x86/kernel/cpu/bugs.c | 32 +
arch/x86/kernel/cpu/common.c | 3 +
arch/x86/kernel/cpu/resctrl/core.c | 4 +-
block/blk-rq-qos.c | 2 +-
drivers/bluetooth/btusb.c | 13 +-
drivers/gpu/drm/drm_gem_shmem_helper.c | 3 +
drivers/gpu/drm/radeon/radeon_encoders.c | 2 +-
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 1 +
drivers/iio/adc/Kconfig | 4 +
.../iio/common/hid-sensors/hid-sensor-trigger.c | 2 +-
drivers/iio/dac/Kconfig | 3 +
drivers/iio/light/opt3001.c | 4 +
drivers/iio/light/veml6030.c | 5 +-
drivers/iio/proximity/Kconfig | 2 +
drivers/iommu/intel/iommu.c | 4 +-
drivers/irqchip/irq-gic-v3-its.c | 26 +-
drivers/md/dm-crypt.c | 37 +-
drivers/net/ethernet/cadence/macb_main.c | 14 +-
drivers/net/ethernet/freescale/enetc/enetc.c | 2 +-
drivers/parport/procfs.c | 22 +-
drivers/pinctrl/pinctrl-ocelot.c | 8 +-
drivers/s390/char/sclp_vt220.c | 4 +-
drivers/usb/host/xhci-ring.c | 2 +-
drivers/usb/host/xhci.h | 2 +-
drivers/usb/serial/option.c | 8 +
fs/fat/namei_vfat.c | 2 +-
fs/nilfs2/dir.c | 50 +-
fs/nilfs2/namei.c | 39 +-
fs/nilfs2/nilfs.h | 2 +-
fs/udf/dir.c | 148 +--
fs/udf/directory.c | 594 ++++++++---
fs/udf/inode.c | 90 --
fs/udf/namei.c | 1038 +++++++-------------
fs/udf/udfdecl.h | 45 +-
include/linux/fsl/enetc_mdio.h | 3 +-
include/linux/irqchip/arm-gic-v4.h | 4 +-
io_uring/io_uring.c | 21 +-
kernel/time/posix-clock.c | 3 +
mm/secretmem.c | 4 +-
mm/swapfile.c | 2 +-
net/bluetooth/af_bluetooth.c | 1 +
net/ipv4/tcp_output.c | 2 +-
net/mac80211/cfg.c | 3 +
net/mac80211/key.c | 2 +-
net/mptcp/mib.c | 3 +
net/mptcp/mib.h | 3 +
net/mptcp/pm_netlink.c | 3 +-
net/mptcp/protocol.c | 23 +-
net/mptcp/protocol.h | 2 +
net/mptcp/subflow.c | 19 +-
sound/pci/hda/patch_conexant.c | 19 +
virt/kvm/kvm_main.c | 5 +-
61 files changed, 1172 insertions(+), 1242 deletions(-)
From: Christoph Hellwig <hch(a)lst.de>
upstream 936e114a245b6e38e0dbf706a67e7611fc993da1 commit.
Move the ki_pos update down a bit to prepare for a better common helper
that invalidates pages based of an iocb.
Link: https://lkml.kernel.org/r/20230601145904.1385409-3-hch@lst.de
Signed-off-by: Christoph Hellwig <hch(a)lst.de>
Reviewed-by: Damien Le Moal <dlemoal(a)kernel.org>
Reviewed-by: Hannes Reinecke <hare(a)suse.de>
Reviewed-by: Darrick J. Wong <djwong(a)kernel.org>
Cc: Al Viro <viro(a)zeniv.linux.org.uk>
Cc: Andreas Gruenbacher <agruenba(a)redhat.com>
Cc: Anna Schumaker <anna(a)kernel.org>
Cc: Chao Yu <chao(a)kernel.org>
Cc: Christian Brauner <brauner(a)kernel.org>
Cc: Ilya Dryomov <idryomov(a)gmail.com>
Cc: Jaegeuk Kim <jaegeuk(a)kernel.org>
Cc: Jens Axboe <axboe(a)kernel.dk>
Cc: Johannes Thumshirn <johannes.thumshirn(a)wdc.com>
Cc: Matthew Wilcox <willy(a)infradead.org>
Cc: Miklos Szeredi <miklos(a)szeredi.hu>
Cc: Miklos Szeredi <mszeredi(a)redhat.com>
Cc: Theodore Ts'o <tytso(a)mit.edu>
Cc: Trond Myklebust <trond.myklebust(a)hammerspace.com>
Cc: Xiubo Li <xiubli(a)redhat.com>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
Signed-off-by: Mahmoud Adam <mngyadam(a)amazon.com>
---
This fixes the ext3/4 data corruption casued by dde4c1e1663b6 ("ext4:
properly sync file size update after O_SYNC direct IO").
reported here: https://lore.kernel.org/all/2024102130-thieving-parchment-7885@gregkh/T/#mf…
fs/iomap/direct-io.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 933f234d5becd..8a49c0d3a7b46 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -93,7 +93,6 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio)
if (offset + ret > dio->i_size &&
!(dio->flags & IOMAP_DIO_WRITE))
ret = dio->i_size - offset;
- iocb->ki_pos += ret;
}
/*
@@ -119,15 +118,18 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio)
}
inode_dio_end(file_inode(iocb->ki_filp));
- /*
- * If this is a DSYNC write, make sure we push it to stable storage now
- * that we've written data.
- */
- if (ret > 0 && (dio->flags & IOMAP_DIO_NEED_SYNC))
- ret = generic_write_sync(iocb, ret);
- kfree(dio);
+ if (ret > 0) {
+ iocb->ki_pos += ret;
+ /*
+ * If this is a DSYNC write, make sure we push it to stable
+ * storage now that we've written data.
+ */
+ if (dio->flags & IOMAP_DIO_NEED_SYNC)
+ ret = generic_write_sync(iocb, ret);
+ }
+ kfree(dio);
return ret;
}
EXPORT_SYMBOL_GPL(iomap_dio_complete);
--
2.40.1
From: "Kirill A. Shutemov" <kirill.shutemov(a)linux.intel.com>
Commit ea7e2d5e49c0 ("mm: call the security_mmap_file() LSM hook in
remap_file_pages()") fixed a security issue, it added an LSM check when
trying to remap file pages, so that LSMs have the opportunity to evaluate
such action like for other memory operations such as mmap() and mprotect().
However, that commit called security_mmap_file() inside the mmap_lock lock,
while the other calls do it before taking the lock, after commit
8b3ec6814c83 ("take security_mmap_file() outside of ->mmap_sem").
This caused lock inversion issue with IMA which was taking the mmap_lock
and i_mutex lock in the opposite way when the remap_file_pages() system
call was called.
Solve the issue by splitting the critical region in remap_file_pages() in
two regions: the first takes a read lock of mmap_lock, retrieves the VMA
and the file descriptor associated, and calculates the 'prot' and 'flags'
variables; the second takes a write lock on mmap_lock, checks that the VMA
flags and the VMA file descriptor are the same as the ones obtained in the
first critical region (otherwise the system call fails), and calls
do_mmap().
In between, after releasing the read lock and before taking the write lock,
call security_mmap_file(), and solve the lock inversion issue.
Cc: stable(a)vger.kernel.org # v6.12-rcx
Fixes: ea7e2d5e49c0 ("mm: call the security_mmap_file() LSM hook in remap_file_pages()")
Reported-by: syzbot+1cd571a672400ef3a930(a)syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-security-module/66f7b10e.050a0220.46d20.0036.…
Reviewed-by: Roberto Sassu <roberto.sassu(a)huawei.com>
Reviewed-by: Jann Horn <jannh(a)google.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes(a)oracle.com>
Tested-by: Roberto Sassu <roberto.sassu(a)huawei.com>
Tested-by: syzbot+1cd571a672400ef3a930(a)syzkaller.appspotmail.com
Signed-off-by: Kirill A. Shutemov <kirill.shutemov(a)linux.intel.com>
---
mm/mmap.c | 69 +++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 52 insertions(+), 17 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index 9c0fb43064b5..f731dd69e162 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1640,6 +1640,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
unsigned long populate = 0;
unsigned long ret = -EINVAL;
struct file *file;
+ vm_flags_t vm_flags;
pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. See Documentation/mm/remap_file_pages.rst.\n",
current->comm, current->pid);
@@ -1656,12 +1657,60 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
if (pgoff + (size >> PAGE_SHIFT) < pgoff)
return ret;
- if (mmap_write_lock_killable(mm))
+ if (mmap_read_lock_killable(mm))
return -EINTR;
+ /*
+ * Look up VMA under read lock first so we can perform the security
+ * without holding locks (which can be problematic). We reacquire a
+ * write lock later and check nothing changed underneath us.
+ */
vma = vma_lookup(mm, start);
- if (!vma || !(vma->vm_flags & VM_SHARED))
+ if (!vma || !(vma->vm_flags & VM_SHARED)) {
+ mmap_read_unlock(mm);
+ return -EINVAL;
+ }
+
+ prot |= vma->vm_flags & VM_READ ? PROT_READ : 0;
+ prot |= vma->vm_flags & VM_WRITE ? PROT_WRITE : 0;
+ prot |= vma->vm_flags & VM_EXEC ? PROT_EXEC : 0;
+
+ flags &= MAP_NONBLOCK;
+ flags |= MAP_SHARED | MAP_FIXED | MAP_POPULATE;
+ if (vma->vm_flags & VM_LOCKED)
+ flags |= MAP_LOCKED;
+
+ /* Save vm_flags used to calculate prot and flags, and recheck later. */
+ vm_flags = vma->vm_flags;
+ file = get_file(vma->vm_file);
+
+ mmap_read_unlock(mm);
+
+ /* Call outside mmap_lock to be consistent with other callers. */
+ ret = security_mmap_file(file, prot, flags);
+ if (ret) {
+ fput(file);
+ return ret;
+ }
+
+ ret = -EINVAL;
+
+ /* OK security check passed, take write lock + let it rip. */
+ if (mmap_write_lock_killable(mm)) {
+ fput(file);
+ return -EINTR;
+ }
+
+ vma = vma_lookup(mm, start);
+
+ if (!vma)
+ goto out;
+
+ /* Make sure things didn't change under us. */
+ if (vma->vm_flags != vm_flags)
+ goto out;
+ if (vma->vm_file != file)
goto out;
if (start + size > vma->vm_end) {
@@ -1689,25 +1738,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
goto out;
}
- prot |= vma->vm_flags & VM_READ ? PROT_READ : 0;
- prot |= vma->vm_flags & VM_WRITE ? PROT_WRITE : 0;
- prot |= vma->vm_flags & VM_EXEC ? PROT_EXEC : 0;
-
- flags &= MAP_NONBLOCK;
- flags |= MAP_SHARED | MAP_FIXED | MAP_POPULATE;
- if (vma->vm_flags & VM_LOCKED)
- flags |= MAP_LOCKED;
-
- file = get_file(vma->vm_file);
- ret = security_mmap_file(vma->vm_file, prot, flags);
- if (ret)
- goto out_fput;
ret = do_mmap(vma->vm_file, start, size,
prot, flags, 0, pgoff, &populate, NULL);
-out_fput:
- fput(file);
out:
mmap_write_unlock(mm);
+ fput(file);
if (populate)
mm_populate(ret, populate);
if (!IS_ERR_VALUE(ret))
--
2.34.1
During the aborting of a command, the software receives a command
completion event for the command ring stopped, with the TRB pointing
to the next TRB after the aborted command.
If the command we abort is located just before the Link TRB in the
command ring, then during the 'command ring stopped' completion event,
the xHC gives the Link TRB in the event's cmd DMA, which causes a
mismatch in handling command completion event.
To handle this situation, an additional check has been added to ignore
the mismatch error and continue the operation.
Fixes: 7f84eef0dafb ("USB: xhci: No-op command queueing and irq handler.")
Cc: stable(a)vger.kernel.org
Signed-off-by: Faisal Hassan <quic_faisalh(a)quicinc.com>
---
Changes in v2:
- Removed traversing of TRBs with in_range() API.
- Simplified the if condition check.
v1 link:
https://lore.kernel.org/all/20241018195953.12315-1-quic_faisalh@quicinc.com
drivers/usb/host/xhci-ring.c | 43 +++++++++++++++++++++++++++++++-----
1 file changed, 38 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index b2950c35c740..de375c9f08ca 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -126,6 +126,29 @@ static void inc_td_cnt(struct urb *urb)
urb_priv->num_tds_done++;
}
+/*
+ * Return true if the DMA is pointing to a Link TRB in the ring;
+ * otherwise, return false.
+ */
+static bool is_dma_link_trb(struct xhci_ring *ring, dma_addr_t dma)
+{
+ struct xhci_segment *seg;
+ union xhci_trb *trb;
+
+ seg = ring->first_seg;
+ do {
+ if (in_range(dma, seg->dma, TRB_SEGMENT_SIZE)) {
+ /* found the TRB, check if it's link */
+ trb = &seg->trbs[(dma - seg->dma) / sizeof(*trb)];
+ return trb_is_link(trb);
+ }
+
+ seg = seg->next;
+ } while (seg != ring->first_seg);
+
+ return false;
+}
+
static void trb_to_noop(union xhci_trb *trb, u32 noop_type)
{
if (trb_is_link(trb)) {
@@ -1718,6 +1741,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
trace_xhci_handle_command(xhci->cmd_ring, &cmd_trb->generic);
+ cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status));
cmd_dequeue_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
cmd_trb);
/*
@@ -1725,17 +1749,26 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
* command.
*/
if (!cmd_dequeue_dma || cmd_dma != (u64)cmd_dequeue_dma) {
- xhci_warn(xhci,
- "ERROR mismatched command completion event\n");
- return;
+ /*
+ * For the 'command ring stopped' completion event, there
+ * is a risk of a mismatch in dequeue pointers if we abort
+ * the command just before the link TRB in the command ring.
+ * In this scenario, the cmd_dma in the event would point
+ * to a link TRB, while the software dequeue pointer circles
+ * back to the start.
+ */
+ if (!(cmd_comp_code == COMP_COMMAND_RING_STOPPED &&
+ is_dma_link_trb(xhci->cmd_ring, cmd_dma))) {
+ xhci_warn(xhci,
+ "ERROR mismatched command completion event\n");
+ return;
+ }
}
cmd = list_first_entry(&xhci->cmd_list, struct xhci_command, cmd_list);
cancel_delayed_work(&xhci->cmd_timer);
- cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status));
-
/* If CMD ring stopped we own the trbs between enqueue and dequeue */
if (cmd_comp_code == COMP_COMMAND_RING_STOPPED) {
complete_all(&xhci->cmd_ring_stop_completion);
--
2.17.1