Hi,
Please backport:
commit a40282dd3c48 ("gcc-plugins: Remove TODO_verify_il for GCC >= 16")
to all stable kernel versions. This prepares the GCC plugins for the
coming GCC 16 release.
Thanks!
-Kees
--
Kees Cook
From: xu xin <xu.xin16(a)zte.com.cn>
This series aim to fix exec/fork inheritance and introduce ksm-utils tools
including ksm-set and ksm-get, you can see the detail in PATCH 1.
Problem
=======
In some extreme scenarios, however, this inheritance of MMF_VM_MERGE_ANY during
exec/fork can fail. For example, when the scanning frequency of ksmd is tuned
extremely high, a process carrying MMF_VM_MERGE_ANY may still fail to pass it to
the newly exec'd process. This happens because ksm_execve() is executed too early
in the do_execve flow (prematurely adding the new mm_struct to the ksm_mm_slot list).
As a result, before do_execve completes, ksmd may have already performed a scan and
found that this new mm_struct has no VM_MERGEABLE VMAs, thus clearing its
MMF_VM_MERGE_ANY flag. Consequently, when the new program executes, the flag
MMF_VM_MERGE_ANY inheritance fails!
Reproduce
========
Prepare ksm-utils in the prerequisite PATCH, and simply do as follows
echo 1 > /sys/kernel/mm/ksm/run;
echo 2000 > /sys/kernel/mm/ksm/pages_to_scan;
echo 0 > /sys/kernel/mm/ksm/sleep_millisecs;
ksm-set -s on [NEW_PROGRAM_BIN] &
ksm-get -a -e
you can see like this:
Pid Comm Merging_pages Ksm_zero_pages Ksm_profit Ksm_mergeable Ksm_merge_any
206 NEW_PROGRAM_BIN 7680 0 30965760 yes no
Note:
If the first time don't reproduce the issue, pkill NEW_PROGRAM_BIN and try run it
again. Usually, we can reproduce it in 5 times.
Root reason
===========
The commit d7597f59d1d33 ("mm: add new api to enable ksm per process") clear the
flag MMF_VM_MERGE_ANY when ksmd found no VM_MERGEABLE VMAs.
xu xin (2):
tools: add ksm-utils tools
mm/ksm: fix exec/fork inheritance support for prctl
mm/ksm.c | 8 +-
tools/mm/Makefile | 12 +-
tools/mm/ksm-utils/Makefile | 10 +
tools/mm/ksm-utils/ksm-get.c | 397 +++++++++++++++++++++++++++++++++++
tools/mm/ksm-utils/ksm-set.c | 144 +++++++++++++
5 files changed, 567 insertions(+), 4 deletions(-)
create mode 100644 tools/mm/ksm-utils/Makefile
create mode 100644 tools/mm/ksm-utils/ksm-get.c
create mode 100644 tools/mm/ksm-utils/ksm-set.c
--
2.25.1
In of_unittest_pci_node_verify(), when the add parameter is false,
device_find_any_child() obtains a reference to a child device. This
function implicitly calls get_device() to increment the device's
reference count before returning the pointer. However, the caller
fails to properly release this reference by calling put_device(),
leading to a device reference count leak. Add put_device() in the else
branch immediately after child_dev is no longer needed.
As the comment of device_find_any_child states: "NOTE: you will need
to drop the reference with put_device() after use".
Found by code review.
Cc: stable(a)vger.kernel.org
Fixes: 26409dd04589 ("of: unittest: Add pci_dt_testdrv pci driver")
Signed-off-by: Ma Ke <make24(a)iscas.ac.cn>
---
Changes in v2:
- modified the put_device() location as suggestions.
---
drivers/of/unittest.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index e3503ec20f6c..388e9ec2cccf 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -4300,6 +4300,7 @@ static int of_unittest_pci_node_verify(struct pci_dev *pdev, bool add)
unittest(!np, "Child device tree node is not removed\n");
child_dev = device_find_any_child(&pdev->dev);
unittest(!child_dev, "Child device is not removed\n");
+ put_device(child_dev);
}
failed:
--
2.17.1
From: Tetsuo Handa <penguin-kernel(a)I-love.SAKURA.ne.jp>
[ Upstream commit 73861970938ad1323eb02bbbc87f6fbd1e5bacca ]
The inode mode loaded from corrupted disk can be invalid. Do like what
commit 0a9e74051313 ("isofs: Verify inode mode when loading from disk")
does.
Reported-by: syzbot <syzbot+895c23f6917da440ed0d(a)syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d
Signed-off-by: Tetsuo Handa <penguin-kernel(a)I-love.SAKURA.ne.jp>
Link: https://lore.kernel.org/ec982681-84b8-4624-94fa-8af15b77cbd2@I-love.SAKURA.…
Signed-off-by: Christian Brauner <brauner(a)kernel.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
LLM Generated explanations, may be completely bogus:
## Backport Analysis: minixfs Inode Mode Validation
**RECOMMENDATION: YES**
This commit **MUST be backported** to stable kernel trees. This is a
critical security and stability fix.
---
### Evidence-Based Analysis
#### 1. **Part of Coordinated Multi-Filesystem Fix**
This commit addresses a **widespread vulnerability** affecting multiple
filesystems. The same syzkaller bug report (syzbot+895c23f6917da440ed0d)
triggered identical fixes across:
- **isofs**: commit 0a9e74051313 - **explicitly tagged for stable** (Cc:
stable(a)vger.kernel.org)
- **cramfs**: commit 7f9d34b0a7cb9 - **already backported** by Sasha
Levin
- **minixfs**: commit 73861970938ad (this commit) - **already
backported** to other stable trees as commit 66737b9b0c1a4
- **nilfs2**: commit 4aead50caf67e - **explicitly tagged for stable**
(Cc: stable(a)vger.kernel.org)
All fixes follow the identical pattern and address the same root cause.
#### 2. **Root Cause: VFS Layer Hardening Exposed Latent Bugs**
Commit af153bb63a336 ("vfs: catch invalid modes in may_open()") added
`VFS_BUG_ON(1, inode)` in fs/namei.c:3418 to catch invalid inode modes.
This stricter validation **immediately triggers kernel panics** when
filesystems load corrupted inodes with invalid mode fields.
**Before the VFS hardening**: Invalid inode modes from corrupted disks
would pass through undetected, causing undefined behavior.
**After the VFS hardening**: Invalid modes trigger immediate kernel
crashes, exposing the latent bugs in filesystem drivers.
#### 3. **Code Change Analysis (fs/minix/inode.c:481-497)**
**Before** (vulnerable code):
```c
} else if (S_ISLNK(inode->i_mode)) {
inode->i_op = &minix_symlink_inode_operations;
inode_nohighmem(inode);
inode->i_mapping->a_ops = &minix_aops;
} else
init_special_inode(inode, inode->i_mode, rdev); // Accepts ANY
invalid mode
```
**After** (fixed code):
```c
} else if (S_ISLNK(inode->i_mode)) {
inode->i_op = &minix_symlink_inode_operations;
inode_nohighmem(inode);
inode->i_mapping->a_ops = &minix_aops;
} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
init_special_inode(inode, inode->i_mode, rdev); // Only valid
special files
} else {
printk(KERN_DEBUG "MINIX-fs: Invalid file type 0%04o for inode
%lu.\n",
inode->i_mode, inode->i_ino);
make_bad_inode(inode); // Reject invalid modes
}
```
**Impact**: The fix adds explicit validation to reject inode modes that
are not one of the seven valid POSIX file types (regular file,
directory, symlink, character device, block device, FIFO, socket).
Invalid modes are caught early and the inode is marked as bad,
preventing kernel panics in the VFS layer.
#### 4. **Security Impact: DoS Vulnerability (CVSS ~6.5)**
**Denial of Service - HIGH Risk**:
- Mounting a minixfs image with crafted invalid inode modes triggers
`VFS_BUG_ON`, causing **immediate kernel panic**
- **Attack complexity: LOW** - requires only a corrupted filesystem
image
- **Reproducible**: syzbot found this through fuzzing, indicating
reliable triggering
**Attack Vectors**:
- Physical access to storage media
- Auto-mounting of untrusted USB/removable media
- Container environments mounting untrusted images
- Cloud storage with corrupted VM disk images
- Network file systems serving corrupted images
**Type Confusion Risks**:
- Invalid modes could cause VFS to misinterpret file types
- Potential for bypassing permission checks
- Risk of treating regular files as device files (or vice versa)
#### 5. **Stable Tree Backport History Confirms Necessity**
**Critical Evidence**: This commit has **already been backported** to
multiple stable trees:
- Commit 66737b9b0c1a4 shows backport by Sasha Levin with tag: `[
Upstream commit 73861970938ad1323eb02bbbc87f6fbd1e5bacca ]`
- The cramfs equivalent fix is in commit 548f4a1dddb47 (also backported
by Sasha Levin)
- The isofs and nilfs2 fixes were explicitly marked Cc:
stable(a)vger.kernel.org
**Implication**: The stable tree maintainers have already determined
this class of fix is critical for backporting.
#### 6. **Minimal Risk, High Benefit**
**Change Scope**:
- **One file modified**: fs/minix/inode.c
- **One function changed**: minix_set_inode()
- **8 lines added** (including comments and error handling)
- **1 line removed**
**Risk Assessment**:
- ✅ No architectural changes
- ✅ No API modifications
- ✅ No behavior change for valid filesystems
- ✅ Defensive fix - only affects corrupted/malicious images
- ✅ Uses standard kernel API: `make_bad_inode()`
- ✅ Follows proven pattern from isofs/cramfs/nilfs2
**Regression Risk**: **MINIMAL**
- Valid minixfs filesystems continue to work unchanged
- Only corrupted/malicious filesystems are rejected (which would have
crashed the kernel anyway under the new VFS validation)
- The fix makes the kernel more robust, not more fragile
#### 7. **Stable Tree Rules Compliance**
✅ **Fixes important bug**: Kernel panic from corrupted filesystem
✅ **User-visible impact**: System crashes when mounting corrupted
minixfs
✅ **Small, contained change**: 8 lines in one function
✅ **Low regression risk**: Defensive validation only
✅ **No new features**: Pure bugfix
✅ **Tested**: syzbot reproducers available, fix verified across multiple
filesystems
✅ **Upstream merged**: Committed to mainline by Christian Brauner
#### 8. **Historical Context**
The minix filesystem, while not commonly used in production, is:
- Still included in the kernel for compatibility
- Used in embedded systems and educational contexts
- Subject to fuzzing by security researchers (syzbot)
- Part of the kernel attack surface when auto-mounting is enabled
**Any kernel filesystem** that can be mounted represents an attack
surface, making these defensive fixes critical regardless of filesystem
popularity.
---
### Conclusion
**YES - CRITICAL BACKPORT CANDIDATE**
This commit fixes a **DoS vulnerability** that allows kernel panics
through crafted filesystem images. It is:
1. Part of a coordinated fix across multiple filesystems
2. Already backported to other stable trees
3. Minimal risk with high security benefit
4. Follows stable tree rules perfectly
5. Addresses a syzbot-reported bug with reproducers
6. Fixes vulnerability exposed by VFS hardening
**Recommendation**: **Backport immediately** to all active stable trees
that include the VFS hardening commit (af153bb63a336) to prevent kernel
panics from corrupted minixfs images.
fs/minix/inode.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index df9d11479caf1..32db676127a9e 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -492,8 +492,14 @@ void minix_set_inode(struct inode *inode, dev_t rdev)
inode->i_op = &minix_symlink_inode_operations;
inode_nohighmem(inode);
inode->i_mapping->a_ops = &minix_aops;
- } else
+ } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
+ S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
init_special_inode(inode, inode->i_mode, rdev);
+ } else {
+ printk(KERN_DEBUG "MINIX-fs: Invalid file type 0%04o for inode %lu.\n",
+ inode->i_mode, inode->i_ino);
+ make_bad_inode(inode);
+ }
}
/*
--
2.51.0
Prevent USB runtime PM (autosuspend) for AX88772* in bind.
usbnet enables runtime PM (autosuspend) by default, so disabling it via
the usb_driver flag is ineffective. On AX88772B, autosuspend shows no
measurable power saving with current driver (no link partner, admin
up/down). The ~0.453 W -> ~0.248 W drop on v6.1 comes from phylib powering
the PHY off on admin-down, not from USB autosuspend.
The real hazard is that with runtime PM enabled, ndo_open() (under RTNL)
may synchronously trigger autoresume (usb_autopm_get_interface()) into
asix_resume() while the USB PM lock is held. Resume paths then invoke
phylink/phylib and MDIO, which also expect RTNL, leading to possible
deadlocks or PM lock vs MDIO wake issues.
To avoid this, keep the device runtime-PM active by taking a usage
reference in ax88772_bind() and dropping it in unbind(). A non-zero PM
usage count blocks runtime suspend regardless of userspace policy
(.../power/control - pm_runtime_allow/forbid), making this approach
robust against sysfs overrides.
System sleep/resume is unchanged.
Fixes: 4a2c7217cd5a ("net: usb: asix: ax88772: manage PHY PM from MAC")
Reported-by: Hubert Wiśniewski <hubert.wisniewski.25632(a)gmail.com>
Closes: https://lore.kernel.org/all/DCGHG5UJT9G3.2K1GHFZ3H87T0@gmail.com
Tested-by: Hubert Wiśniewski <hubert.wisniewski.25632(a)gmail.com>
Reported-by: Marek Szyprowski <m.szyprowski(a)samsung.com>
Closes: https://lore.kernel.org/all/b5ea8296-f981-445d-a09a-2f389d7f6fdd@samsung.com
Cc: stable(a)vger.kernel.org
Signed-off-by: Oleksij Rempel <o.rempel(a)pengutronix.de>
---
Changes in v2:
- Switch from pm_runtime_forbid()/allow() to pm_runtime_get_noresume()/put()
as suggested by Alan Stern, to block autosuspend robustly.
- Reword commit message to clarify the actual deadlock condition
(autoresume under RTNL) as pointed out by Oliver Neukum.
- Keep explanation in commit message, shorten in-code comment.
Link to the measurement results:
https://lore.kernel.org/all/aMkPMa650kfKfmF4@pengutronix.de/
---
drivers/net/usb/asix_devices.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 792ddda1ad49..5c939446515b 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -625,6 +625,21 @@ static void ax88772_suspend(struct usbnet *dev)
asix_read_medium_status(dev, 1));
}
+/* Notes on PM callbacks and locking context:
+ *
+ * - asix_suspend()/asix_resume() are invoked for both runtime PM and
+ * system-wide suspend/resume. For struct usb_driver the ->resume()
+ * callback does not receive pm_message_t, so the resume type cannot
+ * be distinguished here.
+ *
+ * - The MAC driver must hold RTNL when calling phylink interfaces such as
+ * phylink_suspend()/resume(). Those calls will also perform MDIO I/O.
+ *
+ * - Taking RTNL and doing MDIO from a runtime-PM resume callback (while
+ * the USB PM lock is held) is fragile. Since autosuspend brings no
+ * measurable power saving for this device with current driver version, it is
+ * disabled below.
+ */
static int asix_suspend(struct usb_interface *intf, pm_message_t message)
{
struct usbnet *dev = usb_get_intfdata(intf);
@@ -919,6 +934,13 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
if (ret)
goto initphy_err;
+ /* Keep this interface runtime-PM active by taking a usage ref.
+ * Prevents runtime suspend while bound and avoids resume paths
+ * that could deadlock (autoresume under RTNL while USB PM lock
+ * is held, phylink/MDIO wants RTNL).
+ */
+ pm_runtime_get_noresume(&intf->dev);
+
return 0;
initphy_err:
@@ -948,6 +970,8 @@ static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
phylink_destroy(priv->phylink);
ax88772_mdio_unregister(priv);
asix_rx_fixup_common_free(dev->driver_priv);
+ /* Drop the PM usage ref taken in bind() */
+ pm_runtime_put(&intf->dev);
}
static void ax88178_unbind(struct usbnet *dev, struct usb_interface *intf)
@@ -1600,6 +1624,10 @@ static struct usb_driver asix_driver = {
.resume = asix_resume,
.reset_resume = asix_resume,
.disconnect = usbnet_disconnect,
+ /* usbnet will force supports_autosuspend=1; we explicitly forbid RPM
+ * per-interface in bind to keep autosuspend disabled for this driver
+ * by using pm_runtime_forbid().
+ */
.supports_autosuspend = 1,
.disable_hub_initiated_lpm = 1,
};
--
2.47.3
Calling intotify_show_fdinfo() on fd watching an overlayfs inode, while
the overlayfs is being unmounted, can lead to dereferencing NULL ptr.
This issue was found by syzkaller.
Race Condition Diagram:
Thread 1 Thread 2
-------- --------
generic_shutdown_super()
shrink_dcache_for_umount
sb->s_root = NULL
|
| vfs_read()
| inotify_fdinfo()
| * inode get from mark *
| show_mark_fhandle(m, inode)
| exportfs_encode_fid(inode, ..)
| ovl_encode_fh(inode, ..)
| ovl_check_encode_origin(inode)
| * deref i_sb->s_root *
|
|
v
fsnotify_sb_delete(sb)
Which then leads to:
[ 32.133461] Oops: general protection fault, probably for non-canonical address 0xdffffc0000000006: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN NOPTI
[ 32.134438] KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037]
[ 32.135032] CPU: 1 UID: 0 PID: 4468 Comm: systemd-coredum Not tainted 6.17.0-rc6 #22 PREEMPT(none)
<snip registers, unreliable trace>
[ 32.143353] Call Trace:
[ 32.143732] ovl_encode_fh+0xd5/0x170
[ 32.144031] exportfs_encode_inode_fh+0x12f/0x300
[ 32.144425] show_mark_fhandle+0xbe/0x1f0
[ 32.145805] inotify_fdinfo+0x226/0x2d0
[ 32.146442] inotify_show_fdinfo+0x1c5/0x350
[ 32.147168] seq_show+0x530/0x6f0
[ 32.147449] seq_read_iter+0x503/0x12a0
[ 32.148419] seq_read+0x31f/0x410
[ 32.150714] vfs_read+0x1f0/0x9e0
[ 32.152297] ksys_read+0x125/0x240
IOW ovl_check_encode_origin derefs inode->i_sb->s_root, after it was set
to NULL in the unmount path.
Fix it by protecting calling exportfs_encode_fid() from
show_mark_fhandle() with s_umount lock.
This form of fix was suggested by Amir in [1].
[1]: https://lore.kernel.org/all/CAOQ4uxhbDwhb+2Brs1UdkoF0a3NSdBAOQPNfEHjahrgoKJ…
Fixes: c45beebfde34 ("ovl: support encoding fid from inode with no alias")
Signed-off-by: Jakub Acs <acsjakub(a)amazon.de>
Cc: Jan Kara <jack(a)suse.cz>
Cc: Amir Goldstein <amir73il(a)gmail.com>
Cc: Miklos Szeredi <miklos(a)szeredi.hu>
Cc: Christian Brauner <brauner(a)kernel.org>
Cc: linux-unionfs(a)vger.kernel.org
Cc: linux-fsdevel(a)vger.kernel.org
Cc: linux-kernel(a)vger.kernel.org
Cc: stable(a)vger.kernel.org
---
This issue was already discussed in [1] with no consensus reached on the
fix.
This form was suggested as a band-aid fix, without explicity yes/no
reaction. Hence reviving the discussion around the band-aid.
fs/notify/fdinfo.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c
index 1161eabf11ee..9cc7eb863643 100644
--- a/fs/notify/fdinfo.c
+++ b/fs/notify/fdinfo.c
@@ -17,6 +17,7 @@
#include "fanotify/fanotify.h"
#include "fdinfo.h"
#include "fsnotify.h"
+#include "../internal.h"
#if defined(CONFIG_PROC_FS)
@@ -46,7 +47,12 @@ static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
size = f->handle_bytes >> 2;
+ if (!super_trylock_shared(inode->i_sb))
+ return;
+
ret = exportfs_encode_fid(inode, (struct fid *)f->f_handle, &size);
+ up_read(&inode->i_sb->s_umount);
+
if ((ret == FILEID_INVALID) || (ret < 0))
return;
--
2.47.3
Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christian Schlaeger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597