| 0/0 |
2026/05/17 07:37 |
flow |
assessment-security |
1h02m
Results: map[DenialOfService:true Explanation:The bug report indicates a WARNING in `__up_write` called from `inode_unlock` in
`vfs_remove_acl`. The warning `DEBUG_RWSEMS_WARN_ON((rwsem_owner(sem) !=
current) && !rwsem_test_oflags(sem, RWSEM_NONSPINNABLE))` means that
`inode_unlock` is being called on an `i_rwsem` that is not owned by the current
task (in this case, it's already completely unlocked, as `count = 0x0` and
`owner = 0x0`).
Looking at `vfs_remove_acl` in `fs/posix_acl.c`:
```c
retry_deleg:
inode_lock(inode);
error = may_write_xattr(idmap, inode);
if (error)
goto out_inode_unlock;
error = security_inode_remove_acl(idmap, dentry, acl_name);
if (error)
goto out_inode_unlock;
error = try_break_deleg(inode, &delegated_inode);
if (error)
goto out_inode_unlock;
if (likely(!is_bad_inode(inode)))
error = set_posix_acl(idmap, dentry, acl_type, NULL);
else
error = -EIO;
if (!error) {
fsnotify_xattr(dentry);
security_inode_post_remove_acl(idmap, dentry, acl_name);
}
out_inode_unlock:
inode_unlock(inode);
if (is_delegated(&delegated_inode)) {
error = break_deleg_wait(&delegated_inode);
if (!error)
goto retry_deleg;
}
return error;
```
The function locks the inode at the beginning and unlocks it at
`out_inode_unlock`. If `try_break_deleg` returns `-EWOULDBLOCK`, it sets
`delegated_inode.di_inode = inode` and jumps to `out_inode_unlock`. It then
unlocks the inode, and because `is_delegated` is true, it calls
`break_deleg_wait`. `break_deleg_wait` waits for the delegation to break and
then sets `delegated_inode.di_inode = NULL`. If it succeeds, it jumps back to
`retry_deleg`.
However, if `try_break_deleg` returns `0` on the second iteration (or the
first), it proceeds to `set_posix_acl`. After `set_posix_acl` finishes, it jumps
to `out_inode_unlock` and unlocks the inode. Then it checks
`is_delegated(&delegated_inode)`. Since `break_deleg_wait` set
`delegated_inode.di_inode = NULL`, `is_delegated` correctly returns false, and
the function returns.
The issue arises if `try_break_deleg` returns `-EWOULDBLOCK` but
`break_deleg_wait` returns an error (e.g., `-ERESTARTSYS` due to a signal). In
this case, `break_deleg_wait` still sets `delegated_inode.di_inode = NULL`, but
it returns the error. `vfs_remove_acl` then returns the error, leaving the inode
correctly unlocked.
The only way `inode_unlock` can be called on an already unlocked semaphore is if
`set_posix_acl` (or one of the functions it calls) unlocks the inode internally.
We checked many filesystems and none of them unlock the inode in their `set_acl`
implementation. However, if a filesystem's `set_acl` implementation incorrectly
drops the inode lock (or if there's a bug in a specific filesystem's delegation
handling), it would lead to this double unlock.
This is a local denial-of-service (triggering a WARNING and potentially
corrupting the rwsem state if it was locked by another thread in the meantime,
though rwsems have protections against this). It is reachable by unprivileged
users who can call `removexattr` on files they own (or in filesystems they can
mount, like FUSE or overlayfs). It does not lead to memory corruption or
privilege escalation directly, as it's a locking imbalance caught by debug
checks. Exploitable:false FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/05/17 07:37 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/05/17 07:37 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/765b333e5190e2407f5e3bcec229010add3135c0]
|
| 3/1 |
2026/05/17 07:39 |
action |
kernel-builder |
20m
Results: map[KernelObj:/app/workdir/cache/build/ea5ec3bd94ca0b7f991e5ced68a57688dd733ab5]
|
| 4/1 |
2026/05/17 08:00 |
action |
codesearch-prepare |
19m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/05/17 08:19 |
agent |
expert |
20m
Model:
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Instruction:
You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by greeping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Don't make assumptions; verify them with source code access. Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption or elevated privileges.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completly wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control tranfers, that's also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitabability depends on how exactly the uninit value
is used in the code, and what it affects.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidetial Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
------------[ cut here ]------------
DEBUG_RWSEMS_WARN_ON((rwsem_owner(sem) != current) && !rwsem_test_oflags(sem, RWSEM_NONSPINNABLE)): count = 0x0, magic = 0xffff888037fed058, owner = 0x0, curr 0xffff888030ce1e80, list empty
WARNING: kernel/locking/rwsem.c:1381 at __up_write kernel/locking/rwsem.c:1380 [inline], CPU#0: syz.1.1645/13704
WARNING: kernel/locking/rwsem.c:1381 at up_write+0x2d6/0x410 kernel/locking/rwsem.c:1643, CPU#0: syz.1.1645/13704
Modules linked in:
CPU: 0 UID: 0 PID: 13704 Comm: syz.1.1645 Tainted: G L syzkaller #0 PREEMPT(full)
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
RIP: 0010:__up_write kernel/locking/rwsem.c:1380 [inline]
RIP: 0010:up_write+0x388/0x410 kernel/locking/rwsem.c:1643
Code: cc 8b 49 c7 c2 a0 ec cc 8b 4c 0f 44 d0 48 8b 7c 24 08 48 c7 c6 00 ef cc 8b 48 8b 14 24 4c 89 f1 4d 89 e0 4c 8b 4c 24 10 41 52 <67> 48 0f b9 3a 48 83 c4 08 e8 2a fd 0a 03 e9 67 fd ff ff 48 c7 c1
RSP: 0018:ffffc9000613fbd0 EFLAGS: 00010246
RAX: ffffffff8bccec80 RBX: ffff888037fed058 RCX: ffff888037fed058
RDX: 0000000000000000 RSI: ffffffff8bccef00 RDI: ffffffff90152680
RBP: ffff888037fed0b0 R08: 0000000000000000 R09: ffff888030ce1e80
R10: ffffffff8bccec80 R11: ffffed1006ffda0d R12: 0000000000000000
R13: dffffc0000000000 R14: ffff888037fed058 R15: 1ffff11006ffda0c
FS: 00007fd16f7b56c0(0000) GS:ffff888125454000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f588e35f000 CR3: 000000005d459000 CR4: 0000000000350ef0
Call Trace:
<TASK>
inode_unlock include/linux/fs.h:1038 [inline]
vfs_remove_acl+0x763/0x830 fs/posix_acl.c:1251
removexattr fs/xattr.c:1009 [inline]
filename_removexattr fs/xattr.c:1038 [inline]
path_removexattrat+0x51a/0x750 fs/xattr.c:1071
__do_sys_lremovexattr fs/xattr.c:1089 [inline]
__se_sys_lremovexattr fs/xattr.c:1086 [inline]
__x64_sys_lremovexattr+0x65/0x80 fs/xattr.c:1086
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fd16e99c819
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fd16f7b5028 EFLAGS: 00000246 ORIG_RAX: 00000000000000c6
RAX: ffffffffffffffda RBX: 00007fd16ec16090 RCX: 00007fd16e99c819
RDX: 0000000000000000 RSI: 00002000000000c0 RDI: 0000200000000080
RBP: 00007fd16ea32c91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fd16ec16128 R14: 00007fd16ec16090 R15: 00007fff9e2e34a8
</TASK>
----------------
Code disassembly (best guess):
0: cc int3
1: 8b 49 c7 mov -0x39(%rcx),%ecx
4: c2 a0 ec ret $0xeca0
7: cc int3
8: 8b 4c 0f 44 mov 0x44(%rdi,%rcx,1),%ecx
c: d0 48 8b rorb $1,-0x75(%rax)
f: 7c 24 jl 0x35
11: 08 48 c7 or %cl,-0x39(%rax)
14: c6 00 ef movb $0xef,(%rax)
17: cc int3
18: 8b 48 8b mov -0x75(%rax),%ecx
1b: 14 24 adc $0x24,%al
1d: 4c 89 f1 mov %r14,%rcx
20: 4d 89 e0 mov %r12,%r8
23: 4c 8b 4c 24 10 mov 0x10(%rsp),%r9
28: 41 52 push %r10
* 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2f: 48 83 c4 08 add $0x8,%rsp
33: e8 2a fd 0a 03 call 0x30afd62
38: e9 67 fd ff ff jmp 0xfffffda4
3d: 48 rex.W
3e: c7 .byte 0xc7
3f: c1 .byte 0xc1
Reply: The bug report indicates a WARNING in `__up_write` called from `inode_unlock` in `vfs_remove_acl`. The warning `DEBUG_RWSEMS_WARN_ON((rwsem_owner(sem) != current) && !rwsem_test_oflags(sem, RWSEM_NONSPINNABLE))` means that `inode_unlock` is being called on an `i_rwsem` that is not owned by the current task (in this case, it's already completely unlocked, as `count = 0x0` and `owner = 0x0`).
Looking at `vfs_remove_acl` in `fs/posix_acl.c`:
```c
retry_deleg:
inode_lock(inode);
error = may_write_xattr(idmap, inode);
if (error)
goto out_inode_unlock;
error = security_inode_remove_acl(idmap, dentry, acl_name);
if (error)
goto out_inode_unlock;
error = try_break_deleg(inode, &delegated_inode);
if (error)
goto out_inode_unlock;
if (likely(!is_bad_inode(inode)))
error = set_posix_acl(idmap, dentry, acl_type, NULL);
else
error = -EIO;
if (!error) {
fsnotify_xattr(dentry);
security_inode_post_remove_acl(idmap, dentry, acl_name);
}
out_inode_unlock:
inode_unlock(inode);
if (is_delegated(&delegated_inode)) {
error = break_deleg_wait(&delegated_inode);
if (!error)
goto retry_deleg;
}
return error;
```
The function locks the inode at the beginning and unlocks it at `out_inode_unlock`. If `try_break_deleg` returns `-EWOULDBLOCK`, it sets `delegated_inode.di_inode = inode` and jumps to `out_inode_unlock`. It then unlocks the inode, and because `is_delegated` is true, it calls `break_deleg_wait`. `break_deleg_wait` waits for the delegation to break and then sets `delegated_inode.di_inode = NULL`. If it succeeds, it jumps back to `retry_deleg`.
However, if `try_break_deleg` returns `0` on the second iteration (or the first), it proceeds to `set_posix_acl`. After `set_posix_acl` finishes, it jumps to `out_inode_unlock` and unlocks the inode. Then it checks `is_delegated(&delegated_inode)`. Since `break_deleg_wait` set `delegated_inode.di_inode = NULL`, `is_delegated` correctly returns false, and the function returns.
The issue arises if `try_break_deleg` returns `-EWOULDBLOCK` but `break_deleg_wait` returns an error (e.g., `-ERESTARTSYS` due to a signal). In this case, `break_deleg_wait` still sets `delegated_inode.di_inode = NULL`, but it returns the error. `vfs_remove_acl` then returns the error, leaving the inode correctly unlocked.
The only way `inode_unlock` can be called on an already unlocked semaphore is if `set_posix_acl` (or one of the functions it calls) unlocks the inode internally. We checked many filesystems and none of them unlock the inode in their `set_acl` implementation. However, if a filesystem's `set_acl` implementation incorrectly drops the inode lock (or if there's a bug in a specific filesystem's delegation handling), it would lead to this double unlock.
This is a local denial-of-service (triggering a WARNING and potentially corrupting the rwsem state if it was locked by another thread in the meantime, though rwsems have protections against this). It is reachable by unprivileged users who can call `removexattr` on files they own (or in filesystems they can mount, like FUSE or overlayfs). It does not lead to memory corruption or privilege escalation directly, as it's a locking imbalance caught by debug checks.
|
| 6/2 |
2026/05/17 08:19 |
llm |
expert |
0m
Model:
Tokens:
input: 6726
output: 43
thoughts: 382
Thoughts: **Analyzing a Syzkaller Bug Report**
Okay, here's what I'm seeing. We've got a syzkaller bug report, specifically a warning related to read-write semaphores (`rwsem`). The warning, `DEBUG_RWSEMS_WARN_ON`, indicates a potential issue with the semaphore's ownership and state. The message is pretty explicit: it's warning that the current task attempting to release the semaphore isn't its owner, and the `RWSEM_NONSPINNABLE` flag isn't set. The data provided confirms this: `rwsem_owner(sem)` is not the `current` task. I'm noting the count is zero and the owner is NULL, and I see the current task information as well.
The kernel stack trace points us to `vfs_remove_acl` in `fs/posix_acl.c:1251`. This is where I need to focus my attention. It looks like the issue is triggered during ACL removal, likely through the `lremovexattr` system call. The stack trace shows the call chain, starting with the system call itself, going through the file system layer and ending at this point in the ACL removal process.
I need to dive into `fs/posix_acl.c:1251` to understand *why* this improper unlock is happening within `vfs_remove_acl`. There's probably a race condition, incorrect locking logic, or potentially an ownership issue that is leading to an attempt to release a semaphore without proper ownership. I'll examine the surrounding code to grasp how `vfs_remove_acl` interacts with the semaphore, specifically the context of the `inode_unlock` call. The inline functions are a bit annoying but I can work through that to understand the flow. I need to figure out the exact sequence of events that results in the rwsem being handled in this way.
|
| 7/2 |
2026/05/17 08:19 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/posix_acl.c IncludeLines:true Name:vfs_remove_acl]
Results: map[SourceCode:1200: /**
1201: * vfs_remove_acl - remove posix acls
1202: * @idmap: idmap of the mount
1203: * @dentry: the dentry based on which to retrieve the posix acls
1204: * @acl_name: the name of the posix acl
1205: *
1206: * This function removes posix acls.
1207: *
1208: * Return: On success 0, on error negative errno.
1209: */
1210: int vfs_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
1211: const char *acl_name)
1212: {
1213: int acl_type;
1214: int error;
1215: struct inode *inode = d_inode(dentry);
1216: struct delegated_inode delegated_inode = { };
1217:
1218: acl_type = posix_acl_type(acl_name);
1219: if (acl_type < 0)
1220: return -EINVAL;
1221:
1222: retry_deleg:
1223: inode_lock(inode);
1224:
1225: /*
1226: * We only care about restrictions the inode struct itself places upon
1227: * us otherwise POSIX ACLs aren't subject to any VFS restrictions.
1228: */
1229: error = may_write_xattr(idmap, inode);
1230: if (error)
1231: goto out_inode_unlock;
1232:
1233: error = security_inode_remove_acl(idmap, dentry, acl_name);
1234: if (error)
1235: goto out_inode_unlock;
1236:
1237: error = try_break_deleg(inode, &delegated_inode);
1238: if (error)
1239: goto out_inode_unlock;
1240:
1241: if (likely(!is_bad_inode(inode)))
1242: error = set_posix_acl(idmap, dentry, acl_type, NULL);
1243: else
1244: error = -EIO;
1245: if (!error) {
1246: fsnotify_xattr(dentry);
1247: security_inode_post_remove_acl(idmap, dentry, acl_name);
1248: }
1249:
1250: out_inode_unlock:
1251: inode_unlock(inode);
1252:
1253: if (is_delegated(&delegated_inode)) {
1254: error = break_deleg_wait(&delegated_inode);
1255: if (!error)
1256: goto retry_deleg;
1257: }
1258:
1259: return error;
1260: }
SourceFile:fs/posix_acl.c]
|
| 8/2 |
2026/05/17 08:19 |
llm |
expert |
0m
Model:
Tokens:
input: 8441
output: 42
thoughts: 217
Thoughts: **Investigating a Potential Race Condition in ACL Removal**
Okay, so I'm looking at this warning: `DEBUG_RWSEMS_WARN_ON((rwsem_owner(sem) != current) && !rwsem_test_oflags(sem, RWSEM_NONSPINNABLE))`. It's screaming that we're trying to unlock a read-write semaphore (`rwsem`) that the current task doesn't own. That's a classic concurrency bug, and we need to nail down where this is happening in `vfs_remove_acl`.
Specifically, I'm focusing on this code block:
```c
retry_deleg:
inode_lock(inode);
...
error = try_break_deleg(inode, &delegated_inode);
if (error)
goto out_inode_unlock;
...
out_inode_unlock:
inode_unlock(inode);
if (is_delegated(&delegated_inode)) {
error = break_deleg_wait(&delegated_inode);
if (!error)
goto retry_deleg;
}
```
My initial thought is, we've locked the inode, then we call `try_break_deleg`. Immediately after, we unlock the inode! Hold on... Could `try_break_deleg` be *unlocking* the inode? That would explain the warning if it's releasing a resource without proper ownership tracking. We have to verify this; I'm going to jump into `try_break_deleg` and see if that is indeed the case.
|
| 9/2 |
2026/05/17 08:19 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/posix_acl.c IncludeLines:true Name:try_break_deleg]
Results: map[SourceCode: 518: static inline int try_break_deleg(struct inode *inode,
519: struct delegated_inode *di)
520: {
521: int ret;
522:
523: ret = break_deleg(inode, LEASE_BREAK_NONBLOCK);
524: if (ret == -EWOULDBLOCK && di) {
525: di->di_inode = inode;
526: ihold(inode);
527: }
528: return ret;
529: }
SourceFile:include/linux/filelock.h]
|
| 10/2 |
2026/05/17 08:19 |
llm |
expert |
0m
Model:
Tokens:
input: 9236
output: 43
thoughts: 26
Thoughts: Here's my thought process, summarized as you requested:
**Debugging Inode Locking**
Okay, so I was looking at `break_deleg`, thinking that was the key to unlocking the inode... but wait a minute, it doesn't actually seem to do that, does it? That's not its purpose. I need to rethink my approach. If `break_deleg` isn't the solution to my inode locking issue, what other tools or functions are available to me? Hmmm, what about `set_posix_acl`? Could that be interacting with the lock in some way, or providing an alternative mechanism for managing access that influences the lock's behavior? I should investigate that function's implementation and how it interacts with the inode structure itself. It's time to check the documentation and code related to ACLs and see if there's a link there.
|
| 11/2 |
2026/05/17 08:19 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/posix_acl.c IncludeLines:true Name:set_posix_acl]
Results: map[SourceCode: 934: int
935: set_posix_acl(struct mnt_idmap *idmap, struct dentry *dentry,
936: int type, struct posix_acl *acl)
937: {
938: struct inode *inode = d_inode(dentry);
939:
940: if (!IS_POSIXACL(inode))
941: return -EOPNOTSUPP;
942: if (!inode->i_op->set_acl)
943: return -EOPNOTSUPP;
944:
945: if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
946: return acl ? -EACCES : 0;
947: if (!inode_owner_or_capable(idmap, inode))
948: return -EPERM;
949:
950: if (acl) {
951: int ret = posix_acl_valid(inode->i_sb->s_user_ns, acl);
952: if (ret)
953: return ret;
954: }
955: return inode->i_op->set_acl(idmap, dentry, acl, type);
956: }
SourceFile:fs/posix_acl.c]
|
| 12/2 |
2026/05/17 08:19 |
llm |
expert |
0m
Model:
Tokens:
input: 9882
output: 41
thoughts: 112
Thoughts: **Analyzing a Potential Inode Locking Issue**
Okay, so I'm looking at this kernel issue, and I'm wondering if the `inode->i_op->set_acl` function might be the culprit in unlocking the inode prematurely. The syzkaller report isn't giving me any clues about the filesystem involved, so that's the first thing I need to figure out. I know that `inode_unlock` gets called within `vfs_remove_acl`, and that's usually a good place to start digging. If `set_acl` had unlocked the inode before this, `inode_unlock` would generate the warning.
My immediate question is: Is there *any* filesystem out there that actually *does* unlock the inode within its `set_acl` implementation? Seems unlikely, but I need to rule it out. Time to dive into the implementations of `set_acl` and see what the code has to say.
|
| 13/2 |
2026/05/17 08:20 |
tool |
codesearch-find-references |
0m
Error:
Args: map[ContextFile:fs/posix_acl.c IncludeSnippetLines:0 Name:set_acl]
Results: map[References:<nil> TruncatedOutput:false]
|
| 14/2 |
2026/05/17 08:20 |
llm |
expert |
0m
Model:
Tokens:
input: 10256
output: 45
thoughts: 17
Thoughts: Okay, here's the summary, expressed as though I'm the one having these thoughts, targeting an expert audience:
**ACL Implementation Deep Dive**
Okay, so I'm looking at this inode operation structure, and my mind immediately hones in on `set_acl`. Ah, yes, there it is – a field within `struct inode_operations`. Right, so this is where the *actual* ACL setting mechanism is hooked into the core filesystem layer. Good, that confirms the design approach. Now, I need to consider exactly *how* this function interacts with the underlying storage and metadata. It's essentially the entry point for changing the access control list associated with an inode. Let's delve deeper into its interface...
|
| 15/2 |
2026/05/17 08:20 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/posix_acl.c IncludeSnippetLines:0 Name:inode_operations::set_acl]
Results: map[References:[map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:ovl_set_acl SourceFile:fs/overlayfs/inode.c SourceLine:533] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:posix_acl_chmod SourceFile:fs/posix_acl.c SourceLine:613] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:posix_acl_chmod SourceFile:fs/posix_acl.c SourceLine:626] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:set_posix_acl SourceFile:fs/posix_acl.c SourceLine:942] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:set_posix_acl SourceFile:fs/posix_acl.c SourceLine:955]] TruncatedOutput:false]
|
| 16/2 |
2026/05/17 08:20 |
llm |
expert |
0m
Model:
Tokens:
input: 10746
output: 24
thoughts: 26
Thoughts: Here's my thought process, summarized as you requested:
**Deconstructing the Kernel's ACL Implementation**
Okay, I'm staring at these reads, and they're not quite illuminating the full picture. What I need to grasp is the actual initialization of the `set_acl` field within `struct inode_operations`. It’s likely the core mechanism for ACL enforcement, so I need to find its concrete definition. I'm going to search for instances where `struct inode_operations` is defined and `set_acl` is actually initialized to understand the function’s practical implementation. That’s where I'll find the logic in action.
|
| 17/2 |
2026/05/17 08:20 |
tool |
grepper |
0m
Args: map[Expression:\.set_acl[[:space:]]*=]
Results: map[Output:fs/9p/vfs_inode_dotl.c=915=const struct inode_operations v9fs_dir_inode_operations_dotl = {
--
fs/9p/vfs_inode_dotl.c-930- .get_acl = v9fs_iop_get_acl,
fs/9p/vfs_inode_dotl.c:931: .set_acl = v9fs_iop_set_acl,
fs/9p/vfs_inode_dotl.c-932-};
--
fs/9p/vfs_inode_dotl.c=934=const struct inode_operations v9fs_file_inode_operations_dotl = {
--
fs/9p/vfs_inode_dotl.c-939- .get_acl = v9fs_iop_get_acl,
fs/9p/vfs_inode_dotl.c:940: .set_acl = v9fs_iop_set_acl,
fs/9p/vfs_inode_dotl.c-941-};
--
fs/bad_inode.c=163=static const struct inode_operations bad_inode_ops =
--
fs/bad_inode.c-184- .tmpfile = bad_inode_tmpfile,
fs/bad_inode.c:185: .set_acl = bad_inode_set_acl,
fs/bad_inode.c-186-};
--
fs/btrfs/inode.c=10681=static const struct inode_operations btrfs_dir_inode_operations = {
--
fs/btrfs/inode.c-10695- .get_inode_acl = btrfs_get_acl,
fs/btrfs/inode.c:10696: .set_acl = btrfs_set_acl,
fs/btrfs/inode.c-10697- .update_time = btrfs_update_time,
--
fs/btrfs/inode.c=10743=static const struct inode_operations btrfs_file_inode_operations = {
--
fs/btrfs/inode.c-10749- .get_inode_acl = btrfs_get_acl,
fs/btrfs/inode.c:10750: .set_acl = btrfs_set_acl,
fs/btrfs/inode.c-10751- .update_time = btrfs_update_time,
--
fs/btrfs/inode.c=10755=static const struct inode_operations btrfs_special_inode_operations = {
--
fs/btrfs/inode.c-10760- .get_inode_acl = btrfs_get_acl,
fs/btrfs/inode.c:10761: .set_acl = btrfs_set_acl,
fs/btrfs/inode.c-10762- .update_time = btrfs_update_time,
--
fs/ceph/dir.c=2239=const struct inode_operations ceph_dir_iops = {
--
fs/ceph/dir.c-2245- .get_inode_acl = ceph_get_acl,
fs/ceph/dir.c:2246: .set_acl = ceph_set_acl,
fs/ceph/dir.c-2247- .mknod = ceph_mknod,
--
fs/ceph/inode.c=280=const struct inode_operations ceph_file_iops = {
--
fs/ceph/inode.c-285- .get_inode_acl = ceph_get_acl,
fs/ceph/inode.c:286: .set_acl = ceph_set_acl,
fs/ceph/inode.c-287-};
--
fs/ecryptfs/inode.c=1152=const struct inode_operations ecryptfs_dir_iops = {
--
fs/ecryptfs/inode.c-1167- .get_acl = ecryptfs_get_acl,
fs/ecryptfs/inode.c:1168: .set_acl = ecryptfs_set_acl,
fs/ecryptfs/inode.c-1169-};
--
fs/ecryptfs/inode.c=1171=const struct inode_operations ecryptfs_main_iops = {
--
fs/ecryptfs/inode.c-1178- .get_acl = ecryptfs_get_acl,
fs/ecryptfs/inode.c:1179: .set_acl = ecryptfs_set_acl,
fs/ecryptfs/inode.c-1180-};
--
fs/ext2/file.c=332=const struct inode_operations ext2_file_inode_operations = {
--
fs/ext2/file.c-336- .get_inode_acl = ext2_get_acl,
fs/ext2/file.c:337: .set_acl = ext2_set_acl,
fs/ext2/file.c-338- .fiemap = ext2_fiemap,
--
fs/ext2/namei.c=407=const struct inode_operations ext2_dir_inode_operations = {
--
fs/ext2/namei.c-420- .get_inode_acl = ext2_get_acl,
fs/ext2/namei.c:421: .set_acl = ext2_set_acl,
fs/ext2/namei.c-422- .tmpfile = ext2_tmpfile,
--
fs/ext2/namei.c=427=const struct inode_operations ext2_special_inode_operations = {
--
fs/ext2/namei.c-431- .get_inode_acl = ext2_get_acl,
fs/ext2/namei.c:432: .set_acl = ext2_set_acl,
fs/ext2/namei.c-433-};
--
fs/ext4/file.c=981=const struct inode_operations ext4_file_inode_operations = {
--
fs/ext4/file.c-985- .get_inode_acl = ext4_get_acl,
fs/ext4/file.c:986: .set_acl = ext4_set_acl,
fs/ext4/file.c-987- .fiemap = ext4_fiemap,
--
fs/ext4/namei.c=4212=const struct inode_operations ext4_dir_inode_operations = {
--
fs/ext4/namei.c-4226- .get_inode_acl = ext4_get_acl,
fs/ext4/namei.c:4227: .set_acl = ext4_set_acl,
fs/ext4/namei.c-4228- .fiemap = ext4_fiemap,
--
fs/ext4/namei.c=4233=const struct inode_operations ext4_special_inode_operations = {
--
fs/ext4/namei.c-4237- .get_inode_acl = ext4_get_acl,
fs/ext4/namei.c:4238: .set_acl = ext4_set_acl,
fs/ext4/namei.c-4239-};
--
fs/f2fs/file.c=1204=const struct inode_operations f2fs_file_inode_operations = {
--
fs/f2fs/file.c-1207- .get_inode_acl = f2fs_get_acl,
fs/f2fs/file.c:1208: .set_acl = f2fs_set_acl,
fs/f2fs/file.c-1209- .listxattr = f2fs_listxattr,
--
fs/f2fs/namei.c=1352=const struct inode_operations f2fs_dir_inode_operations = {
--
fs/f2fs/namei.c-1365- .get_inode_acl = f2fs_get_acl,
fs/f2fs/namei.c:1366: .set_acl = f2fs_set_acl,
fs/f2fs/namei.c-1367- .listxattr = f2fs_listxattr,
--
fs/f2fs/namei.c=1380=const struct inode_operations f2fs_special_inode_operations = {
--
fs/f2fs/namei.c-1383- .get_inode_acl = f2fs_get_acl,
fs/f2fs/namei.c:1384: .set_acl = f2fs_set_acl,
fs/f2fs/namei.c-1385- .listxattr = f2fs_listxattr,
--
fs/fuse/dir.c=2400=static const struct inode_operations fuse_dir_inode_operations = {
--
fs/fuse/dir.c-2417- .get_acl = fuse_get_acl,
fs/fuse/dir.c:2418: .set_acl = fuse_set_acl,
fs/fuse/dir.c-2419- .fileattr_get = fuse_fileattr_get,
--
fs/fuse/dir.c=2434=static const struct inode_operations fuse_common_inode_operations = {
--
fs/fuse/dir.c-2440- .get_acl = fuse_get_acl,
fs/fuse/dir.c:2441: .set_acl = fuse_set_acl,
fs/fuse/dir.c-2442- .fileattr_get = fuse_fileattr_get,
--
fs/gfs2/inode.c=2293=static const struct inode_operations gfs2_file_iops = {
--
fs/gfs2/inode.c-2299- .get_inode_acl = gfs2_get_acl,
fs/gfs2/inode.c:2300: .set_acl = gfs2_set_acl,
fs/gfs2/inode.c-2301- .update_time = gfs2_update_time,
--
fs/gfs2/inode.c=2306=static const struct inode_operations gfs2_dir_iops = {
--
fs/gfs2/inode.c-2321- .get_inode_acl = gfs2_get_acl,
fs/gfs2/inode.c:2322: .set_acl = gfs2_set_acl,
fs/gfs2/inode.c-2323- .update_time = gfs2_update_time,
--
fs/jffs2/dir.c=56=const struct inode_operations jffs2_dir_inode_operations =
--
fs/jffs2/dir.c-67- .get_inode_acl = jffs2_get_acl,
fs/jffs2/dir.c:68: .set_acl = jffs2_set_acl,
fs/jffs2/dir.c-69- .setattr = jffs2_setattr,
--
fs/jffs2/file.c=69=const struct inode_operations jffs2_file_inode_operations =
--
fs/jffs2/file.c-71- .get_inode_acl = jffs2_get_acl,
fs/jffs2/file.c:72: .set_acl = jffs2_set_acl,
fs/jffs2/file.c-73- .setattr = jffs2_setattr,
--
fs/jfs/file.c=134=const struct inode_operations jfs_file_inode_operations = {
--
fs/jfs/file.c-140- .get_inode_acl = jfs_get_acl,
fs/jfs/file.c:141: .set_acl = jfs_set_acl,
fs/jfs/file.c-142-#endif
--
fs/jfs/namei.c=1523=const struct inode_operations jfs_dir_inode_operations = {
--
fs/jfs/namei.c-1538- .get_inode_acl = jfs_get_acl,
fs/jfs/namei.c:1539: .set_acl = jfs_set_acl,
fs/jfs/namei.c-1540-#endif
--
fs/nfs/nfs3proc.c=1041=static const struct inode_operations nfs3_dir_inode_operations = {
--
fs/nfs/nfs3proc.c-1057- .get_inode_acl = nfs3_get_acl,
fs/nfs/nfs3proc.c:1058: .set_acl = nfs3_set_acl,
fs/nfs/nfs3proc.c-1059-#endif
--
fs/nfs/nfs3proc.c=1062=static const struct inode_operations nfs3_file_inode_operations = {
--
fs/nfs/nfs3proc.c-1068- .get_inode_acl = nfs3_get_acl,
fs/nfs/nfs3proc.c:1069: .set_acl = nfs3_set_acl,
fs/nfs/nfs3proc.c-1070-#endif
--
fs/ntfs3/file.c=1546=const struct inode_operations ntfs_file_inode_operations = {
--
fs/ntfs3/file.c-1550- .get_acl = ntfs_get_acl,
fs/ntfs3/file.c:1551: .set_acl = ntfs_set_acl,
fs/ntfs3/file.c-1552- .fiemap = ntfs_fiemap,
--
fs/ntfs3/namei.c=505=const struct inode_operations ntfs_dir_inode_operations = {
--
fs/ntfs3/namei.c-515- .get_acl = ntfs_get_acl,
fs/ntfs3/namei.c:516: .set_acl = ntfs_set_acl,
fs/ntfs3/namei.c-517- .setattr = ntfs_setattr,
--
fs/ntfs3/namei.c=523=const struct inode_operations ntfs_special_inode_operations = {
--
fs/ntfs3/namei.c-527- .get_acl = ntfs_get_acl,
fs/ntfs3/namei.c:528: .set_acl = ntfs_set_acl,
fs/ntfs3/namei.c-529-};
--
fs/ocfs2/file.c=2783=const struct inode_operations ocfs2_file_iops = {
--
fs/ocfs2/file.c-2789- .get_inode_acl = ocfs2_iop_get_acl,
fs/ocfs2/file.c:2790: .set_acl = ocfs2_iop_set_acl,
fs/ocfs2/file.c-2791- .fileattr_get = ocfs2_fileattr_get,
--
fs/ocfs2/file.c=2795=const struct inode_operations ocfs2_special_file_iops = {
--
fs/ocfs2/file.c-2800- .get_inode_acl = ocfs2_iop_get_acl,
fs/ocfs2/file.c:2801: .set_acl = ocfs2_iop_set_acl,
fs/ocfs2/file.c-2802-};
--
fs/ocfs2/namei.c=2929=const struct inode_operations ocfs2_dir_iops = {
--
fs/ocfs2/namei.c-2944- .get_inode_acl = ocfs2_iop_get_acl,
fs/ocfs2/namei.c:2945: .set_acl = ocfs2_iop_set_acl,
fs/ocfs2/namei.c-2946- .fileattr_get = ocfs2_fileattr_get,
--
fs/orangefs/inode.c=947=static const struct inode_operations orangefs_file_inode_operations = {
fs/orangefs/inode.c-948- .get_inode_acl = orangefs_get_acl,
fs/orangefs/inode.c:949: .set_acl = orangefs_set_acl,
fs/orangefs/inode.c-950- .setattr = orangefs_setattr,
--
fs/orangefs/namei.c=417=const struct inode_operations orangefs_dir_inode_operations = {
--
fs/orangefs/namei.c-419- .get_inode_acl = orangefs_get_acl,
fs/orangefs/namei.c:420: .set_acl = orangefs_set_acl,
fs/orangefs/namei.c-421- .create = orangefs_create,
--
fs/overlayfs/dir.c=1460=const struct inode_operations ovl_dir_inode_operations = {
--
fs/overlayfs/dir.c-1475- .get_acl = ovl_get_acl,
fs/overlayfs/dir.c:1476: .set_acl = ovl_set_acl,
fs/overlayfs/dir.c-1477- .update_time = ovl_update_time,
--
fs/overlayfs/inode.c=729=static const struct inode_operations ovl_file_inode_operations = {
--
fs/overlayfs/inode.c-735- .get_acl = ovl_get_acl,
fs/overlayfs/inode.c:736: .set_acl = ovl_set_acl,
fs/overlayfs/inode.c-737- .update_time = ovl_update_time,
--
fs/overlayfs/inode.c=751=static const struct inode_operations ovl_special_inode_operations = {
--
fs/overlayfs/inode.c-757- .get_acl = ovl_get_acl,
fs/overlayfs/inode.c:758: .set_acl = ovl_set_acl,
fs/overlayfs/inode.c-759- .update_time = ovl_update_time,
--
fs/smb/client/cifsfs.c=1199=const struct inode_operations cifs_dir_inode_ops = {
--
fs/smb/client/cifsfs.c-1214- .get_acl = cifs_get_acl,
fs/smb/client/cifsfs.c:1215: .set_acl = cifs_set_acl,
fs/smb/client/cifsfs.c-1216-};
--
fs/smb/client/cifsfs.c=1218=const struct inode_operations cifs_file_inode_ops = {
--
fs/smb/client/cifsfs.c-1224- .get_acl = cifs_get_acl,
fs/smb/client/cifsfs.c:1225: .set_acl = cifs_set_acl,
fs/smb/client/cifsfs.c-1226-};
--
fs/smb/client/smb1ops.c=1389=struct smb_version_operations smb1_operations = {
--
fs/smb/client/smb1ops.c-1471- .get_acl_by_fid = get_cifs_acl_by_fid,
fs/smb/client/smb1ops.c:1472: .set_acl = set_cifs_acl,
fs/smb/client/smb1ops.c-1473- .make_node = cifs_make_node,
--
fs/smb/client/smb2ops.c=5353=struct smb_version_operations smb20_operations = {
--
fs/smb/client/smb2ops.c-5442- .get_acl_by_fid = get_smb2_acl_by_fid,
fs/smb/client/smb2ops.c:5443: .set_acl = set_smb2_acl,
fs/smb/client/smb2ops.c-5444- .next_header = smb2_next_header,
--
fs/smb/client/smb2ops.c=5455=struct smb_version_operations smb21_operations = {
--
fs/smb/client/smb2ops.c-5547- .get_acl_by_fid = get_smb2_acl_by_fid,
fs/smb/client/smb2ops.c:5548: .set_acl = set_smb2_acl,
fs/smb/client/smb2ops.c-5549- .next_header = smb2_next_header,
--
fs/smb/client/smb2ops.c=5559=struct smb_version_operations smb30_operations = {
--
fs/smb/client/smb2ops.c-5663- .get_acl_by_fid = get_smb2_acl_by_fid,
fs/smb/client/smb2ops.c:5664: .set_acl = set_smb2_acl,
fs/smb/client/smb2ops.c-5665- .next_header = smb2_next_header,
--
fs/smb/client/smb2ops.c=5675=struct smb_version_operations smb311_operations = {
--
fs/smb/client/smb2ops.c-5779- .get_acl_by_fid = get_smb2_acl_by_fid,
fs/smb/client/smb2ops.c:5780: .set_acl = set_smb2_acl,
fs/smb/client/smb2ops.c-5781- .next_header = smb2_next_header,
--
fs/xfs/xfs_iops.c=1281=static const struct inode_operations xfs_inode_operations = {
fs/xfs/xfs_iops.c-1282- .get_inode_acl = xfs_get_acl,
fs/xfs/xfs_iops.c:1283: .set_acl = xfs_set_acl,
fs/xfs/xfs_iops.c-1284- .getattr = xfs_vn_getattr,
--
fs/xfs/xfs_iops.c=1294=static const struct inode_operations xfs_dir_inode_operations = {
--
fs/xfs/xfs_iops.c-1310- .get_inode_acl = xfs_get_acl,
fs/xfs/xfs_iops.c:1311: .set_acl = xfs_set_acl,
fs/xfs/xfs_iops.c-1312- .getattr = xfs_vn_getattr,
--
fs/xfs/xfs_iops.c=1322=static const struct inode_operations xfs_dir_ci_inode_operations = {
--
fs/xfs/xfs_iops.c-1338- .get_inode_acl = xfs_get_acl,
fs/xfs/xfs_iops.c:1339: .set_acl = xfs_set_acl,
fs/xfs/xfs_iops.c-1340- .getattr = xfs_vn_getattr,
--
mm/shmem.c=5241=static const struct inode_operations shmem_inode_operations = {
--
mm/shmem.c-5245- .listxattr = shmem_listxattr,
mm/shmem.c:5246: .set_acl = simple_set_acl,
mm/shmem.c-5247- .fileattr_get = shmem_fileattr_get,
--
mm/shmem.c=5252=static const struct inode_operations shmem_dir_inode_operations = {
--
mm/shmem.c-5273- .setattr = shmem_setattr,
mm/shmem.c:5274: .set_acl = simple_set_acl,
mm/shmem.c-5275-#endif
--
mm/shmem.c=5278=static const struct inode_operations shmem_special_inode_operations = {
--
mm/shmem.c-5284- .setattr = shmem_setattr,
mm/shmem.c:5285: .set_acl = simple_set_acl,
mm/shmem.c-5286-#endif
]
|
| 18/2 |
2026/05/17 08:20 |
llm |
expert |
0m
Model:
Tokens:
input: 17537
output: 43
thoughts: 12
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:
**Investigating `ovl_set_acl`**
Alright, time to dive in. Let's get right to it – I need to take a look at the `ovl_set_acl` function. I have a hunch about something and this is the starting point. Let's see what we're working with here, what's going on under the hood, and how it's interacting with the rest of the overlay filesystem. I'll need to consider this in light of the more general architecture. Let's get to it.
|
| 19/2 |
2026/05/17 08:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/inode.c IncludeLines:true Name:ovl_set_acl]
Results: map[SourceCode: 523: int ovl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
524: struct posix_acl *acl, int type)
525: {
526: int err;
527: struct inode *inode = d_inode(dentry);
528: struct dentry *workdir = ovl_workdir(dentry);
529: struct inode *realinode = ovl_inode_real(inode);
530:
531: if (!IS_POSIXACL(d_inode(workdir)))
532: return -EOPNOTSUPP;
533: if (!realinode->i_op->set_acl)
534: return -EOPNOTSUPP;
535: if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
536: return acl ? -EACCES : 0;
537: if (!inode_owner_or_capable(&nop_mnt_idmap, inode))
538: return -EPERM;
539:
540: /*
541: * Check if sgid bit needs to be cleared (actual setacl operation will
542: * be done with mounter's capabilities and so that won't do it for us).
543: */
544: if (unlikely(inode->i_mode & S_ISGID) && type == ACL_TYPE_ACCESS &&
545: !in_group_p(inode->i_gid) &&
546: !capable_wrt_inode_uidgid(&nop_mnt_idmap, inode, CAP_FSETID)) {
547: struct iattr iattr = { .ia_valid = ATTR_KILL_SGID };
548:
549: err = ovl_setattr(&nop_mnt_idmap, dentry, &iattr);
550: if (err)
551: return err;
552: }
553:
554: return ovl_set_or_remove_acl(dentry, inode, acl, type);
555: }
SourceFile:fs/overlayfs/inode.c]
|
| 20/2 |
2026/05/17 08:20 |
llm |
expert |
0m
Model:
Tokens:
input: 18359
output: 42
thoughts: 45
Thoughts: **Digging into the `ovl_setattr` and ACL Interaction**
Okay, so I'm looking at how attributes are set in the overlay filesystem, specifically focusing on the interaction with ACLs. It seems `ovl_setattr` is being called *from within* `ovl_set_acl`. This immediately makes me wonder about locking. Does `ovl_setattr` handle any inode unlocking that might be necessary? If it's called from `ovl_set_acl`, a deeper understanding of the locking semantics here is critical to avoid race conditions and ensure data consistency.
Time to dive into the implementation of `ovl_setattr` itself. I need to understand its behavior thoroughly, particularly concerning any inode unlocks, to fully grasp the potential implications in this ACL setting context. Let's see what's actually going on in that function.
|
| 21/2 |
2026/05/17 08:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/inode.c IncludeLines:true Name:ovl_setattr]
Results: map[SourceCode: 21: int ovl_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
22: struct iattr *attr)
23: {
24: int err;
25: struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
26: bool full_copy_up = false;
27: struct dentry *upperdentry;
28:
29: err = setattr_prepare(&nop_mnt_idmap, dentry, attr);
30: if (err)
31: return err;
32:
33: if (attr->ia_valid & ATTR_SIZE) {
34: /* Truncate should trigger data copy up as well */
35: full_copy_up = true;
36: }
37:
38: if (!full_copy_up)
39: err = ovl_copy_up(dentry);
40: else
41: err = ovl_copy_up_with_data(dentry);
42: if (!err) {
43: struct inode *winode = NULL;
44:
45: upperdentry = ovl_dentry_upper(dentry);
46:
47: if (attr->ia_valid & ATTR_SIZE) {
48: winode = d_inode(upperdentry);
49: err = get_write_access(winode);
50: if (err)
51: goto out;
52: }
53:
54: if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
55: attr->ia_valid &= ~ATTR_MODE;
56:
57: /*
58: * We might have to translate ovl file into real file object
59: * once use cases emerge. For now, simply don't let underlying
60: * filesystem rely on attr->ia_file
61: */
62: attr->ia_valid &= ~ATTR_FILE;
63:
64: /*
65: * If open(O_TRUNC) is done, VFS calls ->setattr with ATTR_OPEN
66: * set. Overlayfs does not pass O_TRUNC flag to underlying
67: * filesystem during open -> do not pass ATTR_OPEN. This
68: * disables optimization in fuse which assumes open(O_TRUNC)
69: * already set file size to 0. But we never passed O_TRUNC to
70: * fuse. So by clearing ATTR_OPEN, fuse will be forced to send
71: * setattr request to server.
72: */
73: attr->ia_valid &= ~ATTR_OPEN;
74:
75: err = ovl_want_write(dentry);
76: if (err)
77: goto out_put_write;
78:
79: inode_lock(upperdentry->d_inode);
80: with_ovl_creds(dentry->d_sb)
81: err = ovl_do_notify_change(ofs, upperdentry, attr);
82: if (!err)
83: ovl_copyattr(dentry->d_inode);
84: inode_unlock(upperdentry->d_inode);
85: ovl_drop_write(dentry);
86:
87: out_put_write:
88: if (winode)
89: put_write_access(winode);
90: }
91: out:
92: return err;
93: }
SourceFile:fs/overlayfs/inode.c]
|
| 22/2 |
2026/05/17 08:20 |
llm |
expert |
0m
Model:
Tokens:
input: 19682
output: 47
thoughts: 166
Thoughts: **My Analysis of the OverlayFS Attribute Setting Process**
Okay, so I'm digging into how attributes are handled in the OverlayFS. My first observation is that `ovl_setattr` seems to be the key function, and it's responsible for locking and unlocking the `upperdentry->d_inode`. Now, hold on, the call to `ovl_setattr` uses a `dentry`, which is the overlayfs dentry. Interesting. I need to keep that in mind.
I see `ovl_setattr` calls `setattr_prepare`. I wonder if this function is where the core logic resides. Possibly, this is where the interesting actions occur.
Alright, here's an important connection. I just found that `ovl_set_acl` is actually calling `ovl_setattr` with the specific parameters of `&nop_mnt_idmap, dentry, &iattr`. That’s good to know. It helps me piece the puzzle together.
Now, let me make sure I'm following the locking behavior. Does `ovl_setattr` *unlock* the `dentry->d_inode`? Nope, it's actually `inode_lock(upperdentry->d_inode)` that locks the inode of the *upper* dentry.
Let me see, I’m seeing `ovl_set_or_remove_acl` is being called. I need to investigate that call to see how it ties into all of this. I'll need to go and examine that function to understand the flow.
|
| 23/2 |
2026/05/17 08:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/inode.c IncludeLines:true Name:ovl_set_or_remove_acl]
Results: map[SourceCode: 469: static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
470: struct posix_acl *acl, int type)
471: {
472: int err;
473: struct path realpath;
474: const char *acl_name;
475: struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
476: struct dentry *upperdentry = ovl_dentry_upper(dentry);
477: struct dentry *realdentry = upperdentry ?: ovl_dentry_lower(dentry);
478:
479: /*
480: * If ACL is to be removed from a lower file, check if it exists in
481: * the first place before copying it up.
482: */
483: acl_name = posix_acl_xattr_name(type);
484: if (!acl && !upperdentry) {
485: struct posix_acl *real_acl;
486:
487: ovl_path_lower(dentry, &realpath);
488: with_ovl_creds(dentry->d_sb)
489: real_acl = vfs_get_acl(mnt_idmap(realpath.mnt), realdentry, acl_name);
490: if (IS_ERR(real_acl)) {
491: err = PTR_ERR(real_acl);
492: goto out;
493: }
494: posix_acl_release(real_acl);
495: }
496:
497: if (!upperdentry) {
498: err = ovl_copy_up(dentry);
499: if (err)
500: goto out;
501:
502: realdentry = ovl_dentry_upper(dentry);
503: }
504:
505: err = ovl_want_write(dentry);
506: if (err)
507: goto out;
508:
509: with_ovl_creds(dentry->d_sb) {
510: if (acl)
511: err = ovl_do_set_acl(ofs, realdentry, acl_name, acl);
512: else
513: err = ovl_do_remove_acl(ofs, realdentry, acl_name);
514: }
515: ovl_drop_write(dentry);
516:
517: /* copy c/mtime */
518: ovl_copyattr(inode);
519: out:
520: return err;
521: }
SourceFile:fs/overlayfs/inode.c]
|
| 24/2 |
2026/05/17 08:20 |
llm |
expert |
0m
Model:
Tokens:
input: 21063
output: 45
thoughts: 21
Thoughts: Here's my thought process, as it relates to the code:
**ACL Removal in the Overlay Filesystem**
Okay, so I'm tracing the ACL removal path in this overlay filesystem implementation. I see that `ovl_do_remove_acl` is the function responsible. And, what immediately jumps out is that it's *calling* `vfs_remove_acl`. So, this tells me that the overlay filesystem isn't directly handling the underlying ACL removal itself. It's deferring to the virtual filesystem layer's generic function for removing ACLs. This makes sense from a design perspective; the overlay likely needs to handle any overlay-specific considerations like how to handle the ACL metadata on the lower and upper filesystems, but the core work of *actually* removing the ACL data structures is being offloaded. This saves a lot of duplicated code and keeps the overlay layer focused. I'll need to dig deeper to see how the overlay reconciles its behavior with that of vfs_remove_acl.
|
| 25/2 |
2026/05/17 08:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/inode.c IncludeLines:true Name:ovl_do_remove_acl]
Results: map[SourceCode: 358: static inline int ovl_do_remove_acl(struct ovl_fs *ofs, struct dentry *dentry,
359: const char *acl_name)
360: {
361: return vfs_remove_acl(ovl_upper_mnt_idmap(ofs), dentry, acl_name);
362: }
SourceFile:fs/overlayfs/overlayfs.h]
|
| 26/2 |
2026/05/17 08:20 |
llm |
expert |
0m
Model:
Tokens:
input: 21474
output: 38
thoughts: 342
Thoughts: **Debugging OverlayFS ACL Removal**
Okay, so I'm tracing through this `ovl_do_remove_acl` function and it's calling `vfs_remove_acl` on the *upper* dentry, right? Makes sense. But here's where it gets interesting... `vfs_remove_acl` locks the inode it's given. Right, so far so good.
Now, I'm remembering this is all triggered by `removexattr` on the overlayfs dentry itself. So, it's `removexattr` -> `vfs_remove_acl` -> `inode_lock(inode)` – and that `inode` is the overlayfs inode, got it. Then `vfs_remove_acl` calls `set_posix_acl`, which then calls `inode->i_op->set_acl`, which in this case is `ovl_set_acl`.
`ovl_set_acl` is calling `ovl_set_or_remove_acl`, which in turn, goes back to `ovl_do_remove_acl`! And that calls `vfs_remove_acl` on the *upper* dentry. Okay, so that second `vfs_remove_acl` on the *upper* dentry, it calls `inode_lock(upper_inode)`. Then it calls `set_posix_acl` on the *upper* dentry, then unlocks the `upper_inode` using `inode_unlock(upper_inode)`.
Hmm... where's the problem? The bug… the potential bug. `vfs_remove_acl` locks, does its thing, and unlocks. But, wait. It's called from `removexattr`. Let's take a closer look at `removexattr` in `fs/xattr.c` to see if anything jumps out.
|
| 27/2 |
2026/05/17 08:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/xattr.c IncludeLines:true Name:removexattr]
Results: map[SourceCode:1002: /*
1003: * Extended attribute REMOVE operations
1004: */
1005: static long
1006: removexattr(struct mnt_idmap *idmap, struct dentry *d, const char *name)
1007: {
1008: if (is_posix_acl_xattr(name))
1009: return vfs_remove_acl(idmap, d, name);
1010: return vfs_removexattr(idmap, d, name);
1011: }
SourceFile:fs/xattr.c]
|
| 28/2 |
2026/05/17 08:20 |
llm |
expert |
0m
Model:
Tokens:
input: 22440
output: 43
thoughts: 479
Thoughts: **Debugging a Persistent OverlayFS ACL Issue**
Okay, let me break this down. I see that `removexattr` eventually calls `vfs_remove_acl`. `vfs_remove_acl` is the one that's giving me trouble. It's supposed to lock the inode, then call `set_posix_acl`, and finally, unlock the inode. Standard stuff. The problem arises when this happens on an OverlayFS dentry, specifically with the `vfs_remove_acl` call.
So, for the overlayfs dentry, `vfs_remove_acl` locks the overlayfs inode, then calls `ovl_set_acl`, and unlocks the overlayfs inode. Inside `ovl_set_acl` it seems to call `ovl_set_or_remove_acl`, which then calls `ovl_do_remove_acl` and eventually calls `vfs_remove_acl` *again*, but this time on the *upper* dentry.
This second `vfs_remove_acl` call on the upper dentry, of course, locks the *upper* inode, calls `set_posix_acl` on the upper dentry, and finally unlocks the *upper* inode. Then `ovl_set_acl` returns. Then back in the initial call, `vfs_remove_acl` on the *overlayfs* dentry unlocks the *overlayfs* inode. Got it.
But where is the unlock of the unowned rwsem happening? The warning message points to `__up_write` within `vfs_remove_acl`, specifically at line 1251 in `fs/posix_acl.c`. That line is the `inode_unlock(inode);` call.
Okay, the crucial part of the warning is `DEBUG_RWSEMS_WARN_ON((rwsem_owner(sem) != current) && !rwsem_test_oflags(sem, RWSEM_NONSPINNABLE))`. So, the owner of the semaphore is *not* the current task, and that’s a problem. But how can `inode_unlock(inode)` be called if the current task isn't the owner? This is the core issue.
Could the inode itself have changed in some way? No, `inode` is a local variable assigned `d_inode(dentry);` inside `vfs_remove_acl`. `d_inode(dentry)` returns a pointer to the inode, which would have to be very broken to change the value it returns between calls. Locking is a void function that blocks. So locking failure is ruled out. Could someone else have somehow unlocked it? That seems odd.
I should probably re-examine how `ovl_set_acl` works. It seems a race condition might be happening. I need to make sure the overlay code is not unlocking the inode prematurely.
|
| 29/2 |
2026/05/17 08:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/inode.c IncludeLines:true Name:ovl_set_acl]
Results: map[SourceCode: 523: int ovl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
524: struct posix_acl *acl, int type)
525: {
526: int err;
527: struct inode *inode = d_inode(dentry);
528: struct dentry *workdir = ovl_workdir(dentry);
529: struct inode *realinode = ovl_inode_real(inode);
530:
531: if (!IS_POSIXACL(d_inode(workdir)))
532: return -EOPNOTSUPP;
533: if (!realinode->i_op->set_acl)
534: return -EOPNOTSUPP;
535: if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
536: return acl ? -EACCES : 0;
537: if (!inode_owner_or_capable(&nop_mnt_idmap, inode))
538: return -EPERM;
539:
540: /*
541: * Check if sgid bit needs to be cleared (actual setacl operation will
542: * be done with mounter's capabilities and so that won't do it for us).
543: */
544: if (unlikely(inode->i_mode & S_ISGID) && type == ACL_TYPE_ACCESS &&
545: !in_group_p(inode->i_gid) &&
546: !capable_wrt_inode_uidgid(&nop_mnt_idmap, inode, CAP_FSETID)) {
547: struct iattr iattr = { .ia_valid = ATTR_KILL_SGID };
548:
549: err = ovl_setattr(&nop_mnt_idmap, dentry, &iattr);
550: if (err)
551: return err;
552: }
553:
554: return ovl_set_or_remove_acl(dentry, inode, acl, type);
555: }
SourceFile:fs/overlayfs/inode.c]
|
| 30/2 |
2026/05/17 08:20 |
llm |
expert |
0m
Model:
Tokens:
input: 24206
output: 37
thoughts: 162
Thoughts: **OverlayFS Attribute Setting: A Deep Dive**
Okay, so I'm tracing this `ovl_setattr` function, and the first thing that jumps out is that it's operating on a `dentry`! Interesting. That means we're dealing with the directory entry and not just the raw inode.
Right, so `ovl_setattr` calls `setattr_prepare`, which makes sense as a pre-processing step. Then we have `ovl_copy_up`, which indicates data might be moving to an upper layer, as expected in an overlay filesystem. Following that, the `upperdentry->d_inode` is *locked* via `inode_lock`. That's a critical point for concurrency control. Then, `ovl_do_notify_change` is called. Finally, the upper inode is *unlocked* using `inode_unlock`.
I need to confirm if `ovl_setattr` itself is responsible for unlocking, as my immediate reaction is that the `upperdentry->d_inode` is locked/unlocked internally within the function. Let's clarify. Yes, `ovl_setattr` *does* lock and unlock the `upperdentry->d_inode`.
Ah, of course. `ovl_setattr` is defined as an `inode_operations` method. That aligns with the overlayfs architecture perfectly. It's essentially implementing the inode behavior. A standard `setattr` operation usually happens with the inode already locked! This is important for understanding the overall locking strategy.
Now, let's take a closer look at `notify_change`. It's a key part of the process, and I'll need to understand how it interacts with the rest of the mechanism to ensure the file system behaves correctly.
|
| 31/2 |
2026/05/17 08:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/attr.c IncludeLines:true Name:notify_change]
Results: map[SourceCode: 400: /**
401: * notify_change - modify attributes of a filesystem object
402: * @idmap: idmap of the mount the inode was found from
403: * @dentry: object affected
404: * @attr: new attributes
405: * @delegated_inode: returns inode, if the inode is delegated
406: *
407: * The caller must hold the i_rwsem exclusively on the affected object.
408: *
409: * If notify_change discovers a delegation in need of breaking,
410: * it will return -EWOULDBLOCK and return a reference to the inode in
411: * delegated_inode. The caller should then break the delegation and
412: * retry. Because breaking a delegation may take a long time, the
413: * caller should drop the i_rwsem before doing so.
414: *
415: * Alternatively, a caller may pass NULL for delegated_inode. This may
416: * be appropriate for callers that expect the underlying filesystem not
417: * to be NFS exported. Also, passing NULL is fine for callers holding
418: * the file open for write, as there can be no conflicting delegation in
419: * that case.
420: *
421: * If the inode has been found through an idmapped mount the idmap of
422: * the vfsmount must be passed through @idmap. This function will then
423: * take care to map the inode according to @idmap before checking
424: * permissions. On non-idmapped mounts or if permission checking is to be
425: * performed on the raw inode simply pass @nop_mnt_idmap.
426: */
427: int notify_change(struct mnt_idmap *idmap, struct dentry *dentry,
428: struct iattr *attr, struct delegated_inode *delegated_inode)
429: {
430: struct inode *inode = dentry->d_inode;
431: umode_t mode = inode->i_mode;
432: int error;
433: struct timespec64 now;
434: unsigned int ia_valid = attr->ia_valid;
435:
436: WARN_ON_ONCE(!inode_is_locked(inode));
437:
438: error = may_setattr(idmap, inode, ia_valid);
439: if (error)
440: return error;
441:
442: if ((ia_valid & ATTR_MODE)) {
443: /*
444: * Don't allow changing the mode of symlinks:
445: *
446: * (1) The vfs doesn't take the mode of symlinks into account
447: * during permission checking.
448: * (2) This has never worked correctly. Most major filesystems
449: * did return EOPNOTSUPP due to interactions with POSIX ACLs
450: * but did still updated the mode of the symlink.
451: * This inconsistency led system call wrapper providers such
452: * as libc to block changing the mode of symlinks with
453: * EOPNOTSUPP already.
454: * (3) To even do this in the first place one would have to use
455: * specific file descriptors and quite some effort.
456: */
457: if (S_ISLNK(inode->i_mode))
458: return -EOPNOTSUPP;
459:
460: /* Flag setting protected by i_rwsem */
461: if (is_sxid(attr->ia_mode))
462: inode->i_flags &= ~S_NOSEC;
463: }
464:
465: now = current_time(inode);
466:
467: if (ia_valid & ATTR_ATIME_SET)
468: attr->ia_atime = timestamp_truncate(attr->ia_atime, inode);
469: else
470: attr->ia_atime = now;
471: if (ia_valid & ATTR_CTIME_SET)
472: attr->ia_ctime = timestamp_truncate(attr->ia_ctime, inode);
473: else
474: attr->ia_ctime = now;
475: if (ia_valid & ATTR_MTIME_SET)
476: attr->ia_mtime = timestamp_truncate(attr->ia_mtime, inode);
477: else
478: attr->ia_mtime = now;
479:
480: if (ia_valid & ATTR_KILL_PRIV) {
481: error = security_inode_need_killpriv(dentry);
482: if (error < 0)
483: return error;
484: if (error == 0)
485: ia_valid = attr->ia_valid &= ~ATTR_KILL_PRIV;
486: }
487:
488: /*
489: * We now pass ATTR_KILL_S*ID to the lower level setattr function so
490: * that the function has the ability to reinterpret a mode change
491: * that's due to these bits. This adds an implicit restriction that
492: * no function will ever call notify_change with both ATTR_MODE and
493: * ATTR_KILL_S*ID set.
494: */
495: if ((ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) &&
496: (ia_valid & ATTR_MODE))
497: BUG();
498:
499: if (ia_valid & ATTR_KILL_SUID) {
500: if (mode & S_ISUID) {
501: ia_valid = attr->ia_valid |= ATTR_MODE;
502: attr->ia_mode = (inode->i_mode & ~S_ISUID);
503: }
504: }
505: if (ia_valid & ATTR_KILL_SGID) {
506: if (mode & S_ISGID) {
507: if (!(ia_valid & ATTR_MODE)) {
508: ia_valid = attr->ia_valid |= ATTR_MODE;
509: attr->ia_mode = inode->i_mode;
510: }
511: attr->ia_mode &= ~S_ISGID;
512: }
513: }
514: if (!(attr->ia_valid & ~(ATTR_KILL_SUID | ATTR_KILL_SGID)))
515: return 0;
516:
517: /*
518: * Verify that uid/gid changes are valid in the target
519: * namespace of the superblock.
520: */
521: if (ia_valid & ATTR_UID &&
522: !vfsuid_has_fsmapping(idmap, inode->i_sb->s_user_ns,
523: attr->ia_vfsuid))
524: return -EOVERFLOW;
525: if (ia_valid & ATTR_GID &&
526: !vfsgid_has_fsmapping(idmap, inode->i_sb->s_user_ns,
527: attr->ia_vfsgid))
528: return -EOVERFLOW;
529:
530: /* Don't allow modifications of files with invalid uids or
531: * gids unless those uids & gids are being made valid.
532: */
533: if (!(ia_valid & ATTR_UID) &&
534: !vfsuid_valid(i_uid_into_vfsuid(idmap, inode)))
535: return -EOVERFLOW;
536: if (!(ia_valid & ATTR_GID) &&
537: !vfsgid_valid(i_gid_into_vfsgid(idmap, inode)))
538: return -EOVERFLOW;
539:
540: error = security_inode_setattr(idmap, dentry, attr);
541: if (error)
542: return error;
543:
544: /*
545: * If ATTR_DELEG is set, then these attributes are being set on
546: * behalf of the holder of a write delegation. We want to avoid
547: * breaking the delegation in this case.
548: */
549: if (!(ia_valid & ATTR_DELEG)) {
550: error = try_break_deleg(inode, delegated_inode);
551: if (error)
552: return error;
553: }
554:
555: if (inode->i_op->setattr)
556: error = inode->i_op->setattr(idmap, dentry, attr);
557: else
558: error = simple_setattr(idmap, dentry, attr);
559:
560: if (!error) {
561: fsnotify_change(dentry, ia_valid);
562: security_inode_post_setattr(idmap, dentry, ia_valid);
563: }
564:
565: return error;
566: }
SourceFile:fs/attr.c]
|
| 32/2 |
2026/05/17 08:20 |
llm |
expert |
0m
Model:
Tokens:
input: 27512
output: 45
thoughts: 625
Thoughts: **Analyzing the OverlayFS ACL Setting Path**
Okay, let's break this down. My initial thought was that `ovl_set_acl` directly impacts the overlayfs dentry, and thus calls `ovl_setattr` on it. I then noted a potential for a race condition, thinking `setattr_prepare` might be where the lock is, but that's not the case. It looks like `ovl_setattr` calls `ovl_do_notify_change` on the *upper* dentry. That seemed odd, as in, why not lock the upper dentry, first?
Ah, right, `ovl_setattr` *does* lock the upper dentry *before* calling `ovl_do_notify_change`. That's good. But I'm still trying to figure out if there's an inode locking issue here... Specifically, what about the *overlayfs* inode itself?
`vfs_remove_acl` locks the overlayfs inode, then calls `ovl_set_acl`. `ovl_set_acl`, then, calls `ovl_setattr` on the overlayfs dentry. The crucial bit here is that `ovl_setattr` *doesn't* lock the overlayfs inode. It's assuming it's already locked upstream. It does call `setattr_prepare`, but as we saw, that doesn't lock anything. It calls `ovl_copy_up`, then locks the upper dentry, and finally calls `ovl_do_notify_change` and unlocks the upper dentry.
So, where is the bug? The `DEBUG_RWSEMS_WARN_ON` check is key. It signals a problem when the inode's lock is released by someone who *didn't* originally acquire it. But `vfs_remove_acl` *did* lock the overlayfs inode. How can it possibly be unlocked by a different process?
Did `ovl_set_acl` or, perhaps, deeper, `ovl_setattr` unlock the inode? `ovl_setattr` doesn't seem to touch the dentry's inode directly, except for the `ovl_copyattr` function. My hunch is that `ovl_copy_up` *might* unlock the inode. I should check that next.
|
| 33/2 |
2026/05/17 08:21 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/copy_up.c IncludeLines:true Name:ovl_copy_up]
Results: map[SourceCode:1280: int ovl_copy_up(struct dentry *dentry)
1281: {
1282: return ovl_copy_up_flags(dentry, 0);
1283: }
SourceFile:fs/overlayfs/copy_up.c]
|
| 34/2 |
2026/05/17 08:21 |
llm |
expert |
0m
Model:
Tokens:
input: 28783
output: 47
thoughts: 14
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Analyzing `ovl_copy_up_flags`**
Alright, let's dive into this `ovl_copy_up_flags` function. I need to refresh my memory on the specifics of how the overlay filesystem handles this. My initial thought is to quickly ascertain whether this impacts performance, because copy-up operations are always a potential bottleneck. I'm going to quickly recall the possible flags this handles. Are we talking about data-copy versus reflink, metadata only, or potentially even some more esoteric flags related to extended attributes or access control lists? A quick review of the relevant source code is in order. I'll need to confirm if it impacts the default behavior of `ovl_copy_up()` and the different situations it deals with when dealing with lower layers. I need to consider all cases where the file or directory can exist. I need to make sure I am thinking about how these flags may change the behavior of the overlay in relation to the behavior of the lower layers.
|
| 35/2 |
2026/05/17 08:21 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/copy_up.c IncludeLines:true Name:ovl_copy_up_flags]
Results: map[SourceCode:1201: static int ovl_copy_up_flags(struct dentry *dentry, int flags)
1202: {
1203: int err = 0;
1204: bool disconnected = (dentry->d_flags & DCACHE_DISCONNECTED);
1205:
1206: /*
1207: * With NFS export, copy up can get called for a disconnected non-dir.
1208: * In this case, we will copy up lower inode to index dir without
1209: * linking it to upper dir.
1210: */
1211: if (WARN_ON(disconnected && d_is_dir(dentry)))
1212: return -EIO;
1213:
1214: /*
1215: * We may not need lowerdata if we are only doing metacopy up, but it is
1216: * not very important to optimize this case, so do lazy lowerdata lookup
1217: * before any copy up, so we can do it before taking ovl_inode_lock().
1218: */
1219: err = ovl_verify_lowerdata(dentry);
1220: if (err)
1221: return err;
1222:
1223: while (!err) {
1224: struct dentry *next;
1225: struct dentry *parent = NULL;
1226:
1227: if (ovl_already_copied_up(dentry, flags))
1228: break;
1229:
1230: next = dget(dentry);
1231: /* find the topmost dentry not yet copied up */
1232: for (; !disconnected;) {
1233: parent = dget_parent(next);
1234:
1235: if (ovl_dentry_upper(parent))
1236: break;
1237:
1238: dput(next);
1239: next = parent;
1240: }
1241:
1242: with_ovl_creds(dentry->d_sb)
1243: err = ovl_copy_up_one(parent, next, flags);
1244:
1245: dput(parent);
1246: dput(next);
1247: }
1248:
1249: return err;
1250: }
SourceFile:fs/overlayfs/copy_up.c]
|
| 36/2 |
2026/05/17 08:21 |
llm |
expert |
0m
Model:
Tokens:
input: 29778
output: 47
thoughts: 15
Thoughts: Here's the summary, assuming I'm an expert:
**Unpacking `ovl_copy_up_one` and Inode Locking**
Okay, so I'm looking at `ovl_copy_up_one`, and my first thought is: does this function, in its operation, inherently unlock the inode? That's the critical question I need to answer. I know the overlay filesystem code, and I know the potential for race conditions is a constant concern. If the `ovl_copy_up_one` function does *not* unlock the inode implicitly as part of its execution, I need to understand *how* the calling code is handling the locking, and whether the locking is sufficient. We could be leaving a window open for corruption or unexpected behavior. I need to trace this function's control flow carefully and determine exactly where the inode is locked and unlocked and, critically, how those states interact with any other potential operations on the file. Is it released at the beginning or at the end of the operation? Is there a separate function call responsible for unlocking? I'm betting that the inode lock has to be handled on either side of the function call, for performance and safety.
|
| 37/2 |
2026/05/17 08:21 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/copy_up.c IncludeLines:true Name:ovl_copy_up_one]
Results: map[SourceCode:1123: static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
1124: int flags)
1125: {
1126: int err;
1127: DEFINE_DELAYED_CALL(done);
1128: struct path parentpath;
1129: struct ovl_copy_up_ctx ctx = {
1130: .parent = parent,
1131: .dentry = dentry,
1132: .workdir = ovl_workdir(dentry),
1133: };
1134:
1135: if (WARN_ON(!ctx.workdir))
1136: return -EROFS;
1137:
1138: ovl_path_lower(dentry, &ctx.lowerpath);
1139: err = vfs_getattr(&ctx.lowerpath, &ctx.stat,
1140: STATX_BASIC_STATS, AT_STATX_SYNC_AS_STAT);
1141: if (err)
1142: return err;
1143:
1144: if (!kuid_has_mapping(current_user_ns(), ctx.stat.uid) ||
1145: !kgid_has_mapping(current_user_ns(), ctx.stat.gid))
1146: return -EOVERFLOW;
1147:
1148: /*
1149: * With "fsync=strict", we fsync after final metadata copyup, for
1150: * both regular files and directories to get atomic copyup semantics
1151: * on filesystems that do not use strict metadata ordering (e.g. ubifs).
1152: *
1153: * By default, we want to avoid fsync on all meta copyup, because
1154: * that will hurt performance of workloads such as chown -R, so we
1155: * only fsync on data copyup as legacy behavior.
1156: */
1157: ctx.metadata_fsync = ovl_should_sync_metadata(OVL_FS(dentry->d_sb)) &&
1158: (S_ISREG(ctx.stat.mode) || S_ISDIR(ctx.stat.mode));
1159: ctx.metacopy = ovl_need_meta_copy_up(dentry, ctx.stat.mode, flags);
1160:
1161: if (parent) {
1162: ovl_path_upper(parent, &parentpath);
1163: ctx.destdir = parentpath.dentry;
1164:
1165: err = vfs_getattr(&parentpath, &ctx.pstat,
1166: STATX_ATIME | STATX_MTIME,
1167: AT_STATX_SYNC_AS_STAT);
1168: if (err)
1169: return err;
1170: }
1171:
1172: /* maybe truncate regular file. this has no effect on dirs */
1173: if (flags & O_TRUNC)
1174: ctx.stat.size = 0;
1175:
1176: if (S_ISLNK(ctx.stat.mode)) {
1177: ctx.link = vfs_get_link(ctx.lowerpath.dentry, &done);
1178: if (IS_ERR(ctx.link))
1179: return PTR_ERR(ctx.link);
1180: }
1181:
1182: err = ovl_copy_up_start(dentry, flags);
1183: /* err < 0: interrupted, err > 0: raced with another copy-up */
1184: if (unlikely(err)) {
1185: if (err > 0)
1186: err = 0;
1187: } else {
1188: if (!ovl_dentry_upper(dentry))
1189: err = ovl_do_copy_up(&ctx);
1190: if (!err && parent && !ovl_dentry_has_upper_alias(dentry))
1191: err = ovl_link_up(&ctx);
1192: if (!err && ovl_dentry_needs_data_copy_up_locked(dentry, flags))
1193: err = ovl_copy_up_meta_inode_data(&ctx);
1194: ovl_copy_up_end(dentry);
1195: }
1196: do_delayed_call(&done);
1197:
1198: return err;
1199: }
SourceFile:fs/overlayfs/copy_up.c]
|
| 38/2 |
2026/05/17 08:21 |
llm |
expert |
0m
Model:
Tokens:
input: 31401
output: 47
thoughts: 33
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Kernel Investigation: OverlayFS Copy-Up Lock**
Hold on a second, my intuition is screaming a question about the locking behavior within the `ovl_copy_up_start` function, specifically regarding the overlayfs inode. It feels like something significant is happening there. I need to confirm whether `ovl_copy_up_start` *indeed* takes a lock on the overlayfs inode. This is critical for understanding concurrent access and potential race conditions in that critical path. Okay, time to dive into the code... let's get eyes on `ovl_copy_up_start` and see what it's really doing under the hood.
|
| 39/2 |
2026/05/17 08:21 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/copy_up.c IncludeLines:true Name:ovl_copy_up_start]
Results: map[SourceCode: 726: /*
727: * The copy up "transaction" keeps an elevated mnt write count on upper mnt,
728: * but leaves taking freeze protection on upper sb to lower level helpers.
729: */
730: int ovl_copy_up_start(struct dentry *dentry, int flags)
731: {
732: struct inode *inode = d_inode(dentry);
733: int err;
734:
735: err = ovl_inode_lock_interruptible(inode);
736: if (err)
737: return err;
738:
739: if (ovl_already_copied_up_locked(dentry, flags))
740: err = 1; /* Already copied up */
741: else
742: err = ovl_get_write_access(dentry);
743: if (err)
744: goto out_unlock;
745:
746: return 0;
747:
748: out_unlock:
749: ovl_inode_unlock(inode);
750: return err;
751: }
SourceFile:fs/overlayfs/util.c]
|
| 40/2 |
2026/05/17 08:21 |
llm |
expert |
0m
Model:
Tokens:
input: 32021
output: 46
thoughts: 57
Thoughts: **Delving into OverlayFS Inode Locking**
Okay, so I'm looking at this `ovl_inode_lock_interruptible` function, and my initial thought is, "Is this what's responsible for locking the overlayfs inode?" That's the obvious first step, right? Gotta get a handle on how this locking mechanism works. But then, a slightly more specific question pops into my head. Wait a minute, isn't `ovl_inode_lock_interruptible` actually locking `inode->i_rwsem`? That seems more likely, given my experience with how these things are generally handled in the kernel. Alright, before I jump to any conclusions, I need to confirm. Let's dive into the code for `ovl_inode_lock_interruptible` itself and see what the function actually does. I need to understand this locking behavior thoroughly.
|
| 41/2 |
2026/05/17 08:21 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/util.c IncludeLines:true Name:ovl_inode_lock_interruptible]
Results: map[SourceCode: 712: static inline int ovl_inode_lock_interruptible(struct inode *inode)
713: {
714: return mutex_lock_interruptible(&OVL_I(inode)->lock);
715: }
SourceFile:fs/overlayfs/overlayfs.h]
|
| 42/2 |
2026/05/17 08:21 |
llm |
expert |
0m
Model:
Tokens:
input: 32409
output: 47
thoughts: 561
Thoughts: **Analyzing the OverlayFS ACL Bug**
Okay, so the initial thought was wrong – `ovl_copy_up` doesn't unlock `inode->i_rwsem`. That's a mutex, not the read-write semaphore. Let's re-examine the bug. It looks like `vfs_remove_acl` holds `inode->i_rwsem`. Then, it calls `set_posix_acl`, which in turn calls the filesystem-specific `set_acl` operation. In the overlay case, that's `ovl_set_acl`.
Now, digging into `ovl_set_acl`, there's that conditional block related to the S_ISGID bit and ACLs. Critically, if that condition is met, `ovl_setattr` gets called. Now, *that's* the interesting part. `ovl_setattr` calls `setattr_prepare`, then `ovl_copy_up`, and finally `ovl_do_notify_change`. Does `ovl_setattr` itself release `inode->i_rwsem`? No, I don't see any explicit unlocks in `ovl_setattr`.
But wait. `ovl_setattr` is an `inode_operations` method. Usually, the `setattr` operation is invoked through `notify_change`, and the caller is *supposed* to be holding `inode->i_rwsem`. Does `ovl_setattr` *expect* `inode->i_rwsem` to be held? Yes, `notify_change` asserts that it is held by the caller.
Okay, so `ovl_setattr` locks the `upperdentry->d_inode` and then calls `ovl_do_notify_change` on the upper dentry. Does `ovl_do_notify_change` release the overlayfs inode? No. So, what about `ovl_set_or_remove_acl` - does it release the overlayfs inode? Let's check `ovl_set_or_remove_acl` one more time.
|
| 43/2 |
2026/05/17 08:21 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/inode.c IncludeLines:true Name:ovl_set_or_remove_acl]
Results: map[SourceCode: 469: static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
470: struct posix_acl *acl, int type)
471: {
472: int err;
473: struct path realpath;
474: const char *acl_name;
475: struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
476: struct dentry *upperdentry = ovl_dentry_upper(dentry);
477: struct dentry *realdentry = upperdentry ?: ovl_dentry_lower(dentry);
478:
479: /*
480: * If ACL is to be removed from a lower file, check if it exists in
481: * the first place before copying it up.
482: */
483: acl_name = posix_acl_xattr_name(type);
484: if (!acl && !upperdentry) {
485: struct posix_acl *real_acl;
486:
487: ovl_path_lower(dentry, &realpath);
488: with_ovl_creds(dentry->d_sb)
489: real_acl = vfs_get_acl(mnt_idmap(realpath.mnt), realdentry, acl_name);
490: if (IS_ERR(real_acl)) {
491: err = PTR_ERR(real_acl);
492: goto out;
493: }
494: posix_acl_release(real_acl);
495: }
496:
497: if (!upperdentry) {
498: err = ovl_copy_up(dentry);
499: if (err)
500: goto out;
501:
502: realdentry = ovl_dentry_upper(dentry);
503: }
504:
505: err = ovl_want_write(dentry);
506: if (err)
507: goto out;
508:
509: with_ovl_creds(dentry->d_sb) {
510: if (acl)
511: err = ovl_do_set_acl(ofs, realdentry, acl_name, acl);
512: else
513: err = ovl_do_remove_acl(ofs, realdentry, acl_name);
514: }
515: ovl_drop_write(dentry);
516:
517: /* copy c/mtime */
518: ovl_copyattr(inode);
519: out:
520: return err;
521: }
SourceFile:fs/overlayfs/inode.c]
|
| 44/2 |
2026/05/17 08:21 |
llm |
expert |
0m
Model:
Tokens:
input: 34304
output: 43
thoughts: 1118
Thoughts: **Analyzing a Potential Inode Lock/Unlock Mismatch in OverlayFS ACL Handling**
Okay, let's break this down. I'm seeing a potential race condition or incorrect locking/unlocking sequence in OverlayFS, specifically when dealing with ACLs. Initially, I was focusing on the `ovl_do_remove_acl` path, which calls `vfs_remove_acl` on the upper dentry. My understanding was that `vfs_remove_acl` on the upper inode would handle its own locking/unlocking, including delegation breaks, and that it was fine since we're dealing with the *upper* inode.
Then, I shifted gears and considered what happens when `vfs_remove_acl` is called on the *overlayfs* dentry. It locks the overlayfs inode, calls `set_posix_acl` (which then calls `ovl_set_acl`), and unlocks. Initially, I didn't see an issue because `vfs_remove_acl` would work on the *upper* dentry. I had it in my mind that `vfs_remove_acl` *only* locks and unlocks the upper inode, and there was no way it would touch the overlayfs inode.
However, I started to question if `ovl_set_acl` or a related function could somehow *inadvertently* unlock the overlayfs inode *before* `vfs_remove_acl` finishes. I looked at what `ovl_setattr` does, noting that it calls `ovl_do_notify_change` on the upper dentry, which shouldn't unlock the overlayfs inode.
Now, I'm digging deeper into the call trace of the warning. The crucial bit is that `vfs_remove_acl` is called from `removexattr`. The warning is specifically at `inode_unlock` *within* `vfs_remove_acl`. This means we're unlocking an inode that was either not locked by `vfs_remove_acl` or that had been unlocked already. The only way I can see this happening is if `set_posix_acl` or something called by it, like `ovl_set_acl` or `ovl_setattr` and related functions, were releasing the overlayfs inode lock. I need to know where the overlayfs inode gets locked.
I went back to look at `ovl_set_acl` and noticed the special `S_ISGID` handling, where `ovl_setattr` is called. Now I checked `ovl_copy_up` because that's when things might get tricky. I verified that `ovl_copy_up_start` is where the overlayfs inode gets locked and unlocked. I then checked `ovl_copy_up` to see if it drops the inode lock. Nope, it shouldn't.
So, I have to figure out if there is some scenario where `set_posix_acl` might be called on a filesystem that *does* drop the inode lock in the set ACL flow. I'll focus on `posix_acl.c:1251` and work my way outward. I'm going to carefully review the locking primitives and ensure that the overlayfs inode's lock is consistently held where it needs to be, and never dropped prematurely. The fact that the call trace points to the `inode_unlock` within `vfs_remove_acl` is a strong indicator of a lock imbalance, so I'm honing in on the calls between `set_posix_acl` and `vfs_remove_acl`.
|
| 45/2 |
2026/05/17 08:21 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/posix_acl.c IncludeLines:true Name:vfs_remove_acl]
Results: map[SourceCode:1200: /**
1201: * vfs_remove_acl - remove posix acls
1202: * @idmap: idmap of the mount
1203: * @dentry: the dentry based on which to retrieve the posix acls
1204: * @acl_name: the name of the posix acl
1205: *
1206: * This function removes posix acls.
1207: *
1208: * Return: On success 0, on error negative errno.
1209: */
1210: int vfs_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
1211: const char *acl_name)
1212: {
1213: int acl_type;
1214: int error;
1215: struct inode *inode = d_inode(dentry);
1216: struct delegated_inode delegated_inode = { };
1217:
1218: acl_type = posix_acl_type(acl_name);
1219: if (acl_type < 0)
1220: return -EINVAL;
1221:
1222: retry_deleg:
1223: inode_lock(inode);
1224:
1225: /*
1226: * We only care about restrictions the inode struct itself places upon
1227: * us otherwise POSIX ACLs aren't subject to any VFS restrictions.
1228: */
1229: error = may_write_xattr(idmap, inode);
1230: if (error)
1231: goto out_inode_unlock;
1232:
1233: error = security_inode_remove_acl(idmap, dentry, acl_name);
1234: if (error)
1235: goto out_inode_unlock;
1236:
1237: error = try_break_deleg(inode, &delegated_inode);
1238: if (error)
1239: goto out_inode_unlock;
1240:
1241: if (likely(!is_bad_inode(inode)))
1242: error = set_posix_acl(idmap, dentry, acl_type, NULL);
1243: else
1244: error = -EIO;
1245: if (!error) {
1246: fsnotify_xattr(dentry);
1247: security_inode_post_remove_acl(idmap, dentry, acl_name);
1248: }
1249:
1250: out_inode_unlock:
1251: inode_unlock(inode);
1252:
1253: if (is_delegated(&delegated_inode)) {
1254: error = break_deleg_wait(&delegated_inode);
1255: if (!error)
1256: goto retry_deleg;
1257: }
1258:
1259: return error;
1260: }
SourceFile:fs/posix_acl.c]
|
| 46/2 |
2026/05/17 08:21 |
llm |
expert |
0m
Model:
Tokens:
input: 37118
output: 37
thoughts: 200
Thoughts: **Analyzing the Delegation Breaking Process**
Okay, so I'm tracing through this delegation breaking sequence. The key thing that jumps out is this `try_break_deleg` function. It seems to return `-EWOULDBLOCK` if there's an active delegation. Then, the flow jumps into `out_inode_unlock`, the inode gets unlocked, and `break_deleg_wait` is called. Afterwards it goes into `retry_deleg`, which re-locks the inode.
My initial thought was, could `try_break_deleg` handle the inode unlocking? It would streamline things a bit. But wait, let's look at the implementation of `try_break_deleg` itself:
```c
static inline int try_break_deleg(struct inode *inode,
struct delegated_inode *di)
{
int ret;
ret = break_deleg(inode, LEASE_BREAK_NONBLOCK);
if (ret == -EWOULDBLOCK && di) {
di->di_inode = inode;
ihold(inode);
}
return ret;
}
```
No, `try_break_deleg` clearly delegates the work to `break_deleg`. So, the question becomes, does `break_deleg` do the unlocking? I need to delve into that function's implementation to be certain. That's the critical piece of the puzzle.
|
| 47/2 |
2026/05/17 08:21 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/locks.c IncludeLines:true Name:break_deleg]
Results: map[SourceCode: 488: static inline int break_deleg(struct inode *inode, unsigned int flags)
489: {
490: struct file_lock_context *flctx;
491:
492: /*
493: * Since this check is lockless, we must ensure that any refcounts
494: * taken are done before checking i_flctx->flc_lease. Otherwise, we
495: * could end up racing with tasks trying to set a new lease on this
496: * file.
497: */
498: flctx = locks_inode_context(inode);
499: if (!flctx)
500: return 0;
501: smp_mb();
502: if (!list_empty_careful(&flctx->flc_lease)) {
503: flags |= LEASE_BREAK_DELEG;
504: return __break_lease(inode, flags);
505: }
506: return 0;
507: }
SourceFile:include/linux/filelock.h]
|
| 48/2 |
2026/05/17 08:21 |
llm |
expert |
0m
Model:
Tokens:
input: 37983
output: 45
thoughts: 1003
Thoughts: **OverlayFS ACL Lock Analysis**
Okay, so `break_deleg` isn't the key to unlocking the inode. The question now is whether `set_posix_acl` drops the inode lock. Let me review that function again, just to be sure. I see it's calling `inode->i_op->set_acl`. Could that be `ovl_set_acl` in the OverlayFS case? Yep, it is. `ovl_set_acl` then calls `ovl_set_or_remove_acl`, and that leads to `ovl_do_remove_acl`. `ovl_do_remove_acl` makes a call to `vfs_remove_acl` on the *upper* dentry.
Now, here's where it gets interesting: `vfs_remove_acl` on the upper dentry locks *its* inode and then recursively calls `set_posix_acl` on that upper dentry. The crucial question is, does `vfs_remove_acl` on the *upper* dentry inadvertently unlock the *OverlayFS* inode? No, it's just unlocking the upper inode.
But what if the *upper* dentry is the *same* as the overlayfs dentry? That's impossible, that's not how overlayfs works.
Let's consider another angle. Does `ovl_set_acl` call `ovl_setattr`? Yes, and `ovl_setattr` locks the `upperdentry->d_inode`. It then calls `ovl_do_notify_change`, then `inode_unlock(upperdentry->d_inode)`. But, I'm more interested in the case where the overlayfs dentry is involved, and `ovl_setattr` calls `ovl_copy_up`. Does `ovl_copy_up` potentially unlock the overlayfs inode? Let's check `ovl_copy_up_start` again, just to be precise.
Okay, `ovl_copy_up_start` locks `OVL_I(inode)->lock`. Now, let's connect the dots. The critical scenario is that `ovl_copy_up_start` might be called while `inode->i_rwsem` is held. Recall that `vfs_remove_acl` holds `inode->i_rwsem`. So, `ovl_set_acl` calls `ovl_setattr`, which calls `ovl_copy_up`. `ovl_copy_up` then calls `ovl_copy_up_start`, which *does* lock `OVL_I(inode)->lock`. Excellent! That's fine.
Finally, just to be completely thorough, is there any other filesystem where setting ACLs *does* unlock the inode during the process? Let's quickly scan the `btrfs_set_acl` implementation to rule out any gotchas there.
|
| 49/2 |
2026/05/17 08:22 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/btrfs/acl.c IncludeLines:true Name:btrfs_set_acl]
Results: map[SourceCode: 103: int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
104: struct posix_acl *acl, int type)
105: {
106: int ret;
107: struct inode *inode = d_inode(dentry);
108: umode_t old_mode = inode->i_mode;
109:
110: if (type == ACL_TYPE_ACCESS && acl) {
111: ret = posix_acl_update_mode(idmap, inode,
112: &inode->i_mode, &acl);
113: if (ret)
114: return ret;
115: }
116: ret = __btrfs_set_acl(NULL, inode, acl, type);
117: if (ret)
118: inode->i_mode = old_mode;
119: return ret;
120: }
SourceFile:fs/btrfs/acl.c]
|
| 50/2 |
2026/05/17 08:22 |
llm |
expert |
0m
Model:
Tokens:
input: 39986
output: 43
thoughts: 12
Thoughts: Okay, let's dive into this. Here's my thought process on what we're looking at, summarized in the first person:
**Investigating `ext4_set_acl`**
Alright, time to get my hands dirty. I need to take a look at the `ext4_set_acl` function. I'm assuming we're dealing with extended file attributes, probably ACLs. Now, what's going on here that merits closer inspection? Is there a performance bottleneck? A potential security vulnerability? Or am I just trying to understand the code flow better in this part of the filesystem? Whatever the reason, `ext4_set_acl` is the starting point. Let's trace through it, identify its dependencies, and see what the function is doing on the block level. I'll focus on how it translates the ACL representation into on-disk structures and interacts with the inode. Time to see how well it's implemented.
|
| 51/2 |
2026/05/17 08:22 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/ext4/acl.c IncludeLines:true Name:ext4_set_acl]
Results: map[SourceCode: 227: int
228: ext4_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
229: struct posix_acl *acl, int type)
230: {
231: handle_t *handle;
232: int error, credits, retries = 0;
233: size_t acl_size = acl ? ext4_acl_size(acl->a_count) : 0;
234: struct inode *inode = d_inode(dentry);
235: umode_t mode = inode->i_mode;
236: int update_mode = 0;
237:
238: error = dquot_initialize(inode);
239: if (error)
240: return error;
241: retry:
242: error = ext4_xattr_set_credits(inode, acl_size, false /* is_create */,
243: &credits);
244: if (error)
245: return error;
246:
247: handle = ext4_journal_start(inode, EXT4_HT_XATTR, credits);
248: if (IS_ERR(handle))
249: return PTR_ERR(handle);
250:
251: if ((type == ACL_TYPE_ACCESS) && acl) {
252: error = posix_acl_update_mode(idmap, inode, &mode, &acl);
253: if (error)
254: goto out_stop;
255: if (mode != inode->i_mode)
256: update_mode = 1;
257: }
258:
259: error = __ext4_set_acl(handle, inode, type, acl, 0 /* xattr_flags */);
260: if (!error && update_mode) {
261: inode->i_mode = mode;
262: inode_set_ctime_current(inode);
263: error = ext4_mark_inode_dirty(handle, inode);
264: }
265: out_stop:
266: ext4_journal_stop(handle);
267: if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
268: goto retry;
269: return error;
270: }
SourceFile:fs/ext4/acl.c]
|
| 52/2 |
2026/05/17 08:22 |
llm |
expert |
0m
Model:
Tokens:
input: 40966
output: 41
thoughts: 169
Thoughts: **Analyzing Delegation and Locking in `vfs_remove_acl`**
Okay, I'm tracing through `vfs_remove_acl` and my eye just snagged on this sequence: `try_break_deleg` is called right at the start. Interesting. If that returns `-EWOULDBLOCK`, we jump straight to `out_inode_unlock`, releasing the inode lock. Then we have a call to `break_deleg_wait`, presumably to wait for the delegation to actually break. Following that, we hit `retry_deleg`, which re-acquires the lock on the inode.
Now, a red flag is starting to wave in my mind. What happens if `try_break_deleg` *does* return `-EWOULDBLOCK`, indicating that the delegation couldn't be immediately broken, but *after* the `break_deleg_wait`, but *before* we hit the `retry_deleg`, `is_delegated(&delegated_inode)` is false? Does `break_deleg_wait` correctly handle the scenario where the delegation isn't actually present at that point? The potential race condition here is making me want to delve deeper into the `is_delegated` implementation. I need to understand the relationship between that function, `try_break_deleg`, and the lock release/reacquire cycle. This could be a critical point of failure, especially under heavy load or with slow delegated systems, and I need to make sure this is robust.
|
| 53/2 |
2026/05/17 08:22 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/posix_acl.c IncludeLines:true Name:is_delegated]
Results: map[SourceCode: 513: static inline bool is_delegated(struct delegated_inode *di)
514: {
515: return di->di_inode;
516: }
SourceFile:include/linux/filelock.h]
|
| 54/2 |
2026/05/17 08:22 |
llm |
expert |
0m
Model:
Tokens:
input: 41574
output: 39
thoughts: 158
Thoughts: **My Analysis of the Delegation Break Process**
Okay, so I'm looking at this `try_break_deleg` function and the way it handles lease delegation breaks. The core idea is to break a delegation, right? I see the call to `break_deleg` with the `LEASE_BREAK_NONBLOCK` flag. That makes sense – we're trying to break it without blocking if possible.
The interesting part is the `-EWOULDBLOCK` return. If `break_deleg` returns that, it signals that the break isn't immediately possible. But here's where the smarts come in: if a `delegated_inode` structure (`di`) is provided, we set `di->di_inode` to the inode we're dealing with and increment the inode's reference count via `ihold`. This is crucial. It means we're essentially storing the inode and keeping it around because the delegation break is pending. Effectively, `is_delegated` is set to true.
This, of course, then sets the stage for the next function call, `break_deleg_wait`. My gut tells me that's the point where we patiently wait for the lease break to complete. It's probably waiting on an event or a lock to become available, because we were blocked before. It’s a very clean and efficient way to handle a potentially asynchronous operation and keep track of our target. I'll need to dig into `break_deleg_wait` to confirm my suspicion, but this initial bit is quite elegant.
|
| 55/2 |
2026/05/17 08:22 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/locks.c IncludeLines:true Name:break_deleg_wait]
Results: map[SourceCode: 531: static inline int break_deleg_wait(struct delegated_inode *di)
532: {
533: int ret;
534:
535: ret = break_deleg(di->di_inode, 0);
536: iput(di->di_inode);
537: di->di_inode = NULL;
538: return ret;
539: }
SourceFile:include/linux/filelock.h]
|
| 56/2 |
2026/05/17 08:22 |
llm |
expert |
0m
Model:
Tokens:
input: 42252
output: 41
thoughts: 634
Thoughts: **Analyzing a Potential Race Condition in XATTR Removal**
Okay, so I'm looking at this code and trying to understand a possible issue related to removing extended attributes (xattrs) and POSIX ACLs. The core of my current analysis centers around a potential race condition and a kernel warning I'm seeing.
First, the code sequence appears straightforward: `break_deleg` is called, likely to handle delegation, with a wait flag (flags=0). Then `di->di_inode` is set to NULL, and the code jumps to `retry_deleg`. This seems fine at face value.
Then I see a call to `security_inode_remove_acl`. If that function returns an error, the code jumps to `out_inode_unlock`, unlocks the inode, and returns the error. That also seems correct.
However, I started thinking about the case when `removexattr` is called with a name which is not a posix acl. It calls `vfs_remove_acl` from the call trace. So it *is* a posix acl.
Now, I'm focusing on this kernel warning: `DEBUG_RWSEMS_WARN_ON((rwsem_owner(sem) != current) && !rwsem_test_oflags(sem, RWSEM_NONSPINNABLE)): count = 0x0...`. Specifically, `count = 0x0` is critical. It signifies that the read-write semaphore (rwsem) is *unlocked*. So the `inode_unlock(inode)` is trying to unlock an rwsem that is ALREADY unlocked! That's the problem.
How could this happen? The semaphore shouldn't be unlocked at this point! I need to determine what's unlocking it prematurely. My initial thoughts are:
* Could `set_posix_acl` be unlocking it?
* Perhaps `security_inode_remove_acl` has a bug that could cause it to unlock the semaphore incorrectly?
* Is it related to `may_write_xattr`?
I need to dig deeper into the code, and I should check `may_write_xattr`. I need to figure out which path is taking the semaphore unlock and find the reason why it is already unlocked at `inode_unlock`.
|
| 57/2 |
2026/05/17 08:22 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/xattr.c IncludeLines:true Name:may_write_xattr]
Results: map[SourceCode: 83: /**
84: * may_write_xattr - check whether inode allows writing xattr
85: * @idmap: idmap of the mount the inode was found from
86: * @inode: the inode on which to set an xattr
87: *
88: * Check whether the inode allows writing xattrs. Specifically, we can never
89: * set or remove an extended attribute on a read-only filesystem or on an
90: * immutable / append-only inode.
91: *
92: * We also need to ensure that the inode has a mapping in the mount to
93: * not risk writing back invalid i_{g,u}id values.
94: *
95: * Return: On success zero is returned. On error a negative errno is returned.
96: */
97: int may_write_xattr(struct mnt_idmap *idmap, struct inode *inode)
98: {
99: if (IS_IMMUTABLE(inode))
100: return -EPERM;
101: if (IS_APPEND(inode))
102: return -EPERM;
103: if (HAS_UNMAPPED_ID(idmap, inode))
104: return -EPERM;
105: return 0;
106: }
SourceFile:fs/xattr.c]
|
| 58/2 |
2026/05/17 08:22 |
llm |
expert |
0m
Model:
Tokens:
input: 43811
output: 41
thoughts: 28
Thoughts: Okay, here's my take on those thoughts, framed as my own:
**Investigating XATTR Locking Behavior**
Hmm, no, `may_write_xattr` *definitely* doesn't seem to be the key to unlocking this, whatever "this" is. That's a dead end. I need to rethink my approach. Wait a minute... what about `security_inode_remove_acl`? Could that be more relevant? It deals with ACL removal, which might indirectly relate to some form of lock or permission restriction. I should go down that path, it might reveal more than the first one. Let's see if that leads somewhere interesting.
|
| 59/2 |
2026/05/17 08:22 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:security/security.c IncludeLines:true Name:security_inode_remove_acl]
Results: map[SourceCode:1976: /**
1977: * security_inode_remove_acl() - Check if removing a posix acl is allowed
1978: * @idmap: idmap of the mount
1979: * @dentry: file
1980: * @acl_name: acl name
1981: *
1982: * Check permission before removing posix acls, the posix acls are identified
1983: * by @acl_name.
1984: *
1985: * Return: Returns 0 if permission is granted.
1986: */
1987: int security_inode_remove_acl(struct mnt_idmap *idmap,
1988: struct dentry *dentry, const char *acl_name)
1989: {
1990: if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
1991: return 0;
1992: return call_int_hook(inode_remove_acl, idmap, dentry, acl_name);
1993: }
SourceFile:security/security.c]
|
| 60/2 |
2026/05/17 08:22 |
llm |
expert |
0m
Model:
Tokens:
input: 44339
output: 42
thoughts: 771
Thoughts: **Unlocking the Inode - A Deep Dive into ACLs and OverlayFS**
Okay, so security hooks are definitely *not* the key to unlocking these inodes. That's a dead end. Back to the drawing board... it has to be the `set_posix_acl` function. Let's revisit it.
Right, here's `set_posix_acl`: it's the gateway for setting ACLs. The core of the logic checks if ACLs are supported, if the filesystem has a `set_acl` operation defined, and then handles some ownership/permission checks. Crucially, it delegates the *actual* ACL setting to `inode->i_op->set_acl`. Could *that* call be the unlock mechanism?
Now, remember we looked at `ovl_set_acl`, the overlayfs version. This is the more relevant piece. Inside `ovl_set_acl`, we can see it checks some similar conditions and ultimately *also* calls an "set_acl" function. Wait a minute... I see a call to `ovl_setattr` in there as part of the check to clear the sgid bit... That's a very different path! So it seems to be more than just `set_acl` as it also calls `ovl_setattr` sometimes.
Now the question is... does `ovl_setattr` do the unlocking? Let's take another look at that `ovl_setattr` function in detail...
|
| 61/2 |
2026/05/17 08:22 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/inode.c IncludeLines:true Name:ovl_setattr]
Results: map[SourceCode: 21: int ovl_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
22: struct iattr *attr)
23: {
24: int err;
25: struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
26: bool full_copy_up = false;
27: struct dentry *upperdentry;
28:
29: err = setattr_prepare(&nop_mnt_idmap, dentry, attr);
30: if (err)
31: return err;
32:
33: if (attr->ia_valid & ATTR_SIZE) {
34: /* Truncate should trigger data copy up as well */
35: full_copy_up = true;
36: }
37:
38: if (!full_copy_up)
39: err = ovl_copy_up(dentry);
40: else
41: err = ovl_copy_up_with_data(dentry);
42: if (!err) {
43: struct inode *winode = NULL;
44:
45: upperdentry = ovl_dentry_upper(dentry);
46:
47: if (attr->ia_valid & ATTR_SIZE) {
48: winode = d_inode(upperdentry);
49: err = get_write_access(winode);
50: if (err)
51: goto out;
52: }
53:
54: if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
55: attr->ia_valid &= ~ATTR_MODE;
56:
57: /*
58: * We might have to translate ovl file into real file object
59: * once use cases emerge. For now, simply don't let underlying
60: * filesystem rely on attr->ia_file
61: */
62: attr->ia_valid &= ~ATTR_FILE;
63:
64: /*
65: * If open(O_TRUNC) is done, VFS calls ->setattr with ATTR_OPEN
66: * set. Overlayfs does not pass O_TRUNC flag to underlying
67: * filesystem during open -> do not pass ATTR_OPEN. This
68: * disables optimization in fuse which assumes open(O_TRUNC)
69: * already set file size to 0. But we never passed O_TRUNC to
70: * fuse. So by clearing ATTR_OPEN, fuse will be forced to send
71: * setattr request to server.
72: */
73: attr->ia_valid &= ~ATTR_OPEN;
74:
75: err = ovl_want_write(dentry);
76: if (err)
77: goto out_put_write;
78:
79: inode_lock(upperdentry->d_inode);
80: with_ovl_creds(dentry->d_sb)
81: err = ovl_do_notify_change(ofs, upperdentry, attr);
82: if (!err)
83: ovl_copyattr(dentry->d_inode);
84: inode_unlock(upperdentry->d_inode);
85: ovl_drop_write(dentry);
86:
87: out_put_write:
88: if (winode)
89: put_write_access(winode);
90: }
91: out:
92: return err;
93: }
SourceFile:fs/overlayfs/inode.c]
|
| 62/2 |
2026/05/17 08:22 |
llm |
expert |
0m
Model:
Tokens:
input: 46527
output: 41
thoughts: 1001
Thoughts: **Analyzing Potential Inode Locking Issues in Filesystem Operations**
Okay, let's break this down. My initial thought was that `ovl_setattr` might be the culprit, calling `setattr_prepare`. I quickly dismissed that as `setattr_prepare` doesn't seem to unlock the inode.
The next thought led me to `ovl_set_or_remove_acl`. Could it be that this function, or one of its callees, is the one unlocking the inode in a way that creates a race? Looking at the code, it looks like `ovl_do_remove_acl` is the relevant function path. It calls `vfs_remove_acl` on the *upper* dentry, let's call that `upperdentry`, which is distinct from the overlayfs `dentry`.
Crucially, `vfs_remove_acl` then locks the upper inode, performs the ACL operation (using `set_posix_acl`), and *then* unlocks the inode. The key here is the separation of the `upperdentry` and the `dentry`. The report in question doesn't specifically mention overlayfs, so it's likely my initial assumption about the underlying filesystem might be incorrect.
So, let's step back and consider a broader scenario. Could the problem lie in a situation where the target dentry (to which `vfs_remove_acl` is applied) isn't necessarily overlayfs, but some other filesystem? I need to analyze possible filesystems where a similar locking behavior might occur, where setting the ACL could unlock the inode.
I need to confirm if there are any filesystems where `set_acl` has a potential unlock. Back to the drawing board to re-examine the code of various filesystem implementations of `set_acl`. I looked at `btrfs_set_acl`, but the code clearly shows no unlock happening after the ACL operation. So, I need to check `fuse_set_acl`.
|
| 63/2 |
2026/05/17 08:22 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/fuse/acl.c IncludeLines:true Name:fuse_set_acl]
Results: map[SourceCode: 95: int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
96: struct posix_acl *acl, int type)
97: {
98: struct inode *inode = d_inode(dentry);
99: struct fuse_conn *fc = get_fuse_conn(inode);
100: const char *name;
101: int ret;
102:
103: if (fuse_is_bad(inode))
104: return -EIO;
105:
106: if (fc->no_setxattr || fuse_no_acl(fc, inode))
107: return -EOPNOTSUPP;
108:
109: if (type == ACL_TYPE_ACCESS)
110: name = XATTR_NAME_POSIX_ACL_ACCESS;
111: else if (type == ACL_TYPE_DEFAULT)
112: name = XATTR_NAME_POSIX_ACL_DEFAULT;
113: else
114: return -EINVAL;
115:
116: if (acl) {
117: unsigned int extra_flags = 0;
118: /*
119: * Fuse userspace is responsible for updating access
120: * permissions in the inode, if needed. fuse_setxattr
121: * invalidates the inode attributes, which will force
122: * them to be refreshed the next time they are used,
123: * and it also updates i_ctime.
124: */
125: size_t size;
126: void *value;
127:
128: value = posix_acl_to_xattr(fc->user_ns, acl, &size, GFP_KERNEL);
129: if (!value)
130: return -ENOMEM;
131:
132: if (size > PAGE_SIZE) {
133: kfree(value);
134: return -E2BIG;
135: }
136:
137: /*
138: * Fuse daemons without FUSE_POSIX_ACL never changed the passed
139: * through POSIX ACLs. Such daemons don't expect setgid bits to
140: * be stripped.
141: */
142: if (fc->posix_acl &&
143: !in_group_or_capable(idmap, inode,
144: i_gid_into_vfsgid(idmap, inode)))
145: extra_flags |= FUSE_SETXATTR_ACL_KILL_SGID;
146:
147: ret = fuse_setxattr(inode, name, value, size, 0, extra_flags);
148: kfree(value);
149: } else {
150: ret = fuse_removexattr(inode, name);
151: }
152:
153: if (fc->posix_acl) {
154: /*
155: * Fuse daemons without FUSE_POSIX_ACL never cached POSIX ACLs
156: * and didn't invalidate attributes. Retain that behavior.
157: */
158: forget_all_cached_acls(inode);
159: fuse_invalidate_attr(inode);
160: }
161:
162: return ret;
163: }
SourceFile:fs/fuse/acl.c]
|
| 64/2 |
2026/05/17 08:22 |
llm |
expert |
0m
Model:
Tokens:
input: 49008
output: 42
thoughts: 25
Thoughts: Okay, here's my interpretation of those thoughts, crafted with an expert's mind:
**Analyzing the `fuse_removexattr` Call**
Right, `fuse_removexattr` is being invoked. That's the key signal here. Immediately, my mind jumps to inode management. The question that instantly surfaces is: does the execution of `fuse_removexattr` itself trigger, or implicitly participate in, the unlocking of the relevant inode? It's a critical point to consider because locking and unlocking of the inode are related. I need to understand whether this function's completion or the function itself is responsible for releasing the resources. The mechanics of extended attribute removal are heavily dependent on how the underlying file system handles locking and concurrency. So, what's the control flow? What does the code itself do?
|
| 65/2 |
2026/05/17 08:23 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/fuse/xattr.c IncludeLines:true Name:fuse_removexattr]
Results: map[SourceCode: 156: int fuse_removexattr(struct inode *inode, const char *name)
157: {
158: struct fuse_mount *fm = get_fuse_mount(inode);
159: FUSE_ARGS(args);
160: int err;
161:
162: if (fm->fc->no_removexattr)
163: return -EOPNOTSUPP;
164:
165: args.opcode = FUSE_REMOVEXATTR;
166: args.nodeid = get_node_id(inode);
167: args.in_numargs = 2;
168: fuse_set_zero_arg0(&args);
169: args.in_args[1].size = strlen(name) + 1;
170: args.in_args[1].value = name;
171: err = fuse_simple_request(fm, &args);
172: if (err == -ENOSYS) {
173: fm->fc->no_removexattr = 1;
174: err = -EOPNOTSUPP;
175: }
176: if (!err)
177: fuse_update_ctime(inode);
178:
179: return err;
180: }
SourceFile:fs/fuse/xattr.c]
|
| 66/2 |
2026/05/17 08:23 |
llm |
expert |
0m
Model:
Tokens:
input: 49654
output: 43
thoughts: 15
Thoughts: Okay, here's my summary, presented as a stream of thought:
**Quick Analysis: ACL Handling**
No, that's not the direction I need to go. Wait a minute... What about the `bad_inode_set_acl` function? Could that be relevant? Let me check how it works with `inode`...
|
| 67/2 |
2026/05/17 08:23 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/bad_inode.c IncludeLines:true Name:bad_inode_set_acl]
Results: map[SourceCode: 156: static int bad_inode_set_acl(struct mnt_idmap *idmap,
157: struct dentry *dentry, struct posix_acl *acl,
158: int type)
159: {
160: return -EIO;
161: }
SourceFile:fs/bad_inode.c]
|
| 68/2 |
2026/05/17 08:23 |
llm |
expert |
0m
Model:
Tokens:
input: 49903
output: 41
thoughts: 13
Thoughts: Okay, here's my summary, tailored for an expert audience, as if it's a direct representation of my thought process:
**ACLs and Ceph - A Quick Run**
Nope. That's not the direction I want to go down. I'm hitting a roadblock.
Wait a second... what about `ceph_set_acl`? Is there a possibility there? I need to quickly recall the finer details of the ACL implementation with Ceph; specifically, how it interacts with the current project parameters. It might be relevant, it might not. This warrants a more involved investigation, so I can continue with the project at hand.
|
| 69/2 |
2026/05/17 08:23 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/ceph/acl.c IncludeLines:true Name:ceph_set_acl]
Results: map[SourceCode: 90: int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
91: struct posix_acl *acl, int type)
92: {
93: int ret = 0;
94: size_t size = 0;
95: const char *name = NULL;
96: char *value = NULL;
97: struct iattr newattrs;
98: struct inode *inode = d_inode(dentry);
99: struct timespec64 old_ctime = inode_get_ctime(inode);
100: umode_t new_mode = inode->i_mode, old_mode = inode->i_mode;
101:
102: if (ceph_snap(inode) != CEPH_NOSNAP) {
103: ret = -EROFS;
104: goto out;
105: }
106:
107: switch (type) {
108: case ACL_TYPE_ACCESS:
109: name = XATTR_NAME_POSIX_ACL_ACCESS;
110: if (acl) {
111: ret = posix_acl_update_mode(idmap, inode,
112: &new_mode, &acl);
113: if (ret)
114: goto out;
115: }
116: break;
117: case ACL_TYPE_DEFAULT:
118: if (!S_ISDIR(inode->i_mode)) {
119: ret = acl ? -EINVAL : 0;
120: goto out;
121: }
122: name = XATTR_NAME_POSIX_ACL_DEFAULT;
123: break;
124: default:
125: ret = -EINVAL;
126: goto out;
127: }
128:
129: if (acl) {
130: value = posix_acl_to_xattr(&init_user_ns, acl, &size, GFP_NOFS);
131: if (!value) {
132: ret = -ENOMEM;
133: goto out;
134: }
135: }
136:
137: if (new_mode != old_mode) {
138: newattrs.ia_ctime = current_time(inode);
139: newattrs.ia_mode = new_mode;
140: newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
141: ret = __ceph_setattr(idmap, inode, &newattrs, NULL);
142: if (ret)
143: goto out_free;
144: }
145:
146: ret = __ceph_setxattr(inode, name, value, size, 0);
147: if (ret) {
148: if (new_mode != old_mode) {
149: newattrs.ia_ctime = old_ctime;
150: newattrs.ia_mode = old_mode;
151: newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
152: __ceph_setattr(idmap, inode, &newattrs, NULL);
153: }
154: goto out_free;
155: }
156:
157: ceph_set_cached_acl(inode, type, acl);
158:
159: out_free:
160: kfree(value);
161: out:
162: return ret;
163: }
SourceFile:fs/ceph/acl.c]
|
| 70/2 |
2026/05/17 08:23 |
llm |
expert |
0m
Model:
Tokens:
input: 51169
output: 42
thoughts: 832
Thoughts: **Analyzing a Potential Race Condition in ACL Removal**
Okay, so I'm looking at this `vfs_remove_acl` function and something's bugging me. Specifically, I'm thinking about a scenario where `may_write_xattr` might return an error after the inode is locked, and whether that unlocks the inode properly. It seems fine in this case, the code jumps to `out_inode_unlock`, so it is perfectly balanced! The `inode_lock(inode)` call is definitely locking the inode. I checked that it uses a down_write on `i_rwsem`, so that's solid. And it handles bad inodes with `is_bad_inode`, so that's not a concern. And it works with symlinks, even though the code doesn't explicitly check for them.
Now I'm diving deeper into the debugging warning message. It mentions `DEBUG_RWSEMS_WARN_ON`, specifically when the semaphore owner isn't the current process. I see that the `rwsem_owner(sem)` is returning 0, which suggests the read-write semaphore is unlocked, even though it should be locked. The `current` pointer is the current process's address, and it's definitely not zero. So, this means the semaphore is unlocked when it shouldn't be.
The question then becomes: *why* is it unlocked? Could another function, like `set_posix_acl`, somehow be involved? I need to review `set_posix_acl` to see if it might inadvertently unlock a semaphore.
I'm checking the code for `set_posix_acl` to see if it has any oddities. It does a number of checks. It looks like `inode->i_op->set_acl` is the key function to check. Could that function unlock the semaphore in some way? What if `inode->i_op->set_acl` is `shmem_set_acl`, or `simple_set_acl`?
|
| 71/2 |
2026/05/17 08:23 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/posix_acl.c IncludeLines:true Name:simple_set_acl]
Results: map[SourceCode:1016: int simple_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
1017: struct posix_acl *acl, int type)
1018: {
1019: int error;
1020: struct inode *inode = d_inode(dentry);
1021:
1022: if (type == ACL_TYPE_ACCESS) {
1023: error = posix_acl_update_mode(idmap, inode,
1024: &inode->i_mode, &acl);
1025: if (error)
1026: return error;
1027: }
1028:
1029: inode_set_ctime_current(inode);
1030: if (IS_I_VERSION(inode))
1031: inode_inc_iversion(inode);
1032: set_cached_acl(inode, type, acl);
1033: return 0;
1034: }
SourceFile:fs/posix_acl.c]
|
| 72/2 |
2026/05/17 08:23 |
llm |
expert |
0m
Model:
Tokens:
input: 52779
output: 43
thoughts: 28
Thoughts: Okay, here's my summary, framed as my internal thought process:
**Deduction Begins: ACL Context**
Alright, I'm hitting a roadblock. Looks like there's no immediate, obvious "unlock" condition presented here. So, let's pivot and look at the context. We're clearly dealing with an Access Control List (ACL) operation. This suggests that the code is examining or modifying permissions on a file or directory.
Now, let's get down to the potential root of the issue. A key operation for ACL management would be setting the ACL. What if the code path specifically involves `inode->i_op->set_acl`? And, to be precise, what if that function pointer is actually pointing to `jfs_set_acl`? That particular function would define the behavior if JFS (Journaled File System) is being used. This could be a critical juncture to evaluate file permissions.
|
| 73/2 |
2026/05/17 08:23 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/jfs/acl.c IncludeLines:true Name:jfs_set_acl]
Results: map[SourceCode: 92: int jfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
93: struct posix_acl *acl, int type)
94: {
95: int rc;
96: tid_t tid;
97: int update_mode = 0;
98: struct inode *inode = d_inode(dentry);
99: umode_t mode = inode->i_mode;
100:
101: tid = txBegin(inode->i_sb, 0);
102: mutex_lock(&JFS_IP(inode)->commit_mutex);
103: if (type == ACL_TYPE_ACCESS && acl) {
104: rc = posix_acl_update_mode(&nop_mnt_idmap, inode, &mode, &acl);
105: if (rc)
106: goto end_tx;
107: if (mode != inode->i_mode)
108: update_mode = 1;
109: }
110: rc = __jfs_set_acl(tid, inode, type, acl);
111: if (!rc) {
112: if (update_mode) {
113: inode->i_mode = mode;
114: inode_set_ctime_current(inode);
115: mark_inode_dirty(inode);
116: }
117: rc = txCommit(tid, 1, &inode, 0);
118: }
119: end_tx:
120: txEnd(tid);
121: mutex_unlock(&JFS_IP(inode)->commit_mutex);
122: return rc;
123: }
SourceFile:fs/jfs/acl.c]
|
| 74/2 |
2026/05/17 08:23 |
llm |
expert |
0m
Model:
Tokens:
input: 53568
output: 45
thoughts: 28
Thoughts: Okay, here's my take on those thoughts, framed as my own reasoning:
**ACL Setting Analysis**
Right, so I'm hitting a roadblock. Nothing's immediately jumping out as the solution here. It's time to backtrack and try a different angle.
Okay, let's think this through. My main focus at this moment is about how we are interacting with ACLs for file system operations. Let's start with a key question: What function is the system using to set ACLs? Specifically, I need to check the function pointer `inode->i_op->set_acl`. If this pointer is initialized to the `ntfs_set_acl` function, that gives me a clear direction to pursue. I'll need to double check the setup to ensure I am using the right function call, and ensure this part of the process is running as expected, or if there is a problem at this very basic step.
|
| 75/2 |
2026/05/17 08:23 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/ntfs3/xattr.c IncludeLines:true Name:ntfs_set_acl]
Results: map[SourceCode: 675: /*
676: * ntfs_set_acl - inode_operations::set_acl
677: */
678: int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
679: struct posix_acl *acl, int type)
680: {
681: return ntfs_set_acl_ex(idmap, d_inode(dentry), acl, type, false);
682: }
SourceFile:fs/ntfs3/xattr.c]
|
| 76/2 |
2026/05/17 08:23 |
llm |
expert |
0m
Model:
Tokens:
input: 54008
output: 47
thoughts: 14
Thoughts: Okay, here's my attempt at summarizing that thought process, tailored for an expert audience:
**Diving into `ntfs_set_acl_ex`**
Alright, time to dig into `ntfs_set_acl_ex`. I need to refresh my memory on the implementation details. Specifically, I'm thinking about the potential pitfalls, edge cases, and performance implications that are likely buried within that function. I'll need to consider how it interacts with the underlying NTFS structures, particularly how it handles ACEs (Access Control Entries), security descriptors, inheritance, and the whole complex dance of DACLs (Discretionary ACLs) and SACLs (System ACLs). I want to see how the extended attributes are dealt with.
I want to see what protections are in place to prevent resource exhaustion, race conditions, or unexpected behavior when dealing with nested directories or very large ACLs. Are there any known vulnerabilities associated with its use? The specifics of error handling are important as well. I'll be looking for nuances to see how it differs from similar functions and the rationale behind those design decisions. I need to understand this function completely.
|
| 77/2 |
2026/05/17 08:23 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/ntfs3/xattr.c IncludeLines:true Name:ntfs_set_acl_ex]
Results: map[SourceCode: 595: static noinline int ntfs_set_acl_ex(struct mnt_idmap *idmap,
596: struct inode *inode, struct posix_acl *acl,
597: int type, bool init_acl)
598: {
599: const char *name;
600: size_t size, name_len;
601: void *value;
602: int err;
603: int flags;
604: umode_t mode;
605:
606: /* Avoid any operation if inode is bad. */
607: if (unlikely(is_bad_ni(ntfs_i(inode))))
608: return -EINVAL;
609:
610: if (S_ISLNK(inode->i_mode))
611: return -EOPNOTSUPP;
612:
613: mode = inode->i_mode;
614: switch (type) {
615: case ACL_TYPE_ACCESS:
616: /* Do not change i_mode if we are in init_acl */
617: if (acl && !init_acl) {
618: err = posix_acl_update_mode(idmap, inode, &mode, &acl);
619: if (err)
620: return err;
621: }
622: name = XATTR_NAME_POSIX_ACL_ACCESS;
623: name_len = sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1;
624: break;
625:
626: case ACL_TYPE_DEFAULT:
627: if (!S_ISDIR(inode->i_mode))
628: return acl ? -EACCES : 0;
629: name = XATTR_NAME_POSIX_ACL_DEFAULT;
630: name_len = sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1;
631: break;
632:
633: default:
634: return -EINVAL;
635: }
636:
637: if (!acl) {
638: /* Remove xattr if it can be presented via mode. */
639: size = 0;
640: value = NULL;
641: flags = XATTR_REPLACE;
642: } else {
643: value = posix_acl_to_xattr(&init_user_ns, acl, &size, GFP_NOFS);
644: if (!value)
645: return -ENOMEM;
646: flags = 0;
647: }
648:
649: err = ntfs_set_ea(inode, name, name_len, value, size, flags, 0, NULL);
650: if (err == -ENODATA && !size)
651: err = 0; /* Removing non existed xattr. */
652: if (err)
653: goto out;
654:
655: if (inode->i_mode != mode) {
656: umode_t old_mode = inode->i_mode;
657: inode->i_mode = mode;
658: err = ntfs_save_wsl_perm(inode, NULL);
659: if (err) {
660: inode->i_mode = old_mode;
661: goto out;
662: }
663: inode->i_mode = mode;
664: }
665: set_cached_acl(inode, type, acl);
666: inode_set_ctime_current(inode);
667: mark_inode_dirty(inode);
668:
669: out:
670: kfree(value);
671:
672: return err;
673: }
SourceFile:fs/ntfs3/xattr.c]
|
| 78/2 |
2026/05/17 08:23 |
llm |
expert |
0m
Model:
Tokens:
input: 55471
output: 47
thoughts: 1532
Thoughts: **Analyzing a Potential Double Unlock in `vfs_remove_acl`**
Okay, let's break this down. No obvious unlock issue here, initially. My thought process here is to meticulously trace all possible execution paths within `vfs_remove_acl` to ensure that an `inode_unlock` isn't called twice, either directly or indirectly through a called function.
First, I considered the base case: If `removexattr` is called with a POSIX ACL, it calls `vfs_remove_acl`. So, the entry point looks good.
Then I double-checked the standard control flow in `vfs_remove_acl`. Specifically, I scrutinized the `set_posix_acl` function and its interactions with `inode_unlock`. The typical path is `set_posix_acl` -> `out_inode_unlock` -> `inode_unlock`. No immediate double unlock there. I considered the `is_delegated` path and confirmed the locking/unlocking behavior after delegation break and retry looks correct.
Next, I considered various potential error conditions. What if `set_posix_acl` returns an error? `inode_unlock` is called *once* in this scenario. What if `inode_lock` somehow gets called with a NULL `inode`? That would crash immediately. What if there's a `-EWOULDBLOCK` from `try_break_deleg`? This is handled carefully, with a retry after a wait and subsequent lock. Other error codes from `try_break_deleg` also lead to a single unlock.
I then considered the scenario where `set_posix_acl` itself might call `inode_unlock`, but I've examined several of the potential implementations in different filesystems, and I don't see any obvious double-unlock calls within `set_posix_acl` implementations. What if the filesystem doesn't support the operation? `set_posix_acl` will then return `-EOPNOTSUPP` and `inode_unlock` is still only called once in `vfs_remove_acl`.
Next, I considered overlayfs, as it has a nested `vfs_remove_acl` call. But I considered several potential issues. For instance, could `vfs_remove_acl` on the upper dentry unlock the overlayfs inode? The `dentry` and `inode` usage is local within the function, so it's impossible. What if the overlayfs upper dentry and the original dentry are the same? That's impossible. What if the underlying inode changes? The `inode` variable is local so this is a non-issue.
I've checked to make sure `inode_lock` *is* called. This is critical for the synchronization logic.
Now, the crucial clue. The warning I'm seeing is a `DEBUG_RWSEMS_WARN_ON` within `__up_write`, which is called by `up_write` and ultimately `inode_unlock`. The warning indicates an unlocked semaphore, with `count = 0` and `owner = 0`. This is the smoking gun! `inode_unlock` is being called on a semaphore that's *already* unlocked, which means the unlock is being called multiple times.
So, where could the double unlock be happening? I re-traced the path. I've already checked whether `inode_unlock` is called within `set_posix_acl` and confirmed it's not. I've exhaustively checked control flow in `vfs_remove_acl`. So, the double-unlock *must* be happening because of the logic within `vfs_remove_acl` itself, or more likely, within a function called by `set_posix_acl`, but I've covered this. I've re-reviewed all the code, and there are no direct calls to `inode_unlock` within `set_posix_acl`. The potential source of this double-unlock is not apparent at this point. Time to examine the implementations of `set_posix_acl` more closely.
|
| 79/2 |
2026/05/17 08:23 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/nfs/nfs3acl.c IncludeLines:true Name:nfs3_set_acl]
Results: map[SourceCode: 257: int nfs3_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
258: struct posix_acl *acl, int type)
259: {
260: struct posix_acl *orig = acl, *dfacl = NULL, *alloc;
261: struct inode *inode = d_inode(dentry);
262: int status;
263:
264: if (S_ISDIR(inode->i_mode)) {
265: switch(type) {
266: case ACL_TYPE_ACCESS:
267: alloc = get_inode_acl(inode, ACL_TYPE_DEFAULT);
268: if (IS_ERR(alloc))
269: goto fail;
270: dfacl = alloc;
271: break;
272:
273: case ACL_TYPE_DEFAULT:
274: alloc = get_inode_acl(inode, ACL_TYPE_ACCESS);
275: if (IS_ERR(alloc))
276: goto fail;
277: dfacl = acl;
278: acl = alloc;
279: break;
280: }
281: }
282:
283: if (acl == NULL) {
284: alloc = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
285: if (IS_ERR(alloc))
286: goto fail;
287: acl = alloc;
288: }
289: status = __nfs3_proc_setacls(inode, acl, dfacl);
290: out:
291: if (acl != orig)
292: posix_acl_release(acl);
293: if (dfacl != orig)
294: posix_acl_release(dfacl);
295: return status;
296:
297: fail:
298: status = PTR_ERR(alloc);
299: goto out;
300: }
SourceFile:fs/nfs/nfs3acl.c]
|
| 80/2 |
2026/05/17 08:23 |
llm |
expert |
0m
Model:
Tokens:
input: 58560
output: 46
thoughts: 16
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Navigating the ACL Landscape**
Alright, nothing immediately jumping out as a potential solution here. The current approach isn't yielding the desired result, and I'm hitting a wall. Need to pivot.
Okay, let's circle back and consider `xfs_set_acl`. Given the context, this is the logical next step to explore. Perhaps that utility can provide the functionality needed to manage Access Control Lists and address the problem more directly, and thus, unlock a solution.
|
| 81/2 |
2026/05/17 08:24 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/xfs/xfs_acl.c IncludeLines:true Name:xfs_set_acl]
Results: map[SourceCode: 245: int
246: xfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
247: struct posix_acl *acl, int type)
248: {
249: umode_t mode;
250: bool set_mode = false;
251: int error = 0;
252: struct inode *inode = d_inode(dentry);
253:
254: if (!acl)
255: goto set_acl;
256:
257: error = -E2BIG;
258: if (acl->a_count > XFS_ACL_MAX_ENTRIES(XFS_M(inode->i_sb)))
259: return error;
260:
261: if (type == ACL_TYPE_ACCESS) {
262: error = posix_acl_update_mode(idmap, inode, &mode, &acl);
263: if (error)
264: return error;
265: set_mode = true;
266: }
267:
268: set_acl:
269: /*
270: * We set the mode after successfully updating the ACL xattr because the
271: * xattr update can fail at ENOSPC and we don't want to change the mode
272: * if the ACL update hasn't been applied.
273: */
274: error = __xfs_set_acl(inode, acl, type);
275: if (!error && set_mode && mode != inode->i_mode)
276: error = xfs_acl_set_mode(inode, mode);
277: return error;
278: }
SourceFile:fs/xfs/xfs_acl.c]
|
| 82/2 |
2026/05/17 08:24 |
llm |
expert |
0m
Model:
Tokens:
input: 59287
output: 45
thoughts: 17
Thoughts: Okay, here's my summary, presented as a stream of thought:
**Initial Assessment: A Dead End (For Now)**
Alright, so the immediate situation is… nothing. Absolutely nothing. It's a dead end, at least as far as the initial approach I was taking is concerned. No clear path forward has emerged. I need to rethink this, figure out what's missing, and adjust accordingly.
Now, let's step back and consider another angle. Could there be a connection? Is there an opportunity to utilize the functions associated with `f2fs_set_acl`? Perhaps the solution lies within that sphere of operations. Let's explore that area for a moment.
|
| 83/2 |
2026/05/17 08:24 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/f2fs/acl.c IncludeLines:true Name:f2fs_set_acl]
Results: map[SourceCode: 278: int f2fs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
279: struct posix_acl *acl, int type)
280: {
281: struct inode *inode = d_inode(dentry);
282:
283: if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
284: return -EIO;
285:
286: return __f2fs_set_acl(idmap, inode, type, acl, NULL);
287: }
SourceFile:fs/f2fs/acl.c]
|
| 84/2 |
2026/05/17 08:24 |
llm |
expert |
0m
Model:
Tokens:
input: 59697
output: 45
thoughts: 3073
Thoughts: **Analysis of Potential Double Unlock Vulnerability in OverlayFS ACL Handling**
Okay, let's break this down systematically. The initial concern was around potential double unlocks, specifically within the `vfs_remove_acl` and associated functions called during ACL removal. I need to make sure I understand the locking/unlocking flow correctly, especially where delegation and potential errors are involved.
First, I examined a sequence that starts with `ovl_set_acl`, which might call `ovl_setattr`, which in turn can lead to `ovl_copy_up`. `ovl_copy_up` uses a mutex (`OVL_I(inode)->lock`) and the logic around its locking and unlocking within `ovl_copy_up_start`, `ovl_copy_up_one`, and `ovl_copy_up_end` is solid. The mutex prevents race conditions during the copy-up process and is correctly managed. So, no issues there.
The ACL path seemed more promising. Specifically, the call chain of `ovl_set_acl` -> `ovl_set_or_remove_acl` -> `ovl_do_remove_acl` -> `vfs_remove_acl` was of interest. The key part is that `vfs_remove_acl` can be called on the *upper* dentry.
I scrutinized `vfs_remove_acl` itself. It uses `inode_lock` and `inode_unlock` correctly with delegation handling. The `try_break_deleg` function and the retry loop were examined to ensure delegations are handled appropriately, including `-EWOULDBLOCK` errors. I initially thought there might be a flaw where `-EWOULDBLOCK` from `set_posix_acl` would bypass the delegation retry. However, I confirmed that `vfs_remove_acl` does correctly handle the retry logic for the upper inode, ensuring that locking and unlocking are consistent within the delegation flow.
The more tricky question was if there was any path that would unlock the inode *twice*. I had to think of a way `inode_unlock` could be called when the inode was already unlocked.
The critical insight, here, came from the interaction between the overlayfs and the *upper* filesystem. While looking at `vfs_remove_acl`, the call to `set_posix_acl`, the error handling around `-EWOULDBLOCK` and how the inode is unlocked if it's not handled. I checked multiple other filesystems, to look for a case where `set_posix_acl` could call `vfs_remove_acl` and unlock the inode, but this seems very unlikely. If `posix_acl_update_mode` was unlocking the inode.
It all seems robust. So the analysis now shows no double-unlock.
|
| 85/2 |
2026/05/17 08:24 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/posix_acl.c IncludeLines:true Name:posix_acl_update_mode]
Results: map[SourceCode: 683: /**
684: * posix_acl_update_mode - update mode in set_acl
685: * @idmap: idmap of the mount @inode was found from
686: * @inode: target inode
687: * @mode_p: mode (pointer) for update
688: * @acl: acl pointer
689: *
690: * Update the file mode when setting an ACL: compute the new file permission
691: * bits based on the ACL. In addition, if the ACL is equivalent to the new
692: * file mode, set *@acl to NULL to indicate that no ACL should be set.
693: *
694: * As with chmod, clear the setgid bit if the caller is not in the owning group
695: * or capable of CAP_FSETID (see inode_change_ok).
696: *
697: * If the inode has been found through an idmapped mount the idmap of
698: * the vfsmount must be passed through @idmap. This function will then
699: * take care to map the inode according to @idmap before checking
700: * permissions. On non-idmapped mounts or if permission checking is to be
701: * performed on the raw inode simply pass @nop_mnt_idmap.
702: *
703: * Called from set_acl inode operations.
704: */
705: int posix_acl_update_mode(struct mnt_idmap *idmap,
706: struct inode *inode, umode_t *mode_p,
707: struct posix_acl **acl)
708: {
709: umode_t mode = inode->i_mode;
710: int error;
711:
712: error = posix_acl_equiv_mode(*acl, &mode);
713: if (error < 0)
714: return error;
715: if (error == 0)
716: *acl = NULL;
717: if (!in_group_or_capable(idmap, inode,
718: i_gid_into_vfsgid(idmap, inode)))
719: mode &= ~S_ISGID;
720: *mode_p = mode;
721: return 0;
722: }
SourceFile:fs/posix_acl.c]
|
| 86/2 |
2026/05/17 08:24 |
llm |
expert |
0m
Model:
Tokens:
input: 64121
output: 46
thoughts: 506
Thoughts: **Debugging a Kernel Lock Warning**
Okay, so I'm trying to figure out this `syzkaller` report and why this `DEBUG_RWSEMS_WARN_ON` warning is being triggered in `__up_write`. The core of the problem seems to be an invalid unlock, and I need to understand why this would happen in the context of `removexattr`.
First, the initial thought was a simple race condition: `removexattr` called while another thread is modifying the file and that other thread unlocks the inode. But `inode_lock` uses an exclusive `rwsem down_write` lock. If this thread holds the lock, no other thread can *unlock* it. So, that can't be it.
Then I double-checked that `inode_lock(inode)` *actually* locks the inode. It does. So, that's not the problem.
Alright, let's go back to the warning itself: `DEBUG_RWSEMS_WARN_ON((rwsem_owner(sem) != current) && !rwsem_test_oflags(sem, RWSEM_NONSPINNABLE))`. The warning is triggered during `__up_write`. My brain's racing with possibilities. Could the rwsem be downgraded to a read lock somehow? If so, the `owner` would be 0, right? But `vfs_remove_acl` doesn't downgrade the lock. Could `set_posix_acl` be the culprit? But I can't think of any filesystem `set_acl` method that would downgrade it.
Wait! What if we are dealing with a **bdev** or **cdev** inode? Block and character devices have their own `inode_operations`, right? Do they have `set_acl` methods? Let me check `def_blk_aops` or `def_chr_fops`. I don't think they usually do, but I should check.
Hmm, what about the `9p` filesystem? I should check `v9fs_iop_set_acl`...
|
| 87/2 |
2026/05/17 08:24 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/9p/acl.c IncludeLines:true Name:v9fs_iop_set_acl]
Results: map[SourceCode: 155: int v9fs_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
156: struct posix_acl *acl, int type)
157: {
158: int retval;
159: size_t size = 0;
160: void *value = NULL;
161: const char *acl_name;
162: struct v9fs_session_info *v9ses;
163: struct inode *inode = d_inode(dentry);
164:
165: if (acl) {
166: retval = posix_acl_valid(inode->i_sb->s_user_ns, acl);
167: if (retval)
168: goto err_out;
169:
170: value = posix_acl_to_xattr(&init_user_ns, acl, &size, GFP_NOFS);
171: if (!value) {
172: retval = -ENOMEM;
173: goto err_out;
174: }
175: }
176:
177: /*
178: * set the attribute on the remote. Without even looking at the
179: * xattr value. We leave it to the server to validate
180: */
181: acl_name = posix_acl_xattr_name(type);
182: v9ses = v9fs_dentry2v9ses(dentry);
183: if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) {
184: retval = v9fs_xattr_set(dentry, acl_name, value, size, 0);
185: goto err_out;
186: }
187:
188: if (S_ISLNK(inode->i_mode)) {
189: retval = -EOPNOTSUPP;
190: goto err_out;
191: }
192:
193: if (!inode_owner_or_capable(&nop_mnt_idmap, inode)) {
194: retval = -EPERM;
195: goto err_out;
196: }
197:
198: switch (type) {
199: case ACL_TYPE_ACCESS:
200: if (acl) {
201: struct iattr iattr = {};
202: struct posix_acl *acl_mode = acl;
203:
204: retval = posix_acl_update_mode(&nop_mnt_idmap, inode,
205: &iattr.ia_mode,
206: &acl_mode);
207: if (retval)
208: goto err_out;
209: if (!acl_mode) {
210: /*
211: * ACL can be represented by the mode bits.
212: * So don't update ACL below.
213: */
214: kfree(value);
215: value = NULL;
216: size = 0;
217: }
218: iattr.ia_valid = ATTR_MODE;
219: /*
220: * FIXME should we update ctime ?
221: * What is the following setxattr update the mode ?
222: */
223: v9fs_vfs_setattr_dotl(&nop_mnt_idmap, dentry, &iattr);
224: }
225: break;
226: case ACL_TYPE_DEFAULT:
227: if (!S_ISDIR(inode->i_mode)) {
228: retval = acl ? -EINVAL : 0;
229: goto err_out;
230: }
231: break;
232: }
233:
234: retval = v9fs_xattr_set(dentry, acl_name, value, size, 0);
235: if (!retval)
236: set_cached_acl(inode, type, acl);
237:
238: err_out:
239: kfree(value);
240: return retval;
241: }
SourceFile:fs/9p/acl.c]
|
| 88/2 |
2026/05/17 08:24 |
llm |
expert |
0m
Model:
Tokens:
input: 66397
output: 55
thoughts: 39
Thoughts: Okay, here's my interpretation of those thoughts, framed as my own:
**Unpacking the `v9fs_vfs_setattr_dotl` Call**
Alright, hang on a second... I see `v9fs_vfs_setattr_dotl` being called. That's a key function in this 9P file system interaction, likely handling extended attribute setting. Now, the critical question is whether or not this function, specifically, is responsible for unlocking the inode after it's been manipulated. My experience tells me this is something I need to confirm immediately. It’s absolutely vital to understand the locking semantics around attribute changes to avoid data corruption or races. I need to dig into the code and determine whether `v9fs_vfs_setattr_dotl` takes care of the lock, and if so, how it handles it. If not, I need to figure out where and how that locking is managed in this call path. This is a critical point that needs my full attention.
|
| 89/2 |
2026/05/17 08:24 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/9p/vfs_inode_dotl.c IncludeLines:true Name:v9fs_vfs_setattr_dotl]
Results: map[SourceCode: 513: int v9fs_vfs_setattr_dotl(struct mnt_idmap *idmap,
514: struct dentry *dentry, struct iattr *iattr)
515: {
516: int retval, use_dentry = 0;
517: struct inode *inode = d_inode(dentry);
518: struct v9fs_session_info __maybe_unused *v9ses;
519: struct p9_fid *fid = NULL;
520: struct p9_iattr_dotl p9attr = {
521: .uid = INVALID_UID,
522: .gid = INVALID_GID,
523: };
524:
525: p9_debug(P9_DEBUG_VFS, "\n");
526:
527: retval = setattr_prepare(&nop_mnt_idmap, dentry, iattr);
528: if (retval)
529: return retval;
530:
531: v9ses = v9fs_dentry2v9ses(dentry);
532:
533: p9attr.valid = v9fs_mapped_iattr_valid(iattr->ia_valid);
534: if (iattr->ia_valid & ATTR_MODE)
535: p9attr.mode = iattr->ia_mode;
536: if (iattr->ia_valid & ATTR_UID)
537: p9attr.uid = iattr->ia_uid;
538: if (iattr->ia_valid & ATTR_GID)
539: p9attr.gid = iattr->ia_gid;
540: if (iattr->ia_valid & ATTR_SIZE)
541: p9attr.size = iattr->ia_size;
542: if (iattr->ia_valid & ATTR_ATIME_SET) {
543: p9attr.atime_sec = iattr->ia_atime.tv_sec;
544: p9attr.atime_nsec = iattr->ia_atime.tv_nsec;
545: }
546: if (iattr->ia_valid & ATTR_MTIME_SET) {
547: p9attr.mtime_sec = iattr->ia_mtime.tv_sec;
548: p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec;
549: }
550:
551: if (iattr->ia_valid & ATTR_FILE) {
552: fid = iattr->ia_file->private_data;
553: WARN_ON(!fid);
554: }
555: if (!fid) {
556: fid = v9fs_fid_lookup(dentry);
557: use_dentry = 1;
558: }
559: if (IS_ERR(fid))
560: return PTR_ERR(fid);
561:
562: /* Write all dirty data */
563: if (S_ISREG(inode->i_mode)) {
564: retval = filemap_fdatawrite(inode->i_mapping);
565: if (retval < 0)
566: p9_debug(P9_DEBUG_ERROR,
567: "Flushing file prior to setattr failed: %d\n", retval);
568: }
569:
570: retval = p9_client_setattr(fid, &p9attr);
571: if (retval < 0) {
572: if (use_dentry)
573: p9_fid_put(fid);
574: return retval;
575: }
576:
577: if ((iattr->ia_valid & ATTR_SIZE) && iattr->ia_size !=
578: i_size_read(inode)) {
579: truncate_setsize(inode, iattr->ia_size);
580: netfs_resize_file(netfs_inode(inode), iattr->ia_size, true);
581:
582: #ifdef CONFIG_9P_FSCACHE
583: if (v9ses->cache & CACHE_FSCACHE)
584: fscache_resize_cookie(v9fs_inode_cookie(V9FS_I(inode)),
585: iattr->ia_size);
586: #endif
587: }
588:
589: v9fs_invalidate_inode_attr(inode);
590: setattr_copy(&nop_mnt_idmap, inode, iattr);
591: mark_inode_dirty(inode);
592: if (iattr->ia_valid & ATTR_MODE) {
593: /* We also want to update ACL when we update mode bits */
594: retval = v9fs_acl_chmod(inode, fid);
595: if (retval < 0) {
596: if (use_dentry)
597: p9_fid_put(fid);
598: return retval;
599: }
600: }
601: if (use_dentry)
602: p9_fid_put(fid);
603:
604: return 0;
605: }
SourceFile:fs/9p/vfs_inode_dotl.c]
|
| 90/2 |
2026/05/17 08:24 |
llm |
expert |
0m
Model:
Tokens:
input: 68275
output: 21
thoughts: 864
Thoughts: **Debugging a Potential Kernel Panic**
Okay, so I'm trying to figure out this potential kernel panic, and I'm chasing a few leads here. First, I was pondering this `removexattr` scenario and what happens if we're dealing with a delegated dentry and `try_break_deleg` returns `-EWOULDBLOCK`. I was wondering if there's some obscure race where `di->di_inode` isn't set, but now I see that's wrong; the code specifically *sets* `di->di_inode` if it gets `-EWOULDBLOCK`. That settles that.
Then I considered `break_deleg_wait` returning `-EWOULDBLOCK`. That code looks sound. It calls `break_deleg` (which waits), then cleans up the delegate structure. `vfs_remove_acl` seems fine in this case.
Next, I zeroed in on the `vfs_remove_acl` path. My initial thought was, could `set_posix_acl` somehow call `inode_unlock`? I checked a bunch of filesystems, and none of them do that directly. I did wonder about `posix_acl_chmod` since it's used in `setattr` and it could potentially call some inode-related functions, but `set_posix_acl` uses `inode->i_op->set_acl` directly. Okay, that's not it.
Then I had a moment of panic: what if `d_inode(dentry)` is NULL in `vfs_remove_acl`? That would definitely cause a crash! But I'm pretty sure that can't happen, as the filesystem has to exist, so the dentry would have an inode.
Alright, time to regroup. The warning message I'm seeing involves `__up_write` and this `rwsem_owner` check, which suggests the inode write semaphore isn't being used correctly. I'm wondering if `inode_unlock` is being called without a corresponding `inode_lock`. But `inode_lock` is *unconditionally* called at the start of `vfs_remove_acl`! And it's a `down_write`, so it *shouldn't* fail.
Could the `inode` pointer be changing somehow between the lock and unlock? That seemed unlikely, it's a local variable.
Could the `i_rwsem` itself be corrupted, rendering the inode unlocked? If it were, the lock would be zero, but zero would mean *unlocked* - not causing any problem. If it was corrupt it would have garbage values.
Could `inode_unlock` be called twice? That's what I was originally after, and that could happen if `set_posix_acl` had a bug, but I've reviewed those filesystems. I need to be more thorough, though, and search the entire kernel for `inode_unlock` to be sure there isn't something subtle happening. I'll search `fs/` now to be certain. I am now more certain, that I'll find an error.
|
| 91/2 |
2026/05/17 08:25 |
tool |
grepper |
0m
Error:
Args: map[Expression:inode_unlock.*set_acl]
Results:
|
| 92/2 |
2026/05/17 08:25 |
llm |
expert |
0m
Model:
Tokens:
input: 69845
output: 21
thoughts: 8
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to an expert:
**Reflecting on `up_write`**
Hmm, `up_write`... That term keeps surfacing in my mind. It's not immediately obvious what it refers to in this context. Is it an existing function or a planned implementation? Is it a convention, a specific library call, or perhaps a shorthand for an operation? It's key to identify its precise meaning to understand its implications for the task at hand. What's the design context? Is it related to data modification, file access, or perhaps some sort of versioning or updating mechanism? I need to consider its potential scope, any performance trade-offs, and possible conflict scenarios with the existing architecture. The implications of this are important, and need to be worked through.
|
| 93/2 |
2026/05/17 08:25 |
tool |
grepper |
0m
Error:
Args: map[Expression:up_write.*set_acl]
Results:
|
| 94/2 |
2026/05/17 08:25 |
llm |
expert |
0m
Model:
Tokens:
input: 70067
output: 17
thoughts: 88
Thoughts: Okay, let me think this through.
**Investigating a Potential Race Condition in ACL Handling**
Hmm, so I'm wondering about a potential concurrency issue related to ACLs, specifically the interaction between `removexattr` and `vfs_remove_acl`. The situation is this: `set_posix_acl` eventually calls `inode->i_op->set_acl`. Now, here's where it gets interesting – what if the `inode->i_op->set_acl` implementation itself *also* unlocks the inode? That could create a race condition if another thread is also working with the same inode. It seems like a classic lock order problem.
To investigate, I need to look at the implementations of all the `set_acl` methods throughout the filesystem code. I'll need to search the code for any instance where `inode_unlock` (or its equivalents) appears *within* those `set_acl` functions. That will give me the best view of the situation. I need to make sure the lock is held through the duration.
|
| 95/2 |
2026/05/17 08:25 |
tool |
grepper |
0m
Args: map[Expression:inode_unlock]
Results: map[Output:
Full output is too long, showing 500 out of 3273 lines.
Use more precise expression if possible.
[arch/powerpc/platforms/cell/spufs/file.c=1701=static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int datasync)
--
arch/powerpc/platforms/cell/spufs/file.c-1707- err = spufs_mfc_flush(file, NULL);
arch/powerpc/platforms/cell/spufs/file.c:1708: inode_unlock(inode);
arch/powerpc/platforms/cell/spufs/file.c-1709- }
--
arch/powerpc/platforms/cell/spufs/inode.c=174=static void unuse_gang(struct dentry *dir)
--
arch/powerpc/platforms/cell/spufs/inode.c-183- dead = !--gang->alive;
arch/powerpc/platforms/cell/spufs/inode.c:184: inode_unlock(inode);
arch/powerpc/platforms/cell/spufs/inode.c-185-
--
arch/powerpc/platforms/cell/spufs/inode.c=191=static int spufs_dir_close(struct inode *inode, struct file *file)
--
arch/powerpc/platforms/cell/spufs/inode.c-200- spufs_rmdir(parent, dir);
arch/powerpc/platforms/cell/spufs/inode.c:201: inode_unlock(parent);
arch/powerpc/platforms/cell/spufs/inode.c-202-
--
arch/powerpc/platforms/cell/spufs/inode.c=218=spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
--
arch/powerpc/platforms/cell/spufs/inode.c-257-
arch/powerpc/platforms/cell/spufs/inode.c:258: inode_unlock(inode);
arch/powerpc/platforms/cell/spufs/inode.c-259-
--
block/bdev.c=178=int set_blocksize(struct file *file, int size)
--
block/bdev.c-211- filemap_invalidate_unlock(inode->i_mapping);
block/bdev.c:212: inode_unlock(inode);
block/bdev.c-213- }
--
block/blk-zoned.c=435=int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode,
--
block/blk-zoned.c-483- filemap_invalidate_unlock(bdev->bd_mapping);
block/blk-zoned.c:484: inode_unlock(bdev->bd_mapping->host);
block/blk-zoned.c-485- }
--
block/fops.c=602=static loff_t blkdev_llseek(struct file *file, loff_t offset, int whence)
--
block/fops.c-608- retval = fixed_size_llseek(file, offset, whence, i_size_read(bd_inode));
block/fops.c:609: inode_unlock(bd_inode);
block/fops.c-610- return retval;
--
block/fops.c=746=static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
--
block/fops.c-801- ret = blkdev_buffered_write(iocb, from);
block/fops.c:802: inode_unlock_shared(bd_inode);
block/fops.c-803- }
--
block/fops.c=811=static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
--
block/fops.c-855- ret = filemap_read(iocb, to, ret);
block/fops.c:856: inode_unlock_shared(bd_inode);
block/fops.c-857-
--
block/fops.c=868=static long blkdev_fallocate(struct file *file, int mode, loff_t start,
--
block/fops.c-937- filemap_invalidate_unlock(inode->i_mapping);
block/fops.c:938: inode_unlock(inode);
block/fops.c-939- return error;
--
block/ioctl.c=121=static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode,
--
block/ioctl.c-178- filemap_invalidate_unlock(bdev->bd_mapping);
block/ioctl.c:179: inode_unlock(bdev->bd_mapping->host);
block/ioctl.c-180- return err;
--
block/ioctl.c=183=static int blk_ioctl_secure_erase(struct block_device *bdev, blk_mode_t mode,
--
block/ioctl.c-211- filemap_invalidate_unlock(bdev->bd_mapping);
block/ioctl.c:212: inode_unlock(bdev->bd_mapping->host);
block/ioctl.c-213- return err;
--
block/ioctl.c=217=static int blk_ioctl_zeroout(struct block_device *bdev, blk_mode_t mode,
--
block/ioctl.c-254- filemap_invalidate_unlock(bdev->bd_mapping);
block/ioctl.c:255: inode_unlock(bdev->bd_mapping->host);
block/ioctl.c-256- return err;
--
drivers/base/devtmpfs.c=217=static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
--
drivers/base/devtmpfs.c-242- notify_change(&nop_mnt_idmap, dentry, &newattrs, NULL);
drivers/base/devtmpfs.c:243: inode_unlock(d_inode(dentry));
drivers/base/devtmpfs.c-244-
--
drivers/base/devtmpfs.c=317=static int handle_remove(const char *nodename, struct device *dev)
--
drivers/base/devtmpfs.c-342- notify_change(&nop_mnt_idmap, dentry, &newattrs, NULL);
drivers/base/devtmpfs.c:343: inode_unlock(d_inode(dentry));
drivers/base/devtmpfs.c-344- err = vfs_unlink(&nop_mnt_idmap, d_inode(parent.dentry),
--
drivers/block/drbd/drbd_debugfs.c=418=static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, void *),
--
drivers/block/drbd/drbd_debugfs.c-433- ret = 0;
drivers/block/drbd/drbd_debugfs.c:434: inode_unlock(d_inode(parent));
drivers/block/drbd/drbd_debugfs.c-435- if (!ret) {
--
drivers/char/mem.c=590=static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
--
drivers/char/mem.c-611- }
drivers/char/mem.c:612: inode_unlock(file_inode(file));
drivers/char/mem.c-613- return ret;
--
drivers/char/ps3flash.c=277=static int ps3flash_fsync(struct file *file, loff_t start, loff_t end, int datasync)
--
drivers/char/ps3flash.c-282- err = ps3flash_writeback(ps3flash_dev);
drivers/char/ps3flash.c:283: inode_unlock(inode);
drivers/char/ps3flash.c-284- return err;
--
drivers/char/tpm/eventlog/common.c=25=static int tpm_bios_measurements_open(struct inode *inode,
--
drivers/char/tpm/eventlog/common.c-35- if (!inode->i_nlink) {
drivers/char/tpm/eventlog/common.c:36: inode_unlock(inode);
drivers/char/tpm/eventlog/common.c-37- return -ENODEV;
--
drivers/char/tpm/eventlog/common.c-42- get_device(&chip->dev);
drivers/char/tpm/eventlog/common.c:43: inode_unlock(inode);
drivers/char/tpm/eventlog/common.c-44-
--
drivers/dma-buf/udmabuf.c=369=static long udmabuf_create(struct miscdevice *device,
--
drivers/dma-buf/udmabuf.c-434-out_unlock:
drivers/dma-buf/udmabuf.c:435: inode_unlock_shared(file_inode(memfd));
drivers/dma-buf/udmabuf.c-436- fput(memfd);
--
drivers/mtd/ubi/cdev.c=157=static int vol_cdev_fsync(struct file *file, loff_t start, loff_t end,
--
drivers/mtd/ubi/cdev.c-165- err = ubi_sync(ubi->ubi_num);
drivers/mtd/ubi/cdev.c:166: inode_unlock(inode);
drivers/mtd/ubi/cdev.c-167- return err;
--
drivers/usb/gadget/function/f_printer.c=711=printer_fsync(struct file *fd, loff_t start, loff_t end, int datasync)
--
drivers/usb/gadget/function/f_printer.c-722- spin_unlock_irqrestore(&dev->lock, flags);
drivers/usb/gadget/function/f_printer.c:723: inode_unlock(inode);
drivers/usb/gadget/function/f_printer.c-724- return -ENODEV;
--
drivers/usb/gadget/function/f_printer.c-734- }
drivers/usb/gadget/function/f_printer.c:735: inode_unlock(inode);
drivers/usb/gadget/function/f_printer.c-736-
--
drivers/usb/gadget/udc/atmel_usba_udc.c=84=static ssize_t queue_dbg_read(struct file *file, char __user *buf,
--
drivers/usb/gadget/udc/atmel_usba_udc.c-120- }
drivers/usb/gadget/udc/atmel_usba_udc.c:121: inode_unlock(file_inode(file));
drivers/usb/gadget/udc/atmel_usba_udc.c-122-
--
drivers/usb/gadget/udc/atmel_usba_udc.c=139=static int regs_dbg_open(struct inode *inode, struct file *file)
--
drivers/usb/gadget/udc/atmel_usba_udc.c-160-out:
drivers/usb/gadget/udc/atmel_usba_udc.c:161: inode_unlock(inode);
drivers/usb/gadget/udc/atmel_usba_udc.c-162-
--
drivers/usb/gadget/udc/atmel_usba_udc.c=166=static ssize_t regs_dbg_read(struct file *file, char __user *buf,
--
drivers/usb/gadget/udc/atmel_usba_udc.c-175- file_inode(file)->i_size);
drivers/usb/gadget/udc/atmel_usba_udc.c:176: inode_unlock(inode);
drivers/usb/gadget/udc/atmel_usba_udc.c-177-
--
drivers/video/fbdev/core/fb_defio.c=145=int fb_deferred_io_fsync(struct file *file, loff_t start, loff_t end, int datasync)
--
drivers/video/fbdev/core/fb_defio.c-158- flush_delayed_work(&info->deferred_work);
drivers/video/fbdev/core/fb_defio.c:159: inode_unlock(inode);
drivers/video/fbdev/core/fb_defio.c-160-
--
fs/9p/vfs_file.c=415=static int v9fs_file_fsync(struct file *filp, loff_t start, loff_t end,
--
fs/9p/vfs_file.c-433- retval = p9_client_wstat(fid, &wstat);
fs/9p/vfs_file.c:434: inode_unlock(inode);
fs/9p/vfs_file.c-435-
--
fs/9p/vfs_file.c=439=int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
--
fs/9p/vfs_file.c-455- retval = p9_client_fsync(fid, datasync);
fs/9p/vfs_file.c:456: inode_unlock(inode);
fs/9p/vfs_file.c-457-
--
fs/affs/file.c=34=affs_file_release(struct inode *inode, struct file *filp)
--
fs/affs/file.c-43- affs_free_prealloc(inode);
fs/affs/file.c:44: inode_unlock(inode);
fs/affs/file.c-45- }
--
fs/affs/file.c=986=int affs_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
--
fs/affs/file.c-999- ret = err;
fs/affs/file.c:1000: inode_unlock(inode);
fs/affs/file.c-1001- return ret;
--
fs/afs/addr_prefs.c=379=int afs_proc_addr_prefs_write(struct file *file, char *buf, size_t size)
--
fs/afs/addr_prefs.c-442- kfree(preflist);
fs/afs/addr_prefs.c:443: inode_unlock(file_inode(file));
fs/afs/addr_prefs.c-444- _leave(" = %d", ret);
--
fs/afs/proc.c=224=static int afs_proc_rootcell_write(struct file *file, char *buf, size_t size)
--
fs/afs/proc.c-250- printk("busy\n");
fs/afs/proc.c:251: inode_unlock(file_inode(file));
fs/afs/proc.c-252-
--
fs/binfmt_misc.c=719=static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
--
fs/binfmt_misc.c-751-
fs/binfmt_misc.c:752: inode_unlock(inode);
fs/binfmt_misc.c-753- break;
--
fs/binfmt_misc.c=861=static ssize_t bm_status_write(struct file *file, const char __user *buffer,
--
fs/binfmt_misc.c-895-
fs/binfmt_misc.c:896: inode_unlock(inode);
fs/binfmt_misc.c-897- break;
--
fs/bpf_fs_kfuncs.c=286=__bpf_kfunc int bpf_set_dentry_xattr(struct dentry *dentry, const char *name__str,
--
fs/bpf_fs_kfuncs.c-293- ret = bpf_set_dentry_xattr_locked(dentry, name__str, value_p, flags);
fs/bpf_fs_kfuncs.c:294: inode_unlock(inode);
fs/bpf_fs_kfuncs.c-295- return ret;
--
fs/bpf_fs_kfuncs.c=312=__bpf_kfunc int bpf_remove_dentry_xattr(struct dentry *dentry, const char *name__str)
--
fs/bpf_fs_kfuncs.c-318- ret = bpf_remove_dentry_xattr_locked(dentry, name__str);
fs/bpf_fs_kfuncs.c:319: inode_unlock(inode);
fs/bpf_fs_kfuncs.c-320- return ret;
--
fs/btrfs/btrfs_inode.h=662=int btrfs_inode_lock(struct btrfs_inode *inode, unsigned int ilock_flags);
fs/btrfs/btrfs_inode.h:663:void btrfs_inode_unlock(struct btrfs_inode *inode, unsigned int ilock_flags);
fs/btrfs/btrfs_inode.h-664-void btrfs_update_inode_bytes(struct btrfs_inode *inode, const u64 add_bytes,
--
fs/btrfs/defrag.c=1356=int btrfs_defrag_file(struct btrfs_inode *inode, struct file_ra_state *ra,
--
fs/btrfs/defrag.c-1442- ret = -ETXTBSY;
fs/btrfs/defrag.c:1443: btrfs_inode_unlock(inode, 0);
fs/btrfs/defrag.c-1444- break;
--
fs/btrfs/defrag.c-1446- if (!(inode->vfs_inode.i_sb->s_flags & SB_ACTIVE)) {
fs/btrfs/defrag.c:1447: btrfs_inode_unlock(inode, 0);
fs/btrfs/defrag.c-1448- break;
--
fs/btrfs/defrag.c-1462-
fs/btrfs/defrag.c:1463: btrfs_inode_unlock(inode, 0);
fs/btrfs/defrag.c-1464- if (ret < 0)
--
fs/btrfs/defrag.c-1498- inode->defrag_compress = BTRFS_COMPRESS_NONE;
fs/btrfs/defrag.c:1499: btrfs_inode_unlock(inode, 0);
fs/btrfs/defrag.c-1500- }
--
fs/btrfs/delayed-inode.c=1694=bool btrfs_readdir_get_delayed_items(struct btrfs_inode *inode,
--
fs/btrfs/delayed-inode.c-1710- */
fs/btrfs/delayed-inode.c:1711: btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
fs/btrfs/delayed-inode.c-1712- btrfs_inode_lock(inode, 0);
--
fs/btrfs/direct-io.c=791=ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
--
fs/btrfs/direct-io.c-835- if ((ilock_flags & BTRFS_ILOCK_SHARED) && !IS_NOSEC(inode)) {
fs/btrfs/direct-io.c:836: btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
fs/btrfs/direct-io.c-837- ilock_flags &= ~BTRFS_ILOCK_SHARED;
--
fs/btrfs/direct-io.c-842- if (ret <= 0) {
fs/btrfs/direct-io.c:843: btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
fs/btrfs/direct-io.c-844- return ret;
--
fs/btrfs/direct-io.c-848- if (ret < 0) {
fs/btrfs/direct-io.c:849: btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
fs/btrfs/direct-io.c-850- goto out;
--
fs/btrfs/direct-io.c-859- pos + iov_iter_count(from) > i_size_read(inode)) {
fs/btrfs/direct-io.c:860: btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
fs/btrfs/direct-io.c-861- ilock_flags &= ~BTRFS_ILOCK_SHARED;
--
fs/btrfs/direct-io.c-865- if (check_direct_IO(fs_info, from, pos)) {
fs/btrfs/direct-io.c:866: btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
fs/btrfs/direct-io.c-867- goto buffered;
--
fs/btrfs/direct-io.c-881- if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
fs/btrfs/direct-io.c:882: btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
fs/btrfs/direct-io.c-883- goto buffered;
--
fs/btrfs/direct-io.c-954-
fs/btrfs/direct-io.c:955: btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
fs/btrfs/direct-io.c-956-
--
fs/btrfs/direct-io.c=1026=ssize_t btrfs_direct_read(struct kiocb *iocb, struct iov_iter *to)
--
fs/btrfs/direct-io.c-1087- }
fs/btrfs/direct-io.c:1088: btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_SHARED);
fs/btrfs/direct-io.c-1089- return ret < 0 ? ret : read;
--
fs/btrfs/fiemap.c=879=int btrfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
--
fs/btrfs/fiemap.c-918- if (ret) {
fs/btrfs/fiemap.c:919: btrfs_inode_unlock(btrfs_inode, BTRFS_ILOCK_SHARED);
fs/btrfs/fiemap.c-920- return ret;
--
fs/btrfs/fiemap.c-924- ret = extent_fiemap(btrfs_inode, fieinfo, start, len);
fs/btrfs/fiemap.c:925: btrfs_inode_unlock(btrfs_inode, BTRFS_ILOCK_SHARED);
fs/btrfs/fiemap.c-926-
--
fs/btrfs/file.c=1349=ssize_t btrfs_buffered_write(struct kiocb *iocb, struct iov_iter *iter)
--
fs/btrfs/file.c-1398-out:
fs/btrfs/file.c:1399: btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
fs/btrfs/file.c-1400- return num_written ? num_written : ret;
--
fs/btrfs/file.c=1403=static ssize_t btrfs_encoded_write(struct kiocb *iocb, struct iov_iter *from,
--
fs/btrfs/file.c-1429-out:
fs/btrfs/file.c:1430: btrfs_inode_unlock(BTRFS_I(inode), 0);
fs/btrfs/file.c-1431- return ret;
--
fs/btrfs/file.c=1557=int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
--
fs/btrfs/file.c-1631- else
fs/btrfs/file.c:1632: btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
fs/btrfs/file.c-1633- goto out;
--
fs/btrfs/file.c-1759- else
fs/btrfs/file.c:1760: btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
fs/btrfs/file.c-1761-
--
fs/btrfs/file.c-1831- else
fs/btrfs/file.c:1832: btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
fs/btrfs/file.c-1833- goto out;
--
fs/btrfs/file.c=2651=static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
--
fs/btrfs/file.c-2714- if (ret) {
fs/btrfs/file.c:2715: btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
fs/btrfs/file.c-2716- return ret;
--
fs/btrfs/file.c-2811- }
fs/btrfs/file.c:2812: btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
fs/btrfs/file.c-2813- return ret;
--
fs/btrfs/file.c=3095=static long btrfs_fallocate(struct file *file, int mode,
--
fs/btrfs/file.c-3187- ret = btrfs_zero_range(inode, offset, len, mode);
fs/btrfs/file.c:3188: btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
fs/btrfs/file.c-3189- return ret;
--
fs/btrfs/file.c-3284-out:
fs/btrfs/file.c:3285: btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
fs/btrfs/file.c-3286- extent_changeset_free(data_reserved);
--
fs/btrfs/file.c=3787=static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
--
fs/btrfs/file.c-3797- offset = find_desired_extent(file, offset, whence);
fs/btrfs/file.c:3798: btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_SHARED);
fs/btrfs/file.c-3799- break;
--
fs/btrfs/inode.c=352=int btrfs_inode_lock(struct btrfs_inode *inode, unsigned int ilock_flags)
--
fs/btrfs/inode.c-381- */
fs/btrfs/inode.c:382:void btrfs_inode_unlock(struct btrfs_inode *inode, unsigned int ilock_flags)
fs/btrfs/inode.c-383-{
--
fs/btrfs/inode.c-386- if (ilock_flags & BTRFS_ILOCK_SHARED)
fs/btrfs/inode.c:387: inode_unlock_shared(&inode->vfs_inode);
fs/btrfs/inode.c-388- else
fs/btrfs/inode.c:389: inode_unlock(&inode->vfs_inode);
fs/btrfs/inode.c-390-}
--
fs/btrfs/inode.c=6212=static int btrfs_get_dir_last_index(struct btrfs_inode *dir, u64 *index)
--
fs/btrfs/inode.c-6228-out:
fs/btrfs/inode.c:6229: btrfs_inode_unlock(dir, 0);
fs/btrfs/inode.c-6230-
--
fs/btrfs/inode.c=9454=static ssize_t btrfs_encoded_read_inline(
--
fs/btrfs/inode.c-9528- btrfs_unlock_extent(io_tree, start, lockend, cached_state);
fs/btrfs/inode.c:9529: btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
fs/btrfs/inode.c-9530- *unlocked = true;
--
fs/btrfs/inode.c=9644=ssize_t btrfs_encoded_read_regular(struct kiocb *iocb, struct iov_iter *iter,
--
fs/btrfs/inode.c-9673- btrfs_unlock_extent(io_tree, start, lockend, cached_state);
fs/btrfs/inode.c:9674: btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
fs/btrfs/inode.c-9675- *unlocked = true;
--
fs/btrfs/inode.c=9708=ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter,
--
fs/btrfs/inode.c-9730- if (iocb->ki_pos >= inode->vfs_inode.i_size) {
fs/btrfs/inode.c:9731: btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
fs/btrfs/inode.c-9732- return 0;
--
fs/btrfs/inode.c-9853- btrfs_unlock_extent(io_tree, start, lockend, cached_state);
fs/btrfs/inode.c:9854: btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
fs/btrfs/inode.c-9855- unlocked = true;
--
fs/btrfs/inode.c-9871- if (!unlocked && ret != -EIOCBQUEUED)
fs/btrfs/inode.c:9872: btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
fs/btrfs/inode.c-9873- return ret;
--
fs/btrfs/ioctl.c=2159=static noinline int btrfs_ioctl_snap_destroy(struct file *file,
--
fs/btrfs/ioctl.c-2360- ret = btrfs_delete_subvolume(BTRFS_I(dir), dentry);
fs/btrfs/ioctl.c:2361: btrfs_inode_unlock(BTRFS_I(inode), 0);
fs/btrfs/ioctl.c-2362- if (!ret)
--
fs/btrfs/ioctl.c=4290=static int btrfs_ioctl_encoded_read(struct file *file, void __user *argp,
--
fs/btrfs/ioctl.c-4381- btrfs_unlock_extent(io_tree, start, lockend, &cached_state);
fs/btrfs/ioctl.c:4382: btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
fs/btrfs/ioctl.c-4383- }
--
fs/btrfs/ioctl.c=4535=static void btrfs_uring_read_finished(struct io_tw_req tw_req, io_tw_token_t tw)
--
fs/btrfs/ioctl.c-4579- btrfs_unlock_extent(io_tree, priv->start, priv->lockend, &priv->cached_state);
fs/btrfs/ioctl.c:4580: btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
fs/btrfs/ioctl.c-4581-
--
fs/btrfs/ioctl.c=4605=static int btrfs_uring_read_extent(struct kiocb *iocb, struct iov_iter *iter,
--
fs/btrfs/ioctl.c-4669- btrfs_unlock_extent(io_tree, start, lockend, &cached_state);
fs/btrfs/ioctl.c:4670: btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
fs/btrfs/ioctl.c-4671- kfree(priv);
--
fs/btrfs/ioctl.c=4680=static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue_flags)
--
fs/btrfs/ioctl.c-4793- btrfs_unlock_extent(io_tree, start, lockend, &cached_state);
fs/btrfs/ioctl.c:4794: btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
fs/btrfs/ioctl.c-4795- }
--
fs/btrfs/reflink.c=872=loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
--
fs/btrfs/reflink.c-906- if (same_inode) {
fs/btrfs/reflink.c:907: btrfs_inode_unlock(src_inode, BTRFS_ILOCK_MMAP);
fs/btrfs/reflink.c-908- } else {
--
fs/btrfs/relocation.c=2663=static noinline_for_stack int prealloc_file_extent_cluster(struct reloc_control *rc)
--
fs/btrfs/relocation.c-2718- }
fs/btrfs/relocation.c:2719: btrfs_inode_unlock(inode, 0);
fs/btrfs/relocation.c-2720-
--
fs/cachefiles/interface.c=115=static int cachefiles_adjust_size(struct cachefiles_object *object)
--
fs/cachefiles/interface.c-160-truncate_failed:
fs/cachefiles/interface.c:161: inode_unlock(file_inode(file));
fs/cachefiles/interface.c-162-
--
fs/cachefiles/namei.c=33=static bool cachefiles_mark_inode_in_use(struct cachefiles_object *object,
--
fs/cachefiles/namei.c-39- can_use = __cachefiles_mark_inode_in_use(object, inode);
fs/cachefiles/namei.c:40: inode_unlock(inode);
fs/cachefiles/namei.c-41- return can_use;
--
fs/cachefiles/namei.c=54=static void cachefiles_do_unmark_inode_in_use(struct cachefiles_object *object,
--
fs/cachefiles/namei.c-58- __cachefiles_unmark_inode_in_use(object, inode);
fs/cachefiles/namei.c:59: inode_unlock(inode);
fs/cachefiles/namei.c-60-}
--
fs/cachefiles/namei.c=84=struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
--
fs/cachefiles/namei.c-165-
fs/cachefiles/namei.c:166: inode_unlock(d_inode(subdir));
fs/cachefiles/namei.c-167-
--
fs/cachefiles/namei.c-194-mark_error:
fs/cachefiles/namei.c:195: inode_unlock(d_inode(subdir));
fs/cachefiles/namei.c-196- dput(subdir);
--
fs/cachefiles/namei.c-209-nomem_d_alloc:
fs/cachefiles/namei.c:210: inode_unlock(d_inode(dir));
fs/cachefiles/namei.c-211- _leave(" = -ENOMEM");
--
fs/cachefiles/namei.c=786=int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir,
--
fs/cachefiles/namei.c-808- }
fs/cachefiles/namei.c:809: inode_unlock(inode);
fs/cachefiles/namei.c-810- if (ret < 0)
--
fs/cachefiles/namei.c=843=int cachefiles_check_in_use(struct cachefiles_cache *cache, struct dentry *dir,
--
fs/cachefiles/namei.c-852-
fs/cachefiles/namei.c:853: inode_unlock(d_inode(dir));
fs/cachefiles/namei.c-854- dput(victim);
--
fs/ceph/dir.c=674=static loff_t ceph_dir_llseek(struct file *file, loff_t offset, int whence)
--
fs/ceph/dir.c-714-out:
fs/ceph/dir.c:715: inode_unlock(inode);
fs/ceph/dir.c-716- return retval;
--
fs/ceph/export.c=445=static int __get_snap_name(struct dentry *parent, char *name,
--
fs/ceph/export.c-504- err = ceph_mdsc_do_request(fsc->mdsc, NULL, req);
fs/ceph/export.c:505: inode_unlock(dir);
fs/ceph/export.c-506-
--
fs/ceph/export.c=548=static int ceph_get_name(struct dentry *parent, char *name,
--
fs/ceph/export.c-575- err = ceph_mdsc_do_request(mdsc, NULL, req);
fs/ceph/export.c:576: inode_unlock(dir);
fs/ceph/export.c-577-
--
fs/ceph/file.c=2668=static long ceph_fallocate(struct file *file, int mode,
--
]
]
|
| 96/2 |
2026/05/17 08:25 |
llm |
expert |
0m
Model:
Tokens:
input: 80719
output: 47
thoughts: 1648
Thoughts: **Deep Dive into a Potential Inode Locking Issue**
Okay, so I'm looking at this `inode_unlock` call and trying to figure out if there's a double unlock scenario that could be triggered. My initial thought was to see if any of the `set_acl` implementations across various filesystems (`btrfs`, `ext4`, `fuse`, `ceph`, `jfs`, `ntfs`, `simple`, `nfs3`, `xfs`, `f2fs`, `v9fs`, `ovl`) were doing their own inode unlocking, but a quick scan of those shows none of them do that.
Now, I start considering the larger control flow, particularly around how `vfs_remove_acl` might interact with `set_posix_acl` and the locking. I reason that if `set_posix_acl` were to re-lock the inode after `vfs_remove_acl` unlocks it, that could be a problem. But, I don't see any of the filesystems doing so.
Then, I'm digging through the syzkaller report, and I see this warning related to a write lock being released: `WARNING: kernel/locking/rwsem.c:1381 at __up_write kernel/locking/rwsem.c:1380 [inline], CPU#0: syz.1.1645/13704`. This gets me thinking about `try_break_deleg`.
I'm zeroing in on this potential issue with `try_break_deleg`. Specifically, if `try_break_deleg` returns `-EWOULDBLOCK`, we hit the `out_inode_unlock` label, the inode gets unlocked, and then `break_deleg_wait` is called. That could lead to a re-locking issue, but it seems that `break_deleg_wait` is set up to address this, and I need to check the exact circumstances. I'm focusing on what happens if `try_break_deleg` returns `-EWOULDBLOCK` and `is_delegated(&delegated_inode)` is FALSE. I trace the logic and determine that because of the way the variables are set, the code works as expected and this shouldn't be an issue.
Then I expand to other errors. I realize that an error other than `-EWOULDBLOCK` returned by `try_break_deleg` will be handled correctly: the `delegated_inode` won't be set and the error will be handled. The inode will get unlocked, then the error will be returned.
So then, I consider the error path from `break_deleg_wait`. If `break_deleg_wait` *does* return an error, the lock is already unlocked at `out_inode_unlock`, so the correct thing is to just return.
I'm thinking now about `set_posix_acl` itself; specifically what errors it could return, and if that changes anything. If `set_posix_acl` returns an error, it goes to `out_inode_unlock`, the inode gets unlocked, and then it checks `is_delegated`, but `try_break_deleg` returns 0, so `is_delegated` is FALSE, and the error gets returned. This still seems correct.
I also then consider an error path in `may_write_xattr` as a part of a call to `vfs_remove_acl`. If `may_write_xattr` returns an error, the code still unlocks the inode, and returns.
Now, I'm back at the main question: Is there *any* path where `inode_unlock` is called twice? I re-affirm my previous belief that none of the filesystems unlock the inode, then decide to check `cifs_set_acl`, just in case.
|
| 97/2 |
2026/05/17 08:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/smb/client/cifsacl.c IncludeLines:true Name:cifs_set_acl]
Results: map[SourceCode:1771: int cifs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
1772: struct posix_acl *acl, int type)
1773: {
1774: #if defined(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) && defined(CONFIG_CIFS_POSIX)
1775: int rc = -EOPNOTSUPP;
1776: unsigned int xid;
1777: struct super_block *sb = dentry->d_sb;
1778: struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
1779: struct tcon_link *tlink;
1780: struct cifs_tcon *pTcon;
1781: const char *full_path;
1782: void *page;
1783:
1784: tlink = cifs_sb_tlink(cifs_sb);
1785: if (IS_ERR(tlink))
1786: return PTR_ERR(tlink);
1787: pTcon = tlink_tcon(tlink);
1788:
1789: xid = get_xid();
1790: page = alloc_dentry_path();
1791:
1792: full_path = build_path_from_dentry(dentry, page);
1793: if (IS_ERR(full_path)) {
1794: rc = PTR_ERR(full_path);
1795: goto out;
1796: }
1797:
1798: if (!acl)
1799: goto out;
1800:
1801: /* return dos attributes as pseudo xattr */
1802: /* return alt name if available as pseudo attr */
1803:
1804: /* if proc/fs/cifs/streamstoxattr is set then
1805: search server for EAs or streams to
1806: returns as xattrs */
1807: if (posix_acl_xattr_size(acl->a_count) > CIFSMaxBufSize) {
1808: cifs_dbg(FYI, "size of EA value too large\n");
1809: rc = -EOPNOTSUPP;
1810: goto out;
1811: }
1812:
1813: switch (type) {
1814: case ACL_TYPE_ACCESS:
1815: if (sb->s_flags & SB_POSIXACL)
1816: rc = cifs_do_set_acl(xid, pTcon, full_path, acl,
1817: ACL_TYPE_ACCESS,
1818: cifs_sb->local_nls,
1819: cifs_remap(cifs_sb));
1820: break;
1821:
1822: case ACL_TYPE_DEFAULT:
1823: if (sb->s_flags & SB_POSIXACL)
1824: rc = cifs_do_set_acl(xid, pTcon, full_path, acl,
1825: ACL_TYPE_DEFAULT,
1826: cifs_sb->local_nls,
1827: cifs_remap(cifs_sb));
1828: break;
1829: }
1830:
1831: out:
1832: free_dentry_path(page);
1833: free_xid(xid);
1834: cifs_put_tlink(tlink);
1835: return rc;
1836: #else
1837: return -EOPNOTSUPP;
1838: #endif
1839: }
SourceFile:fs/smb/client/cifsacl.c]
|
| 98/2 |
2026/05/17 08:25 |
llm |
expert |
0m
Model:
Tokens:
input: 84329
output: 43
thoughts: 16
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Navigating the ACL Landscape**
Alright, nothing immediately jumping out as a potential solution here. The current approach isn't yielding the desired result, and I'm hitting a wall. Need to pivot.
My mind immediately jumps to a potential avenue: `orangefs_set_acl`. Given the context, this seems like the most likely function within the OrangeFS suite that deals with setting Access Control Lists. It's the obvious candidate to explore further. I'll need to refresh my memory on its exact implementation, parameters, and return codes. The devil is always in the details with ACLs.
|
| 99/2 |
2026/05/17 08:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/orangefs/acl.c IncludeLines:true Name:orangefs_set_acl]
Results: map[SourceCode: 115: int orangefs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
116: struct posix_acl *acl, int type)
117: {
118: int error;
119: struct iattr iattr;
120: int rc;
121: struct inode *inode = d_inode(dentry);
122:
123: memset(&iattr, 0, sizeof iattr);
124:
125: if (type == ACL_TYPE_ACCESS && acl) {
126: /*
127: * posix_acl_update_mode checks to see if the permissions
128: * described by the ACL can be encoded into the
129: * object's mode. If so, it sets "acl" to NULL
130: * and "mode" to the new desired value. It is up to
131: * us to propagate the new mode back to the server...
132: */
133: error = posix_acl_update_mode(&nop_mnt_idmap, inode,
134: &iattr.ia_mode, &acl);
135: if (error) {
136: gossip_err("%s: posix_acl_update_mode err: %d\n",
137: __func__,
138: error);
139: return error;
140: }
141:
142: if (inode->i_mode != iattr.ia_mode)
143: iattr.ia_valid = ATTR_MODE;
144:
145: }
146:
147: rc = __orangefs_set_acl(inode, acl, type);
148:
149: if (!rc && (iattr.ia_valid == ATTR_MODE))
150: rc = __orangefs_setattr_mode(dentry, &iattr);
151:
152: return rc;
153: }
SourceFile:fs/orangefs/acl.c]
|
| 100/2 |
2026/05/17 08:25 |
llm |
expert |
0m
Model:
Tokens:
input: 85152
output: 47
thoughts: 18
Thoughts: Okay, here's my summary, presented as a stream of thought:
**No Unlock - A Dead End?**
Alright, initial scan complete. Nothing immediately jumping out here to help with the unlock. This feels like a dead end for the moment. Gotta keep searching, keep looking. Let's not get discouraged.
Wait... something just poked at the back of my mind... what about `jffs2_set_acl`? Is there something exploitable there? I should consider it. That function might provide a potential vector. I need to refresh my memory and check the documentation. See if it's applicable to what I'm dealing with. Worth a closer look.
|
| 101/2 |
2026/05/17 08:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/jffs2/acl.c IncludeLines:true Name:jffs2_set_acl]
Results: map[SourceCode: 231: int jffs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
232: struct posix_acl *acl, int type)
233: {
234: int rc, xprefix;
235: struct inode *inode = d_inode(dentry);
236:
237: switch (type) {
238: case ACL_TYPE_ACCESS:
239: xprefix = JFFS2_XPREFIX_ACL_ACCESS;
240: if (acl) {
241: umode_t mode;
242:
243: rc = posix_acl_update_mode(&nop_mnt_idmap, inode, &mode,
244: &acl);
245: if (rc)
246: return rc;
247: if (inode->i_mode != mode) {
248: struct iattr attr;
249:
250: attr.ia_valid = ATTR_MODE | ATTR_CTIME;
251: attr.ia_mode = mode;
252: attr.ia_ctime = current_time(inode);
253: rc = jffs2_do_setattr(inode, &attr);
254: if (rc < 0)
255: return rc;
256: }
257: }
258: break;
259: case ACL_TYPE_DEFAULT:
260: xprefix = JFFS2_XPREFIX_ACL_DEFAULT;
261: if (!S_ISDIR(inode->i_mode))
262: return acl ? -EACCES : 0;
263: break;
264: default:
265: return -EINVAL;
266: }
267: rc = __jffs2_set_acl(inode, xprefix, acl);
268: if (!rc)
269: set_cached_acl(inode, type, acl);
270: return rc;
271: }
SourceFile:fs/jffs2/acl.c]
|
| 102/2 |
2026/05/17 08:25 |
llm |
expert |
0m
Model:
Tokens:
input: 85990
output: 48
thoughts: 24
Thoughts: Okay, here's my summary, in the first person, as if these are my thoughts, keeping in mind my expertise:
**Potential Inode Lock Conundrum**
Alright, looking at this code, I initially thought there was no explicit unlock operation to be performed in this context. Everything seemed straightforward at first glance. However, that line of thinking didn't sit quite right with me. I've seen these types of operations trip people up before.
Then it hit me: hang on a second. Could `jffs2_do_setattr` actually be handling the unlock implicitly? It's a key function in this area, setting attributes is a common operation. Considering the intricacies of JFFS2 and its inode management, it's very plausible that the attribute setting routine, or a function it calls, *does* in fact unlock the inode internally. This warrants a deeper look at the implementation of `jffs2_do_setattr`. I need to review its code path thoroughly to confirm whether this is indeed the case. If it *is* unlocking, then there's no problem; the absence of an explicit `unlock` is perfectly fine. If not, then a deeper investigation is required to determine why the lock is not released.
|
| 103/2 |
2026/05/17 08:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/jffs2/fs.c IncludeLines:true Name:jffs2_do_setattr]
Results: map[SourceCode: 32: int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
33: {
34: struct jffs2_full_dnode *old_metadata, *new_metadata;
35: struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
36: struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
37: struct jffs2_raw_inode *ri;
38: union jffs2_device_node dev;
39: unsigned char *mdata = NULL;
40: int mdatalen = 0;
41: unsigned int ivalid;
42: uint32_t alloclen;
43: int ret;
44: int alloc_type = ALLOC_NORMAL;
45:
46: jffs2_dbg(1, "%s(): ino #%lu\n", __func__, inode->i_ino);
47:
48: /* Special cases - we don't want more than one data node
49: for these types on the medium at any time. So setattr
50: must read the original data associated with the node
51: (i.e. the device numbers or the target name) and write
52: it out again with the appropriate data attached */
53: if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
54: /* For these, we don't actually need to read the old node */
55: mdatalen = jffs2_encode_dev(&dev, inode->i_rdev);
56: mdata = (char *)&dev;
57: jffs2_dbg(1, "%s(): Writing %d bytes of kdev_t\n",
58: __func__, mdatalen);
59: } else if (S_ISLNK(inode->i_mode)) {
60: mutex_lock(&f->sem);
61: mdatalen = f->metadata->size;
62: mdata = kmalloc(f->metadata->size, GFP_USER);
63: if (!mdata) {
64: mutex_unlock(&f->sem);
65: return -ENOMEM;
66: }
67: ret = jffs2_read_dnode(c, f, f->metadata, mdata, 0, mdatalen);
68: if (ret) {
69: mutex_unlock(&f->sem);
70: kfree(mdata);
71: return ret;
72: }
73: mutex_unlock(&f->sem);
74: jffs2_dbg(1, "%s(): Writing %d bytes of symlink target\n",
75: __func__, mdatalen);
76: }
77:
78: ri = jffs2_alloc_raw_inode();
79: if (!ri) {
80: if (S_ISLNK(inode->i_mode))
81: kfree(mdata);
82: return -ENOMEM;
83: }
84:
85: ret = jffs2_reserve_space(c, sizeof(*ri) + mdatalen, &alloclen,
86: ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
87: if (ret) {
88: jffs2_free_raw_inode(ri);
89: if (S_ISLNK(inode->i_mode))
90: kfree(mdata);
91: return ret;
92: }
93: mutex_lock(&f->sem);
94: ivalid = iattr->ia_valid;
95:
96: ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
97: ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
98: ri->totlen = cpu_to_je32(sizeof(*ri) + mdatalen);
99: ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));
100:
101: ri->ino = cpu_to_je32(inode->i_ino);
102: ri->version = cpu_to_je32(++f->highest_version);
103:
104: ri->uid = cpu_to_je16((ivalid & ATTR_UID)?
105: from_kuid(&init_user_ns, iattr->ia_uid):i_uid_read(inode));
106: ri->gid = cpu_to_je16((ivalid & ATTR_GID)?
107: from_kgid(&init_user_ns, iattr->ia_gid):i_gid_read(inode));
108:
109: if (ivalid & ATTR_MODE)
110: ri->mode = cpu_to_jemode(iattr->ia_mode);
111: else
112: ri->mode = cpu_to_jemode(inode->i_mode);
113:
114:
115: ri->isize = cpu_to_je32((ivalid & ATTR_SIZE)?iattr->ia_size:inode->i_size);
116: ri->atime = cpu_to_je32(I_SEC((ivalid & ATTR_ATIME)?iattr->ia_atime:inode_get_atime(inode)));
117: ri->mtime = cpu_to_je32(I_SEC((ivalid & ATTR_MTIME)?iattr->ia_mtime:inode_get_mtime(inode)));
118: ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode_get_ctime(inode)));
119:
120: ri->offset = cpu_to_je32(0);
121: ri->csize = ri->dsize = cpu_to_je32(mdatalen);
122: ri->compr = JFFS2_COMPR_NONE;
123: if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {
124: /* It's an extension. Make it a hole node */
125: ri->compr = JFFS2_COMPR_ZERO;
126: ri->dsize = cpu_to_je32(iattr->ia_size - inode->i_size);
127: ri->offset = cpu_to_je32(inode->i_size);
128: } else if (ivalid & ATTR_SIZE && !iattr->ia_size) {
129: /* For truncate-to-zero, treat it as deletion because
130: it'll always be obsoleting all previous nodes */
131: alloc_type = ALLOC_DELETION;
132: }
133: ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
134: if (mdatalen)
135: ri->data_crc = cpu_to_je32(crc32(0, mdata, mdatalen));
136: else
137: ri->data_crc = cpu_to_je32(0);
138:
139: new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, alloc_type);
140: if (S_ISLNK(inode->i_mode))
141: kfree(mdata);
142:
143: if (IS_ERR(new_metadata)) {
144: jffs2_complete_reservation(c);
145: jffs2_free_raw_inode(ri);
146: mutex_unlock(&f->sem);
147: return PTR_ERR(new_metadata);
148: }
149: /* It worked. Update the inode */
150: inode_set_atime_to_ts(inode, ITIME(je32_to_cpu(ri->atime)));
151: inode_set_ctime_to_ts(inode, ITIME(je32_to_cpu(ri->ctime)));
152: inode_set_mtime_to_ts(inode, ITIME(je32_to_cpu(ri->mtime)));
153: inode->i_mode = jemode_to_cpu(ri->mode);
154: i_uid_write(inode, je16_to_cpu(ri->uid));
155: i_gid_write(inode, je16_to_cpu(ri->gid));
156:
157:
158: old_metadata = f->metadata;
159:
160: if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size)
161: jffs2_truncate_fragtree (c, &f->fragtree, iattr->ia_size);
162:
163: if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {
164: jffs2_add_full_dnode_to_inode(c, f, new_metadata);
165: inode->i_size = iattr->ia_size;
166: inode->i_blocks = (inode->i_size + 511) >> 9;
167: f->metadata = NULL;
168: } else {
169: f->metadata = new_metadata;
170: }
171: if (old_metadata) {
172: jffs2_mark_node_obsolete(c, old_metadata->raw);
173: jffs2_free_full_dnode(old_metadata);
174: }
175: jffs2_free_raw_inode(ri);
176:
177: mutex_unlock(&f->sem);
178: jffs2_complete_reservation(c);
179:
180: /* We have to do the truncate_setsize() without f->sem held, since
181: some pages may be locked and waiting for it in read_folio().
182: We are protected from a simultaneous write() extending i_size
183: back past iattr->ia_size, because do_truncate() holds the
184: generic inode semaphore. */
185: if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size) {
186: truncate_setsize(inode, iattr->ia_size);
187: inode->i_blocks = (inode->i_size + 511) >> 9;
188: }
189:
190: return 0;
191: }
SourceFile:fs/jffs2/fs.c]
|
| 104/2 |
2026/05/17 08:25 |
llm |
expert |
0m
Model:
Tokens:
input: 89425
output: 41
thoughts: 2027
Thoughts: **Double Unlock Conundrum Analysis**
Okay, let's break this down systematically. The core concern is whether `inode_unlock` gets called twice in any scenario within the `vfs_remove_acl` execution path, particularly when OverlayFS is involved and POSIX ACLs are manipulated.
First, the simple scenario. If `vfs_remove_acl` is called and takes the straightforward path, locking and unlocking the inode seems normal. Then, we need to consider what happens when `set_posix_acl` is called, potentially calling an OverlayFS `set_acl` operation, and whether that introduces an unlock before the intended one. Specifically if `vfs_remove_acl` is called on the *upper* dentry, and it calls `try_break_deleg` with `-EWOULDBLOCK`, this triggers the delegation retry loop with `break_deleg_wait` that appears, at first glance, like it may cause problems. However, after careful tracing, it seems that there's no double unlock because `break_deleg_wait` will always set the `delegated_inode` to `NULL`. The code will only loop and re-lock if `try_break_deleg` returns `-EWOULDBLOCK`, which sets the `delegated_inode`'s `di_inode` to the inode, and `break_deleg_wait` is then called which clears the delegate, so the second call to unlock never happens.
Next, consider the `ovl_setattr` and other scenarios. If `ovl_set_acl` calls `ovl_setattr` which in turn locks and unlocks the upper inode, that's still on a different inode (the upper inode), so that doesn't cause a double unlock. The overlayfs inode itself remains locked until it should be unlocked.
Now, let's explore if there are conditions when `vfs_remove_acl`'s flow branches to cause the unlock to occur twice. We consider the retry loop that occurs within `vfs_remove_acl`. If `break_deleg_wait` returns 0, the code goes to `retry_deleg`, which re-locks the inode. If `try_break_deleg` returns `-EWOULDBLOCK`, it unlocks. But the subsequent `break_deleg_wait` will always set `delegated_inode.di_inode` to NULL, so there's no way to reach `retry_deleg` in this case and thus no chance for a double unlock. What if `try_break_deleg` returns `-EWOULDBLOCK`, and `break_deleg_wait` returns an error? That's still fine, we unlock once.
We need to consider error paths. What if `set_posix_acl` returns an error, or if `is_bad_inode(inode)` is true? In those cases, the code immediately unlocks. This seems correct. Similarly, if `may_write_xattr` or `security_inode_remove_acl` return errors, it will return an error and unlock. This looks clean.
Now, we need to make sure *other* parts of the code don't cause an unlock. We need to check if any other functions, called in the same context, also call `inode_unlock`. No, `fsnotify_xattr` doesn't unlock the inode and neither does `security_inode_post_remove_acl`. The same goes for if `removexattr` calls `vfs_remove_acl`. That does *not* double unlock. Similarly, `path_removexattrat` doesn't double unlock.
Thus, based on this analysis, I'm confident there is no double unlock vulnerability in the current code paths related to `vfs_remove_acl` and OverlayFS, even when POSIX ACLs are used. The delegation retry loop is handled correctly. Error paths are also handled to prevent double unlocks.
|
| 105/2 |
2026/05/17 08:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/xattr.c IncludeLines:true Name:path_removexattrat]
Results: map[SourceCode:1049: static int path_removexattrat(int dfd, const char __user *pathname,
1050: unsigned int at_flags, const char __user *name)
1051: {
1052: struct xattr_name kname;
1053: unsigned int lookup_flags;
1054: int error;
1055:
1056: if ((at_flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0)
1057: return -EINVAL;
1058:
1059: error = import_xattr_name(&kname, name);
1060: if (error)
1061: return error;
1062:
1063: CLASS(filename_maybe_null, filename)(pathname, at_flags);
1064: if (!filename) {
1065: CLASS(fd, f)(dfd);
1066: if (fd_empty(f))
1067: return -EBADF;
1068: return file_removexattr(fd_file(f), &kname);
1069: }
1070: lookup_flags = (at_flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
1071: return filename_removexattr(dfd, filename, lookup_flags, &kname);
1072: }
SourceFile:fs/xattr.c]
|
| 106/2 |
2026/05/17 08:26 |
llm |
expert |
0m
Model:
Tokens:
input: 92743
output: 40
thoughts: 25
Thoughts: **A Sudden Realization**
No, that's not right. The flow isn't as simple as I initially thought. Wait a minute... what if the `filename_removexattr` function, within its execution path, makes a call to `inode_unlock`? That's a crucial point I need to verify. My assumption about the order of operations was incomplete; this potential interaction could drastically alter the implications I'm considering. This warrants a deeper look into the code, and how these different parts are interwoven. I need to trace that call path immediately.
|
| 107/2 |
2026/05/17 08:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/xattr.c IncludeLines:true Name:filename_removexattr]
Results: map[SourceCode:1026: static int filename_removexattr(int dfd, struct filename *filename,
1027: unsigned int lookup_flags, struct xattr_name *kname)
1028: {
1029: struct path path;
1030: int error;
1031:
1032: retry:
1033: error = filename_lookup(dfd, filename, lookup_flags, &path, NULL);
1034: if (error)
1035: return error;
1036: error = mnt_want_write(path.mnt);
1037: if (!error) {
1038: error = removexattr(mnt_idmap(path.mnt), path.dentry, kname->name);
1039: mnt_drop_write(path.mnt);
1040: }
1041: path_put(&path);
1042: if (retry_estale(error, lookup_flags)) {
1043: lookup_flags |= LOOKUP_REVAL;
1044: goto retry;
1045: }
1046: return error;
1047: }
SourceFile:fs/xattr.c]
|
| 108/2 |
2026/05/17 08:26 |
llm |
expert |
0m
Model:
Tokens:
input: 93271
output: 49
thoughts: 1207
Thoughts: **Analyzing the `vfs_remove_acl` Function and its Interactions**
Okay, let's break this down systematically. My initial thought was straightforward, but let's delve deeper into the edge cases.
First, let's consider the case where `vfs_remove_acl` is called on a symlink. We lock the inode, and `may_write_xattr`, `security_inode_remove_acl`, and `try_break_deleg` all proceed as expected, returning 0. Then `set_posix_acl` is called, which, crucially, returns `-EOPNOTSUPP` because the `inode->i_op->set_acl` function is NULL for symlinks. The inode is then unlocked, and `-EOPNOTSUPP` is returned. This is the correct behavior.
Next, consider a directory. Again, we lock the inode. The checks (`may_write_xattr`, `security_inode_remove_acl`, `try_break_deleg`) all succeed, returning 0. This time, `set_posix_acl` returns 0. The inode is then unlocked, and 0 is returned, also perfectly correct.
For a regular file, the process is identical to the directory case, with the same result: 0 is returned after the inode is unlocked. This is expected.
Now, things get interesting with OverlayFS. Let's say `set_posix_acl` calls `ovl_set_acl`, which then calls `ovl_set_or_remove_acl`, which calls `ovl_do_remove_acl`, which calls `vfs_remove_acl` on the UPPER dentry. The UPPER inode is locked. Then, `set_posix_acl` is called on the UPPER dentry. Finally, the UPPER inode is unlocked, and then `vfs_remove_acl` on the OVERLAYFS dentry unlocks the OVERLAYFS inode. This sequence of locking and unlocking is logically sound.
Let's now consider a case in which `ovl_set_acl` calls `ovl_setattr`. `ovl_setattr` locks the UPPER inode, performs its tasks, then calls `ovl_do_notify_change` and *then* unlocks the UPPER inode. Following this, `ovl_set_acl` goes on to call `ovl_set_or_remove_acl`, then `ovl_do_remove_acl`, which calls `vfs_remove_acl` on the UPPER dentry. This locks the UPPER inode. We then get `set_posix_acl` called on the UPPER dentry, and finally, the UPPER inode is unlocked, and then `vfs_remove_acl` on the OVERLAYFS dentry unlocks the OVERLAYFS inode. This is also correct.
The next consideration is if `ovl_setattr` itself unlocks the OVERLAYFS inode directly. We reviewed the code for `ovl_setattr`, and it does *not* unlock the OVERLAYFS inode.
What about `ovl_copy_up`? Does that unlock the OVERLAYFS inode? We check the code and `ovl_copy_up` locks and unlocks `OVL_I(inode)->lock`, which is a mutex. It does *not* unlock `inode->i_rwsem`.
Finally, let's investigate the condition where `ovl_set_acl` is called, with `inode->i_mode & S_ISGID` being true, `type` is `ACL_TYPE_ACCESS`, and the user is not in the group (`!in_group_p(inode->i_gid)`) *and* doesn't have the `CAP_FSETID` capability (`!capable_wrt_inode_uidgid(&nop_mnt_idmap, inode, CAP_FSETID)`). In this case, `ovl_setattr` is called. If `ovl_setattr` returns an error, that error is returned up through `ovl_set_acl`, then `set_posix_acl`. The OVERLAYFS inode is then unlocked by `vfs_remove_acl`. This represents the correct propagation of errors.
So, let's dig a bit deeper into what `ovl_setattr` may do.
What about `setattr_prepare`? Does it unlock the inode? We reviewed `setattr_prepare`, and it does *not* unlock the inode.
What if `ovl_setattr` calls `ovl_copy_up_with_data`? Does it unlock the OVERLAYFS inode? We'll need to check the code for `ovl_copy_up_with_data` to ensure this
|
| 109/2 |
2026/05/17 08:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/copy_up.c IncludeLines:true Name:ovl_copy_up_with_data]
Results: map[SourceCode:1275: int ovl_copy_up_with_data(struct dentry *dentry)
1276: {
1277: return ovl_copy_up_flags(dentry, O_WRONLY);
1278: }
SourceFile:fs/overlayfs/copy_up.c]
|
| 110/2 |
2026/05/17 08:26 |
llm |
expert |
0m
Model:
Tokens:
input: 95652
output: 43
thoughts: 189
Thoughts: **OverlayFS Inode Unlocking Conundrum**
Okay, so I'm trying to figure out why an OverlayFS inode might be getting unlocked, and I'm methodically working through the potential culprits. First, I ruled out `ovl_copy_up_flags`. Seems pretty straightforward, that function doesn't touch the lock. Then I thought, *hold on*, could `ovl_do_notify_change` be the key? It does call `notify_change` on the upper dentry, which *could* be the mechanism. But no, `notify_change` doesn't unlock the OverlayFS inode either. Frustrating.
Alright, shifting gears. What about `ovl_set_or_remove_acl`? Maybe it's doing something sneaky. Does it call `ovl_copy_up` under the hood? Nope, just confirmed that. Okay, new plan. Does `ovl_set_or_remove_acl` call `ovl_want_write`? *That's* the next logical step. And the million-dollar question: Does `ovl_want_write` unlock the OverlayFS inode? Time to dive into that function and see what's going on in there. It's the only remaining likely suspect.
|
| 111/2 |
2026/05/17 08:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/overlayfs/util.c IncludeLines:true Name:ovl_want_write]
Results: map[SourceCode: 35: int ovl_want_write(struct dentry *dentry)
36: {
37: struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
38: return mnt_want_write(ovl_upper_mnt(ofs));
39: }
SourceFile:fs/overlayfs/util.c]
|
| 112/2 |
2026/05/17 08:26 |
llm |
expert |
0m
Model:
Tokens:
input: 96274
output: 43
thoughts: 342
Thoughts: **My Current Train of Thought**
Okay, initially I was ready to dismiss this, but hold on a moment. Let's trace this out. Could it be that `ovl_set_or_remove_acl` ends up calling `ovl_do_set_acl`? And looking at the code, it does!
```c
static inline int ovl_do_set_acl(struct ovl_fs *ofs, struct dentry *dentry,
const char *acl_name, struct posix_acl *acl)
{
return vfs_set_acl(ovl_upper_mnt_idmap(ofs), dentry, acl_name, acl);
}
```
That then calls `vfs_set_acl`, which handles locking the upper inode, calling `set_posix_acl` on the upper dentry, and finally unlocking the upper inode. Seems perfectly sound, so far.
But, hang on... let's think about the case where `vfs_remove_acl` is called and, crucially, before it, `inode_lock` is called. Then we're calling `set_posix_acl`, and `set_posix_acl` calls `inode->i_op->set_acl`. What if *that* `inode->i_op->set_acl` is, say, `shmem_set_acl`? Wait, no, `shmem_set_acl` is just `simple_set_acl`. I checked that before, and it *doesn't* unlock the inode.
Or... what if it were `bad_inode_set_acl`? That would return `-EIO`, and it *still* wouldn't unlock the inode.
Okay, let's step back a bit and consider other possibilities. What if `inode->i_op->set_acl` is `ext2_set_acl`?
|
| 113/2 |
2026/05/17 08:26 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:fs/ext2/acl.c IncludeLines:true Name:ext2_set_acl]
Results: map[SourceCode: SourceFile:]
|
| 114/2 |
2026/05/17 08:26 |
llm |
expert |
0m
Model:
Tokens:
input: 97097
output: 20
thoughts: 30
Thoughts: Here's my thought process, as if I were analyzing that statement:
**Checking ACL Function Location in ext2 Filesystem**
Okay, so the code mentions `ext2_set_acl` and implies it resides in `fs/ext2/acl.c`. My initial reaction is to pause and mentally verify that. While it *sounds* right, I never fully trust an assumption, especially when dealing with filesystem internals. A quick sanity check is always wise. I'll need to confirm that `fs/ext2/acl.c` actually *does* house the `ext2_set_acl` function. I will quickly look at my notes. Just because the filename *suggests* it, doesn't mean it is the case. It is important to know this detail, as it relates to my area of expertise.
|
| 115/2 |
2026/05/17 08:26 |
tool |
grepper |
0m
Args: map[Expression:ext2_set_acl]
Results: map[Output:fs/ext2/acl.c=182=static int
fs/ext2/acl.c:183:__ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
fs/ext2/acl.c-184-{
--
fs/ext2/acl.c=221=int
fs/ext2/acl.c:222:ext2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
fs/ext2/acl.c-223- struct posix_acl *acl, int type)
--
fs/ext2/acl.c-236- }
fs/ext2/acl.c:237: error = __ext2_set_acl(inode, acl, type);
fs/ext2/acl.c-238- if (!error && update_mode) {
--
fs/ext2/acl.c=253=ext2_init_acl(struct inode *inode, struct inode *dir)
--
fs/ext2/acl.c-262- if (default_acl) {
fs/ext2/acl.c:263: error = __ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
fs/ext2/acl.c-264- posix_acl_release(default_acl);
--
fs/ext2/acl.c-269- if (!error)
fs/ext2/acl.c:270: error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
fs/ext2/acl.c-271- posix_acl_release(acl);
--
fs/ext2/acl.h=58=extern struct posix_acl *ext2_get_acl(struct inode *inode, int type, bool rcu);
fs/ext2/acl.h:59:extern int ext2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
fs/ext2/acl.h-60- struct posix_acl *acl, int type);
fs/ext2/acl.h=61=extern int ext2_init_acl (struct inode *, struct inode *);
--
fs/ext2/acl.h-65-#define ext2_get_acl NULL
fs/ext2/acl.h:66:#define ext2_set_acl NULL
fs/ext2/acl.h-67-
--
fs/ext2/file.c=332=const struct inode_operations ext2_file_inode_operations = {
--
fs/ext2/file.c-336- .get_inode_acl = ext2_get_acl,
fs/ext2/file.c:337: .set_acl = ext2_set_acl,
fs/ext2/file.c-338- .fiemap = ext2_fiemap,
--
fs/ext2/namei.c=407=const struct inode_operations ext2_dir_inode_operations = {
--
fs/ext2/namei.c-420- .get_inode_acl = ext2_get_acl,
fs/ext2/namei.c:421: .set_acl = ext2_set_acl,
fs/ext2/namei.c-422- .tmpfile = ext2_tmpfile,
--
fs/ext2/namei.c=427=const struct inode_operations ext2_special_inode_operations = {
--
fs/ext2/namei.c-431- .get_inode_acl = ext2_get_acl,
fs/ext2/namei.c:432: .set_acl = ext2_set_acl,
fs/ext2/namei.c-433-};
]
|
| 116/2 |
2026/05/17 08:26 |
llm |
expert |
0m
Model:
Tokens:
input: 98299
output: 43
thoughts: 12
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:
**Diving into `ext2_set_acl`**
Alright, time to dig in. The immediate thought here is, "Let's get straight to `ext2_set_acl`." No beating around the bush. I'm going to jump right into the implementation. I need to understand how the ACLs are being set within the ext2 filesystem. This means looking at the data structures involved, the permission checks, the allocation of space (if necessary), and any potential errors it handles. I'm specifically thinking about how it interacts with the inode, extended attributes, and the filesystem metadata in general. It's a key function for file security and access control, so knowing the intricacies is crucial. Time to examine the code.
|
| 117/2 |
2026/05/17 08:26 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:fs/ext2/acl.c IncludeLines:true Name:ext2_set_acl]
Results: map[SourceCode: SourceFile:]
|
| 118/2 |
2026/05/17 08:26 |
llm |
expert |
0m
Model:
Tokens:
input: 98556
output: 23
thoughts: 12
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and presented as if it were my own internal monologue:
**Navigating the Codebase**
Alright, let's see. I'm digging into this function, trying to isolate the specific area of interest. I've been tracing the execution flow, and I'm pretty sure I'm close to the crux of the problem. Hmmm, where was that variable defined again? Okay, no need to waste time scanning the whole file... yes, there! It's at line 221. Perfect. That's exactly where I need to focus my attention. Now I can move forward with my analysis.
|
| 119/2 |
2026/05/17 08:27 |
tool |
read-file |
0m
Args:
Results: map[Contents:// SPDX-License-Identifier: GPL-2.0
/*
* linux/fs/ext2/acl.c
*
* Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
*/
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include "ext2.h"
#include "xattr.h"
#include "acl.h"
/*
* Convert from filesystem to in-memory representation.
*/
static struct posix_acl *
ext2_acl_from_disk(const void *value, size_t size)
{
const char *end = (char *)value + size;
int n, count;
struct posix_acl *acl;
if (!value)
return NULL;
if (size < sizeof(ext2_acl_header))
return ERR_PTR(-EINVAL);
if (((ext2_acl_header *)value)->a_version !=
cpu_to_le32(EXT2_ACL_VERSION))
return ERR_PTR(-EINVAL);
value = (char *)value + sizeof(ext2_acl_header);
count = ext2_acl_count(size);
if (count < 0)
return ERR_PTR(-EINVAL);
if (count == 0)
return NULL;
acl = posix_acl_alloc(count, GFP_KERNEL);
if (!acl)
return ERR_PTR(-ENOMEM);
for (n=0; n < count; n++) {
ext2_acl_entry *entry =
(ext2_acl_entry *)value;
if ((char *)value + sizeof(ext2_acl_entry_short) > end)
goto fail;
acl->a_entries[n].e_tag = le16_to_cpu(entry->e_tag);
acl->a_entries[n].e_perm = le16_to_cpu(entry->e_perm);
switch(acl->a_entries[n].e_tag) {
case ACL_USER_OBJ:
case ACL_GROUP_OBJ:
case ACL_MASK:
case ACL_OTHER:
value = (char *)value +
sizeof(ext2_acl_entry_short);
break;
case ACL_USER:
value = (char *)value + sizeof(ext2_acl_entry);
if ((char *)value > end)
goto fail;
acl->a_entries[n].e_uid =
make_kuid(&init_user_ns,
le32_to_cpu(entry->e_id));
break;
case ACL_GROUP:
value = (char *)value + sizeof(ext2_acl_entry);
if ((char *)value > end)
goto fail;
acl->a_entries[n].e_gid =
make_kgid(&init_user_ns,
le32_to_cpu(entry->e_id));
break;
default:
goto fail;
}
}
if (value != end)
goto fail;
return acl;
fail:
posix_acl_release(acl);
return ERR_PTR(-EINVAL);
}
/*
* Convert from in-memory to filesystem representation.
*/
static void *
ext2_acl_to_disk(const struct posix_acl *acl, size_t *size)
{
ext2_acl_header *ext_acl;
char *e;
size_t n;
*size = ext2_acl_size(acl->a_count);
ext_acl = kmalloc(sizeof(ext2_acl_header) + acl->a_count *
sizeof(ext2_acl_entry), GFP_KERNEL);
if (!ext_acl)
return ERR_PTR(-ENOMEM);
ext_acl->a_version = cpu_to_le32(EXT2_ACL_VERSION);
e = (char *)ext_acl + sizeof(ext2_acl_header);
for (n=0; n < acl->a_count; n++) {
const struct posix_acl_entry *acl_e = &acl->a_entries[n];
ext2_acl_entry *entry = (ext2_acl_entry *)e;
entry->e_tag = cpu_to_le16(acl_e->e_tag);
entry->e_perm = cpu_to_le16(acl_e->e_perm);
switch(acl_e->e_tag) {
case ACL_USER:
entry->e_id = cpu_to_le32(
from_kuid(&init_user_ns, acl_e->e_uid));
e += sizeof(ext2_acl_entry);
break;
case ACL_GROUP:
entry->e_id = cpu_to_le32(
from_kgid(&init_user_ns, acl_e->e_gid));
e += sizeof(ext2_acl_entry);
break;
case ACL_USER_OBJ:
case ACL_GROUP_OBJ:
case ACL_MASK:
case ACL_OTHER:
e += sizeof(ext2_acl_entry_short);
break;
default:
goto fail;
}
}
return (char *)ext_acl;
fail:
kfree(ext_acl);
return ERR_PTR(-EINVAL);
}
/*
* inode->i_mutex: don't care
*/
struct posix_acl *
ext2_get_acl(struct inode *inode, int type, bool rcu)
{
int name_index;
char *value = NULL;
struct posix_acl *acl;
int retval;
if (rcu)
return ERR_PTR(-ECHILD);
switch (type) {
case ACL_TYPE_ACCESS:
name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
break;
case ACL_TYPE_DEFAULT:
name_index = EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT;
break;
default:
BUG();
}
retval = ext2_xattr_get(inode, name_index, "", NULL, 0);
if (retval > 0) {
value = kmalloc(retval, GFP_KERNEL);
if (!value)
return ERR_PTR(-ENOMEM);
retval = ext2_xattr_get(inode, name_index, "", value, retval);
}
if (retval > 0)
acl = ext2_acl_from_disk(value, retval);
else if (retval == -ENODATA || retval == -ENOSYS)
acl = NULL;
else
acl = ERR_PTR(retval);
kfree(value);
return acl;
}
static int
__ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
{
int name_index;
void *value = NULL;
size_t size = 0;
int error;
switch(type) {
case ACL_TYPE_ACCESS:
name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
break;
case ACL_TYPE_DEFAULT:
name_index = EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT;
if (!S_ISDIR(inode->i_mode))
return acl ? -EACCES : 0;
break;
default:
return -EINVAL;
}
if (acl) {
value = ext2_acl_to_disk(acl, &size);
if (IS_ERR(value))
return (int)PTR_ERR(value);
}
error = ext2_xattr_set(inode, name_index, "", value, size, 0);
kfree(value);
if (!error)
set_cached_acl(inode, type, acl);
return error;
}
/*
* inode->i_mutex: down
*/
int
ext2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
int error;
int update_mode = 0;
struct inode *inode = d_inode(dentry);
umode_t mode = inode->i_mode;
if (type == ACL_TYPE_ACCESS && acl) {
error = posix_acl_update_mode(&nop_mnt_idmap, inode, &mode,
&acl);
if (error)
return error;
update_mode = 1;
}
error = __ext2_set_acl(inode, acl, type);
if (!error && update_mode) {
inode->i_mode = mode;
inode_set_ctime_current(inode);
mark_inode_dirty(inode);
}
return error;
}
/*
* Initialize the ACLs of a new inode. Called from ext2_new_inode.
*
* dir->i_mutex: down
* inode->i_mutex: up (access to inode is still exclusive)
*/
int
ext2_init_acl(struct inode *inode, struct inode *dir)
{
struct posix_acl *default_acl, *acl;
int error;
error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
if (error)
return error;
if (default_acl) {
error = __ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
posix_acl_release(default_acl);
} else {
inode->i_default_acl = NULL;
}
if (acl) {
if (!error)
error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
posix_acl_release(acl);
} else {
inode->i_acl = NULL;
}
return error;
}
]
|
| 120/2 |
2026/05/17 08:27 |
llm |
expert |
0m
Model:
Tokens:
input: 101248
output: 24
thoughts: 1668
Thoughts: **Debugging a Potentially Unlocked Inode**
Okay, so I'm diving into this `vfs_remove_acl` function and trying to figure out how an inode lock could be prematurely unlocked. My initial thought was that some clever filesystem interaction was bypassing the locking, but that doesn't seem to be the case. I quickly dismissed the idea of a simple unlock by another thread because the check would catch that.
I started tracing a potential path through overlayfs, suspecting a race condition between upper and lower filesystem operations. I saw a possible locking sequence with `ovl_set_acl` leading to nested calls to `vfs_remove_acl` on both the overlay and upper dentries, which could be problematic if the same inode was used. However, I didn't see an explicit race or deadlock.
Then I considered the delegation path: `vfs_remove_acl` might be interrupted by a delegation break. While `break_deleg_wait` could clear `di->di_inode`, it gets re-locked in a retry. So, no luck there.
I wondered if some error return path from `try_break_deleg` could trigger an unlock without a corresponding lock. But that leads to a legitimate error return which, while it would interrupt the locking sequence, isn't the root cause of the error.
Then, I focused on the `ovl_setattr` path, figuring that potentially some operations there may unlock and relock. I reviewed the `ovl_setattr` code flow, particularly the `ovl_do_notify_change` path, but it returns `-EWOULDBLOCK` and goes through the correct path. So no.
I then considered whether the inode itself might be freed *before* the lock is acquired. This is unlikely because the dentry holds a reference to the inode, which would keep it alive.
Let's rethink this warning. I'm focusing on why `rwsem_owner(sem) != current` when `count = 0x0`. The warning indicates an unlock on an unlocked semaphore. `inode_lock` is *always* called before `inode_unlock`, so it seems impossible that a thread would call unlock on a semaphore it didn't previously lock.
Aha! What if `downgrade_write` is the culprit? If `downgrade_write` is called, the owner is cleared (set to 0), and then the subsequent `inode_unlock` will try to `up_write` a semaphore *without* an owner. It would trigger the warning. I need to check if `vfs_remove_acl` or related functions call `downgrade_write`. Let me search for it!
|
| 121/2 |
2026/05/17 08:27 |
tool |
grepper |
0m
Args: map[Expression:downgrade_write.*i_rwsem]
Results: map[Output:fs/btrfs/delayed-inode.c=1744=void btrfs_readdir_put_delayed_items(struct btrfs_inode *inode,
--
fs/btrfs/delayed-inode.c-1765- */
fs/btrfs/delayed-inode.c:1766: downgrade_write(&inode->vfs_inode.i_rwsem);
fs/btrfs/delayed-inode.c-1767-}
--
fs/ceph/io.c=59=int ceph_start_io_read(struct inode *inode)
--
fs/ceph/io.c-84- ceph_block_o_direct(ci, inode);
fs/ceph/io.c:85: downgrade_write(&inode->i_rwsem);
fs/ceph/io.c-86-
--
fs/ceph/io.c=171=int ceph_start_io_direct(struct inode *inode)
--
fs/ceph/io.c-196- ceph_block_buffered(ci, inode);
fs/ceph/io.c:197: downgrade_write(&inode->i_rwsem);
fs/ceph/io.c-198-
--
fs/netfs/locking.c=56=int netfs_start_io_read(struct inode *inode)
--
fs/netfs/locking.c-74- }
fs/netfs/locking.c:75: downgrade_write(&inode->i_rwsem);
fs/netfs/locking.c-76- return 0;
--
fs/netfs/locking.c=101=int netfs_start_io_write(struct inode *inode)
--
fs/netfs/locking.c-111- }
fs/netfs/locking.c:112: downgrade_write(&inode->i_rwsem);
fs/netfs/locking.c-113- return 0;
--
fs/netfs/locking.c=167=int netfs_start_io_direct(struct inode *inode)
--
fs/netfs/locking.c-187- }
fs/netfs/locking.c:188: downgrade_write(&inode->i_rwsem);
fs/netfs/locking.c-189- return 0;
--
fs/nfs/io.c=34=nfs_start_io_read(struct inode *inode)
--
fs/nfs/io.c-51- nfs_file_block_o_direct(nfsi);
fs/nfs/io.c:52: downgrade_write(&inode->i_rwsem);
fs/nfs/io.c-53-
--
fs/nfs/io.c=129=nfs_start_io_direct(struct inode *inode)
--
fs/nfs/io.c-146- nfs_block_buffered(nfsi, inode);
fs/nfs/io.c:147: downgrade_write(&inode->i_rwsem);
fs/nfs/io.c-148-
--
fs/readdir.c=31=int wrap_directory_iterator(struct file *file,
--
fs/readdir.c-66-
fs/readdir.c:67: downgrade_write(&inode->i_rwsem);
fs/readdir.c-68- return ret;
--
fs/xfs/xfs_inode.c=272=xfs_ilock_demote(
--
fs/xfs/xfs_inode.c-284- if (lock_flags & XFS_IOLOCK_EXCL)
fs/xfs/xfs_inode.c:285: downgrade_write(&VFS_I(ip)->i_rwsem);
fs/xfs/xfs_inode.c-286-
]
|
| 122/2 |
2026/05/17 08:27 |
llm |
expert |
6m
Model:
Tokens:
input: 104511
output: 66
thoughts: 62910
|
| 123/2 |
2026/05/17 08:33 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:false FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 124/2 |
2026/05/17 08:33 |
llm |
expert |
6m
Model:
Tokens:
input: 167551
output: 970
thoughts: 62914
|
| 125/1 |
2026/05/17 08:40 |
action |
format-explanation |
0m
Results: map[Explanation:The bug report indicates a WARNING in `__up_write` called from `inode_unlock` in
`vfs_remove_acl`. The warning `DEBUG_RWSEMS_WARN_ON((rwsem_owner(sem) !=
current) && !rwsem_test_oflags(sem, RWSEM_NONSPINNABLE))` means that
`inode_unlock` is being called on an `i_rwsem` that is not owned by the current
task (in this case, it's already completely unlocked, as `count = 0x0` and
`owner = 0x0`).
Looking at `vfs_remove_acl` in `fs/posix_acl.c`:
```c
retry_deleg:
inode_lock(inode);
error = may_write_xattr(idmap, inode);
if (error)
goto out_inode_unlock;
error = security_inode_remove_acl(idmap, dentry, acl_name);
if (error)
goto out_inode_unlock;
error = try_break_deleg(inode, &delegated_inode);
if (error)
goto out_inode_unlock;
if (likely(!is_bad_inode(inode)))
error = set_posix_acl(idmap, dentry, acl_type, NULL);
else
error = -EIO;
if (!error) {
fsnotify_xattr(dentry);
security_inode_post_remove_acl(idmap, dentry, acl_name);
}
out_inode_unlock:
inode_unlock(inode);
if (is_delegated(&delegated_inode)) {
error = break_deleg_wait(&delegated_inode);
if (!error)
goto retry_deleg;
}
return error;
```
The function locks the inode at the beginning and unlocks it at
`out_inode_unlock`. If `try_break_deleg` returns `-EWOULDBLOCK`, it sets
`delegated_inode.di_inode = inode` and jumps to `out_inode_unlock`. It then
unlocks the inode, and because `is_delegated` is true, it calls
`break_deleg_wait`. `break_deleg_wait` waits for the delegation to break and
then sets `delegated_inode.di_inode = NULL`. If it succeeds, it jumps back to
`retry_deleg`.
However, if `try_break_deleg` returns `0` on the second iteration (or the
first), it proceeds to `set_posix_acl`. After `set_posix_acl` finishes, it jumps
to `out_inode_unlock` and unlocks the inode. Then it checks
`is_delegated(&delegated_inode)`. Since `break_deleg_wait` set
`delegated_inode.di_inode = NULL`, `is_delegated` correctly returns false, and
the function returns.
The issue arises if `try_break_deleg` returns `-EWOULDBLOCK` but
`break_deleg_wait` returns an error (e.g., `-ERESTARTSYS` due to a signal). In
this case, `break_deleg_wait` still sets `delegated_inode.di_inode = NULL`, but
it returns the error. `vfs_remove_acl` then returns the error, leaving the inode
correctly unlocked.
The only way `inode_unlock` can be called on an already unlocked semaphore is if
`set_posix_acl` (or one of the functions it calls) unlocks the inode internally.
We checked many filesystems and none of them unlock the inode in their `set_acl`
implementation. However, if a filesystem's `set_acl` implementation incorrectly
drops the inode lock (or if there's a bug in a specific filesystem's delegation
handling), it would lead to this double unlock.
This is a local denial-of-service (triggering a WARNING and potentially
corrupting the rwsem state if it was locked by another thread in the meantime,
though rwsems have protections against this). It is reachable by unprivileged
users who can call `removexattr` on files they own (or in filesystems they can
mount, like FUSE or overlayfs). It does not lead to memory corruption or
privilege escalation directly, as it's a locking imbalance caught by debug
checks.]
|