| 0/0 |
2026/05/23 11:12 |
flow |
assessment-security |
25m
Results: map[DenialOfService:false Explanation:The reported bug is a KCSAN data-race between a write to
`cpu_base->expires_next` in `hrtimer_interrupt` and a read of the same variable
in `print_cpu`.
**Analysis:**
1. **Trigger mechanism:** The read occurs in `print_cpu`, which is invoked by
`timer_list_show`. This function is executed when reading the `/proc/timer_list`
file or when triggering the SysRq-Q command.
2. **Privilege level:** The `/proc/timer_list` file is created with `0400`
permissions (`proc_create_seq_private("timer_list", 0400, ...)`), meaning it is
only readable by the global root user. Unprivileged users cannot read it.
Furthermore, it is not accessible from within an unprivileged user namespace
because the file is owned by the global root (UID 0), which is not mapped into
the user namespace, preventing `CAP_DAC_OVERRIDE` from bypassing the permission
check. SysRq triggers also require root privileges (writing to
`/proc/sysrq-trigger`) or physical access.
3. **Impact:** The data race is completely benign. `print_cpu` reads the 8-byte
`expires_next` value locklessly simply to print it for diagnostic purposes. If a
concurrent write occurs, the read might fetch an intermediate or torn value,
which would merely result in a garbage timestamp being printed to the seq_file.
This cannot cause memory corruption, control-flow hijacking, kernel crashes, or
any form of denial-of-service.
**Conclusion:**
This is a benign diagnostic data race restricted to the root user. It has no
security impact, is not exploitable, and cannot be triggered by unprivileged
users, network traffic, or other external vectors. Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/05/23 11:12 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/05/23 11:12 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/fdb7cb6bb7b27f7e6d7ef669765813dd83c15406]
|
| 3/1 |
2026/05/23 11:13 |
action |
kernel-builder |
11m
Results: map[KernelObj:/app/workdir/cache/build/8c4827c6c7734fe87e2fc497164821fb44622630]
|
| 4/1 |
2026/05/23 11:24 |
action |
codesearch-prepare |
9m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/05/23 11:34 |
agent |
expert |
3m
Model:
Results: map[DenialOfService:false Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false 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).
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.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
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:
==================================================================
BUG: KCSAN: data-race in hrtimer_interrupt / print_cpu
write to 0xffff888237c1b8e8 of 8 bytes by interrupt on cpu 0:
hrtimer_interrupt+0x1ea/0x850 kernel/time/hrtimer.c:2105
local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1050 [inline]
__sysvec_apic_timer_interrupt+0x5f/0x1c0 arch/x86/kernel/apic/apic.c:1067
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1061 [inline]
sysvec_apic_timer_interrupt+0x6f/0x80 arch/x86/kernel/apic/apic.c:1061
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:697
kcsan_setup_watchpoint+0x404/0x410 kernel/kcsan/core.c:705
tlb_flush_pte_range include/asm-generic/tlb.h:622 [inline]
tlb_remove_tlb_entries include/asm-generic/tlb.h:675 [inline]
zap_present_folio_ptes mm/memory.c:1650 [inline]
zap_present_ptes mm/memory.c:1714 [inline]
do_zap_pte_range mm/memory.c:1816 [inline]
zap_pte_range mm/memory.c:1918 [inline]
zap_pmd_range mm/memory.c:2004 [inline]
zap_pud_range mm/memory.c:2032 [inline]
zap_p4d_range mm/memory.c:2053 [inline]
__zap_vma_range+0x1404/0x2c10 mm/memory.c:2093
unmap_vmas+0x22a/0x340 mm/memory.c:2162
exit_mmap+0x1ab/0x5f0 mm/mmap.c:1300
__mmput+0x28/0x1c0 kernel/fork.c:1178
mmput+0x40/0x50 kernel/fork.c:1201
exit_mm+0x113/0x1a0 kernel/exit.c:581
do_exit+0x442/0x1530 kernel/exit.c:963
__do_sys_exit kernel/exit.c:1085 [inline]
__se_sys_exit kernel/exit.c:1083 [inline]
__x64_sys_exit+0x1f/0x20 kernel/exit.c:1083
x64_sys_call+0x301d/0x3020 arch/x86/include/generated/asm/syscalls_64.h:61
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x12c/0x3b0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
read to 0xffff888237c1b8e8 of 8 bytes by task 24599 on cpu 1:
print_cpu+0x2fb/0x670 kernel/time/timer_list.c:129
timer_list_show+0x107/0x170 kernel/time/timer_list.c:291
seq_read_iter+0x636/0x940 fs/seq_file.c:273
proc_reg_read_iter+0x110/0x180 fs/proc/inode.c:299
copy_splice_read+0x471/0x6c0 fs/splice.c:362
do_splice_read fs/splice.c:980 [inline]
splice_direct_to_actor+0x26e/0x670 fs/splice.c:1084
do_splice_direct_actor fs/splice.c:1202 [inline]
do_splice_direct+0x119/0x1a0 fs/splice.c:1228
do_sendfile+0x382/0x650 fs/read_write.c:1372
__do_sys_sendfile64 fs/read_write.c:1433 [inline]
__se_sys_sendfile64 fs/read_write.c:1419 [inline]
__x64_sys_sendfile64+0x105/0x150 fs/read_write.c:1419
x64_sys_call+0x2dc4/0x3020 arch/x86/include/generated/asm/syscalls_64.h:41
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x12c/0x3b0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
value changed: 0x000000cde75a636b -> 0x000000cde75e1b80
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 UID: 0 PID: 24599 Comm: syz.4.4498 Tainted: G W syzkaller #0 PREEMPT(full)
Tainted: [W]=WARN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
==================================================================
Reply: The reported bug is a KCSAN data-race between a write to `cpu_base->expires_next` in `hrtimer_interrupt` and a read of the same variable in `print_cpu`.
**Analysis:**
1. **Trigger mechanism:** The read occurs in `print_cpu`, which is invoked by `timer_list_show`. This function is executed when reading the `/proc/timer_list` file or when triggering the SysRq-Q command.
2. **Privilege level:** The `/proc/timer_list` file is created with `0400` permissions (`proc_create_seq_private("timer_list", 0400, ...)`), meaning it is only readable by the global root user. Unprivileged users cannot read it. Furthermore, it is not accessible from within an unprivileged user namespace because the file is owned by the global root (UID 0), which is not mapped into the user namespace, preventing `CAP_DAC_OVERRIDE` from bypassing the permission check. SysRq triggers also require root privileges (writing to `/proc/sysrq-trigger`) or physical access.
3. **Impact:** The data race is completely benign. `print_cpu` reads the 8-byte `expires_next` value locklessly simply to print it for diagnostic purposes. If a concurrent write occurs, the read might fetch an intermediate or torn value, which would merely result in a garbage timestamp being printed to the seq_file. This cannot cause memory corruption, control-flow hijacking, kernel crashes, or any form of denial-of-service.
**Conclusion:**
This is a benign diagnostic data race restricted to the root user. It has no security impact, is not exploitable, and cannot be triggered by unprivileged users, network traffic, or other external vectors.
|
| 6/2 |
2026/05/23 11:34 |
llm |
expert |
0m
Model:
Tokens:
input: 6939
output: 82
thoughts: 141
Thoughts: **Analyzing a KCSAN Data-Race Report**
Okay, so I've got a KCSAN data-race report here. Looks like there's a race condition. The report indicates a conflict between a write and a read operation. Specifically, `hrtimer_interrupt` is writing 8 bytes, and `print_cpu` is reading those same 8 bytes. Interesting. The write operation originates from `kernel/time/hrtimer.c:2105`, occurring within the `hrtimer_interrupt` function. The read is at `kernel/time/timer_list.c:129`, and it's happening inside the `print_cpu` function.
Now, let's break this down. The read is triggered by accessing `/proc/timer_list` through `timer_list_show`, which is as expected. Reading `/proc/timer_list` is a common way to inspect the state of kernel timers. The write, however, is triggered by a timer interrupt, specifically `hrtimer_interrupt`.
Time to dive into the source code for these two locations and understand the data structures involved, and the potential for concurrent access. I need to figure out what data is being written and read, how the memory is shared, and if there's any synchronization (or lack thereof) that's causing this. This is a classic concurrency problem, I'll bet it's something simple that was overlooked, so lets get to it.
|
| 7/2 |
2026/05/23 11:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c IncludeLines:true Name:hrtimer_interrupt]
Results: map[SourceCode:2079: /*
2080: * High resolution timer interrupt
2081: * Called with interrupts disabled
2082: */
2083: void hrtimer_interrupt(struct clock_event_device *dev)
2084: {
2085: struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases);
2086: ktime_t expires_next, now, entry_time, delta;
2087: unsigned long flags;
2088: int retries = 0;
2089:
2090: BUG_ON(!cpu_base->hres_active);
2091: cpu_base->nr_events++;
2092: dev->next_event = KTIME_MAX;
2093: dev->next_event_forced = 0;
2094:
2095: raw_spin_lock_irqsave(&cpu_base->lock, flags);
2096: entry_time = now = hrtimer_update_base(cpu_base);
2097: retry:
2098: cpu_base->deferred_rearm = true;
2099: /*
2100: * Set expires_next to KTIME_MAX, which prevents that remote CPUs queue
2101: * timers while __hrtimer_run_queues() is expiring the clock bases.
2102: * Timers which are re/enqueued on the local CPU are not affected by
2103: * this.
2104: */
2105: cpu_base->expires_next = KTIME_MAX;
2106:
2107: if (!ktime_before(now, cpu_base->softirq_expires_next)) {
2108: cpu_base->softirq_expires_next = KTIME_MAX;
2109: cpu_base->softirq_activated = true;
2110: raise_timer_softirq(HRTIMER_SOFTIRQ);
2111: }
2112:
2113: __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_HARD);
2114:
2115: /*
2116: * The next timer was already expired due to:
2117: * - tracing
2118: * - long lasting callbacks
2119: * - being scheduled away when running in a VM
2120: *
2121: * We need to prevent that we loop forever in the hrtiner interrupt
2122: * routine. We give it 3 attempts to avoid overreacting on some
2123: * spurious event.
2124: */
2125: now = hrtimer_update_base(cpu_base);
2126: expires_next = hrtimer_update_next_event(cpu_base);
2127: cpu_base->hang_detected = false;
2128: if (expires_next < now) {
2129: if (++retries < 3)
2130: goto retry;
2131:
2132: delta = ktime_sub(now, entry_time);
2133: cpu_base->max_hang_time = max_t(unsigned int, cpu_base->max_hang_time, delta);
2134: cpu_base->nr_hangs++;
2135: cpu_base->hang_detected = true;
2136: }
2137:
2138: hrtimer_interrupt_rearm(cpu_base, expires_next);
2139: raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
2140: }
SourceFile:kernel/time/hrtimer.c]
|
| 8/2 |
2026/05/23 11:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/timer_list.c IncludeLines:true Name:print_cpu]
Results: map[SourceCode: 111: static void print_cpu(struct seq_file *m, int cpu, u64 now)
112: {
113: struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);
114: int i;
115:
116: SEQ_printf(m, "cpu: %d\n", cpu);
117: for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
118: SEQ_printf(m, " clock %d:\n", i);
119: print_base(m, cpu_base->clock_base + i, now);
120: }
121: #define P(x) \
122: SEQ_printf(m, " .%-15s: %Lu\n", #x, \
123: (unsigned long long)(cpu_base->x))
124: #define P_ns(x) \
125: SEQ_printf(m, " .%-15s: %Lu nsecs\n", #x, \
126: (unsigned long long)(ktime_to_ns(cpu_base->x)))
127:
128: #ifdef CONFIG_HIGH_RES_TIMERS
129: P_ns(expires_next);
130: P(hres_active);
131: P(nr_events);
132: P(nr_retries);
133: P(nr_hangs);
134: P(max_hang_time);
135: #endif
136: #undef P
137: #undef P_ns
138:
139: #ifdef CONFIG_TICK_ONESHOT
140: # define P(x) \
141: SEQ_printf(m, " .%-15s: %Lu\n", #x, \
142: (unsigned long long)(ts->x))
143: # define P_ns(x) \
144: SEQ_printf(m, " .%-15s: %Lu nsecs\n", #x, \
145: (unsigned long long)(ktime_to_ns(ts->x)))
146: # define P_flag(x, f) \
147: SEQ_printf(m, " .%-15s: %d\n", #x, !!(ts->flags & (f)))
148:
149: {
150: struct tick_sched *ts = tick_get_tick_sched(cpu);
151: P_flag(nohz, TS_FLAG_NOHZ);
152: P_flag(highres, TS_FLAG_HIGHRES);
153: P_ns(last_tick);
154: P_flag(tick_stopped, TS_FLAG_STOPPED);
155: P(idle_jiffies);
156: P(idle_calls);
157: P(idle_sleeps);
158: P_ns(idle_entrytime);
159: P_ns(idle_waketime);
160: P_ns(idle_exittime);
161: P_ns(idle_sleeptime);
162: P_ns(iowait_sleeptime);
163: P(last_jiffies);
164: P(next_timer);
165: P_ns(idle_expires);
166: SEQ_printf(m, "jiffies: %Lu\n",
167: (unsigned long long)jiffies);
168: }
169: #endif
170:
171: #undef P
172: #undef P_ns
173: SEQ_printf(m, "\n");
174: }
SourceFile:kernel/time/timer_list.c]
|
| 9/2 |
2026/05/23 11:34 |
llm |
expert |
0m
Model:
Tokens:
input: 9605
output: 44
thoughts: 393
Thoughts: **Analyzing a Benign Data Race in HRTimers**
Okay, so I'm looking at this code and immediately see a potential data race. It looks like the issue revolves around `cpu_base->expires_next` in the high-resolution timers (HRTimers) code. Specifically, the race is between the `hrtimer_interrupt` function and the `print_cpu` function.
In `hrtimer_interrupt`, there's a critical section protected by `cpu_base->lock`. Inside this critical section, `cpu_base->expires_next` is being manipulated. It's first set to `KTIME_MAX` as part of a mechanism to prevent race conditions during timer queue processing, and I can see the intention behind this, it's about controlling timer re-queuing during a critical expiry process.
However, in `print_cpu`, there's a read of `cpu_base->expires_next`. And I can see that this read happens *without* holding that same lock. My gut reaction is: data race! But it's likely a benign one.
The `print_cpu` function is using a `seq_file` for output, so this read is likely for diagnostic purposes. The value read is simply printed to the output. The fact that the code uses `ktime_to_ns` suggests that it's dealing with nanoseconds, but the important point is this: if `print_cpu` reads a torn or intermediate value for `expires_next`, which could easily happen with a lockless read, it'll just print whatever it reads. No harm, no foul. `ktime_to_ns` looks to be a simple cast or some minor arithmetic operation, so there's no complex or volatile manipulation happening here. So, at worst, the output will be slightly misleading. I'll just double-check the implementation of `ktime_to_ns` to be certain.
This is a classic example of a benign data race: a lockless read of a diagnostic value where the consequences of a race are minor or acceptable. This is a very familiar pattern in `/proc` or `/sys` files, where real-time accuracy isn't critical.
|
| 10/2 |
2026/05/23 11:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/timer_list.c IncludeLines:true Name:ktime_to_ns]
Results: map[SourceCode: 77: /* Convert ktime_t to nanoseconds */
78: static inline s64 ktime_to_ns(const ktime_t kt)
79: {
80: return kt;
81: }
SourceFile:include/linux/ktime.h]
|
| 11/2 |
2026/05/23 11:34 |
llm |
expert |
0m
Model:
Tokens:
input: 10611
output: 51
thoughts: 87
Thoughts: **Analyzing the Benign Nature of this Data Race**
Okay, so looking at this, `ktime_to_ns` just passes along that `s64` value, essentially returning it directly. And from what I'm seeing, `print_cpu` is simply reading that 8-byte integer and printing it out. There's really nothing sophisticated happening here.
Given this, I am quite confident that this can't possibly result in any serious issues. There's no possibility of memory corruption, no chance of control flow hijacking, and no real vector for a denial of service. The underlying integer itself cannot be changed by another process while it is in a read process of another since it's an integer. This is just a completely benign data race. The worst-case scenario is an incorrect value, which won't cause any security implications.
Now, let me just quickly verify if `/proc/timer_list` is accessible to unprivileged users, just to be thorough.
|
| 12/2 |
2026/05/23 11:34 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:kernel/time/timer_list.c IncludeSnippetLines:5 Name:timer_list_show SourceTreePrefix:]
Results: map[References:<nil> TruncatedOutput:false]
|
| 13/2 |
2026/05/23 11:34 |
llm |
expert |
0m
Model:
Tokens:
input: 10976
output: 43
thoughts: 31
Thoughts: Here's a summary of my thought process, as requested:
**Navigating Kernel Timers**
Okay, so I'm looking at this code and I see `timer_list_show` ā that function name rings a bell. Ah, yes, it seems to be involved with the timer functionality. The obvious next step is to pinpoint its definition. The cross-referencing is pointing me towards `kernel/time/timer_list.c`. Let's open that file and dive into the implementation. I need to understand what `timer_list_show` is doing within the broader context of the timer management system. I need to determine its purpose and how it fits into the kernel's overall timing mechanism. Let's see what we can find.
|
| 14/2 |
2026/05/23 11:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/timer_list.c IncludeLines:true Name:timer_list_show]
Results: map[SourceCode: 284: static int timer_list_show(struct seq_file *m, void *v)
285: {
286: struct timer_list_iter *iter = v;
287:
288: if (iter->cpu == -1 && !iter->second_pass)
289: timer_list_header(m, iter->now);
290: else if (!iter->second_pass)
291: print_cpu(m, iter->cpu, iter->now);
292: #ifdef CONFIG_GENERIC_CLOCKEVENTS
293: else if (iter->cpu == -1 && iter->second_pass)
294: timer_list_show_tickdevices_header(m);
295: else
296: print_tickdevice(m, tick_get_device(iter->cpu), iter->cpu);
297: #endif
298: return 0;
299: }
SourceFile:kernel/time/timer_list.c]
|
| 15/2 |
2026/05/23 11:34 |
llm |
expert |
0m
Model:
Tokens:
input: 11507
output: 19
thoughts: 15
Thoughts: Here's my thought process, as if I were considering this myself:
**Tracing `timer_list_show` Usage**
Okay, I need to understand the impact of `timer_list_show`. My immediate approach is to figure out where it's actually *used* in the codebase. I don't want to get lost in the weeds right away. Knowing the call sites will give me a critical context. I can use my tools to locate all the instances where this function is called. From there, I'll examine the surrounding code to determine how `timer_list_show` fits into the broader picture. I need to understand its arguments and return values and how they are handled. With that information, I'll be in a much better position to assess its purpose and potential consequences.
|
| 16/2 |
2026/05/23 11:34 |
tool |
grepper |
0m
Args: map[Expression:timer_list_show]
Results: map[Output:drivers/tty/sysrq.c=189=static void sysrq_handle_show_timers(u8 key)
drivers/tty/sysrq.c-190-{
drivers/tty/sysrq.c:191: sysrq_timer_list_show();
drivers/tty/sysrq.c-192-}
--
include/linux/hrtimer.h=344=extern void __init hrtimers_init(void);
--
include/linux/hrtimer.h-346-/* Show pending timers: */
include/linux/hrtimer.h:347:extern void sysrq_timer_list_show(void);
include/linux/hrtimer.h-348-
--
kernel/time/timer_list.c=178=print_tickdevice(struct seq_file *m, struct tick_device *td, int cpu)
--
kernel/time/timer_list.c-241-
kernel/time/timer_list.c:242:static void timer_list_show_tickdevices_header(struct seq_file *m)
kernel/time/timer_list.c-243-{
--
kernel/time/timer_list.c=257=static inline void timer_list_header(struct seq_file *m, u64 now)
--
kernel/time/timer_list.c-264-
kernel/time/timer_list.c:265:void sysrq_timer_list_show(void)
kernel/time/timer_list.c-266-{
--
kernel/time/timer_list.c-275-#ifdef CONFIG_GENERIC_CLOCKEVENTS
kernel/time/timer_list.c:276: timer_list_show_tickdevices_header(NULL);
kernel/time/timer_list.c-277- for_each_online_cpu(cpu)
--
kernel/time/timer_list.c-283-#ifdef CONFIG_PROC_FS
kernel/time/timer_list.c:284:static int timer_list_show(struct seq_file *m, void *v)
kernel/time/timer_list.c-285-{
--
kernel/time/timer_list.c-293- else if (iter->cpu == -1 && iter->second_pass)
kernel/time/timer_list.c:294: timer_list_show_tickdevices_header(m);
kernel/time/timer_list.c-295- else
--
kernel/time/timer_list.c=342=static const struct seq_operations timer_list_sops = {
--
kernel/time/timer_list.c-345- .stop = timer_list_stop,
kernel/time/timer_list.c:346: .show = timer_list_show,
kernel/time/timer_list.c-347-};
--
lib/sys_info.c=139=static void __sys_info(unsigned long si_mask)
--
lib/sys_info.c-147- if (si_mask & SYS_INFO_TIMERS)
lib/sys_info.c:148: sysrq_timer_list_show();
lib/sys_info.c-149-
]
|
| 17/2 |
2026/05/23 11:34 |
llm |
expert |
0m
Model:
Tokens:
input: 12522
output: 20
thoughts: 29
Thoughts: Here's my summary, as if I were thinking these thoughts:
**Tracing the Usage of `timer_list_sops`**
Okay, so I see `timer_list_sops` is in play. My first thought is to understand its scope and impact. Let's trace back where this is actually being *used*. Knowing where `timer_list_sops` is referenced will give me a better understanding of how the system is designed and function in the broader context. Time to start digging through the code...
|
| 18/2 |
2026/05/23 11:34 |
tool |
grepper |
0m
Args: map[Expression:timer_list_sops]
Results: map[Output:kernel/time/timer_list.c=338=static void timer_list_stop(struct seq_file *seq, void *v)
--
kernel/time/timer_list.c-341-
kernel/time/timer_list.c:342:static const struct seq_operations timer_list_sops = {
kernel/time/timer_list.c-343- .start = timer_list_start,
--
kernel/time/timer_list.c=349=static int __init init_timer_list_procfs(void)
--
kernel/time/timer_list.c-352-
kernel/time/timer_list.c:353: pe = proc_create_seq_private("timer_list", 0400, NULL, &timer_list_sops,
kernel/time/timer_list.c-354- sizeof(struct timer_list_iter), NULL);
]
|
| 19/2 |
2026/05/23 11:34 |
llm |
expert |
0m
Model:
Tokens:
input: 12921
output: 63
thoughts: 479
Thoughts: **Analyzing `/proc/timer_list` Accessibility in User Namespaces**
Okay, so I'm looking at this `proc_create_seq_private` call, specifically the permissions, `0400`. That's root-readable, right? Just the owner, which is root, can read it. So, that means unprivileged processes are locked out, that seems pretty standard. But hold on, what about user namespaces? I need to think this through carefully.
Since it's a `/proc` entry, it's a global procfs file, so generally, these aren't accessible from non-init user namespaces unless specifically mounted or exposed. But... `/proc` *is* mounted in user namespaces. Hmm. The owner is root in the init namespace.
Ah, right, if a user *does* create a user namespace and mounts `/proc`, files owned by root in the init namespace will be seen as `nobody` (or maybe `overflowuid`) within the new user namespace. And they *won't* have read access to it because they don't have `CAP_DAC_OVERRIDE` in the init namespace. This is important, it's about the owner of the inode. They only have the override within their *own* namespace.
So, let's test the hypothesis: Is `/proc/timer_list` actually accessible? If an unprivileged user creates a user namespace, they become root *in that namespace* and can mount `/proc`, sure. However, the inode for `/proc/timer_list` will still be owned by the init namespace's root (uid 0).
Since the user namespace root doesn't map to the init namespace root, that file is going to appear as `nobody` (like, 65534) in the user namespace.
And the permissions? They're still `0400`. The user namespace root doesn't have `CAP_DAC_OVERRIDE` that *trumps* the init namespace's root. That's a crucial point.
Wait... `CAP_DAC_OVERRIDE` in a user namespace *only* applies to files whose UIDs are mapped *into* that user namespace! So, if the file's UID, which is zero in the init namespace, isn't mapped, it's treated as `overflowuid`. And even *then*, `CAP_DAC_OVERRIDE` in the user namespace doesn't give them access! This is the key.
Therefore, my conclusion is that `/proc/timer_list` *is NOT* accessible from user namespaces created by unprivileged users. I'm pretty confident in that analysis. Now, I should verify this by checking it out.
|
| 20/2 |
2026/05/23 11:34 |
tool |
codeexpert |
2m
Args: map[Question:Is `/proc/timer_list` readable by a process in a user namespace created by an unprivileged user? The file is created with `proc_create_seq_private("timer_list", 0400, ...)`.]
Results: map[Answer:No, `/proc/timer_list` is **not readable** by a process in a user namespace created by an unprivileged user.
The file is created in `kernel/time/timer_list.c` with the following call:
```c
pe = proc_create_seq_private("timer_list", 0400, NULL, &timer_list_sops,
sizeof(struct timer_list_iter), NULL);
```
The mode `0400` restricts read access to the owner of the file. In the case of `/proc/timer_list`, the owner is the global root user (UID 0 in the initial user namespace), as it is created as a top-level entry in the global `/proc` filesystem and inherits the UID/GID of the `proc_root` entry (which is 0).
When an unprivileged user creates a new user namespace, they typically map their own global UID (e.g., 1000) to UID 0 inside the new namespace. However, the global root user (UID 0) is generally not mapped into such a namespace.
The kernel's permission check (specifically `generic_permission` and `capable_wrt_inode_uidgid`) works as follows:
1. **UID Match**: The process's filesystem UID (global 1000) is compared with the file's UID (global 0). They do not match.
2. **Capabilities**: The kernel checks if the process has the `CAP_DAC_OVERRIDE` or `CAP_DAC_READ_SEARCH` capability. While the process may have these capabilities *within its own user namespace*, these capabilities only allow overriding permissions for files owned by UIDs that are mapped into that namespace. Since global UID 0 is not mapped, the process's capabilities do not grant access to the file.
This restriction was intentionally introduced in commit `8e7df2b5b7f2` ("timer/debug: Change /proc/timer_list from 0444 to 0400") to prevent non-root users from accessing kernel timing and address information.]
|
| 21/3 |
2026/05/23 11:34 |
agent |
codeexpert |
2m
Model:
Instruction:
You are a capable Linux kernel developer tasked with researching complex questions
about kernel source code. You will be given a concrete question, and need to provide
a concrete answer.
Use tools extensively while researching the question. Don't make assumptions,
or rely on your previous knowledge about the kernel source code, use available tools
to access the actual source code.
Use all available sources of information:
- kernel source code
- documentation in the Documentation dir in the source tree
- git commits descriptions, git blame
Prefer calling several tools at the same time to save round-trips.
Prompt: Is `/proc/timer_list` readable by a process in a user namespace created by an unprivileged user? The file is created with `proc_create_seq_private("timer_list", 0400, ...)`.
Reply: No, `/proc/timer_list` is **not readable** by a process in a user namespace created by an unprivileged user.
The file is created in `kernel/time/timer_list.c` with the following call:
```c
pe = proc_create_seq_private("timer_list", 0400, NULL, &timer_list_sops,
sizeof(struct timer_list_iter), NULL);
```
The mode `0400` restricts read access to the owner of the file. In the case of `/proc/timer_list`, the owner is the global root user (UID 0 in the initial user namespace), as it is created as a top-level entry in the global `/proc` filesystem and inherits the UID/GID of the `proc_root` entry (which is 0).
When an unprivileged user creates a new user namespace, they typically map their own global UID (e.g., 1000) to UID 0 inside the new namespace. However, the global root user (UID 0) is generally not mapped into such a namespace.
The kernel's permission check (specifically `generic_permission` and `capable_wrt_inode_uidgid`) works as follows:
1. **UID Match**: The process's filesystem UID (global 1000) is compared with the file's UID (global 0). They do not match.
2. **Capabilities**: The kernel checks if the process has the `CAP_DAC_OVERRIDE` or `CAP_DAC_READ_SEARCH` capability. While the process may have these capabilities *within its own user namespace*, these capabilities only allow overriding permissions for files owned by UIDs that are mapped into that namespace. Since global UID 0 is not mapped, the process's capabilities do not grant access to the file.
This restriction was intentionally introduced in commit `8e7df2b5b7f2` ("timer/debug: Change /proc/timer_list from 0444 to 0400") to prevent non-root users from accessing kernel timing and address information.
|
| 22/4 |
2026/05/23 11:34 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 3245
output: 19
thoughts: 152
Thoughts: **Investigating the Readability of /proc/timer_list in User Namespaces**
Okay, so I'm being asked a pretty specific question: can an unprivileged user, operating within a user namespace they created, actually read `/proc/timer_list`? Seems straightforward, right? I've seen this kind of thing before. My initial thought is, based on the `proc_create_seq_private("timer_list", 0400, ...)` call, it's probably *not* going to be readable. The mode `0400` *should* mean "read-only for owner" ā and the owner is almost certainly root in this context.
But, I know better than to jump to conclusions. I need to understand how `proc_create_seq_private` functions *specifically* with regard to permissions and namespaces. Does it perform the standard credential checks against the calling process? Most of the `proc_create*` family does, based on my past experience. But I need to be sure. I've encountered some quirks in the past.
So, first things first: I'm going to have to dive into the kernel source. My immediate goal is to locate the code that actually creates that `/proc/timer_list` entry. I need to see *precisely* how the permissions are handled and if any namespace-specific considerations are taken into account during the permission checks. That's my starting point.
|
| 23/4 |
2026/05/23 11:35 |
tool |
grepper |
0m
Args: map[Expression:"timer_list"]
Results: map[Output:kernel/time/timer.c=776=static const struct debug_obj_descr timer_debug_descr = {
kernel/time/timer.c:777: .name = "timer_list",
kernel/time/timer.c-778- .debug_hint = timer_debug_hint,
--
kernel/time/timer_list.c=349=static int __init init_timer_list_procfs(void)
--
kernel/time/timer_list.c-352-
kernel/time/timer_list.c:353: pe = proc_create_seq_private("timer_list", 0400, NULL, &timer_list_sops,
kernel/time/timer_list.c-354- sizeof(struct timer_list_iter), NULL);
]
|
| 24/4 |
2026/05/23 11:35 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 3934
output: 24
thoughts: 361
Thoughts: **Analyzing the Timer List Procfs Entry**
Okay, so I'm looking at how the `/proc/timer_list` file is created. The code in `kernel/time/timer_list.c` shows it's being set up in `init_timer_list_procfs` using `proc_create_seq_private`. The interesting part is the mode: `0400`. This is important, as it restricts access to the owner of the file. In a standard setup, that owner would likely be global root for files under `/proc`. However, things get a bit more nuanced within user namespaces.
My immediate question now is, given that the file is created with `0400` permissions and, likely, owned by root (uid 0), how does the proc filesystem handle permission checks when a process *within* a user namespace attempts to read this file? Specifically, if global root is mapped differently (or not at all) inside the namespace. The crucial point hinges on whether the accessing process has `CAP_DAC_OVERRIDE`, or if it's considered the owner in a user namespace. Since the permission is only read by the owner, that's what's vital.
I need to confirm who actually *is* the owner of `/proc/timer_list`. My experience tells me it's either the user who mounted the procfs or it defaults to global root. This ownership is key to how permissions will ultimately be resolved. Let me double-check the code in `kernel/time/timer_list.c` for any namespace-specific handling or modifications to the ownership or permission setting.
|
| 25/4 |
2026/05/23 11:35 |
tool |
read-file |
0m
Args: map[File:kernel/time/timer_list.c]
Results: map[Contents:// SPDX-License-Identifier: GPL-2.0
/*
* List pending timers
*
* Copyright(C) 2006, Red Hat, Inc., Ingo Molnar
*/
#include <linux/proc_fs.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/sched.h>
#include <linux/seq_file.h>
#include <linux/kallsyms.h>
#include <linux/nmi.h>
#include <linux/uaccess.h>
#include "tick-internal.h"
struct timer_list_iter {
int cpu;
bool second_pass;
u64 now;
};
/*
* This allows printing both to /proc/timer_list and
* to the console (on SysRq-Q):
*/
__printf(2, 3)
static void SEQ_printf(struct seq_file *m, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
if (m)
seq_vprintf(m, fmt, args);
else
vprintk(fmt, args);
va_end(args);
}
static void
print_timer(struct seq_file *m, struct hrtimer *taddr, struct hrtimer *timer,
int idx, u64 now)
{
SEQ_printf(m, " #%d: <%p>, %ps", idx, taddr, ACCESS_PRIVATE(timer, function));
SEQ_printf(m, ", S:%02x", timer->is_queued);
SEQ_printf(m, "\n");
SEQ_printf(m, " # expires at %Lu-%Lu nsecs [in %Ld to %Ld nsecs]\n",
(unsigned long long)ktime_to_ns(hrtimer_get_softexpires(timer)),
(unsigned long long)ktime_to_ns(hrtimer_get_expires(timer)),
(long long)(ktime_to_ns(hrtimer_get_softexpires(timer)) - now),
(long long)(ktime_to_ns(hrtimer_get_expires(timer)) - now));
}
static void print_active_timers(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
{
struct timerqueue_linked_node *curr;
struct hrtimer *timer, tmp;
unsigned long next = 0, i;
unsigned long flags;
next_one:
i = 0;
touch_nmi_watchdog();
raw_spin_lock_irqsave(&base->cpu_base->lock, flags);
curr = timerqueue_linked_first(&base->active);
/*
* Crude but we have to do this O(N*N) thing, because
* we have to unlock the base when printing:
*/
while (curr && i < next) {
curr = timerqueue_linked_next(curr);
i++;
}
if (curr) {
timer = container_of(curr, struct hrtimer, node);
tmp = *timer;
raw_spin_unlock_irqrestore(&base->cpu_base->lock, flags);
print_timer(m, timer, &tmp, i, now);
next++;
goto next_one;
}
raw_spin_unlock_irqrestore(&base->cpu_base->lock, flags);
}
static void
print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
{
SEQ_printf(m, " .base: %p\n", base);
SEQ_printf(m, " .index: %d\n", base->index);
SEQ_printf(m, " .resolution: %u nsecs\n", hrtimer_resolution);
#ifdef CONFIG_HIGH_RES_TIMERS
SEQ_printf(m, " .offset: %Ld nsecs\n",
(long long) base->offset);
#endif
SEQ_printf(m, "active timers:\n");
print_active_timers(m, base, now + ktime_to_ns(base->offset));
}
static void print_cpu(struct seq_file *m, int cpu, u64 now)
{
struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);
int i;
SEQ_printf(m, "cpu: %d\n", cpu);
for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
SEQ_printf(m, " clock %d:\n", i);
print_base(m, cpu_base->clock_base + i, now);
}
#define P(x) \
SEQ_printf(m, " .%-15s: %Lu\n", #x, \
(unsigned long long)(cpu_base->x))
#define P_ns(x) \
SEQ_printf(m, " .%-15s: %Lu nsecs\n", #x, \
(unsigned long long)(ktime_to_ns(cpu_base->x)))
#ifdef CONFIG_HIGH_RES_TIMERS
P_ns(expires_next);
P(hres_active);
P(nr_events);
P(nr_retries);
P(nr_hangs);
P(max_hang_time);
#endif
#undef P
#undef P_ns
#ifdef CONFIG_TICK_ONESHOT
# define P(x) \
SEQ_printf(m, " .%-15s: %Lu\n", #x, \
(unsigned long long)(ts->x))
# define P_ns(x) \
SEQ_printf(m, " .%-15s: %Lu nsecs\n", #x, \
(unsigned long long)(ktime_to_ns(ts->x)))
# define P_flag(x, f) \
SEQ_printf(m, " .%-15s: %d\n", #x, !!(ts->flags & (f)))
{
struct tick_sched *ts = tick_get_tick_sched(cpu);
P_flag(nohz, TS_FLAG_NOHZ);
P_flag(highres, TS_FLAG_HIGHRES);
P_ns(last_tick);
P_flag(tick_stopped, TS_FLAG_STOPPED);
P(idle_jiffies);
P(idle_calls);
P(idle_sleeps);
P_ns(idle_entrytime);
P_ns(idle_waketime);
P_ns(idle_exittime);
P_ns(idle_sleeptime);
P_ns(iowait_sleeptime);
P(last_jiffies);
P(next_timer);
P_ns(idle_expires);
SEQ_printf(m, "jiffies: %Lu\n",
(unsigned long long)jiffies);
}
#endif
#undef P
#undef P_ns
SEQ_printf(m, "\n");
}
#ifdef CONFIG_GENERIC_CLOCKEVENTS
static void
print_tickdevice(struct seq_file *m, struct tick_device *td, int cpu)
{
struct clock_event_device *dev = td->evtdev;
touch_nmi_watchdog();
SEQ_printf(m, "Tick Device: mode: %d\n", td->mode);
if (cpu < 0)
SEQ_printf(m, "Broadcast device\n");
else
SEQ_printf(m, "Per CPU device: %d\n", cpu);
SEQ_printf(m, "Clock Event Device: ");
if (!dev) {
SEQ_printf(m, "<NULL>\n");
return;
}
SEQ_printf(m, "%s\n", dev->name);
SEQ_printf(m, " max_delta_ns: %llu\n",
(unsigned long long) dev->max_delta_ns);
SEQ_printf(m, " min_delta_ns: %llu\n",
(unsigned long long) dev->min_delta_ns);
SEQ_printf(m, " mult: %u\n", dev->mult);
SEQ_printf(m, " shift: %u\n", dev->shift);
SEQ_printf(m, " mode: %d\n", clockevent_get_state(dev));
SEQ_printf(m, " next_event: %Ld nsecs\n",
(unsigned long long) ktime_to_ns(dev->next_event));
SEQ_printf(m, " set_next_event: %ps\n", dev->set_next_event);
if (dev->set_state_shutdown)
SEQ_printf(m, " shutdown: %ps\n",
dev->set_state_shutdown);
if (dev->set_state_periodic)
SEQ_printf(m, " periodic: %ps\n",
dev->set_state_periodic);
if (dev->set_state_oneshot)
SEQ_printf(m, " oneshot: %ps\n",
dev->set_state_oneshot);
if (dev->set_state_oneshot_stopped)
SEQ_printf(m, " oneshot stopped: %ps\n",
dev->set_state_oneshot_stopped);
if (dev->tick_resume)
SEQ_printf(m, " resume: %ps\n",
dev->tick_resume);
SEQ_printf(m, " event_handler: %ps\n", dev->event_handler);
SEQ_printf(m, "\n");
SEQ_printf(m, " retries: %lu\n", dev->retries);
#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
if (cpu >= 0) {
const struct clock_event_device *wd = tick_get_wakeup_device(cpu);
SEQ_printf(m, "Wakeup Device: %s\n", wd ? wd->name : "<NULL>");
}
#endif
SEQ_printf(m, "\n");
}
static void timer_list_show_tickdevices_header(struct seq_file *m)
{
#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
print_tickdevice(m, tick_get_broadcast_device(), -1);
SEQ_printf(m, "tick_broadcast_mask: %*pb\n",
cpumask_pr_args(tick_get_broadcast_mask()));
#ifdef CONFIG_TICK_ONESHOT
SEQ_printf(m, "tick_broadcast_oneshot_mask: %*pb\n",
cpumask_pr_args(tick_get_broadcast_oneshot_mask()));
#endif
SEQ_printf(m, "\n");
#endif
}
#endif
static inline void timer_list_header(struct seq_file *m, u64 now)
{
SEQ_printf(m, "Timer List Version: v0.10\n");
SEQ_printf(m, "HRTIMER_MAX_CLOCK_BASES: %d\n", HRTIMER_MAX_CLOCK_BASES);
SEQ_printf(m, "now at %Ld nsecs\n", (unsigned long long)now);
SEQ_printf(m, "\n");
}
void sysrq_timer_list_show(void)
{
u64 now = ktime_to_ns(ktime_get());
int cpu;
timer_list_header(NULL, now);
for_each_online_cpu(cpu)
print_cpu(NULL, cpu, now);
#ifdef CONFIG_GENERIC_CLOCKEVENTS
timer_list_show_tickdevices_header(NULL);
for_each_online_cpu(cpu)
print_tickdevice(NULL, tick_get_device(cpu), cpu);
#endif
return;
}
#ifdef CONFIG_PROC_FS
static int timer_list_show(struct seq_file *m, void *v)
{
struct timer_list_iter *iter = v;
if (iter->cpu == -1 && !iter->second_pass)
timer_list_header(m, iter->now);
else if (!iter->second_pass)
print_cpu(m, iter->cpu, iter->now);
#ifdef CONFIG_GENERIC_CLOCKEVENTS
else if (iter->cpu == -1 && iter->second_pass)
timer_list_show_tickdevices_header(m);
else
print_tickdevice(m, tick_get_device(iter->cpu), iter->cpu);
#endif
return 0;
}
static void *move_iter(struct timer_list_iter *iter, loff_t offset)
{
for (; offset; offset--) {
iter->cpu = cpumask_next(iter->cpu, cpu_online_mask);
if (iter->cpu >= nr_cpu_ids) {
#ifdef CONFIG_GENERIC_CLOCKEVENTS
if (!iter->second_pass) {
iter->cpu = -1;
iter->second_pass = true;
} else
return NULL;
#else
return NULL;
#endif
}
}
return iter;
}
static void *timer_list_start(struct seq_file *file, loff_t *offset)
{
struct timer_list_iter *iter = file->private;
if (!*offset)
iter->now = ktime_to_ns(ktime_get());
iter->cpu = -1;
iter->second_pass = false;
return move_iter(iter, *offset);
}
static void *timer_list_next(struct seq_file *file, void *v, loff_t *offset)
{
struct timer_list_iter *iter = file->private;
++*offset;
return move_iter(iter, 1);
}
static void timer_list_stop(struct seq_file *seq, void *v)
{
}
static const struct seq_operations timer_list_sops = {
.start = timer_list_start,
.next = timer_list_next,
.stop = timer_list_stop,
.show = timer_list_show,
};
static int __init init_timer_list_procfs(void)
{
struct proc_dir_entry *pe;
pe = proc_create_seq_private("timer_list", 0400, NULL, &timer_list_sops,
sizeof(struct timer_list_iter), NULL);
if (!pe)
return -ENOMEM;
return 0;
}
__initcall(init_timer_list_procfs);
#endif
]
|
| 26/4 |
2026/05/23 11:35 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 8344
output: 43
thoughts: 99
Thoughts: Okay, here's my summary, tailored to an expert like myself:
**Investigating `proc_create_seq_private` and Permissions**
Right, so I've got a file created with `0400` permissions. Nothing too surprising there. The key, however, is that `proc_create_seq_private` function is employed in its creation. My immediate thought is, I need to understand how *that* specific function handles the user and group IDs (UID/GID) for the newly created proc entry. My gut says that if `proc_create_seq_private` doesn't explicitly set them, it'll default to root (0). That's the typical behavior, and I need to confirm this.
Time to dive into the source code to get the definitive answer. I'll need to locate the definition of `proc_create_seq_private` -- `fs/proc/generic.c` seems like the most likely place, or wherever the relevant procfs code resides for my kernel version. I'll focus on how the UID/GID are set or defaulted during the creation process. That should tell me if I need to explicitly set them to avoid running afoul of security constraints.
|
| 27/4 |
2026/05/23 11:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/proc/generic.c IncludeLines:true Name:proc_create_seq_private]
Results: map[SourceCode: 634: struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode,
635: struct proc_dir_entry *parent, const struct seq_operations *ops,
636: unsigned int state_size, void *data)
637: {
638: struct proc_dir_entry *p;
639:
640: p = proc_create_reg(name, mode, &parent, data);
641: if (!p)
642: return NULL;
643: p->proc_ops = &proc_seq_ops;
644: p->seq_ops = ops;
645: p->state_size = state_size;
646: return proc_register(parent, p);
647: }
SourceFile:fs/proc/generic.c]
|
| 28/4 |
2026/05/23 11:35 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 9000
output: 41
thoughts: 21
Thoughts: Here's my take on the thought process, as requested:
**Deconstructing the Process Creation**
Okay, so the code's jumping into `proc_create_reg`. That function name rings a bell, but let's not rely on memory alone. I need to understand what's happening at this core level. This feels like the pivotal point for the process creation, the function that's responsible for the registration aspects of the procedure, and that likely involves setting up the data structures and context needed for the new process within the kernel's process table or its equivalent. We need to dig into this `proc_create_reg` to figure out its inner workings. Let's see what that function does.
|
| 29/4 |
2026/05/23 11:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/proc/generic.c IncludeLines:true Name:proc_create_reg]
Results: map[SourceCode: 566: struct proc_dir_entry *proc_create_reg(const char *name, umode_t mode,
567: struct proc_dir_entry **parent, void *data)
568: {
569: struct proc_dir_entry *p;
570:
571: if ((mode & S_IFMT) == 0)
572: mode |= S_IFREG;
573: if ((mode & S_IALLUGO) == 0)
574: mode |= S_IRUGO;
575: if (WARN_ON_ONCE(!S_ISREG(mode)))
576: return NULL;
577:
578: p = __proc_create(parent, name, mode, 1);
579: if (p) {
580: p->proc_iops = &proc_file_inode_operations;
581: p->data = data;
582: }
583: return p;
584: }
SourceFile:fs/proc/generic.c]
|
| 30/4 |
2026/05/23 11:35 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 9532
output: 40
thoughts: 8
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm deep in the weeds of kernel development:
**Initial Assessment: Creation of a Process Entry**
Alright, so the core of this operation hinges on the `__proc_create` function. That immediately tells me we're dealing with the fundamental setup of a process or a related process-like entity within the kernel. I need to understand the context. Is this a new task, a thread, or perhaps a system-level process we're constructing? The name itself screams "create," so it's likely about instantiating a new process control block (PCB), or its equivalent in this architecture.
My mind immediately starts ticking through the implications. Iām thinking about the arguments passed to `__proc_create`. What data structures are initialized? What security checks are performed? How does it allocate memory for the process's context and address space if it handles such allocation? Does it register the new process with any global data structures, such as a process table or a scheduler queue? I'll probably need to understand the flow control to ensure it's thread-safe. I'm wondering if this is a low-level operation that builds up the necessary data structures or if this is the high-level API call for user-facing applications. Understanding the semantics of `__proc_create` is absolutely crucial for tracing through the rest of the execution path. And I know I will need to look up documentation to ensure I understand every aspect of this function.
|
| 31/4 |
2026/05/23 11:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/proc/generic.c IncludeLines:true Name:__proc_create]
Results: map[SourceCode: 418: static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
419: const char *name,
420: umode_t mode,
421: nlink_t nlink)
422: {
423: struct proc_dir_entry *ent = NULL;
424: const char *fn;
425: struct qstr qstr;
426:
427: if (xlate_proc_name(name, parent, &fn) != 0)
428: goto out;
429: qstr.name = fn;
430: qstr.len = strlen(fn);
431: if (qstr.len == 0 || qstr.len >= 256) {
432: WARN(1, "name len %u\n", qstr.len);
433: return NULL;
434: }
435: if (qstr.len == 1 && fn[0] == '.') {
436: WARN(1, "name '.'\n");
437: return NULL;
438: }
439: if (qstr.len == 2 && fn[0] == '.' && fn[1] == '.') {
440: WARN(1, "name '..'\n");
441: return NULL;
442: }
443: if (*parent == &proc_root && name_to_int(&qstr) != ~0U) {
444: WARN(1, "create '/proc/%s' by hand\n", qstr.name);
445: return NULL;
446: }
447: if (is_empty_pde(*parent)) {
448: WARN(1, "attempt to add to permanently empty directory");
449: return NULL;
450: }
451:
452: ent = kmem_cache_zalloc(proc_dir_entry_cache, GFP_KERNEL);
453: if (!ent)
454: goto out;
455:
456: if (qstr.len + 1 <= SIZEOF_PDE_INLINE_NAME) {
457: ent->name = ent->inline_name;
458: } else {
459: ent->name = kmalloc(qstr.len + 1, GFP_KERNEL);
460: if (!ent->name) {
461: pde_free(ent);
462: return NULL;
463: }
464: }
465:
466: memcpy(ent->name, fn, qstr.len + 1);
467: ent->namelen = qstr.len;
468: ent->mode = mode;
469: ent->nlink = nlink;
470: ent->subdir = RB_ROOT;
471: refcount_set(&ent->refcnt, 1);
472: spin_lock_init(&ent->pde_unload_lock);
473: INIT_LIST_HEAD(&ent->pde_openers);
474: proc_set_user(ent, (*parent)->uid, (*parent)->gid);
475:
476: /* Revalidate everything under /proc/${pid}/net */
477: if ((*parent)->flags & PROC_ENTRY_FORCE_LOOKUP)
478: pde_force_lookup(ent);
479:
480: out:
481: return ent;
482: }
SourceFile:fs/proc/generic.c]
|
| 32/4 |
2026/05/23 11:35 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 10929
output: 42
thoughts: 377
Thoughts: **Analyzing the /proc/timer_list Entry Creation**
Okay, so I'm digging into how the `/proc/timer_list` entry is created. My initial thought was to look at how the user and group are set for this new process entry. The code snippet in `__proc_create` shows that `proc_set_user` sets the new entry's UID and GID to those of its parent. That's straightforward enough.
The tricky part is that, for `/proc/timer_list`, the parent seems to be `NULL` in the `proc_create_seq_private` function. My initial assumption was this would default the UID/GID to that of `proc_root`, but that's not what the code appears to do.
Now I'm looking at `proc_create_reg`. This function is pivotal; it takes a `struct proc_dir_entry **parent`. The double pointer is unusual and now I see that `proc_create_seq_private` *passes the address* of its `parent` variable to `proc_create_reg`. This is a crucial distinction. If `parent` is initially `NULL`, it's now a pointer to `NULL`, which changes how it's handled.
Okay, let's step through. `proc_create_reg` calls `__proc_create`, passing the potentially-`NULL` parent. In `__proc_create`, the `xlate_proc_name` function seems like the logical place to check. That function probably has to handle this potential `NULL` parent and correctly process the entry's parent. I need to investigate `xlate_proc_name` to see what it's doing with that `NULL` pointer. That's the key to understanding the UID/GID assignment.
|
| 33/4 |
2026/05/23 11:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/proc/generic.c IncludeLines:true Name:xlate_proc_name]
Results: map[SourceCode: 182: static int xlate_proc_name(const char *name, struct proc_dir_entry **ret,
183: const char **residual)
184: {
185: int rv;
186:
187: read_lock(&proc_subdir_lock);
188: rv = __xlate_proc_name(name, ret, residual);
189: read_unlock(&proc_subdir_lock);
190: return rv;
191: }
SourceFile:fs/proc/generic.c]
|
| 34/4 |
2026/05/23 11:35 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 11904
output: 43
thoughts: 10
Thoughts: Okay, here's my attempt at summarizing the thought process, tailored for an expert audience, and written in the first person:
**Analyzing `__xlate_proc_name` and Its Implications**
Alright, let's break this down. When I see `__xlate_proc_name`, my mind immediately goes into overdrive, considering its potential role in translation or conversion processes. The double underscore prefix is a classic indicator, isn't it? It suggests an internal, implementation-specific function or symbol, very likely hidden from direct public use. That sparks a few questions right off the bat:
* **What's the context?** Am I dealing with a compiler, an interpreter, a library, or a specific system call? The application domain is crucial to interpreting this. Is it a language runtime, OS kernel component, or something else entirely? The environment will significantly color my understanding.
* **What's being translated?** Is it code (e.g., intermediate representation to machine code, or even source code translation), data, or addresses? The data type or structure undergoing translation provides a lot of context here. Is this an internal data representation being translated into a more user-friendly form?
* **What's the process?** Based on the name, it's clear there's some sort of name translation happening. Are we talking about symbol resolution, stringification, or macro expansion? Is it related to dynamic linking, name mangling, or something more specialized? The algorithm employed here is what I want to understand.
* **How robust is it?** Error handling is key. This could be where the magic, or the bugs, reside. What are the failure modes? What happens if the name can't be translated? Are there graceful fallbacks or will it throw a cryptic error? And what about security? Does this process introduce any vulnerabilities, such as format string vulnerabilities?
* **Performance implications:** Any kind of name translation, especially if done dynamically, can introduce performance bottlenecks. I need to think about how often this function gets called, the complexity of its logic, and any caching or optimization strategies that might be in place. If it's a critical path, every cycle matters.
So, while I'm looking at `__xlate_proc_name`, I'm simultaneously probing for clues about these areas. It could be a simple utility function, or a highly sophisticated piece of the puzzle. I need more information to really pin it down, but the initial impressions give me a good framework to start with. Let's see how much more context I can gather.
|
| 35/4 |
2026/05/23 11:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/proc/generic.c IncludeLines:true Name:__xlate_proc_name]
Results: map[SourceCode: 157: /*
158: * This function parses a name such as "tty/driver/serial", and
159: * returns the struct proc_dir_entry for "/proc/tty/driver", and
160: * returns "serial" in residual.
161: */
162: static int __xlate_proc_name(const char *name, struct proc_dir_entry **ret,
163: const char **residual)
164: {
165: const char *cp = name, *next;
166: struct proc_dir_entry *de;
167:
168: de = *ret ?: &proc_root;
169: while ((next = strchr(cp, '/')) != NULL) {
170: de = pde_subdir_find(de, cp, next - cp);
171: if (!de) {
172: WARN(1, "name '%s'\n", name);
173: return -ENOENT;
174: }
175: cp = next + 1;
176: }
177: *residual = cp;
178: *ret = de;
179: return 0;
180: }
SourceFile:fs/proc/generic.c]
|
| 36/4 |
2026/05/23 11:35 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 12888
output: 39
thoughts: 130
Thoughts: **Analyzing the User ID and Group ID Assignment in `procfs`**
Okay, so I'm tracing the user and group ID assignments within the `procfs` implementation, specifically when creating a new entry. It looks like if `*ret` is `NULL`, the code defaults to using `&proc_root`. This means `parent` gets set to `&proc_root` in that scenario. Makes sense, that's the default root directory. Then, back in `__proc_create`, on line 474, `proc_set_user(ent, (*parent)->uid, (*parent)->gid)` is executed. Aha, so `ent->uid` and `ent->gid` are assigned values from the parent ā which, in this `NULL` `ret` case, is `proc_root.uid` and `proc_root.gid`. This is the crux of how the permissions are propagated from the root. Now, to be absolutely certain of the default initial values I need to check where `proc_root` is initialized. Let me go over to `fs/proc/root.c` and take a look.
|
| 37/4 |
2026/05/23 11:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/proc/root.c IncludeLines:true Name:proc_root]
Results: map[SourceCode: 442: /*
443: * This is the root "inode" in the /proc tree..
444: */
445: struct proc_dir_entry proc_root = {
446: .low_ino = PROCFS_ROOT_INO,
447: .namelen = 5,
448: .mode = S_IFDIR | S_IRUGO | S_IXUGO,
449: .nlink = 2,
450: .refcnt = REFCOUNT_INIT(1),
451: .proc_iops = &proc_root_inode_operations,
452: .proc_dir_ops = &proc_root_operations,
453: .parent = &proc_root,
454: .subdir = RB_ROOT,
455: .name = "/proc",
456: };
SourceFile:fs/proc/root.c]
|
| 38/4 |
2026/05/23 11:35 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 13580
output: 41
thoughts: 362
Thoughts: **Analyzing `/proc/timer_list` Permissions in User Namespaces**
Okay, so I'm looking at this code and trying to figure out the security implications, specifically around `/proc/timer_list`. My initial thought was that since the code doesn't explicitly assign a user ID (`.uid`) or group ID (`.gid`), it should default to 0, which would be the global root, `GLOBAL_ROOT_UID/GID`. But then I saw the `proc_set_user` function, and that clarifies things: it *does* set `de->uid` and `de->gid`, just not directly in this snippet.
So that means `/proc/timer_list` *is* owned by the global root user and group, and its mode is `0400`. That's important. It basically means only the global root can read it.
Now, the interesting question is: what happens when a process in a *user namespace* tries to access it? That's where things get tricky. A process inside a user namespace has a specific UID within *that* namespace. If it's the "root" of the namespace, its UID inside that namespace is 0. But, crucially, its UID in the initial, or "parent", namespace (where `/proc/timer_list` was created) is whatever UID was used to create that namespace.
Then I paused and considered `/proc` itself. I had to remind myself about how it works with user namespaces. I know `/proc` is usually shared, but some parts are namespace-specific. However, `/proc/timer_list` is a global file, created at boot. That makes the whole thing much more interesting.
Okay, so if a process within a user namespace tries to *open* `/proc/timer_list`, the kernel will perform a permission check. The inode for `/proc/timer_list` will have `i_uid` and `i_gid` which will be derived from the `proc_dir_entry`. That's the key.
Now, I need to see exactly how `proc_get_inode` sets the inode's UID and GID to be absolutely certain. It would be helpful to trace the code to understand how it deals with UID/GID translation in the context of user namespaces. Understanding that link is the most important piece of the puzzle.
|
| 39/4 |
2026/05/23 11:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/proc/inode.c IncludeLines:true Name:proc_get_inode]
Results: map[SourceCode: 628: struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
629: {
630: struct inode *inode = new_inode(sb);
631:
632: if (!inode) {
633: pde_put(de);
634: return NULL;
635: }
636:
637: inode->i_private = de->data;
638: inode->i_ino = de->low_ino;
639: simple_inode_init_ts(inode);
640: PROC_I(inode)->pde = de;
641: if (is_empty_pde(de)) {
642: make_empty_dir_inode(inode);
643: return inode;
644: }
645:
646: if (de->mode) {
647: inode->i_mode = de->mode;
648: inode->i_uid = de->uid;
649: inode->i_gid = de->gid;
650: }
651: if (de->size)
652: inode->i_size = de->size;
653: if (de->nlink)
654: set_nlink(inode, de->nlink);
655:
656: if (S_ISREG(inode->i_mode)) {
657: inode->i_op = de->proc_iops;
658: if (pde_has_proc_read_iter(de))
659: inode->i_fop = &proc_iter_file_ops;
660: else
661: inode->i_fop = &proc_reg_file_ops;
662: #ifdef CONFIG_COMPAT
663: if (pde_has_proc_compat_ioctl(de)) {
664: if (pde_has_proc_read_iter(de))
665: inode->i_fop = &proc_iter_file_ops_compat;
666: else
667: inode->i_fop = &proc_reg_file_ops_compat;
668: }
669: #endif
670: } else if (S_ISDIR(inode->i_mode)) {
671: inode->i_op = de->proc_iops;
672: inode->i_fop = de->proc_dir_ops;
673: } else if (S_ISLNK(inode->i_mode)) {
674: inode->i_op = de->proc_iops;
675: inode->i_fop = NULL;
676: } else {
677: BUG();
678: }
679: return inode;
680: }
SourceFile:fs/proc/inode.c]
|
| 40/4 |
2026/05/23 11:35 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 15324
output: 43
thoughts: 650
Thoughts: **Analyzing `/proc/timer_list` Access in User Namespaces**
Okay, so I'm diving into how `/proc/timer_list` works with user namespaces. It looks like the inode's UID and GID are set from the `proc_dir_entry`, and that's initially global root (UID 0). Makes sense. Now, the standard VFS permission check, probably using something like `generic_permission`, kicks in when a process in a user namespace tries to access it.
Right, the key here is how the kernel handles credentials in user namespaces. It's comparing the process's `fsuid` with the inode's `i_uid`. And, oh yeah, I need to remember that `inode->i_uid` is a `kuid_t`, that's an *internal* kernel representation, meaning it's using the *global* UID. Got it.
Permission checks usually boil down to something like `inode_owner_or_capable`, so either the `fsuid` matches `i_uid` or the process has `CAP_DAC_OVERRIDE`. Now, the tricky part... capabilities are *namespaced*. So, a process's `CAP_DAC_OVERRIDE` in a user namespace only works for files where the global UID is mapped into the namespace.
If `/proc/timer_list` is owned by global root, which it is, and the user namespace *doesn't* map global root (UID 0) ā which is typical for unprivileged namespaces ā then even `CAP_DAC_OVERRIDE` within the namespace won't help. The file's still owned by global root, and the process's `fsuid` (likely some non-zero global UID) won't match.
Hold on, I see the catch. Unprivileged user namespaces usually map the creating user's UID to 0 in the new namespace, but not usually global UID 0. If global UID 0 *isn't* mapped, the file's UID will appear to be something else, usually `overflowuid` (65534) from within the namespace, or some other unmapped UID. So the process's UID would definitely not match the apparent owner. And `CAP_DAC_OVERRIDE` won't apply to global root.
So, for a `0400` file owned by global root, it *should* be inaccessible to an unprivileged user within a user namespace unless, and this is important, the namespace has global root mapped *or* the user is actually global root. Makes sense.
But wait a minute, I have to remember that `/proc` isn't always standard. Some `/proc` files can have custom permission handlers. However, `timer_list` uses `proc_file_inode_operations`, so it's probably using the standard VFS checks.
Time to go check `proc_file_inode_operations` to be absolutely certain...
|
| 41/4 |
2026/05/23 11:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/proc/generic.c IncludeLines:true Name:proc_file_inode_operations]
Results: map[SourceCode: 153: static const struct inode_operations proc_file_inode_operations = {
154: .setattr = proc_setattr,
155: };
SourceFile:fs/proc/generic.c]
|
| 42/4 |
2026/05/23 11:35 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 16731
output: 30
thoughts: 1335
Thoughts: **Analyzing `/proc/timer_list` Accessibility in User Namespaces**
Okay, so the initial question revolves around whether an unprivileged user can read `/proc/timer_list`. My first thought is that since there's no explicit `.permission` method, it relies on the default file permissions. Then, I need to verify that `proc_create_seq_private` is consistently used with `0400` for this file, which the user confirmed. I've double-checked in the kernel code (`kernel/time/timer_list.c`) and that's indeed the case.
The key then becomes how the `proc` filesystem behaves within user namespaces, specifically around mount options. When mounting `/proc` in a user namespace, it usually creates a new mount instance linked to the associated PID namespace. Given that user namespaces and PID namespaces are frequently created together, I need to understand what happens to file UIDs in this scenario.
I've looked at `proc_fill_super` in `fs/proc/root.c` and remember that `proc_get_inode` will use the `de->uid` and `de->gid`. `proc_root`'s `uid` and `gid` are initialized to 0. The crucial part here is how this interacts with user namespace mapping. If the global UID 0 isn't mapped within the user namespace, the inode's `i_uid` remains global UID 0, and `stat` will likely report an `overflowuid`.
With a `0400` permission, only the owner (global UID 0) can read it. However, if my UID within the namespace is, say, 1000 (mapped to 0), I am *not* the owner. Therefore, I can't read it. I'm wondering if there's any mechanism to change ownership of `/proc` entries based on the namespace. While some entries under `/proc/[pid]/` get the PID's owner, `/proc/timer_list` is a top-level entry.
Let's quickly check whether `timer_list` has some namespace specific treatment or some security check to see if it is considered safe. I don't see any special handling in `kernel/time/timer_list.c`. The `proc_set_user` function isn't called after the creation of the entry, so there is no way to change the user's permissions once the file is made.
A key concern is that this `/proc` file might leak kernel addresses, as it displays addresses. I know `%p` might be hashed unless `%pK` is used, and `kptr_restrict` is set. Even with those measures, timing information might still be exposed. I confirmed from the code that `timer_list_show` prints addresses.
I've verified that `proc_create_seq_private` is the *only* method of creating the file.
Now, if the user namespace *does* map global UID 0 (which is unlikely), a process could be UID 0 and access it. But, this is ruled out by the premise of an unprivileged user.
I've also verified that the file creation mode is indeed `0400`. There's no after-the-fact change to permissions.
Finally, I checked for other `timer_list` proc files with a `git grep`, but this appears to be the only one. Just to be completely thorough, I confirmed that `proc_root`'s UID/GID are always initialized to 0, and that no code changes them later. I verified this with a search of the code.
Given the `0400` permissions, the default ownership of UID 0, the lack of any namespace-specific permission changes, and that the unprivileged user *likely* cannot map UID 0, the answer should be no; the user cannot read `/proc/timer_list`.
|
| 43/4 |
2026/05/23 11:35 |
tool |
grepper |
0m
Error:
Args: map[Expression:proc_root.uid|proc_set_user\(&proc_root]
Results:
|
| 44/4 |
2026/05/23 11:36 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 18947
output: 22
thoughts: 1111
Thoughts: **Analyzing the Accessibility of `/proc/timer_list`**
Okay, let's break this down. My initial understanding is that `/proc/timer_list` inherits its ownership from `proc_root`, which, in turn, is owned by global root. Its mode is set to `0400`, meaning it's intended to be readable only by root.
I should double-check that `proc_create_seq_private` *always* sets this mode. Right, it's hardcoded, so that's consistent. I also made sure that the `subset=pid` mount option does not change this behavior, it doesn't.
Now, I can't directly verify if an unprivileged user can read it on a live system, but I can trace the code. I need to figure out *how* the permission check actually happens.
My next step is to examine the read path. I'm looking for special permission checks in `seq_read` or `proc_reg_read`. I know `proc_reg_open` is called when the file is opened, and if the associated `proc_ops` structure has a `.proc_open` method, that's called. For `timer_list`, this uses `proc_seq_ops` which means `proc_seq_open` is called, which then uses `seq_open`. Nothing obvious there.
The permission check should be happening in the VFS layer, specifically with `may_open`. `may_open` then calls `inode_permission`. `inode_permission` calls `do_inode_permission`. If the inode has an `.i_op->permission` method defined, that's called; otherwise, it calls `generic_permission`. The `proc_file_inode_operations` doesn't have a `.permission` method, so it uses `generic_permission`.
`generic_permission` first checks ACLs, but it's the `acl_permission_check` that matters here. If there are no ACLs, it checks the mode bits directly. With `0400`, it checks: if the caller's UID matches the inode's UID, then the read permission (the `4`) is checked. If the caller's UID does *not* match, it checks group and other permissions. Those are 0, so access is denied unless the user has `CAP_DAC_OVERRIDE`.
`capable_wrt_inode_uidgid` will be called, which in turn checks if the caller has the capability in the namespace that owns the inode.
Now, who owns the inode? The inode's UID/GID are global root. I know that the procfs superblock has `s_user_ns`. If procfs is mounted in a user namespace, then `s_user_ns` is that user namespace.
I should re-examine how the `proc_mount` function sets `s_user_ns`. Let me look at `fs/proc/root.c`... Ah, yes. It uses `mount_ns`. So, if a user namespace is involved, this is the key. It's likely `mount_nodev`, but I need to confirm this.
|
| 45/4 |
2026/05/23 11:36 |
tool |
read-file |
0m
Args:
Results: map[Contents:// SPDX-License-Identifier: GPL-2.0
/*
* linux/fs/proc/root.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*
* proc root directory handling functions
*/
#include <linux/errno.h>
#include <linux/time.h>
#include <linux/proc_fs.h>
#include <linux/stat.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/sched/stat.h>
#include <linux/module.h>
#include <linux/bitops.h>
#include <linux/user_namespace.h>
#include <linux/fs_context.h>
#include <linux/mount.h>
#include <linux/pid_namespace.h>
#include <linux/fs_parser.h>
#include <linux/cred.h>
#include <linux/magic.h>
#include <linux/slab.h>
#include "internal.h"
struct proc_fs_context {
struct pid_namespace *pid_ns;
unsigned int mask;
enum proc_hidepid hidepid;
int gid;
enum proc_pidonly pidonly;
};
enum proc_param {
Opt_gid,
Opt_hidepid,
Opt_subset,
Opt_pidns,
};
static const struct fs_parameter_spec proc_fs_parameters[] = {
fsparam_u32("gid", Opt_gid),
fsparam_string("hidepid", Opt_hidepid),
fsparam_string("subset", Opt_subset),
fsparam_file_or_string("pidns", Opt_pidns),
{}
};
static inline int valid_hidepid(unsigned int value)
{
return (value == HIDEPID_OFF ||
value == HIDEPID_NO_ACCESS ||
value == HIDEPID_INVISIBLE ||
value == HIDEPID_NOT_PTRACEABLE);
}
static int proc_parse_hidepid_param(struct fs_context *fc, struct fs_parameter *param)
{
struct proc_fs_context *ctx = fc->fs_private;
struct fs_parameter_spec hidepid_u32_spec = fsparam_u32("hidepid", Opt_hidepid);
struct fs_parse_result result;
int base = (unsigned long)hidepid_u32_spec.data;
if (param->type != fs_value_is_string)
return invalf(fc, "proc: unexpected type of hidepid value\n");
if (!kstrtouint(param->string, base, &result.uint_32)) {
if (!valid_hidepid(result.uint_32))
return invalf(fc, "proc: unknown value of hidepid - %s\n", param->string);
ctx->hidepid = result.uint_32;
return 0;
}
if (!strcmp(param->string, "off"))
ctx->hidepid = HIDEPID_OFF;
else if (!strcmp(param->string, "noaccess"))
ctx->hidepid = HIDEPID_NO_ACCESS;
else if (!strcmp(param->string, "invisible"))
ctx->hidepid = HIDEPID_INVISIBLE;
else if (!strcmp(param->string, "ptraceable"))
ctx->hidepid = HIDEPID_NOT_PTRACEABLE;
else
return invalf(fc, "proc: unknown value of hidepid - %s\n", param->string);
return 0;
}
static int proc_parse_subset_param(struct fs_context *fc, char *value)
{
struct proc_fs_context *ctx = fc->fs_private;
while (value) {
char *ptr = strchr(value, ',');
if (ptr != NULL)
*ptr++ = '\0';
if (*value != '\0') {
if (!strcmp(value, "pid")) {
ctx->pidonly = PROC_PIDONLY_ON;
} else {
return invalf(fc, "proc: unsupported subset option - %s\n", value);
}
}
value = ptr;
}
return 0;
}
#ifdef CONFIG_PID_NS
static int proc_parse_pidns_param(struct fs_context *fc,
struct fs_parameter *param,
struct fs_parse_result *result)
{
struct proc_fs_context *ctx = fc->fs_private;
struct pid_namespace *target, *active = task_active_pid_ns(current);
struct ns_common *ns;
struct file *ns_filp __free(fput) = NULL;
switch (param->type) {
case fs_value_is_file:
/* came through fsconfig, steal the file reference */
ns_filp = no_free_ptr(param->file);
break;
case fs_value_is_string:
ns_filp = filp_open(param->string, O_RDONLY, 0);
break;
default:
WARN_ON_ONCE(true);
break;
}
if (!ns_filp)
ns_filp = ERR_PTR(-EBADF);
if (IS_ERR(ns_filp)) {
errorfc(fc, "could not get file from pidns argument");
return PTR_ERR(ns_filp);
}
if (!proc_ns_file(ns_filp))
return invalfc(fc, "pidns argument is not an nsfs file");
ns = get_proc_ns(file_inode(ns_filp));
if (ns->ns_type != CLONE_NEWPID)
return invalfc(fc, "pidns argument is not a pidns file");
target = container_of(ns, struct pid_namespace, ns);
/*
* pidns= is shorthand for joining the pidns to get a fsopen fd, so the
* permission model should be the same as pidns_install().
*/
if (!ns_capable(target->user_ns, CAP_SYS_ADMIN)) {
errorfc(fc, "insufficient permissions to set pidns");
return -EPERM;
}
if (!pidns_is_ancestor(target, active))
return invalfc(fc, "cannot set pidns to non-descendant pidns");
put_pid_ns(ctx->pid_ns);
ctx->pid_ns = get_pid_ns(target);
put_user_ns(fc->user_ns);
fc->user_ns = get_user_ns(ctx->pid_ns->user_ns);
return 0;
}
#endif /* CONFIG_PID_NS */
static int proc_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
struct proc_fs_context *ctx = fc->fs_private;
struct fs_parse_result result;
int opt, err;
opt = fs_parse(fc, proc_fs_parameters, param, &result);
if (opt < 0)
return opt;
switch (opt) {
case Opt_gid:
ctx->gid = result.uint_32;
break;
case Opt_hidepid:
err = proc_parse_hidepid_param(fc, param);
if (err)
return err;
break;
case Opt_subset:
err = proc_parse_subset_param(fc, param->string);
if (err)
return err;
break;
case Opt_pidns:
#ifdef CONFIG_PID_NS
/*
* We would have to RCU-protect every proc_pid_ns() or
* proc_sb_info() access if we allowed this to be reconfigured
* for an existing procfs instance. Luckily, procfs instances
* are cheap to create, and mount-beneath would let you
* atomically replace an instance even with overmounts.
*/
if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
errorfc(fc, "cannot reconfigure pidns for existing procfs");
return -EBUSY;
}
err = proc_parse_pidns_param(fc, param, &result);
if (err)
return err;
break;
#else
errorfc(fc, "pidns mount flag not supported on this system");
return -EOPNOTSUPP;
#endif
default:
return -EINVAL;
}
ctx->mask |= 1 << opt;
return 0;
}
static void proc_apply_options(struct proc_fs_info *fs_info,
struct fs_context *fc,
struct user_namespace *user_ns)
{
struct proc_fs_context *ctx = fc->fs_private;
if (ctx->mask & (1 << Opt_gid))
fs_info->pid_gid = make_kgid(user_ns, ctx->gid);
if (ctx->mask & (1 << Opt_hidepid))
fs_info->hide_pid = ctx->hidepid;
if (ctx->mask & (1 << Opt_subset))
fs_info->pidonly = ctx->pidonly;
if (ctx->mask & (1 << Opt_pidns) &&
!WARN_ON_ONCE(fc->purpose == FS_CONTEXT_FOR_RECONFIGURE)) {
put_pid_ns(fs_info->pid_ns);
fs_info->pid_ns = get_pid_ns(ctx->pid_ns);
}
}
static int proc_fill_super(struct super_block *s, struct fs_context *fc)
{
struct proc_fs_context *ctx = fc->fs_private;
struct inode *root_inode;
struct proc_fs_info *fs_info;
int ret;
fs_info = kzalloc_obj(*fs_info);
if (!fs_info)
return -ENOMEM;
fs_info->pid_ns = get_pid_ns(ctx->pid_ns);
proc_apply_options(fs_info, fc, current_user_ns());
/* User space would break if executables or devices appear on proc */
s->s_iflags |= SB_I_USERNS_VISIBLE | SB_I_NOEXEC | SB_I_NODEV;
s->s_flags |= SB_NODIRATIME | SB_NOSUID | SB_NOEXEC;
s->s_blocksize = 1024;
s->s_blocksize_bits = 10;
s->s_magic = PROC_SUPER_MAGIC;
s->s_op = &proc_sops;
s->s_time_gran = 1;
s->s_fs_info = fs_info;
/*
* procfs isn't actually a stacking filesystem; however, there is
* too much magic going on inside it to permit stacking things on
* top of it
*/
s->s_stack_depth = FILESYSTEM_MAX_STACK_DEPTH;
/* procfs dentries and inodes don't require IO to create */
s->s_shrink->seeks = 0;
pde_get(&proc_root);
root_inode = proc_get_inode(s, &proc_root);
if (!root_inode) {
pr_err("proc_fill_super: get root inode failed\n");
return -ENOMEM;
}
s->s_root = d_make_root(root_inode);
if (!s->s_root) {
pr_err("proc_fill_super: allocate dentry failed\n");
return -ENOMEM;
}
ret = proc_setup_self(s);
if (ret) {
return ret;
}
return proc_setup_thread_self(s);
}
static int proc_reconfigure(struct fs_context *fc)
{
struct super_block *sb = fc->root->d_sb;
struct proc_fs_info *fs_info = proc_sb_info(sb);
sync_filesystem(sb);
proc_apply_options(fs_info, fc, current_user_ns());
return 0;
}
static int proc_get_tree(struct fs_context *fc)
{
return get_tree_nodev(fc, proc_fill_super);
}
static void proc_fs_context_free(struct fs_context *fc)
{
struct proc_fs_context *ctx = fc->fs_private;
put_pid_ns(ctx->pid_ns);
kfree(ctx);
}
static const struct fs_context_operations proc_fs_context_ops = {
.free = proc_fs_context_free,
.parse_param = proc_parse_param,
.get_tree = proc_get_tree,
.reconfigure = proc_reconfigure,
};
static int proc_init_fs_context(struct fs_context *fc)
{
struct proc_fs_context *ctx;
ctx = kzalloc_obj(struct proc_fs_context);
if (!ctx)
return -ENOMEM;
ctx->pid_ns = get_pid_ns(task_active_pid_ns(current));
put_user_ns(fc->user_ns);
fc->user_ns = get_user_ns(ctx->pid_ns->user_ns);
fc->fs_private = ctx;
fc->ops = &proc_fs_context_ops;
return 0;
}
static void proc_kill_sb(struct super_block *sb)
{
struct proc_fs_info *fs_info = proc_sb_info(sb);
kill_anon_super(sb);
if (fs_info) {
put_pid_ns(fs_info->pid_ns);
kfree_rcu(fs_info, rcu);
}
}
static struct file_system_type proc_fs_type = {
.name = "proc",
.init_fs_context = proc_init_fs_context,
.parameters = proc_fs_parameters,
.kill_sb = proc_kill_sb,
.fs_flags = FS_USERNS_MOUNT | FS_DISALLOW_NOTIFY_PERM,
};
void __init proc_root_init(void)
{
proc_init_kmemcache();
set_proc_pid_nlink();
proc_self_init();
proc_thread_self_init();
proc_symlink("mounts", NULL, "self/mounts");
proc_net_init();
proc_mkdir("fs", NULL);
proc_mkdir("driver", NULL);
proc_create_mount_point("fs/nfsd"); /* somewhere for the nfsd filesystem to be mounted */
#if defined(CONFIG_SUN_OPENPROMFS) || defined(CONFIG_SUN_OPENPROMFS_MODULE)
/* just give it a mountpoint */
proc_create_mount_point("openprom");
#endif
proc_tty_init();
proc_mkdir("bus", NULL);
proc_sys_init();
/*
* Last things last. It is not like userspace processes eager
* to open /proc files exist at this point but register last
* anyway.
*/
register_filesystem(&proc_fs_type);
}
static int proc_root_getattr(struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
generic_fillattr(&nop_mnt_idmap, request_mask, d_inode(path->dentry),
stat);
stat->nlink = proc_root.nlink + nr_processes();
return 0;
}
static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry, unsigned int flags)
{
if (!proc_pid_lookup(dentry, flags))
return NULL;
return proc_lookup(dir, dentry, flags);
}
static int proc_root_readdir(struct file *file, struct dir_context *ctx)
{
if (ctx->pos < FIRST_PROCESS_ENTRY) {
int error = proc_readdir(file, ctx);
if (unlikely(error <= 0))
return error;
ctx->pos = FIRST_PROCESS_ENTRY;
}
return proc_pid_readdir(file, ctx);
}
/*
* The root /proc directory is special, as it has the
* <pid> directories. Thus we don't use the generic
* directory handling functions for that..
*/
static const struct file_operations proc_root_operations = {
.read = generic_read_dir,
.iterate_shared = proc_root_readdir,
.llseek = generic_file_llseek,
};
/*
* proc root can do almost nothing..
*/
static const struct inode_operations proc_root_inode_operations = {
.lookup = proc_root_lookup,
.getattr = proc_root_getattr,
};
/*
* This is the root "inode" in the /proc tree..
*/
struct proc_dir_entry proc_root = {
.low_ino = PROCFS_ROOT_INO,
.namelen = 5,
.mode = S_IFDIR | S_IRUGO | S_IXUGO,
.nlink = 2,
.refcnt = REFCOUNT_INIT(1),
.proc_iops = &proc_root_inode_operations,
.proc_dir_ops = &proc_root_operations,
.parent = &proc_root,
.subdir = RB_ROOT,
.name = "/proc",
};
]
|
| 46/4 |
2026/05/23 11:36 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 25182
output: 35
thoughts: 1778
Thoughts: **Analyzing `/proc/timer_list` Accessibility in User Namespaces**
Okay, so the user's question brings up an interesting access control scenario within user namespaces, specifically regarding `/proc/timer_list`. Let me think this through step by step.
Initially, in the context of `proc_init_fs_context`, the `fc->user_ns` is set to the user namespace of the PID namespace. This implies that if a user creates a new user namespace and then a new PID namespace, the `s->s_user_ns` within the `proc` filesystem will be that new user namespace.
Now, considering the `generic_permission` check, which utilizes `capable_wrt_inode_uidgid`, we need to understand how permissions are determined. `privileged_wrt_inode_uidgid` is key here: it checks if the inode's UID and GID have mappings within the current user namespace. If there's no mapping for the inode's UID (global 0, in the case of `timer_list`) or GID, access is denied. Since `timer_list`'s UID is global 0, and our unprivileged user's UID is something else, this means `CAP_DAC_OVERRIDE` isn't going to help. Moreover, because the file's mode is `0400`, the access is denied outright unless the effective UID matches the file's owner.
My immediate thought was whether there might be exceptions for `/proc` files, given their system-level nature, but in this case, `/proc/timer_list` is definitely `0400`. We know it is a global PDE and is created for every proc instance. Also, I must ensure that `timer_list` is not hidden, for example, if `subset=pid` is used (it is not). It might return `ENOENT` if the filesystem is subsetted to PIDs.
The core question, then, is about an unprivileged user within their own namespace. They can mount `proc`, if they also have their own PID namespace. However, the files *within* that mount will have the same global UIDs as the regular `/proc` (mostly). So, I checked to ensure whether the user, even if "root" within their namespace (by mapping their UID to 0), can access it. Because the inode's UID is *global* 0, their "local" root wouldn't be the owner, and thus wouldn't be able to access it.
Now, I revisited the code to confirm if there are any other instances where `timer_list` is created, but it's only created once, during boot. I also considered whether `proc_set_user` might be called with the namespace's root UID, but `init_timer_list_procfs` runs early, in the initial namespace, so no luck there.
I questioned if the file was created with a different mode, perhaps `0444`, in the past. Checking the current code, however, confirms the `0400` mode. I even checked `git log` about the permissions of `timer_list` but that's a shot in the dark.
I briefly considered the `sysrq` path, knowing SysRq-Q calls `sysrq_timer_list_show`, but that prints to dmesg, which isn't the same as accessing `/proc/timer_list`. I need to stay focused on the user's original question.
Furthermore, I explored if `proc_create_seq_private` might use the current namespace when creating the PDE but PDEs are global and not per-namespace, so the file's UID and GID are set at creation. `proc_get_inode` uses those fixed values. The code makes it clear `/proc/timer_list` always has `i_uid = 0` (global). I re-checked `proc_get_inode` to ensure there isn't any overriding code.
I also looked at `proc_set_user`, where `de->uid` and `de->gid` are set but the parent's UID for `timer_list` is 0, so that doesn't help the unprivileged user either.
Thus, the logical conclusion is:
1. `/proc/timer_list` is owned by global UID 0.
2. Its mode is `0400` (readable only by the owner).
3. An unprivileged user in a user namespace has a *different* global UID.
4. Even if they are "root" (UID 0) inside *their* namespace, their *global* UID remains their original UID (e.g., 1000).
5. The
|
| 47/4 |
2026/05/23 11:36 |
tool |
git-log |
0m
Args: map[CodeRegexp:timer_list PathPrefix:kernel/time/timer_list.c]
Results: map[Output:a9314773a91a timer_list: Guard procfs specific code
58c5fc2b96e4 time: Remove useless filenames in top level comments
44414d82cfe0 proc: introduce proc_create_seq_private
8e7df2b5b7f2 timer/debug: Change /proc/timer_list from 0444 to 0400
84a78a6504f5 timer_list: correct the iterator for timer_list
b3956a896ea5 timer_list: Convert timer list to be a proper seq_file
60cf7ea849e7 timer_list: Split timer_list_show_tickdevices
828c09509b96 const: constify remaining file_operations
de809347aeef timers: Drop write permission on /proc/timer_list
c33fff0afbef kernel: use non-racy method for proc entries creation
]
|
| 48/4 |
2026/05/23 11:36 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 28269
output: 26
thoughts: 46
Thoughts: Okay, here's my interpretation of that commit message, expressed as my internal thought process:
**Diving into that Kernel Timer Change**
Right, that caught my eye: `8e7df2b5b7f2 timer/debug: Change /proc/timer_list from 0444 to 0400`. Always interesting to see low-level changes like this affecting `/proc`. Okay, time to dissect that commit. I'm immediately thinking about the implications of modifying the permissions on `/proc/timer_list`. Why the shift from 0444 (read-only for all) to 0400 (read-only for root)? My expert spidey senses are tingling - it suggests a security or information disclosure concern has been identified. I'm going to want to understand the rationale behind this tightening. Was there a vulnerability related to unprivileged processes accessing the timer list that needed patching? Or perhaps it was deemed an inadvertent leak of sensitive timing information that could be used for side-channel attacks? The details are crucial. Let's see if the commit message sheds any more light on the motivations, or if there's a related CVE or security advisory I need to dig into. This is definitely a change that warrants a deeper look.
|
| 49/4 |
2026/05/23 11:36 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 8e7df2b5b7f245c9bd11064712db5cb69044a362
Author: Ingo Molnar <mingo@kernel.org>
Date: Mon Nov 13 07:15:41 2017 +0100
timer/debug: Change /proc/timer_list from 0444 to 0400
While it uses %pK, there's still few reasons to read this file
as non-root.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 0e7f5428a148..0ed768b56c60 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -389,7 +389,7 @@ static int __init init_timer_list_procfs(void)
{
struct proc_dir_entry *pe;
- pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
+ pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
if (!pe)
return -ENOMEM;
return 0;
]
|
| 50/4 |
2026/05/23 11:36 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 29069
output: 22
thoughts: 920
Thoughts: **Analyzing File Permissions and User Namespaces**
Okay, so the commit message mentions `%pK`, but my immediate scan of the code shows `%p`, specifically in the `print_timer` function. It seems `%p` is used for the address and `%ps` for the symbol name. I need to make sure I am not missing a recent change that has not updated the documentation. Then it dawns on me: `%p` is hashed in modern kernels, which is generally preferred over `%pK` due to `kptr_restrict`.
The key here is the `0400` permission. That restricts access to the file's owner, which is global root. An unprivileged user inside a user namespace is *not* global root. They might *think* they are root within their namespace, but the kernel knows they aren't the file's owner.
The question then becomes, can an unprivileged user ever read it? Even in the initial user namespace, the `0400` permission prevents access. What if they're in a user namespace and have a UID mapping for what they think is root?
Let me think. The check is handled by `proc_create_seq_private` with `0400`, which relies on `generic_permission`. As I recall, that uses `capable_wrt_inode_uidgid`. I remember that the `capable_wrt_inode_uidgid` will return false if the inode's UID isn't mapped. An unprivileged user cannot map global UID 0 to a local UID within their namespace. They'll typically map their own UID (e.g., 1000) to 0. So, inside the namespace, the local UID 0 is the global UID 1000, not global UID 0. The file is owned by global UID 0. The user (global 1000, local 0) is not the owner, and they don't have capabilities over global UID 0. So, no, they cannot read it.
Are there any other `/proc` files with `0400` permissions that *are* readable within a user namespace? Some in `/proc/net` are namespace-aware, but `timer_list` isn't. Let me verify. I'll search `kernel/time/timer_list.c` for any mention of `struct net`, `user_namespace`, or `pid_namespace`. Nope, nothing there.
Actually, let me check the use of `proc_create_seq_private`. Many `/proc` files are `0444`, but `timer_list` is specifically `0400`. There was a previous commit using the `proc_create_seq_private` API but that's just a change in the API, nothing more. I need to check if there are other files created with `0400` permissions in `/proc`.
|
| 51/4 |
2026/05/23 11:36 |
tool |
grepper |
0m
Args: map[Expression:proc_create.*0400]
Results: map[Output:arch/arm/kernel/atags_proc.c=33=static int __init init_atags_procfs(void)
--
arch/arm/kernel/atags_proc.c-63-
arch/arm/kernel/atags_proc.c:64: tags_entry = proc_create_data("atags", 0400, NULL, &atags_proc_ops, b);
arch/arm/kernel/atags_proc.c-65- if (!tags_entry)
--
arch/m68k/kernel/bootinfo_proc.c=55=static int __init init_bootinfo_procfs(void)
--
arch/m68k/kernel/bootinfo_proc.c-69-
arch/m68k/kernel/bootinfo_proc.c:70: pde = proc_create_data("bootinfo", 0400, NULL, &bootinfo_proc_ops, NULL);
arch/m68k/kernel/bootinfo_proc.c-71- if (!pde) {
--
arch/parisc/kernel/pdc_chassis.c=269=static int __init pdc_chassis_create_procfs(void)
--
arch/parisc/kernel/pdc_chassis.c-282- PDC_CHASSIS_VER);
arch/parisc/kernel/pdc_chassis.c:283: proc_create_single("chassis", 0400, NULL, pdc_chassis_warn_show);
arch/parisc/kernel/pdc_chassis.c-284- return 0;
--
arch/powerpc/kernel/rtas-proc.c=231=static int __init proc_rtas_init(void)
--
arch/powerpc/kernel/rtas-proc.c-251- &ppc_rtas_tone_volume_proc_ops);
arch/powerpc/kernel/rtas-proc.c:252: proc_create_single("powerpc/rtas/rmo_buffer", 0400, NULL,
arch/powerpc/kernel/rtas-proc.c-253- ppc_rtas_rmo_buf_show);
--
arch/powerpc/kernel/rtasd.c=546=static int __init rtas_init(void)
--
arch/powerpc/kernel/rtasd.c-555-
arch/powerpc/kernel/rtasd.c:556: entry = proc_create("powerpc/rtas/error_log", 0400, NULL,
arch/powerpc/kernel/rtasd.c-557- &rtas_log_proc_ops);
--
fs/smb/client/cifs_debug.c=924=cifs_proc_init(void)
--
fs/smb/client/cifs_debug.c-932-
fs/smb/client/cifs_debug.c:933: proc_create_single("open_files", 0400, proc_fs_cifs,
fs/smb/client/cifs_debug.c-934- cifs_debug_files_proc_show);
--
fs/smb/client/cifs_debug.c-938-#else /* CONFIG_CIFS_DEBUG */
fs/smb/client/cifs_debug.c:939: proc_create_single("open_dirs", 0400, proc_fs_cifs, cifs_debug_dirs_proc_show);
fs/smb/client/cifs_debug.c-940-#endif /* !CONFIG_CIFS_DEBUG */
--
fs/smb/server/proc.c=22=struct proc_dir_entry *ksmbd_proc_create(const char *name,
--
fs/smb/server/proc.c-25-{
fs/smb/server/proc.c:26: return proc_create_single_data(name, 0400, ksmbd_proc_fs,
fs/smb/server/proc.c-27- show, v);
--
kernel/time/timer_list.c=349=static int __init init_timer_list_procfs(void)
--
kernel/time/timer_list.c-352-
kernel/time/timer_list.c:353: pe = proc_create_seq_private("timer_list", 0400, NULL, &timer_list_sops,
kernel/time/timer_list.c-354- sizeof(struct timer_list_iter), NULL);
--
lib/alloc_tag.c=927=static int __init alloc_tag_init(void)
--
lib/alloc_tag.c-948-
lib/alloc_tag.c:949: if (!proc_create_seq_private(ALLOCINFO_FILE_NAME, 0400, NULL, &allocinfo_seq_op,
lib/alloc_tag.c-950- sizeof(struct allocinfo_private), NULL)) {
--
mm/vmalloc.c=5295=static int __init proc_vmalloc_init(void)
mm/vmalloc.c-5296-{
mm/vmalloc.c:5297: proc_create_single("vmallocinfo", 0400, NULL, vmalloc_info_show);
mm/vmalloc.c-5298- return 0;
--
mm/vmstat.c=2268=void __init init_mm_internals(void)
--
mm/vmstat.c-2294- proc_create_seq("buddyinfo", 0444, NULL, &fragmentation_op);
mm/vmstat.c:2295: proc_create_seq("pagetypeinfo", 0400, NULL, &pagetypeinfo_op);
mm/vmstat.c-2296- proc_create_seq("vmstat", 0444, NULL, &vmstat_op);
--
net/sunrpc/cache.c=1664=static int create_cache_proc_entries(struct cache_detail *cd, struct net *net)
--
net/sunrpc/cache.c-1688- if (cd->cache_show) {
net/sunrpc/cache.c:1689: p = proc_create_data("content", S_IFREG | 0400, cd->procfs,
net/sunrpc/cache.c-1690- &content_proc_ops, cd);
]
|
| 52/4 |
2026/05/23 11:36 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 32285
output: 23
thoughts: 1401
Thoughts: **Security Analysis of /proc/timer_list in User Namespaces**
Okay, so I'm looking at these files with `0400` permissions: `vmallocinfo`, `pagetypeinfo`, and especially `timer_list`. If an unprivileged user in a user namespace could read these, it's a huge security hole ā leaking sensitive kernel info. The `0400` is there *specifically* to prevent this.
Right, so, the key is whether the `proc` filesystem's `FS_USERNS_MOUNT` flag changes anything. Let me look at the code... Yep, `proc_fs_type` has `FS_USERNS_MOUNT`, meaning it's mountable inside a user namespace. When it's mounted, the superblock's `s_user_ns` is set to the namespace of the caller. But how does that affect permissions?
The `generic_permission` function is where permissions are checked. It uses `capable_wrt_inode_uidgid`. If the inode UID is 0 (root, globally), and that UID isn't mapped in the user namespace, the check should fail, right? I need to confirm that `proc_get_inode` doesn't mess with UIDs.
Ah, `proc_get_inode` just sets `inode->i_uid = de->uid`. And `de->uid` is a `kuid_t`, a *global* UID. So the inode always has a global UID of 0, and in a user namespace where global 0 isn't mapped, that's not "privileged".
There are some exceptions for `proc` files, "namespace-safe" files. But `timer_list` isn't one of them. And `proc_create_seq_private` is called with a `NULL` parent, putting `timer_list` right at the root of `/proc`.
If I'm in a user namespace and mount `proc`, the files are the *same* PDEs. The inodes might be new, but they're initialized from the same PDEs. So `/proc/timer_list` will *always* have `i_uid = 0`.
Can an unprivileged user *somehow* map global UID 0? Not unless they have `CAP_SETUID` in the parent namespace, which they *won't* if they're actually unprivileged.
So, the answer is "no," it shouldn't be possible. But let's verify. Let me check `proc_setattr`.
Okay, `proc_setattr` lets you change UID/GID, but NOT mode. But even to change UID/GID, you need to be the owner or have `CAP_CHOWN`. An unprivileged user is neither. And all `proc` mounts share the same PDE tree, so trying a different mount won't work.
But let's think this through. Can an unprivileged user read `/proc/timer_list` even in the *initial* namespace? No. It's `0400`, owned by root. If they can't read it there, they definitely can't read it in a more restricted user namespace.
Unless the user namespace somehow *makes* them the owner. As we saw, that only happens if global UID 0 is mapped to them. Which, as we know, can't happen.
What if they map their own UID (e.g., 1000) to 0 inside the namespace? They become UID 0 *inside* the namespace. But the file's `i_uid` is still global 0. Their global UID is still 1000. So, they're not the owner.
What if the `i_uid` *was* also mapped, though? Remember, `proc_get_inode` sets `inode->i_uid` to the global UID from the PDE. So, no.
Definitely "No."
Wait, let's check the code specifically in `kernel/time/timer_list.c`. Anything special for `timer_list_show`? Nope. It doesn't check permissions. Permissions are checked at `open()`. Is there any other way to access it? Maybe through another file? No. Is `timer_list` available in `/proc/self/`? No. What about in a network namespace? No, it's not in `/proc/net`.
Okay, finally, some documentation. Anything in `Documentation/admin-guide/kernel-parameters.txt`? Nope. Let's check `Documentation/filesystems/proc.rst`.
|
| 53/4 |
2026/05/23 11:36 |
tool |
read-file |
0m
Args: map[File:Documentation/filesystems/proc.rst]
Results: map[Contents:.. SPDX-License-Identifier: GPL-2.0
====================
The /proc Filesystem
====================
===================== ======================================= ================
/proc/sys Terrehon Bowden <terrehon@pacbell.net>, October 7 1999
Bodo Bauer <bb@ricochet.net>
2.4.x update Jorge Nerin <comandante@zaralinux.com> November 14 2000
move /proc/sys Shen Feng <shen@cn.fujitsu.com> April 1 2009
fixes/update part 1.1 Stefani Seibold <stefani@seibold.net> June 9 2009
===================== ======================================= ================
.. Table of Contents
0 Preface
0.1 Introduction/Credits
0.2 Legal Stuff
1 Collecting System Information
1.1 Process-Specific Subdirectories
1.2 Kernel data
1.3 IDE devices in /proc/ide
1.4 Networking info in /proc/net
1.5 SCSI info
1.6 Parallel port info in /proc/parport
1.7 TTY info in /proc/tty
1.8 Miscellaneous kernel statistics in /proc/stat
1.9 Ext4 file system parameters
2 Modifying System Parameters
3 Per-Process Parameters
3.1 /proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj - Adjust the oom-killer
score
3.2 /proc/<pid>/oom_score - Display current oom-killer score
3.3 /proc/<pid>/io - Display the IO accounting fields
3.4 /proc/<pid>/coredump_filter - Core dump filtering settings
3.5 /proc/<pid>/mountinfo - Information about mounts
3.6 /proc/<pid>/comm & /proc/<pid>/task/<tid>/comm
3.7 /proc/<pid>/task/<tid>/children - Information about task children
3.8 /proc/<pid>/fdinfo/<fd> - Information about opened file
3.9 /proc/<pid>/map_files - Information about memory mapped files
3.10 /proc/<pid>/timerslack_ns - Task timerslack value
3.11 /proc/<pid>/patch_state - Livepatch patch operation state
3.12 /proc/<pid>/arch_status - Task architecture specific information
3.13 /proc/<pid>/fd - List of symlinks to open files
3.14 /proc/<pid>/ksm_stat - Information about the process's ksm status.
4 Configuring procfs
4.1 Mount options
5 Filesystem behavior
Preface
=======
0.1 Introduction/Credits
------------------------
We'd like to thank Alan Cox, Rik van Riel, and Alexey Kuznetsov and a lot of
other people for help compiling this documentation. We'd also like to extend a
special thank you to Andi Kleen for documentation, which we relied on heavily
to create this document, as well as the additional information he provided.
Thanks to everybody else who contributed source or docs to the Linux kernel
and helped create a great piece of software... :)
The latest version of this document is available online at
https://www.kernel.org/doc/html/latest/filesystems/proc.html
0.2 Legal Stuff
---------------
We don't guarantee the correctness of this document, and if you come to us
complaining about how you screwed up your system because of incorrect
documentation, we won't feel responsible...
Chapter 1: Collecting System Information
========================================
In This Chapter
---------------
* Investigating the properties of the pseudo file system /proc and its
ability to provide information on the running Linux system
* Examining /proc's structure
* Uncovering various information about the kernel and the processes running
on the system
------------------------------------------------------------------------------
The proc file system acts as an interface to internal data structures in the
kernel. It can be used to obtain information about the system and to change
certain kernel parameters at runtime (sysctl).
First, we'll take a look at the read-only parts of /proc. In Chapter 2, we
show you how you can use /proc/sys to change settings.
1.1 Process-Specific Subdirectories
-----------------------------------
The directory /proc contains (among other things) one subdirectory for each
process running on the system, which is named after the process ID (PID).
The link 'self' points to the process reading the file system. Each process
subdirectory has the entries listed in Table 1-1.
A process can read its own information from /proc/PID/* with no extra
permissions. When reading /proc/PID/* information for other processes, reading
process is required to have either CAP_SYS_PTRACE capability with
PTRACE_MODE_READ access permissions, or, alternatively, CAP_PERFMON
capability. This applies to all read-only information like `maps`, `environ`,
`pagemap`, etc. The only exception is `mem` file due to its read-write nature,
which requires CAP_SYS_PTRACE capabilities with more elevated
PTRACE_MODE_ATTACH permissions; CAP_PERFMON capability does not grant access
to /proc/PID/mem for other processes.
Note that an open file descriptor to /proc/<pid> or to any of its
contained files or subdirectories does not prevent <pid> being reused
for some other process in the event that <pid> exits. Operations on
open /proc/<pid> file descriptors corresponding to dead processes
never act on any new process that the kernel may, through chance, have
also assigned the process ID <pid>. Instead, operations on these FDs
usually fail with ESRCH.
.. table:: Table 1-1: Process specific entries in /proc
============= ===============================================================
File Content
============= ===============================================================
clear_refs Clears page referenced bits shown in smaps output
cmdline Command line arguments
cpu Current and last cpu in which it was executed (2.4)(smp)
cwd Link to the current working directory
environ Values of environment variables
exe Link to the executable of this process
fd Directory, which contains all file descriptors
maps Memory maps to executables and library files (2.4)
mem Memory held by this process
root Link to the root directory of this process
stat Process status
statm Process memory status information
status Process status in human readable form
wchan Present with CONFIG_KALLSYMS=y: it shows the kernel function
symbol the task is blocked in - or "0" if not blocked.
pagemap Page table
stack Report full stack trace, enable via CONFIG_STACKTRACE
smaps An extension based on maps, showing the memory consumption of
each mapping and flags associated with it
smaps_rollup Accumulated smaps stats for all mappings of the process. This
can be derived from smaps, but is faster and more convenient
numa_maps An extension based on maps, showing the memory locality and
binding policy as well as mem usage (in pages) of each mapping.
============= ===============================================================
For example, to get the status information of a process, all you have to do is
read the file /proc/PID/status::
>cat /proc/self/status
Name: cat
State: R (running)
Tgid: 5452
Pid: 5452
PPid: 743
TracerPid: 0 (2.4)
Uid: 501 501 501 501
Gid: 100 100 100 100
FDSize: 256
Groups: 100 14 16
Kthread: 0
VmPeak: 5004 kB
VmSize: 5004 kB
VmLck: 0 kB
VmHWM: 476 kB
VmRSS: 476 kB
RssAnon: 352 kB
RssFile: 120 kB
RssShmem: 4 kB
VmData: 156 kB
VmStk: 88 kB
VmExe: 68 kB
VmLib: 1412 kB
VmPTE: 20 kb
VmSwap: 0 kB
HugetlbPages: 0 kB
CoreDumping: 0
THP_enabled: 1
Threads: 1
SigQ: 0/28578
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 0000000000000000
CapInh: 00000000fffffeff
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: ffffffffffffffff
CapAmb: 0000000000000000
NoNewPrivs: 0
Seccomp: 0
Speculation_Store_Bypass: thread vulnerable
SpeculationIndirectBranch: conditional enabled
voluntary_ctxt_switches: 0
nonvoluntary_ctxt_switches: 1
This shows you nearly the same information you would get if you viewed it with
the ps command. In fact, ps uses the proc file system to obtain its
information. But you get a more detailed view of the process by reading the
file /proc/PID/status. It fields are described in table 1-2.
The statm file contains more detailed information about the process
memory usage. Its seven fields are explained in Table 1-3. The stat file
contains detailed information about the process itself. Its fields are
explained in Table 1-4.
(for SMP CONFIG users)
For making accounting scalable, RSS related information are handled in an
asynchronous manner and the value may not be very precise. To see a precise
snapshot of a moment, you can see /proc/<pid>/smaps file and scan page table.
It's slow but very precise.
.. table:: Table 1-2: Contents of the status fields (as of 4.19)
========================== ===================================================
Field Content
========================== ===================================================
Name filename of the executable
Umask file mode creation mask
State state (R is running, S is sleeping, D is sleeping
in an uninterruptible wait, Z is zombie,
T is traced or stopped)
Tgid thread group ID
Ngid NUMA group ID (0 if none)
Pid process id
PPid process id of the parent process
TracerPid PID of process tracing this process (0 if not, or
the tracer is outside of the current pid namespace)
Uid Real, effective, saved set, and file system UIDs
Gid Real, effective, saved set, and file system GIDs
FDSize number of file descriptor slots currently allocated
Groups supplementary group list
NStgid descendant namespace thread group ID hierarchy
NSpid descendant namespace process ID hierarchy
NSpgid descendant namespace process group ID hierarchy
NSsid descendant namespace session ID hierarchy
Kthread kernel thread flag, 1 is yes, 0 is no
VmPeak peak virtual memory size
VmSize total program size
VmLck locked memory size
VmPin pinned memory size
VmHWM peak resident set size ("high water mark")
VmRSS size of memory portions. It contains the three
following parts
(VmRSS = RssAnon + RssFile + RssShmem)
RssAnon size of resident anonymous memory
RssFile size of resident file mappings
RssShmem size of resident shmem memory (includes SysV shm,
mapping of tmpfs and shared anonymous mappings)
VmData size of private data segments
VmStk size of stack segments
VmExe size of text segment
VmLib size of shared library code
VmPTE size of page table entries
VmSwap amount of swap used by anonymous private data
(shmem swap usage is not included)
HugetlbPages size of hugetlb memory portions
CoreDumping process's memory is currently being dumped
(killing the process may lead to a corrupted core)
THP_enabled process is allowed to use THP (returns 0 when
PR_SET_THP_DISABLE is set on the process to disable
THP completely, not just partially)
Threads number of threads
SigQ number of signals queued/max. number for queue
SigPnd bitmap of pending signals for the thread
ShdPnd bitmap of shared pending signals for the process
SigBlk bitmap of blocked signals
SigIgn bitmap of ignored signals
SigCgt bitmap of caught signals
CapInh bitmap of inheritable capabilities
CapPrm bitmap of permitted capabilities
CapEff bitmap of effective capabilities
CapBnd bitmap of capabilities bounding set
CapAmb bitmap of ambient capabilities
NoNewPrivs no_new_privs, like prctl(PR_GET_NO_NEW_PRIV, ...)
Seccomp seccomp mode, like prctl(PR_GET_SECCOMP, ...)
Speculation_Store_Bypass speculative store bypass mitigation status
SpeculationIndirectBranch indirect branch speculation mode
Cpus_allowed mask of CPUs on which this process may run
Cpus_allowed_list Same as previous, but in "list format"
Mems_allowed mask of memory nodes allowed to this process
Mems_allowed_list Same as previous, but in "list format"
voluntary_ctxt_switches number of voluntary context switches
nonvoluntary_ctxt_switches number of non voluntary context switches
========================== ===================================================
.. table:: Table 1-3: Contents of the statm fields (as of 2.6.8-rc3)
======== =============================== ==============================
Field Content
======== =============================== ==============================
size total program size (pages) (same as VmSize in status)
resident size of memory portions (pages) (same as VmRSS in status)
shared number of pages that are shared (i.e. backed by a file, same
as RssFile+RssShmem in status)
trs number of pages that are 'code' (not including libs; broken,
includes data segment)
lrs number of pages of library (always 0 on 2.6)
drs number of pages of data/stack (including libs; broken,
includes library text)
dt number of dirty pages (always 0 on 2.6)
======== =============================== ==============================
.. table:: Table 1-4: Contents of the stat fields (as of 2.6.30-rc7)
============= ===============================================================
Field Content
============= ===============================================================
pid process id
tcomm filename of the executable
state state (R is running, S is sleeping, D is sleeping in an
uninterruptible wait, Z is zombie, T is traced or stopped)
ppid process id of the parent process
pgrp pgrp of the process
sid session id
tty_nr tty the process uses
tty_pgrp pgrp of the tty
flags task flags
min_flt number of minor faults
cmin_flt number of minor faults with child's
maj_flt number of major faults
cmaj_flt number of major faults with child's
utime user mode jiffies
stime kernel mode jiffies
cutime user mode jiffies with child's
cstime kernel mode jiffies with child's
priority priority level
nice nice level
num_threads number of threads
it_real_value (obsolete, always 0)
start_time time the process started after system boot
vsize virtual memory size
rss resident set memory size
rsslim current limit in bytes on the rss
start_code address above which program text can run
end_code address below which program text can run
start_stack address of the start of the main process stack
esp current value of ESP
eip current value of EIP
pending bitmap of pending signals
blocked bitmap of blocked signals
sigign bitmap of ignored signals
sigcatch bitmap of caught signals
0 (place holder, used to be the wchan address,
use /proc/PID/wchan instead)
0 (place holder)
0 (place holder)
exit_signal signal to send to parent thread on exit
task_cpu which CPU the task is scheduled on
rt_priority realtime priority
policy scheduling policy (man sched_setscheduler)
blkio_ticks time spent waiting for block IO
gtime guest time of the task in jiffies
cgtime guest time of the task children in jiffies
start_data address above which program data+bss is placed
end_data address below which program data+bss is placed
start_brk address above which program heap can be expanded with brk()
arg_start address above which program command line is placed
arg_end address below which program command line is placed
env_start address above which program environment is placed
env_end address below which program environment is placed
exit_code the thread's exit_code in the form reported by the waitpid
system call
============= ===============================================================
The /proc/PID/maps file contains the currently mapped memory regions and
their access permissions.
The format is::
address perms offset dev inode pathname
08048000-08049000 r-xp 00000000 03:00 8312 /opt/test
08049000-0804a000 rw-p 00001000 03:00 8312 /opt/test
0804a000-0806b000 rw-p 00000000 00:00 0 [heap]
a7cb1000-a7cb2000 ---p 00000000 00:00 0
a7cb2000-a7eb2000 rw-p 00000000 00:00 0
a7eb2000-a7eb3000 ---p 00000000 00:00 0
a7eb3000-a7ed5000 rw-p 00000000 00:00 0
a7ed5000-a8008000 r-xp 00000000 03:00 4222 /lib/libc.so.6
a8008000-a800a000 r--p 00133000 03:00 4222 /lib/libc.so.6
a800a000-a800b000 rw-p 00135000 03:00 4222 /lib/libc.so.6
a800b000-a800e000 rw-p 00000000 00:00 0
a800e000-a8022000 r-xp 00000000 03:00 14462 /lib/libpthread.so.0
a8022000-a8023000 r--p 00013000 03:00 14462 /lib/libpthread.so.0
a8023000-a8024000 rw-p 00014000 03:00 14462 /lib/libpthread.so.0
a8024000-a8027000 rw-p 00000000 00:00 0
a8027000-a8043000 r-xp 00000000 03:00 8317 /lib/ld-linux.so.2
a8043000-a8044000 r--p 0001b000 03:00 8317 /lib/ld-linux.so.2
a8044000-a8045000 rw-p 0001c000 03:00 8317 /lib/ld-linux.so.2
aff35000-aff4a000 rw-p 00000000 00:00 0 [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
where "address" is the address space in the process that it occupies, "perms"
is a set of permissions::
r = read
w = write
x = execute
s = shared
p = private (copy on write)
"offset" is the offset into the mapping, "dev" is the device (major:minor), and
"inode" is the inode on that device. 0 indicates that no inode is associated
with the memory region, as the case would be with BSS (uninitialized data).
The "pathname" shows the name associated file for this mapping. If the mapping
is not associated with a file:
=================== ===========================================
[heap] the heap of the program
[stack] the stack of the main process
[vdso] the "virtual dynamic shared object",
the kernel system call handler
[anon:<name>] a private anonymous mapping that has been
named by userspace
[anon_shmem:<name>] an anonymous shared memory mapping that has
been named by userspace
=================== ===========================================
or if empty, the mapping is anonymous.
Starting with 6.11 kernel, /proc/PID/maps provides an alternative
ioctl()-based API that gives ability to flexibly and efficiently query and
filter individual VMAs. This interface is binary and is meant for more
efficient and easy programmatic use. `struct procmap_query`, defined in
linux/fs.h UAPI header, serves as an input/output argument to the
`PROCMAP_QUERY` ioctl() command. See comments in linus/fs.h UAPI header for
details on query semantics, supported flags, data returned, and general API
usage information.
The /proc/PID/smaps is an extension based on maps, showing the memory
consumption for each of the process's mappings. For each mapping (aka Virtual
Memory Area, or VMA) there is a series of lines such as the following::
08048000-080bc000 r-xp 00000000 03:02 13130 /bin/bash
Size: 1084 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Rss: 892 kB
Pss: 374 kB
Pss_Dirty: 0 kB
Shared_Clean: 892 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Referenced: 892 kB
Anonymous: 0 kB
KSM: 0 kB
LazyFree: 0 kB
AnonHugePages: 0 kB
FilePmdMapped: 0 kB
ShmemPmdMapped: 0 kB
Shared_Hugetlb: 0 kB
Private_Hugetlb: 0 kB
Swap: 0 kB
SwapPss: 0 kB
Locked: 0 kB
THPeligible: 0
VmFlags: rd ex mr mw me dw
The first of these lines shows the same information as is displayed for
the mapping in /proc/PID/maps. Following lines show the size of the
mapping (size); the smallest possible page size allocated when backing a
VMA (KernelPageSize), which is the granularity in which VMA modifications
can be performed; the smallest possible page size that could be used by the
MMU (MMUPageSize) when backing a VMA; the amount of the mapping that is
currently resident in RAM (RSS); the process's proportional share of this
mapping (PSS); and the number of clean and dirty shared and private pages
in the mapping.
"KernelPageSize" always corresponds to "MMUPageSize", except when a larger
kernel page size is emulated on a system with a smaller page size used by the
MMU, which is the case for some PPC64 setups with hugetlb. Furthermore,
"KernelPageSize" and "MMUPageSize" always correspond to the smallest
possible granularity (fallback) that can be encountered in a VMA throughout
its lifetime. These values are not affected by Transparent Huge Pages
being in effect, or any usage of larger MMU page sizes (either through
architectural huge-page mappings or other explicit/implicit coalescing of
virtual ranges performed by the MMU). "AnonHugePages", "ShmemPmdMapped" and
"FilePmdMapped" provide insight into the usage of PMD-level architectural
huge-page mappings.
The "proportional set size" (PSS) of a process is the count of pages it has
in memory, where each page is divided by the number of processes sharing it.
So if a process has 1000 pages all to itself, and 1000 shared with one other
process, its PSS will be 1500. "Pss_Dirty" is the portion of PSS which
consists of dirty pages. ("Pss_Clean" is not included, but it can be
calculated by subtracting "Pss_Dirty" from "Pss".)
Traditionally, a page is accounted as "private" if it is mapped exactly once,
and a page is accounted as "shared" when mapped multiple times, even when
mapped in the same process multiple times. Note that this accounting is
independent of MAP_SHARED.
In some kernel configurations, the semantics of pages part of a larger
allocation (e.g., THP) can differ: a page is accounted as "private" if all
pages part of the corresponding large allocation are *certainly* mapped in the
same process, even if the page is mapped multiple times in that process. A
page is accounted as "shared" if any page page of the larger allocation
is *maybe* mapped in a different process. In some cases, a large allocation
might be treated as "maybe mapped by multiple processes" even though this
is no longer the case.
Some kernel configurations do not track the precise number of times a page part
of a larger allocation is mapped. In this case, when calculating the PSS, the
average number of mappings per page in this larger allocation might be used
as an approximation for the number of mappings of a page. The PSS calculation
will be imprecise in this case.
"Referenced" indicates the amount of memory currently marked as referenced or
accessed.
"Anonymous" shows the amount of memory that does not belong to any file. Even
a mapping associated with a file may contain anonymous pages: when MAP_PRIVATE
and a page is modified, the file page is replaced by a private anonymous copy.
"KSM" reports how many of the pages are KSM pages. Note that KSM-placed zeropages
are not included, only actual KSM pages.
"LazyFree" shows the amount of memory which is marked by madvise(MADV_FREE).
The memory isn't freed immediately with madvise(). It's freed in memory
pressure if the memory is clean. Please note that the printed value might
be lower than the real value due to optimizations used in the current
implementation. If this is not desirable please file a bug report.
"AnonHugePages", "ShmemPmdMapped" and "FilePmdMapped" show the amount of
memory backed by Transparent Huge Pages that are currently mapped by
architectural huge-page mappings at the PMD level. "AnonHugePages"
corresponds to memory that does not belong to a file, "ShmemPmdMapped" to
shared memory (shmem/tmpfs) and "FilePmdMapped" to file-backed memory
(excluding shmem/tmpfs).
There are no dedicated entries for Transparent Huge Pages (or similar concepts)
that are not mapped by architectural huge-page mappings at the PMD level.
"Shared_Hugetlb" and "Private_Hugetlb" show the amounts of memory backed by
hugetlbfs page which is *not* counted in "RSS" or "PSS" field for historical
reasons. And these are not included in {Shared,Private}_{Clean,Dirty} field.
"Swap" shows how much would-be-anonymous memory is also used, but out on swap.
For shmem mappings, "Swap" includes also the size of the mapped (and not
replaced by copy-on-write) part of the underlying shmem object out on swap.
"SwapPss" shows proportional swap share of this mapping. Unlike "Swap", this
does not take into account swapped out page of underlying shmem objects.
"Locked" indicates whether the mapping is locked in memory or not.
"THPeligible" indicates whether the mapping is eligible for allocating
naturally aligned THP pages of any currently enabled size. 1 if true, 0
otherwise.
If both the kernel and the CPU support protection keys (pkeys),
"ProtectionKey" indicates the memory protection key associated with the
virtual memory area.
"VmFlags" field deserves a separate description. This member represents the
kernel flags associated with the particular virtual memory area in two letter
encoded manner. The codes are the following:
== =============================================================
rd readable
wr writeable
ex executable
sh shared
mr may read
mw may write
me may execute
ms may share
gd stack segment growns down
pf pure PFN range
lo pages are locked in memory
io memory mapped I/O area
sr sequential read advise provided
rr random read advise provided
dc do not copy area on fork
de do not expand area on remapping
ac area is accountable
nr swap space is not reserved for the area
ht area uses huge tlb pages
sf synchronous page fault
ar architecture specific flag
wf wipe on fork
dd do not include area into core dump
sd soft dirty flag
mm mixed map area
hg huge page advise flag
nh no huge page advise flag
mg mergeable advise flag
bt arm64 BTI guarded page
mt arm64 MTE allocation tags are enabled
um userfaultfd missing tracking
uw userfaultfd wr-protect tracking
ui userfaultfd minor fault
ss shadow/guarded control stack page
sl sealed
lf lock on fault pages
dp always lazily freeable mapping
gu maybe contains guard regions (if not set, definitely doesn't)
== =============================================================
Note that there is no guarantee that every flag and associated mnemonic will
be present in all further kernel releases. Things get changed, the flags may
be vanished or the reverse -- new added. Interpretation of their meaning
might change in future as well. So each consumer of these flags has to
follow each specific kernel version for the exact semantic.
This file is only present if the CONFIG_MMU kernel configuration option is
enabled.
Note: reading /proc/PID/maps or /proc/PID/smaps is inherently racy (consistent
output can be achieved only in the single read call).
This typically manifests when doing partial reads of these files while the
memory map is being modified. Despite the races, we do provide the following
guarantees:
1) The mapped addresses never go backwards, which implies no two
regions will ever overlap.
2) If there is something at a given vaddr during the entirety of the
life of the smaps/maps walk, there will be some output for it.
The /proc/PID/smaps_rollup file includes the same fields as /proc/PID/smaps,
but their values are the sums of the corresponding values for all mappings of
the process. Additionally, it contains these fields:
- Pss_Anon
- Pss_File
- Pss_Shmem
They represent the proportional shares of anonymous, file, and shmem pages, as
described for smaps above. These fields are omitted in smaps since each
mapping identifies the type (anon, file, or shmem) of all pages it contains.
Thus all information in smaps_rollup can be derived from smaps, but at a
significantly higher cost.
The /proc/PID/clear_refs is used to reset the PG_Referenced and ACCESSED/YOUNG
bits on both physical and virtual pages associated with a process, and the
soft-dirty bit on pte (see Documentation/admin-guide/mm/soft-dirty.rst
for details).
To clear the bits for all the pages associated with the process::
> echo 1 > /proc/PID/clear_refs
To clear the bits for the anonymous pages associated with the process::
> echo 2 > /proc/PID/clear_refs
To clear the bits for the file mapped pages associated with the process::
> echo 3 > /proc/PID/clear_refs
To clear the soft-dirty bit::
> echo 4 > /proc/PID/clear_refs
To reset the peak resident set size ("high water mark") to the process's
current value::
> echo 5 > /proc/PID/clear_refs
Any other value written to /proc/PID/clear_refs will have no effect.
The /proc/pid/pagemap gives the PFN, which can be used to find the pageflags
using /proc/kpageflags and number of times a page is mapped using
/proc/kpagecount. For detailed explanation, see
Documentation/admin-guide/mm/pagemap.rst.
The /proc/pid/numa_maps is an extension based on maps, showing the memory
locality and binding policy, as well as the memory usage (in pages) of
each mapping. The output follows a general format where mapping details get
summarized separated by blank spaces, one mapping per each file line::
address policy mapping details
00400000 default file=/usr/local/bin/app mapped=1 active=0 N3=1 kernelpagesize_kB=4
00600000 default file=/usr/local/bin/app anon=1 dirty=1 N3=1 kernelpagesize_kB=4
3206000000 default file=/lib64/ld-2.12.so mapped=26 mapmax=6 N0=24 N3=2 kernelpagesize_kB=4
320621f000 default file=/lib64/ld-2.12.so anon=1 dirty=1 N3=1 kernelpagesize_kB=4
3206220000 default file=/lib64/ld-2.12.so anon=1 dirty=1 N3=1 kernelpagesize_kB=4
3206221000 default anon=1 dirty=1 N3=1 kernelpagesize_kB=4
3206800000 default file=/lib64/libc-2.12.so mapped=59 mapmax=21 active=55 N0=41 N3=18 kernelpagesize_kB=4
320698b000 default file=/lib64/libc-2.12.so
3206b8a000 default file=/lib64/libc-2.12.so anon=2 dirty=2 N3=2 kernelpagesize_kB=4
3206b8e000 default file=/lib64/libc-2.12.so anon=1 dirty=1 N3=1 kernelpagesize_kB=4
3206b8f000 default anon=3 dirty=3 active=1 N3=3 kernelpagesize_kB=4
7f4dc10a2000 default anon=3 dirty=3 N3=3 kernelpagesize_kB=4
7f4dc10b4000 default anon=2 dirty=2 active=1 N3=2 kernelpagesize_kB=4
7f4dc1200000 default file=/anon_hugepage\040(deleted) huge anon=1 dirty=1 N3=1 kernelpagesize_kB=2048
7fff335f0000 default stack anon=3 dirty=3 N3=3 kernelpagesize_kB=4
7fff3369d000 default mapped=1 mapmax=35 active=0 N3=1 kernelpagesize_kB=4
Where:
"address" is the starting address for the mapping;
"policy" reports the NUMA memory policy set for the mapping (see Documentation/admin-guide/mm/numa_memory_policy.rst);
"mapping details" summarizes mapping data such as mapping type, page usage counters,
node locality page counters (N0 == node0, N1 == node1, ...) and the kernel page
size, in KB, that is backing the mapping up.
Note that some kernel configurations do not track the precise number of times
a page part of a larger allocation (e.g., THP) is mapped. In these
configurations, "mapmax" might corresponds to the average number of mappings
per page in such a larger allocation instead.
1.2 Kernel data
---------------
Similar to the process entries, the kernel data files give information about
the running kernel. The files used to obtain this information are contained in
/proc and are listed in Table 1-5. Not all of these will be present in your
system. It depends on the kernel configuration and the loaded modules, which
files are there, and which are missing.
.. table:: Table 1-5: Kernel info in /proc
============ ===============================================================
File Content
============ ===============================================================
allocinfo Memory allocations profiling information
apm Advanced power management info
bootconfig Kernel command line obtained from boot config,
and, if there were kernel parameters from the
boot loader, a "# Parameters from bootloader:"
line followed by a line containing those
parameters prefixed by "# ". (5.5)
buddyinfo Kernel memory allocator information (see text) (2.5)
bus Directory containing bus specific information
cmdline Kernel command line, both from bootloader and embedded
in the kernel image
cpuinfo Info about the CPU
devices Available devices (block and character)
dma Used DMA channels
filesystems Supported filesystems
driver Various drivers grouped here, currently rtc (2.4)
execdomains Execdomains, related to security (2.4)
fb Frame Buffer devices (2.4)
fs File system parameters, currently nfs/exports (2.4)
ide Directory containing info about the IDE subsystem
interrupts Interrupt usage
iomem Memory map (2.4)
ioports I/O port usage
irq Masks for irq to cpu affinity (2.4)(smp?)
isapnp ISA PnP (Plug&Play) Info (2.4)
kcore Kernel core image (can be ELF or A.OUT(deprecated in 2.4))
kmsg Kernel messages
ksyms Kernel symbol table
loadavg Load average of last 1, 5 & 15 minutes;
number of processes currently runnable (running or on ready queue);
total number of processes in system;
last pid created.
All fields are separated by one space except "number of
processes currently runnable" and "total number of processes
in system", which are separated by a slash ('/'). Example:
0.61 0.61 0.55 3/828 22084
locks Kernel locks
meminfo Memory info
misc Miscellaneous
modules List of loaded modules
mounts Mounted filesystems
net Networking info (see text)
pagetypeinfo Additional page allocator information (see text) (2.5)
partitions Table of partitions known to the system
pci Deprecated info of PCI bus (new way -> /proc/bus/pci/,
decoupled by lspci (2.4)
rtc Real time clock
scsi SCSI info (see text)
slabinfo Slab pool info
softirqs softirq usage
stat Overall statistics
swaps Swap space utilization
sys See chapter 2
sysvipc Info of SysVIPC Resources (msg, sem, shm) (2.4)
tty Info of tty drivers
uptime Wall clock since boot, combined idle time of all cpus
version Kernel version
video bttv info of video resources (2.4)
vmallocinfo Show vmalloced areas
============ ===============================================================
You can, for example, check which interrupts are currently in use and what
they are used for by looking in the file /proc/interrupts::
> cat /proc/interrupts
CPU0
0: 8728810 XT-PIC timer
1: 895 XT-PIC keyboard
2: 0 XT-PIC cascade
3: 531695 XT-PIC aha152x
4: 2014133 XT-PIC serial
5: 44401 XT-PIC pcnet_cs
8: 2 XT-PIC rtc
11: 8 XT-PIC i82365
12: 182918 XT-PIC PS/2 Mouse
13: 1 XT-PIC fpu
14: 1232265 XT-PIC ide0
15: 7 XT-PIC ide1
NMI: 0
In 2.4.* a couple of lines where added to this file LOC & ERR (this time is the
output of a SMP machine)::
> cat /proc/interrupts
CPU0 CPU1
0: 1243498 1214548 IO-APIC-edge timer
1: 8949 8958 IO-APIC-edge keyboard
2: 0 0 XT-PIC cascade
5: 11286 10161 IO-APIC-edge soundblaster
8: 1 0 IO-APIC-edge rtc
9: 27422 27407 IO-APIC-edge 3c503
12: 113645 113873 IO-APIC-edge PS/2 Mouse
13: 0 0 XT-PIC fpu
14: 22491 24012 IO-APIC-edge ide0
15: 2183 2415 IO-APIC-edge ide1
17: 30564 30414 IO-APIC-level eth0
18: 177 164 IO-APIC-level bttv
NMI: 2457961 2457959
LOC: 2457882 2457881
ERR: 2155
NMI is incremented in this case because every timer interrupt generates a NMI
(Non Maskable Interrupt) which is used by the NMI Watchdog to detect lockups.
LOC is the local interrupt counter of the internal APIC of every CPU.
ERR is incremented in the case of errors in the IO-APIC bus (the bus that
connects the CPUs in a SMP system. This means that an error has been detected,
the IO-APIC automatically retry the transmission, so it should not be a big
problem, but you should read the SMP-FAQ.
In 2.6.2* /proc/interrupts was expanded again. This time the goal was for
/proc/interrupts to display every IRQ vector in use by the system, not
just those considered 'most important'. The new vectors are:
THR
interrupt raised when a machine check threshold counter
(typically counting ECC corrected errors of memory or cache) exceeds
a configurable threshold. Only available on some systems.
TRM
a thermal event interrupt occurs when a temperature threshold
has been exceeded for the CPU. This interrupt may also be generated
when the temperature drops back to normal.
SPU
a spurious interrupt is some interrupt that was raised then lowered
by some IO device before it could be fully processed by the APIC. Hence
the APIC sees the interrupt but does not know what device it came from.
For this case the APIC will generate the interrupt with a IRQ vector
of 0xff. This might also be generated by chipset bugs.
RES, CAL, TLB
rescheduling, call and TLB flush interrupts are
sent from one CPU to another per the needs of the OS. Typically,
their statistics are used by kernel developers and interested users to
determine the occurrence of interrupts of the given type.
The above IRQ vectors are displayed only when relevant. For example,
the threshold vector does not exist on x86_64 platforms. Others are
suppressed when the system is a uniprocessor. As of this writing, only
i386 and x86_64 platforms support the new IRQ vector displays.
Of some interest is the introduction of the /proc/irq directory to 2.4.
It could be used to set IRQ to CPU affinity. This means that you can "hook" an
IRQ to only one CPU, or to exclude a CPU of handling IRQs. The contents of the
irq subdir is one subdir for each IRQ, and default_smp_affinity.
For example::
> ls /proc/irq/
0 10 12 14 16 18 2 4 6 8 default_smp_affinity
1 11 13 15 17 19 3 5 7 9
> ls /proc/irq/0/
smp_affinity
smp_affinity is a bitmask, in which you can specify which CPUs can handle the
IRQ. You can set it by doing::
> echo 1 > /proc/irq/10/smp_affinity
This means that only the first CPU will handle the IRQ, but you can also echo
5 which means that only the first and third CPU can handle the IRQ.
The contents of each smp_affinity file is the same by default::
> cat /proc/irq/0/smp_affinity
ffffffff
There is an alternate interface, smp_affinity_list which allows specifying
a CPU range instead of a bitmask::
> cat /proc/irq/0/smp_affinity_list
1024-1031
The default_smp_affinity mask applies to all non-active IRQs, which are the
IRQs which have not yet been allocated/activated, and hence which lack a
/proc/irq/[0-9]* directory.
The node file on an SMP system shows the node to which the device using the IRQ
reports itself as being attached. This hardware locality information does not
include information about any possible driver locality preference.
The way IRQs are routed is handled by the IO-APIC, and it's Round Robin
between all the CPUs which are allowed to handle it. As usual the kernel has
more info than you and does a better job than you, so the defaults are the
best choice for almost everyone. [Note this applies only to those IO-APIC's
that support "Round Robin" interrupt distribution.]
There are three more important subdirectories in /proc: net, scsi, and sys.
The general rule is that the contents, or even the existence of these
directories, depend on your kernel configuration. If SCSI is not enabled, the
directory scsi may not exist. The same is true with the net, which is there
only when networking support is present in the running kernel.
The slabinfo file gives information about memory usage at the slab level.
Linux uses slab pools for memory management above page level in version 2.2.
Commonly used objects have their own slab pool (such as network buffers,
directory cache, and so on).
::
> cat /proc/buddyinfo
Node 0, zone DMA 0 4 5 4 4 3 ...
Node 0, zone Normal 1 0 0 1 101 8 ...
Node 0, zone HighMem 2 0 0 1 1 0 ...
External fragmentation is a problem under some workloads, and buddyinfo is a
useful tool for helping diagnose these problems. Buddyinfo will give you a
clue as to how big an area you can safely allocate, or why a previous
allocation failed.
Each column represents the number of pages of a certain order which are
available. In this case, there are 0 chunks of 2^0*PAGE_SIZE available in
ZONE_DMA, 4 chunks of 2^1*PAGE_SIZE in ZONE_DMA, 101 chunks of 2^4*PAGE_SIZE
available in ZONE_NORMAL, etc...
More information relevant to external fragmentation can be found in
pagetypeinfo::
> cat /proc/pagetypeinfo
Page block order: 9
Pages per block: 512
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
Node 0, zone DMA, type Unmovable 0 0 0 1 1 1 1 1 1 1 0
Node 0, zone DMA, type Reclaimable 0 0 0 0 0 0 0 0 0 0 0
Node 0, zone DMA, type Movable 1 1 2 1 2 1 1 0 1 0 2
Node 0, zone DMA, type Reserve 0 0 0 0 0 0 0 0 0 1 0
Node 0, zone DMA, type Isolate 0 0 0 0 0 0 0 0 0 0 0
Node 0, zone DMA32, type Unmovable 103 54 77 1 1 1 11 8 7 1 9
Node 0, zone DMA32, type Reclaimable 0 0 2 1 0 0 0 0 1 0 0
Node 0, zone DMA32, type Movable 169 152 113 91 77 54 39 13 6 1 452
Node 0, zone DMA32, type Reserve 1 2 2 2 2 0 1 1 1 1 0
Node 0, zone DMA32, type Isolate 0 0 0 0 0 0 0 0 0 0 0
Number of blocks type Unmovable Reclaimable Movable Reserve Isolate
Node 0, zone DMA 2 0 5 1 0
Node 0, zone DMA32 41 6 967 2 0
Fragmentation avoidance in the kernel works by grouping pages of different
migrate types into the same contiguous regions of memory called page blocks.
A page block is typically the size of the default hugepage size, e.g. 2MB on
X86-64. By keeping pages grouped based on their ability to move, the kernel
can reclaim pages within a page block to satisfy a high-order allocation.
The pagetypinfo begins with information on the size of a page block. It
then gives the same type of information as buddyinfo except broken down
by migrate-type and finishes with details on how many page blocks of each
type exist.
If min_free_kbytes has been tuned correctly (recommendations made by hugeadm
from libhugetlbfs https://github.com/libhugetlbfs/libhugetlbfs/), one can
make an estimate of the likely number of huge pages that can be allocated
at a given point in time. All the "Movable" blocks should be allocatable
unless memory has been mlock()'d. Some of the Reclaimable blocks should
also be allocatable although a lot of filesystem metadata may have to be
reclaimed to achieve this.
allocinfo
~~~~~~~~~
Provides information about memory allocations at all locations in the code
base. Each allocation in the code is identified by its source file, line
number, module (if originates from a loadable module) and the function calling
the allocation. The number of bytes allocated and number of calls at each
location are reported. The first line indicates the version of the file, the
second line is the header listing fields in the file.
If file version is 2.0 or higher then each line may contain additional
<key>:<value> pairs representing extra information about the call site.
For example if the counters are not accurate, the line will be appended with
"accurate:no" pair.
Supported markers in v2:
accurate:no
Absolute values of the counters in this line are not accurate
because of the failure to allocate memory to track some of the
allocations made at this location. Deltas in these counters are
accurate, therefore counters can be used to track allocation size
and count changes.
Example output.
::
> tail -n +3 /proc/allocinfo | sort -rn
127664128 31168 mm/page_ext.c:270 func:alloc_page_ext
56373248 4737 mm/slub.c:2259 func:alloc_slab_page
14880768 3633 mm/readahead.c:247 func:page_cache_ra_unbounded
14417920 3520 mm/mm_init.c:2530 func:alloc_large_system_hash
13377536 234 block/blk-mq.c:3421 func:blk_mq_alloc_rqs
11718656 2861 mm/filemap.c:1919 func:__filemap_get_folio
9192960 2800 kernel/fork.c:307 func:alloc_thread_stack_node
4206592 4 net/netfilter/nf_conntrack_core.c:2567 func:nf_ct_alloc_hashtable
4136960 1010 drivers/staging/ctagmod/ctagmod.c:20 [ctagmod] func:ctagmod_start
3940352 962 mm/memory.c:4214 func:alloc_anon_folio
2894464 22613 fs/kernfs/dir.c:615 func:__kernfs_new_node
...
meminfo
~~~~~~~
Provides information about distribution and utilization of memory. This
varies by architecture and compile options. Some of the counters reported
here overlap. The memory reported by the non overlapping counters may not
add up to the overall memory usage and the difference for some workloads
can be substantial. In many cases there are other means to find out
additional memory using subsystem specific interfaces, for instance
/proc/net/sockstat for TCP memory allocations.
Example output. You may not have all of these fields.
::
> cat /proc/meminfo
MemTotal: 32858820 kB
MemFree: 21001236 kB
MemAvailable: 27214312 kB
Buffers: 581092 kB
Cached: 5587612 kB
SwapCached: 0 kB
Active: 3237152 kB
Inactive: 7586256 kB
Active(anon): 94064 kB
Inactive(anon): 4570616 kB
Active(file): 3143088 kB
Inactive(file): 3015640 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Zswap: 1904 kB
Zswapped: 7792 kB
Dirty: 12 kB
Writeback: 0 kB
AnonPages: 4654780 kB
Mapped: 266244 kB
Shmem: 9976 kB
KReclaimable: 517708 kB
Slab: 660044 kB
SReclaimable: 517708 kB
SUnreclaim: 142336 kB
KernelStack: 11168 kB
PageTables: 20540 kB
SecPageTables: 0 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 16429408 kB
Committed_AS: 7715148 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 40444 kB
VmallocChunk: 0 kB
Percpu: 29312 kB
EarlyMemtestBad: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 4149248 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
FileHugePages: 0 kB
FilePmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
Unaccepted: 0 kB
Balloon: 0 kB
GPUActive: 0 kB
GPUReclaim: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
DirectMap4k: 401152 kB
DirectMap2M: 10008576 kB
DirectMap1G: 24117248 kB
MemTotal
Total usable RAM (i.e. physical RAM minus a few reserved
bits and the kernel binary code)
MemFree
Total free RAM. On highmem systems, the sum of LowFree+HighFree
MemAvailable
An estimate of how much memory is available for starting new
applications, without swapping. Calculated from MemFree,
SReclaimable, the size of the file LRU lists, and the low
watermarks in each zone.
The estimate takes into account that the system needs some
page cache to function well, and that not all reclaimable
slab will be reclaimable, due to items being in use. The
impact of those factors will vary from system to system.
Buffers
Relatively temporary storage for raw disk blocks
shouldn't get tremendously large (20MB or so)
Cached
In-memory cache for files read from the disk (the
pagecache) as well as tmpfs & shmem.
Doesn't include SwapCached.
SwapCached
Memory that once was swapped out, is swapped back in but
still also is in the swapfile (if memory is needed it
doesn't need to be swapped out AGAIN because it is already
in the swapfile. This saves I/O)
Active
Memory that has been used more recently and usually not
reclaimed unless absolutely necessary.
Inactive
Memory which has been less recently used. It is more
eligible to be reclaimed for other purposes
Unevictable
Memory allocated for userspace which cannot be reclaimed, such
as mlocked pages, ramfs backing pages, secret memfd pages etc.
Mlocked
Memory locked with mlock().
HighTotal, HighFree
Highmem is all memory above ~860MB of physical memory.
Highmem areas are for use by userspace programs, or
for the pagecache. The kernel must use tricks to access
this memory, making it slower to access than lowmem.
LowTotal, LowFree
Lowmem is memory which can be used for everything that
highmem can be used for, but it is also available for the
kernel's use for its own data structures. Among many
other things, it is where everything from the Slab is
allocated. Bad things happen when you're out of lowmem.
SwapTotal
total amount of swap space available
SwapFree
Memory which has been evicted from RAM, and is temporarily
on the disk
Zswap
Memory consumed by the zswap backend (compressed size)
Zswapped
Amount of anonymous memory stored in zswap (original size)
Dirty
Memory which is waiting to get written back to the disk
Writeback
Memory which is actively being written back to the disk
AnonPages
Non-file backed pages mapped into userspace page tables. Note that
some kernel configurations might consider all pages part of a
larger allocation (e.g., THP) as "mapped", as soon as a single
page is mapped.
Mapped
files which have been mmapped, such as libraries. Note that some
kernel configurations might consider all pages part of a larger
allocation (e.g., THP) as "mapped", as soon as a single page is
mapped.
Shmem
Total memory used by shared memory (shmem) and tmpfs
KReclaimable
Kernel allocations that the kernel will attempt to reclaim
under memory pressure. Includes SReclaimable (below), and other
direct allocations with a shrinker.
Slab
in-kernel data structures cache
SReclaimable
Part of Slab, that might be reclaimed, such as caches
SUnreclaim
Part of Slab, that cannot be reclaimed on memory pressure
KernelStack
Memory consumed by the kernel stacks of all tasks
PageTables
Memory consumed by userspace page tables
SecPageTables
Memory consumed by secondary page tables, this currently includes
KVM mmu and IOMMU allocations on x86 and arm64.
NFS_Unstable
Always zero. Previously counted pages which had been written to
the server, but has not been committed to stable storage.
Bounce
Always zero. Previously memory used for block device
"bounce buffers".
WritebackTmp
Always zero. Previously memory used by FUSE for temporary
writeback buffers.
CommitLimit
Based on the overcommit ratio ('vm.overcommit_ratio'),
this is the total amount of memory currently available to
be allocated on the system. This limit is only adhered to
if strict overcommit accounting is enabled (mode 2 in
'vm.overcommit_memory').
The CommitLimit is calculated with the following formula::
CommitLimit = ([total RAM pages] - [total huge TLB pages]) *
overcommit_ratio / 100 + [total swap pages]
For example, on a system with 1G of physical RAM and 7G
of swap with a `vm.overcommit_ratio` of 30 it would
yield a CommitLimit of 7.3G.
For more details, see the memory overcommit documentation
in mm/overcommit-accounting.
Committed_AS
The amount of memory presently allocated on the system.
The committed memory is a sum of all of the memory which
has been allocated by processes, even if it has not been
"used" by them as of yet. A process which malloc()'s 1G
of memory, but only touches 300M of it will show up as
using 1G. This 1G is memory which has been "committed" to
by the VM and can be used at any time by the allocating
application. With strict overcommit enabled on the system
(mode 2 in 'vm.overcommit_memory'), allocations which would
exceed the CommitLimit (detailed above) will not be permitted.
This is useful if one needs to guarantee that processes will
not fail due to lack of memory once that memory has been
successfully allocated.
VmallocTotal
total size of vmalloc virtual address space
VmallocUsed
amount of vmalloc area which is used
VmallocChunk
largest contiguous block of vmalloc area which is free
Percpu
Memory allocated to the percpu allocator used to back percpu
allocations. This stat excludes the cost of metadata.
EarlyMemtestBad
The amount of RAM/memory in kB, that was identified as corrupted
by early memtest. If memtest was not run, this field will not
be displayed at all. Size is never rounded down to 0 kB.
That means if 0 kB is reported, you can safely assume
there was at least one pass of memtest and none of the passes
found a single faulty byte of RAM.
HardwareCorrupted
The amount of RAM/memory in KB, the kernel identifies as
corrupted.
AnonHugePages
Non-file backed huge pages mapped into userspace page tables
ShmemHugePages
Memory used by shared memory (shmem) and tmpfs allocated
with huge pages
ShmemPmdMapped
Shared memory mapped into userspace with huge pages
FileHugePages
Memory used for filesystem data (page cache) allocated
with huge pages
FilePmdMapped
Page cache mapped into userspace with huge pages
CmaTotal
Memory reserved for the Contiguous Memory Allocator (CMA)
CmaFree
Free remaining memory in the CMA reserves
Unaccepted
Memory that has not been accepted by the guest
Balloon
Memory returned to Host by VM Balloon Drivers
GPUActive
System memory allocated to active GPU objects
GPUReclaim
System memory stored in GPU pools for reuse. This memory is not
counted in GPUActive. It is shrinker reclaimable memory kept in a reuse
pool because it has non-standard page table attributes, like WC or UC.
HugePages_Total, HugePages_Free, HugePages_Rsvd, HugePages_Surp, Hugepagesize, Hugetlb
See Documentation/admin-guide/mm/hugetlbpage.rst.
DirectMap4k, DirectMap2M, DirectMap1G
Breakdown of page table sizes used in the kernel's
identity mapping of RAM
vmallocinfo
~~~~~~~~~~~
Provides information about vmalloced/vmaped areas. One line per area,
containing the virtual address range of the area, size in bytes,
caller information of the creator, and optional information depending
on the kind of area:
========== ===================================================
pages=nr number of pages
phys=addr if a physical address was specified
ioremap I/O mapping (ioremap() and friends)
vmalloc vmalloc() area
vmap vmap()ed pages
user VM_USERMAP area
vpages buffer for pages pointers was vmalloced (huge area)
N<node>=nr (Only on NUMA kernels)
Number of pages allocated on memory node <node>
========== ===================================================
::
> cat /proc/vmallocinfo
0xffffc20000000000-0xffffc20000201000 2101248 alloc_large_system_hash+0x204 ...
/0x2c0 pages=512 vmalloc N0=128 N1=128 N2=128 N3=128
0xffffc20000201000-0xffffc20000302000 1052672 alloc_large_system_hash+0x204 ...
/0x2c0 pages=256 vmalloc N0=64 N1=64 N2=64 N3=64
0xffffc20000302000-0xffffc20000304000 8192 acpi_tb_verify_table+0x21/0x4f...
phys=7fee8000 ioremap
0xffffc20000304000-0xffffc20000307000 12288 acpi_tb_verify_table+0x21/0x4f...
phys=7fee7000 ioremap
0xffffc2000031d000-0xffffc2000031f000 8192 init_vdso_vars+0x112/0x210
0xffffc2000031f000-0xffffc2000032b000 49152 cramfs_uncompress_init+0x2e ...
/0x80 pages=11 vmalloc N0=3 N1=3 N2=2 N3=3
0xffffc2000033a000-0xffffc2000033d000 12288 sys_swapon+0x640/0xac0 ...
pages=2 vmalloc N1=2
0xffffc20000347000-0xffffc2000034c000 20480 xt_alloc_table_info+0xfe ...
/0x130 [x_tables] pages=4 vmalloc N0=4
0xffffffffa0000000-0xffffffffa000f000 61440 sys_init_module+0xc27/0x1d00 ...
pages=14 vmalloc N2=14
0xffffffffa000f000-0xffffffffa0014000 20480 sys_init_module+0xc27/0x1d00 ...
pages=4 vmalloc N1=4
0xffffffffa0014000-0xffffffffa0017000 12288 sys_init_module+0xc27/0x1d00 ...
pages=2 vmalloc N1=2
0xffffffffa0017000-0xffffffffa0022000 45056 sys_init_module+0xc27/0x1d00 ...
pages=10 vmalloc N0=10
softirqs
~~~~~~~~
Provides counts of softirq handlers serviced since boot time, for each CPU.
::
> cat /proc/softirqs
CPU0 CPU1 CPU2 CPU3
HI: 0 0 0 0
TIMER: 27166 27120 27097 27034
NET_TX: 0 0 0 17
NET_RX: 42 0 0 39
BLOCK: 0 0 107 1121
TASKLET: 0 0 0 290
SCHED: 27035 26983 26971 26746
HRTIMER: 0 0 0 0
RCU: 1678 1769 2178 2250
1.3 Networking info in /proc/net
--------------------------------
The subdirectory /proc/net follows the usual pattern. Table 1-8 shows the
additional values you get for IP version 6 if you configure the kernel to
support this. Table 1-9 lists the files and their meaning.
.. table:: Table 1-8: IPv6 info in /proc/net
========== =====================================================
File Content
========== =====================================================
udp6 UDP sockets (IPv6)
tcp6 TCP sockets (IPv6)
raw6 Raw device statistics (IPv6)
igmp6 IP multicast addresses, which this host joined (IPv6)
if_inet6 List of IPv6 interface addresses
ipv6_route Kernel routing table for IPv6
rt6_stats Global IPv6 routing tables statistics
sockstat6 Socket statistics (IPv6)
snmp6 Snmp data (IPv6)
========== =====================================================
.. table:: Table 1-9: Network info in /proc/net
============= ================================================================
File Content
============= ================================================================
arp Kernel ARP table
dev network devices with statistics
dev_mcast the Layer2 multicast groups a device is listening too
(interface index, label, number of references, number of bound
addresses).
dev_stat network device status
ip_fwchains Firewall chain linkage
ip_fwnames Firewall chain names
ip_masq Directory containing the masquerading tables
ip_masquerade Major masquerading table
netstat Network statistics
raw raw device statistics
route Kernel routing table
rpc Directory containing rpc info
rt_cache Routing cache
snmp SNMP data
sockstat Socket statistics
softnet_stat Per-CPU incoming packets queues statistics of online CPUs
tcp TCP sockets
udp UDP sockets
unix UNIX domain sockets
wireless Wireless interface data (Wavelan etc)
igmp IP multicast addresses, which this host joined
psched Global packet scheduler parameters.
netlink List of PF_NETLINK sockets
ip_mr_vifs List of multicast virtual interfaces
ip_mr_cache List of multicast routing cache
============= ================================================================
You can use this information to see which network devices are available in
your system and how much traffic was routed over those devices::
> cat /proc/net/dev
Inter-|Receive |[...
face |bytes packets errs drop fifo frame compressed multicast|[...
lo: 908188 5596 0 0 0 0 0 0 [...
ppp0:15475140 20721 410 0 0 410 0 0 [...
eth0: 614530 7085 0 0 0 0 0 1 [...
...] Transmit
...] bytes packets errs drop fifo colls carrier compressed
...] 908188 5596 0 0 0 0 0 0
...] 1375103 17405 0 0 0 0 0 0
...] 1703981 5535 0 0 0 3 0 0
In addition, each Channel Bond interface has its own directory. For
example, the bond0 device will have a directory called /proc/net/bond0/.
It will contain information that is specific to that bond, such as the
current slaves of the bond, the link status of the slaves, and how
many times the slaves link has failed.
1.4 SCSI info
-------------
If you have a SCSI or ATA host adapter in your system, you'll find a
subdirectory named after the driver for this adapter in /proc/scsi.
You'll also see a list of all recognized SCSI devices in /proc/scsi::
>cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: IBM Model: DGHS09U Rev: 03E0
Type: Direct-Access ANSI SCSI revision: 03
Host: scsi0 Channel: 00 Id: 06 Lun: 00
Vendor: PIONEER Model: CD-ROM DR-U06S Rev: 1.04
Type: CD-ROM ANSI SCSI revision: 02
The directory named after the driver has one file for each adapter found in
the system. These files contain information about the controller, including
the used IRQ and the IO address range. The amount of information shown is
dependent on the adapter you use. The example shows the output for an Adaptec
AHA-2940 SCSI adapter::
> cat /proc/scsi/aic7xxx/0
Adaptec AIC7xxx driver version: 5.1.19/3.2.4
Compile Options:
TCQ Enabled By Default : Disabled
AIC7XXX_PROC_STATS : Disabled
AIC7XXX_RESET_DELAY : 5
Adapter Configuration:
SCSI Adapter: Adaptec AHA-294X Ultra SCSI host adapter
Ultra Wide Controller
PCI MMAPed I/O Base: 0xeb001000
Adapter SEEPROM Config: SEEPROM found and used.
Adaptec SCSI BIOS: Enabled
IRQ: 10
SCBs: Active 0, Max Active 2,
Allocated 15, HW 16, Page 255
Interrupts: 160328
BIOS Control Word: 0x18b6
Adapter Control Word: 0x005b
Extended Translation: Enabled
Disconnect Enable Flags: 0xffff
Ultra Enable Flags: 0x0001
Tag Queue Enable Flags: 0x0000
Ordered Queue Tag Flags: 0x0000
Default Tag Queue Depth: 8
Tagged Queue By Device array for aic7xxx host instance 0:
{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255}
Actual queue depth per device for aic7xxx host instance 0:
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
Statistics:
(scsi0:0:0:0)
Device using Wide/Sync transfers at 40.0 MByte/sec, offset 8
Transinfo settings: current(12/8/1/0), goal(12/8/1/0), user(12/15/1/0)
Total transfers 160151 (74577 reads and 85574 writes)
(scsi0:0:6:0)
Device using Narrow/Sync transfers at 5.0 MByte/sec, offset 15
Transinfo settings: current(50/15/0/0), goal(50/15/0/0), user(50/15/0/0)
Total transfers 0 (0 reads and 0 writes)
1.5 Parallel port info in /proc/parport
---------------------------------------
The directory /proc/parport contains information about the parallel ports of
your system. It has one subdirectory for each port, named after the port
number (0,1,2,...).
These directories contain the four files shown in Table 1-10.
.. table:: Table 1-10: Files in /proc/parport
========= ====================================================================
File Content
========= ====================================================================
autoprobe Any IEEE-1284 device ID information that has been acquired.
devices list of the device drivers using that port. A + will appear by the
name of the device currently using the port (it might not appear
against any).
hardware Parallel port's base address, IRQ line and DMA channel.
irq IRQ that parport is using for that port. This is in a separate
file to allow you to alter it by writing a new value in (IRQ
number or none).
========= ====================================================================
1.6 TTY info in /proc/tty
-------------------------
Information about the available and actually used tty's can be found in the
directory /proc/tty. You'll find entries for drivers and line disciplines in
this directory, as shown in Table 1-11.
.. table:: Table 1-11: Files in /proc/tty
============= ==============================================
File Content
============= ==============================================
drivers list of drivers and their usage
ldiscs registered line disciplines
driver/serial usage statistic and status of single tty lines
============= ==============================================
To see which tty's are currently in use, you can simply look into the file
/proc/tty/drivers::
> cat /proc/tty/drivers
pty_slave /dev/pts 136 0-255 pty:slave
pty_master /dev/ptm 128 0-255 pty:master
pty_slave /dev/ttyp 3 0-255 pty:slave
pty_master /dev/pty 2 0-255 pty:master
serial /dev/cua 5 64-67 serial:callout
serial /dev/ttyS 4 64-67 serial
/dev/tty0 /dev/tty0 4 0 system:vtmaster
/dev/ptmx /dev/ptmx 5 2 system
/dev/console /dev/console 5 1 system:console
/dev/tty /dev/tty 5 0 system:/dev/tty
unknown /dev/tty 4 1-63 console
1.7 Miscellaneous kernel statistics in /proc/stat
-------------------------------------------------
Various pieces of information about kernel activity are available in the
/proc/stat file. All of the numbers reported in this file are aggregates
since the system first booted. For a quick look, simply cat the file::
> cat /proc/stat
cpu 237902850 368826709 106375398 1873517540 1135548 0 14507935 0 0 0
cpu0 60045249 91891769 26331539 468411416 495718 0 5739640 0 0 0
cpu1 59746288 91759249 26609887 468860630 312281 0 4384817 0 0 0
cpu2 59489247 92985423 26904446 467808813 171668 0 2268998 0 0 0
cpu3 58622065 92190267 26529524 468436680 155879 0 2114478 0 0 0
intr 8688370575 8 3373 0 0 0 0 0 0 1 40791 0 0 353317 0 0 0 0 224789828 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 190974333 41958554 123983334 43 0 224593 0 0 0 <more 0's deleted>
ctxt 22848221062
btime 1605316999
processes 746787147
procs_running 2
procs_blocked 0
softirq 12121874454 100099120 3938138295 127375644 2795979 187870761 0 173808342 3072582055 52608 224184354
The very first "cpu" line aggregates the numbers in all of the other "cpuN"
lines. These numbers identify the amount of time the CPU has spent performing
different kinds of work. Time units are in USER_HZ (typically hundredths of a
second). The meanings of the columns are as follows, from left to right:
- user: normal processes executing in user mode
- nice: niced processes executing in user mode
- system: processes executing in kernel mode
- idle: twiddling thumbs
- iowait: In a word, iowait stands for waiting for I/O to complete. But there
are several problems:
1. CPU will not wait for I/O to complete, iowait is the time that a task is
waiting for I/O to complete. When CPU goes into idle state for
outstanding task I/O, another task will be scheduled on this CPU.
2. In a multi-core CPU, the task waiting for I/O to complete is not running
on any CPU, so the iowait of each CPU is difficult to calculate.
3. The value of iowait field in /proc/stat will decrease in certain
conditions.
So, the iowait is not reliable by reading from /proc/stat.
- irq: servicing interrupts
- softirq: servicing softirqs
- steal: involuntary wait
- guest: running a normal guest
- guest_nice: running a niced guest
The "intr" line gives counts of interrupts serviced since boot time, for each
of the possible system interrupts. The first column is the total of all
interrupts serviced including unnumbered architecture specific interrupts;
each subsequent column is the total for that particular numbered interrupt.
Unnumbered interrupts are not shown, only summed into the total.
The "ctxt" line gives the total number of context switches across all CPUs.
The "btime" line gives the time at which the system booted, in seconds since
the Unix epoch.
The "processes" line gives the number of processes and threads created, which
includes (but is not limited to) those created by calls to the fork() and
clone() system calls.
The "procs_running" line gives the total number of threads that are
running or ready to run (i.e., the total number of runnable threads).
The "procs_blocked" line gives the number of processes currently blocked,
waiting for I/O to complete.
The "softirq" line gives counts of softirqs serviced since boot time, for each
of the possible system softirqs. The first column is the total of all
softirqs serviced; each subsequent column is the total for that particular
softirq.
1.8 Ext4 file system parameters
-------------------------------
Information about mounted ext4 file systems can be found in
/proc/fs/ext4. Each mounted filesystem will have a directory in
/proc/fs/ext4 based on its device name (i.e., /proc/fs/ext4/hdc or
/proc/fs/ext4/sda9 or /proc/fs/ext4/dm-0). The files in each per-device
directory are shown in Table 1-12, below.
.. table:: Table 1-12: Files in /proc/fs/ext4/<devname>
============== ==========================================================
File Content
mb_groups details of multiblock allocator buddy cache of free blocks
============== ==========================================================
1.9 /proc/consoles
-------------------
Shows registered system console lines.
To see which character device lines are currently used for the system console
/dev/console, you may simply look into the file /proc/consoles::
> cat /proc/consoles
tty0 -WU (ECp) 4:7
ttyS0 -W- (Ep) 4:64
The columns are:
+--------------------+-------------------------------------------------------+
| device | name of the device |
+====================+=======================================================+
| operations | * R = can do read operations |
| | * W = can do write operations |
| | * U = can do unblank |
+--------------------+-------------------------------------------------------+
| flags | * E = it is enabled |
| | * C = it is preferred console |
| | * B = it is primary boot console |
| | * p = it is used for printk buffer |
| | * b = it is not a TTY but a Braille device |
| | * a = it is safe to use when cpu is offline |
+--------------------+-------------------------------------------------------+
| major:minor | major and minor number of the device separated by a |
| | colon |
+--------------------+-------------------------------------------------------+
Summary
-------
The /proc file system serves information about the running system. It not only
allows access to process data but also allows you to request the kernel status
by reading files in the hierarchy.
The directory structure of /proc reflects the types of information and makes
it easy, if not obvious, where to look for specific data.
Chapter 2: Modifying System Parameters
======================================
In This Chapter
---------------
* Modifying kernel parameters by writing into files found in /proc/sys
* Exploring the files which modify certain parameters
* Review of the /proc/sys file tree
------------------------------------------------------------------------------
A very interesting part of /proc is the directory /proc/sys. This is not only
a source of information, it also allows you to change parameters within the
kernel. Be very careful when attempting this. You can optimize your system,
but you can also cause it to crash. Never alter kernel parameters on a
production system. Set up a development machine and test to make sure that
everything works the way you want it to. You may have no alternative but to
reboot the machine once an error has been made.
To change a value, simply echo the new value into the file.
You need to be root to do this. You can create your own boot script
to perform this every time your system boots.
The files in /proc/sys can be used to fine tune and monitor miscellaneous and
general things in the operation of the Linux kernel. Since some of the files
can inadvertently disrupt your system, it is advisable to read both
documentation and source before actually making adjustments. In any case, be
very careful when writing to any of these files. The entries in /proc may
change slightly between the 2.1.* and the 2.2 kernel, so if there is any doubt
review the kernel documentation in the directory linux/Documentation.
This chapter is heavily based on the documentation included in the pre 2.2
kernels, and became part of it in version 2.2.1 of the Linux kernel.
Please see: Documentation/admin-guide/sysctl/ directory for descriptions of
these entries.
Summary
-------
Certain aspects of kernel behavior can be modified at runtime, without the
need to recompile the kernel, or even to reboot the system. The files in the
/proc/sys tree can not only be read, but also modified. You can use the echo
command to write value into these files, thereby changing the default settings
of the kernel.
Chapter 3: Per-process Parameters
=================================
3.1 /proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj- Adjust the oom-killer score
--------------------------------------------------------------------------------
These files can be used to adjust the badness heuristic used to select which
process gets killed in out of memory (oom) conditions.
The badness heuristic assigns a value to each candidate task ranging from 0
(never kill) to 1000 (always kill) to determine which process is targeted. The
units are roughly a proportion along that range of allowed memory the process
may allocate from based on an estimation of its current memory and swap use.
For example, if a task is using all allowed memory, its badness score will be
1000. If it is using half of its allowed memory, its score will be 500.
The amount of "allowed" memory depends on the context in which the oom killer
was called. If it is due to the memory assigned to the allocating task's cpuset
being exhausted, the allowed memory represents the set of mems assigned to that
cpuset. If it is due to a mempolicy's node(s) being exhausted, the allowed
memory represents the set of mempolicy nodes. If it is due to a memory
limit (or swap limit) being reached, the allowed memory is that configured
limit. Finally, if it is due to the entire system being out of memory, the
allowed memory represents all allocatable resources.
The value of /proc/<pid>/oom_score_adj is added to the badness score before it
is used to determine which task to kill. Acceptable values range from -1000
(OOM_SCORE_ADJ_MIN) to +1000 (OOM_SCORE_ADJ_MAX). This allows userspace to
polarize the preference for oom killing either by always preferring a certain
task or completely disabling it. The lowest possible value, -1000, is
equivalent to disabling oom killing entirely for that task since it will always
report a badness score of 0.
Consequently, it is very simple for userspace to define the amount of memory to
consider for each task. Setting a /proc/<pid>/oom_score_adj value of +500, for
example, is roughly equivalent to allowing the remainder of tasks sharing the
same system, cpuset, mempolicy, or memory controller resources to use at least
50% more memory. A value of -500, on the other hand, would be roughly
equivalent to discounting 50% of the task's allowed memory from being considered
as scoring against the task.
For backwards compatibility with previous kernels, /proc/<pid>/oom_adj may also
be used to tune the badness score. Its acceptable values range from -16
(OOM_ADJUST_MIN) to +15 (OOM_ADJUST_MAX) and a special value of -17
(OOM_DISABLE) to disable oom killing entirely for that task. Its value is
scaled linearly with /proc/<pid>/oom_score_adj.
The value of /proc/<pid>/oom_score_adj may be reduced no lower than the last
value set by a CAP_SYS_RESOURCE process. To reduce the value any lower
requires CAP_SYS_RESOURCE.
3.2 /proc/<pid>/oom_score - Display current oom-killer score
-------------------------------------------------------------
This file can be used to check the current score used by the oom-killer for
any given <pid>. Use it together with /proc/<pid>/oom_score_adj to tune which
process should be killed in an out-of-memory situation.
Please note that the exported value includes oom_score_adj so it is
effectively in range [0,2000].
3.3 /proc/<pid>/io - Display the IO accounting fields
-------------------------------------------------------
This file contains IO statistics for each running process.
Example
~~~~~~~
::
test:/tmp # dd if=/dev/zero of=/tmp/test.dat &
[1] 3828
test:/tmp # cat /proc/3828/io
rchar: 323934931
wchar: 323929600
syscr: 632687
syscw: 632675
read_bytes: 0
write_bytes: 323932160
cancelled_write_bytes: 0
Description
~~~~~~~~~~~
rchar
^^^^^
I/O counter: chars read
The number of bytes which this task has caused to be read from storage. This
is simply the sum of bytes which this process passed to read() and pread().
It includes things like tty IO and it is unaffected by whether or not actual
physical disk IO was required (the read might have been satisfied from
pagecache).
wchar
^^^^^
I/O counter: chars written
The number of bytes which this task has caused, or shall cause to be written
to disk. Similar caveats apply here as with rchar.
syscr
^^^^^
I/O counter: read syscalls
Attempt to count the number of read I/O operations, i.e. syscalls like read()
and pread().
syscw
^^^^^
I/O counter: write syscalls
Attempt to count the number of write I/O operations, i.e. syscalls like
write() and pwrite().
read_bytes
^^^^^^^^^^
I/O counter: bytes read
Attempt to count the number of bytes which this process really did cause to
be fetched from the storage layer. Done at the submit_bio() level, so it is
accurate for block-backed filesystems. <please add status regarding NFS and
CIFS at a later time>
write_bytes
^^^^^^^^^^^
I/O counter: bytes written
Attempt to count the number of bytes which this process caused to be sent to
the storage layer. This is done at page-dirtying time.
cancelled_write_bytes
^^^^^^^^^^^^^^^^^^^^^
The big inaccuracy here is truncate. If a process writes 1MB to a file and
then deletes the file, it will in fact perform no writeout. But it will have
been accounted as having caused 1MB of write.
In other words: The number of bytes which this process caused to not happen,
by truncating pagecache. A task can cause "negative" IO too. If this task
truncates some dirty pagecache, some IO which another task has been accounted
for (in its write_bytes) will not be happening. We _could_ just subtract that
from the truncating task's write_bytes, but there is information loss in doing
that.
.. Note::
At its current implementation state, this is a bit racy on 32-bit machines:
if process A reads process B's /proc/pid/io while process B is updating one
of those 64-bit counters, process A could see an intermediate result.
More information about this can be found within the taskstats documentation in
Documentation/accounting.
3.4 /proc/<pid>/coredump_filter - Core dump filtering settings
---------------------------------------------------------------
When a process is dumped, all anonymous memory is written to a core file as
long as the size of the core file isn't limited. But sometimes we don't want
to dump some memory segments, for example, huge shared memory or DAX.
Conversely, sometimes we want to save file-backed memory segments into a core
file, not only the individual files.
/proc/<pid>/coredump_filter allows you to customize which memory segments
will be dumped when the <pid> process is dumped. coredump_filter is a bitmask
of memory types. If a bit of the bitmask is set, memory segments of the
corresponding memory type are dumped, otherwise they are not dumped.
The following 9 memory types are supported:
- (bit 0) anonymous private memory
- (bit 1) anonymous shared memory
- (bit 2) file-backed private memory
- (bit 3) file-backed shared memory
- (bit 4) ELF header pages in file-backed private memory areas (it is
effective only if the bit 2 is cleared)
- (bit 5) hugetlb private memory
- (bit 6) hugetlb shared memory
- (bit 7) DAX private memory
- (bit 8) DAX shared memory
Note that MMIO pages such as frame buffer are never dumped and vDSO pages
are always dumped regardless of the bitmask status.
Note that bits 0-4 don't affect hugetlb or DAX memory. hugetlb memory is
only affected by bit 5-6, and DAX is only affected by bits 7-8.
The default value of coredump_filter is 0x33; this means all anonymous memory
segments, ELF header pages and hugetlb private memory are dumped.
If you don't want to dump all shared memory segments attached to pid 1234,
write 0x31 to the process's proc file::
$ echo 0x31 > /proc/1234/coredump_filter
When a new process is created, the process inherits the bitmask status from its
parent. It is useful to set up coredump_filter before the program runs.
For example::
$ echo 0x7 > /proc/self/coredump_filter
$ ./some_program
3.5 /proc/<pid>/mountinfo - Information about mounts
--------------------------------------------------------
This file contains lines of the form::
36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue
(1)(2)(3) (4) (5) (6) (nā¦m) (m+1)(m+2) (m+3) (m+4)
(1) mount ID: unique identifier of the mount (may be reused after umount)
(2) parent ID: ID of parent (or of self for the top of the mount tree)
(3) major:minor: value of st_dev for files on filesystem
(4) root: root of the mount within the filesystem
(5) mount point: mount point relative to the process's root
(6) mount options: per mount options
(nā¦m) optional fields: zero or more fields of the form "tag[:value]"
(m+1) separator: marks the end of the optional fields
(m+2) filesystem type: name of filesystem of the form "type[.subtype]"
(m+3) mount source: filesystem specific information or "none"
(m+4) super options: per super block options
Parsers should ignore all unrecognised optional fields. Currently the
possible optional fields are:
================ ==============================================================
shared:X mount is shared in peer group X
master:X mount is slave to peer group X
propagate_from:X mount is slave and receives propagation from peer group X [#]_
unbindable mount is unbindable
================ ==============================================================
.. [#] X is the closest dominant peer group under the process's root. If
X is the immediate master of the mount, or if there's no dominant peer
group under the same root, then only the "master:X" field is present
and not the "propagate_from:X" field.
For more information on mount propagation see:
Documentation/filesystems/sharedsubtree.rst
3.6 /proc/<pid>/comm & /proc/<pid>/task/<tid>/comm
--------------------------------------------------------
These files provide a method to access a task's comm value. It also allows for
a task to set its own or one of its thread siblings comm value. The comm value
is limited in size compared to the cmdline value, so writing anything longer
then the kernel's TASK_COMM_LEN (currently 16 chars, including the NUL
terminator) will result in a truncated comm value.
3.7 /proc/<pid>/task/<tid>/children - Information about task children
-------------------------------------------------------------------------
This file provides a fast way to retrieve first level children pids
of a task pointed by <pid>/<tid> pair. The format is a space separated
stream of pids.
Note the "first level" here -- if a child has its own children they will
not be listed here; one needs to read /proc/<children-pid>/task/<tid>/children
to obtain the descendants.
Since this interface is intended to be fast and cheap it doesn't
guarantee to provide precise results and some children might be
skipped, especially if they've exited right after we printed their
pids, so one needs to either stop or freeze processes being inspected
if precise results are needed.
3.8 /proc/<pid>/fdinfo/<fd> - Information about opened file
---------------------------------------------------------------
This file provides information associated with an opened file. The regular
files have at least four fields -- 'pos', 'flags', 'mnt_id' and 'ino'.
The 'pos' represents the current offset of the opened file in decimal
form [see lseek(2) for details], 'flags' denotes the octal O_xxx mask the
file has been created with [see open(2) for details] and 'mnt_id' represents
mount ID of the file system containing the opened file [see 3.5
/proc/<pid>/mountinfo for details]. 'ino' represents the inode number of
the file.
A typical output is::
pos: 0
flags: 0100002
mnt_id: 19
ino: 63107
All locks associated with a file descriptor are shown in its fdinfo too::
lock: 1: FLOCK ADVISORY WRITE 359 00:13:11691 0 EOF
The files such as eventfd, fsnotify, signalfd, epoll among the regular pos/flags
pair provide additional information particular to the objects they represent.
Eventfd files
~~~~~~~~~~~~~
::
pos: 0
flags: 04002
mnt_id: 9
ino: 63107
eventfd-count: 5a
where 'eventfd-count' is hex value of a counter.
Signalfd files
~~~~~~~~~~~~~~
::
pos: 0
flags: 04002
mnt_id: 9
ino: 63107
sigmask: 0000000000000200
where 'sigmask' is hex value of the signal mask associated
with a file.
Epoll files
~~~~~~~~~~~
::
pos: 0
flags: 02
mnt_id: 9
ino: 63107
tfd: 5 events: 1d data: ffffffffffffffff pos:0 ino:61af sdev:7
where 'tfd' is a target file descriptor number in decimal form,
'events' is events mask being watched and the 'data' is data
associated with a target [see epoll(7) for more details].
The 'pos' is current offset of the target file in decimal form
[see lseek(2)], 'ino' and 'sdev' are inode and device numbers
where target file resides, all in hex format.
Fsnotify files
~~~~~~~~~~~~~~
For inotify files the format is the following::
pos: 0
flags: 02000000
mnt_id: 9
ino: 63107
inotify wd:3 ino:9e7e sdev:800013 mask:800afce ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:7e9e0000640d1b6d
where 'wd' is a watch descriptor in decimal form, i.e. a target file
descriptor number, 'ino' and 'sdev' are inode and device where the
target file resides and the 'mask' is the mask of events, all in hex
form [see inotify(7) for more details].
If the kernel was built with exportfs support, the path to the target
file is encoded as a file handle. The file handle is provided by three
fields 'fhandle-bytes', 'fhandle-type' and 'f_handle', all in hex
format.
If the kernel is built without exportfs support the file handle won't be
printed out.
If there is no inotify mark attached yet the 'inotify' line will be omitted.
For fanotify files the format is::
pos: 0
flags: 02
mnt_id: 9
ino: 63107
fanotify flags:10 event-flags:0
fanotify mnt_id:12 mflags:40 mask:38 ignored_mask:40000003
fanotify ino:4f969 sdev:800013 mflags:0 mask:3b ignored_mask:40000000 fhandle-bytes:8 fhandle-type:1 f_handle:69f90400c275b5b4
where fanotify 'flags' and 'event-flags' are values used in fanotify_init
call, 'mnt_id' is the mount point identifier, 'mflags' is the value of
flags associated with mark which are tracked separately from events
mask. 'ino' and 'sdev' are target inode and device, 'mask' is the events
mask and 'ignored_mask' is the mask of events which are to be ignored.
All are in hex format. Incorporation of 'mflags', 'mask' and 'ignored_mask'
provide information about flags and mask used in fanotify_mark
call [see fsnotify manpage for details].
While the first three lines are mandatory and always printed, the rest is
optional and may be omitted if no marks created yet.
Timerfd files
~~~~~~~~~~~~~
::
pos: 0
flags: 02
mnt_id: 9
ino: 63107
clockid: 0
ticks: 0
settime flags: 01
it_value: (0, 49406829)
it_interval: (1, 0)
where 'clockid' is the clock type and 'ticks' is the number of the timer expirations
that have occurred [see timerfd_create(2) for details]. 'settime flags' are
flags in octal form been used to setup the timer [see timerfd_settime(2) for
details]. 'it_value' is remaining time until the timer expiration.
'it_interval' is the interval for the timer. Note the timer might be set up
with TIMER_ABSTIME option which will be shown in 'settime flags', but 'it_value'
still exhibits timer's remaining time.
DMA Buffer files
~~~~~~~~~~~~~~~~
::
pos: 0
flags: 04002
mnt_id: 9
ino: 63107
size: 32768
count: 2
exp_name: system-heap
where 'size' is the size of the DMA buffer in bytes. 'count' is the file count of
the DMA buffer file. 'exp_name' is the name of the DMA buffer exporter.
VFIO Device files
~~~~~~~~~~~~~~~~~
::
pos: 0
flags: 02000002
mnt_id: 17
ino: 5122
vfio-device-syspath: /sys/devices/pci0000:e0/0000:e0:01.1/0000:e1:00.0/0000:e2:05.0/0000:e8:00.0
where 'vfio-device-syspath' is the sysfs path corresponding to the VFIO device
file.
3.9 /proc/<pid>/map_files - Information about memory mapped files
---------------------------------------------------------------------
This directory contains symbolic links which represent memory mapped files
the process is maintaining. Example output::
| lr-------- 1 root root 64 Jan 27 11:24 333c600000-333c620000 -> /usr/lib64/ld-2.18.so
| lr-------- 1 root root 64 Jan 27 11:24 333c81f000-333c820000 -> /usr/lib64/ld-2.18.so
| lr-------- 1 root root 64 Jan 27 11:24 333c820000-333c821000 -> /usr/lib64/ld-2.18.so
| ...
| lr-------- 1 root root 64 Jan 27 11:24 35d0421000-35d0422000 -> /usr/lib64/libselinux.so.1
| lr-------- 1 root root 64 Jan 27 11:24 400000-41a000 -> /usr/bin/ls
The name of a link represents the virtual memory bounds of a mapping, i.e.
vm_area_struct::vm_start-vm_area_struct::vm_end.
The main purpose of the map_files is to retrieve a set of memory mapped
files in a fast way instead of parsing /proc/<pid>/maps or
/proc/<pid>/smaps, both of which contain many more records. At the same
time one can open(2) mappings from the listings of two processes and
comparing their inode numbers to figure out which anonymous memory areas
are actually shared.
3.10 /proc/<pid>/timerslack_ns - Task timerslack value
---------------------------------------------------------
This file provides the value of the task's timerslack value in nanoseconds.
This value specifies an amount of time that normal timers may be deferred
in order to coalesce timers and avoid unnecessary wakeups.
This allows a task's interactivity vs power consumption tradeoff to be
adjusted.
Writing 0 to the file will set the task's timerslack to the default value.
Valid values are from 0 - ULLONG_MAX
An application setting the value must have PTRACE_MODE_ATTACH_FSCREDS level
permissions on the task specified to change its timerslack_ns value.
3.11 /proc/<pid>/patch_state - Livepatch patch operation state
-----------------------------------------------------------------
When CONFIG_LIVEPATCH is enabled, this file displays the value of the
patch state for the task.
A value of '-1' indicates that no patch is in transition.
A value of '0' indicates that a patch is in transition and the task is
unpatched. If the patch is being enabled, then the task hasn't been
patched yet. If the patch is being disabled, then the task has already
been unpatched.
A value of '1' indicates that a patch is in transition and the task is
patched. If the patch is being enabled, then the task has already been
patched. If the patch is being disabled, then the task hasn't been
unpatched yet.
3.12 /proc/<pid>/arch_status - task architecture specific status
-------------------------------------------------------------------
When CONFIG_PROC_PID_ARCH_STATUS is enabled, this file displays the
architecture specific status of the task.
Example
~~~~~~~
::
$ cat /proc/6753/arch_status
AVX512_elapsed_ms: 8
Description
~~~~~~~~~~~
x86 specific entries
~~~~~~~~~~~~~~~~~~~~~
AVX512_elapsed_ms
^^^^^^^^^^^^^^^^^^
If AVX512 is supported on the machine, this entry shows the milliseconds
elapsed since the last time AVX512 usage was recorded. The recording
happens on a best effort basis when a task is scheduled out. This means
that the value depends on two factors:
1) The time which the task spent on the CPU without being scheduled
out. With CPU isolation and a single runnable task this can take
several seconds.
2) The time since the task was scheduled out last. Depending on the
reason for being scheduled out (time slice exhausted, syscall ...)
this can be arbitrary long time.
As a consequence the value cannot be considered precise and authoritative
information. The application which uses this information has to be aware
of the overall scenario on the system in order to determine whether a
task is a real AVX512 user or not. Precise information can be obtained
with performance counters.
A special value of '-1' indicates that no AVX512 usage was recorded, thus
the task is unlikely an AVX512 user, but depends on the workload and the
scheduling scenario, it also could be a false negative mentioned above.
3.13 /proc/<pid>/fd - List of symlinks to open files
-------------------------------------------------------
This directory contains symbolic links which represent open files
the process is maintaining. Example output::
lr-x------ 1 root root 64 Sep 20 17:53 0 -> /dev/null
l-wx------ 1 root root 64 Sep 20 17:53 1 -> /dev/null
lrwx------ 1 root root 64 Sep 20 17:53 10 -> 'socket:[12539]'
lrwx------ 1 root root 64 Sep 20 17:53 11 -> 'socket:[12540]'
lrwx------ 1 root root 64 Sep 20 17:53 12 -> 'socket:[12542]'
The number of open files for the process is stored in 'size' member
of stat() output for /proc/<pid>/fd for fast access.
-------------------------------------------------------
3.14 /proc/<pid>/ksm_stat - Information about the process's ksm status
----------------------------------------------------------------------
When CONFIG_KSM is enabled, each process has this file which displays
the information of ksm merging status.
Example
~~~~~~~
::
/ # cat /proc/self/ksm_stat
ksm_rmap_items 0
ksm_zero_pages 0
ksm_merging_pages 0
ksm_process_profit 0
ksm_merge_any: no
ksm_mergeable: no
Description
~~~~~~~~~~~
ksm_rmap_items
^^^^^^^^^^^^^^
The number of ksm_rmap_item structures in use. The structure
ksm_rmap_item stores the reverse mapping information for virtual
addresses. KSM will generate a ksm_rmap_item for each ksm-scanned page of
the process.
ksm_zero_pages
^^^^^^^^^^^^^^
When /sys/kernel/mm/ksm/use_zero_pages is enabled, it represent how many
empty pages are merged with kernel zero pages by KSM.
ksm_merging_pages
^^^^^^^^^^^^^^^^^
It represents how many pages of this process are involved in KSM merging
(not including ksm_zero_pages). It is the same with what
/proc/<pid>/ksm_merging_pages shows.
ksm_process_profit
^^^^^^^^^^^^^^^^^^
The profit that KSM brings (Saved bytes). KSM can save memory by merging
identical pages, but also can consume additional memory, because it needs
to generate a number of rmap_items to save each scanned page's brief rmap
information. Some of these pages may be merged, but some may not be abled
to be merged after being checked several times, which are unprofitable
memory consumed.
ksm_merge_any
^^^^^^^^^^^^^
It specifies whether the process's 'mm is added by prctl() into the
candidate list of KSM or not, and if KSM scanning is fully enabled at
process level.
ksm_mergeable
^^^^^^^^^^^^^
It specifies whether any VMAs of the process''s mms are currently
applicable to KSM.
More information about KSM can be found in
Documentation/admin-guide/mm/ksm.rst.
Chapter 4: Configuring procfs
=============================
4.1 Mount options
---------------------
The following mount options are supported:
========= ========================================================
hidepid= Set /proc/<pid>/ access mode.
gid= Set the group authorized to learn processes information.
subset= Show only the specified subset of procfs.
pidns= Specify a the namespace used by this procfs.
========= ========================================================
hidepid=off or hidepid=0 means classic mode - everybody may access all
/proc/<pid>/ directories (default).
hidepid=noaccess or hidepid=1 means users may not access any /proc/<pid>/
directories but their own. Sensitive files like cmdline, sched*, status are now
protected against other users. This makes it impossible to learn whether any
user runs specific program (given the program doesn't reveal itself by its
behaviour). As an additional bonus, as /proc/<pid>/cmdline is unaccessible for
other users, poorly written programs passing sensitive information via program
arguments are now protected against local eavesdroppers.
hidepid=invisible or hidepid=2 means hidepid=1 plus all /proc/<pid>/ will be
fully invisible to other users. It doesn't mean that it hides a fact whether a
process with a specific pid value exists (it can be learned by other means, e.g.
by "kill -0 $PID"), but it hides process's uid and gid, which may be learned by
stat()'ing /proc/<pid>/ otherwise. It greatly complicates an intruder's task of
gathering information about running processes, whether some daemon runs with
elevated privileges, whether other user runs some sensitive program, whether
other users run any program at all, etc.
hidepid=ptraceable or hidepid=4 means that procfs should only contain
/proc/<pid>/ directories that the caller can ptrace.
gid= defines a group authorized to learn processes information otherwise
prohibited by hidepid=. If you use some daemon like identd which needs to learn
information about processes information, just add identd to this group.
subset=pid hides all top level files and directories in the procfs that
are not related to tasks.
pidns= specifies a pid namespace (either as a string path to something like
`/proc/$pid/ns/pid`, or a file descriptor when using `FSCONFIG_SET_FD`) that
will be used by the procfs instance when translating pids. By default, procfs
will use the calling process's active pid namespace. Note that the pid
namespace of an existing procfs instance cannot be modified (attempting to do
so will give an `-EBUSY` error).
Chapter 5: Filesystem behavior
==============================
Originally, before the advent of pid namespace, procfs was a global file
system. It means that there was only one procfs instance in the system.
When pid namespace was added, a separate procfs instance was mounted in
each pid namespace. So, procfs mount options are global among all
mountpoints within the same namespace::
# grep ^proc /proc/mounts
proc /proc proc rw,relatime,hidepid=2 0 0
# strace -e mount mount -o hidepid=1 -t proc proc /tmp/proc
mount("proc", "/tmp/proc", "proc", 0, "hidepid=1") = 0
+++ exited with 0 +++
# grep ^proc /proc/mounts
proc /proc proc rw,relatime,hidepid=2 0 0
proc /tmp/proc proc rw,relatime,hidepid=2 0 0
and only after remounting procfs mount options will change at all
mountpoints::
# mount -o remount,hidepid=1 -t proc proc /tmp/proc
# grep ^proc /proc/mounts
proc /proc proc rw,relatime,hidepid=1 0 0
proc /tmp/proc proc rw,relatime,hidepid=1 0 0
This behavior is different from the behavior of other filesystems.
The new procfs behavior is more like other filesystems. Each procfs mount
creates a new procfs instance. Mount options affect own procfs instance.
It means that it became possible to have several procfs instances
displaying tasks with different filtering options in one pid namespace::
# mount -o hidepid=invisible -t proc proc /proc
# mount -o hidepid=noaccess -t proc proc /tmp/proc
# grep ^proc /proc/mounts
proc /proc proc rw,relatime,hidepid=invisible 0 0
proc /tmp/proc proc rw,relatime,hidepid=noaccess 0 0
]
|
| 54/4 |
2026/05/23 11:37 |
llm |
codeexpert |
0m
Model:
Tokens:
input: 64945
output: 464
thoughts: 1576
Thoughts: **Analysis of `/proc/timer_list` Accessibility**
Okay, let's break this down systematically. The documentation mentions `timer_list` as residing within `/proc`, though it's strangely absent from the expected table. I can confirm its existence, however. I recall that the `/proc/sys` entries require root privileges, and there are specific access rules for `/proc/<pid>/`. For top-level files like `/proc/timer_list`, we're dealing with standard VFS permissions.
Given `timer_list`'s `0400` permissions and ownership by global root, the restriction to global root seems straightforward. So, my initial inclination is "No," it's not readable.
To be absolutely certain, I considered edge cases:
* **User Namespace and Root:** If an unprivileged user created a namespace as root, they could map UID 0, but the scenario specifies an *unprivileged* user.
* **`sudo`:** Using `sudo` grants privilege, violating the unprivileged constraint.
* **`unshare -r`:** With `unshare -r`, the current UID is mapped to 0 inside the new namespace. If the current UID is 1000, then inside the namespace, UID 0 is global UID 1000. The file `/proc/timer_list` is owned by global UID 0. Global UID 0 is NOT mapped in the namespace. So the user (global 1000) is NOT the owner of the file (global 0).
I double-checked `proc_create_seq_private` to ensure it uses the parent's UID, which defaults to `proc_root` (UID 0), and I confirmed `proc_root.uid` is never modified. The `proc_set_user` function, in `__proc_create`, uses `(*parent)->uid` if `parent` is `proc_root`.
I needed to make sure that the `proc_root` isn't per-namespace. I searched for it, and confirmed that it is a global variable. `proc_net` is special; however, `timer_list` is a global file, not within the `net` subdirectory.
The crucial point is that capabilities like `CAP_DAC_OVERRIDE` and `CAP_DAC_READ_SEARCH` in a user namespace only apply to files where the owner UID is mapped within that namespace. Global UID 0, being unmapped, means these capabilities are ineffective.
I went back to the source code for the `timer_list` proc entry creation. There's no conditional mode setting. `proc_create_seq_private` is a function, not a macro, so no tricks there.
I also checked if creating the namespace with `CLONE_NEWUSER` but NOT `CLONE_NEWPID` would change things. No, since it's the same mount, the permissions are the same. A new PID namespace and a new `proc` mount use the same PDE tree and inodes inherit the same UID/GID.
Finally, does `kptr_restrict` matter? No, because the permission check happens before attempting to read the content.
The commit `8e7df2b5b7f2` specifically sets the mode to `0400` to restrict access.
**Conclusion:**
* `/proc/timer_list`'s mode is explicitly `0400`.
* It's owned by global root (UID 0).
* Standard VFS permission logic applies to `/proc` files.
* An unprivileged user in a user namespace does not have global UID 0.
* Even with namespace capabilities, global UID 0 is unmapped.
* Thus, an unprivileged user cannot read `/proc/timer_list`. My answer remains: "No."
|
| 55/2 |
2026/05/23 11:37 |
llm |
expert |
0m
Model:
Tokens:
input: 14520
output: 66
thoughts: 484
Thoughts: **My Assessment of the Timer List Vulnerability**
Alright, let's break this down. First, the crucial aspect is that this isn't exploitable by unprivileged processes or within user namespaces. That's good. Now, onto the core issue: the data race. It's a read and write conflict on an 8-byte value ā specifically, the `cpu_base->expires_next` field. The read is part of printing to a `seq_file`, and the write updates the same field.
From a security perspective, this looks benign. It's highly unlikely to cause memory corruption, a denial-of-service condition, or any other security concern. So, Exploitable is false, DenialOfService is false. Unprivileged and UserNamespace are also false. No VMGuestTrigger, VMHostTrigger, NetworkTrigger, RemoteTrigger, PeripheralTrigger, or FilesystemTrigger either.
I need to confirm all the entry points to `timer_list_show`, just in case. It's called from `sysrq_timer_list_show`, which is itself triggered by `sysrq_handle_show_timers`. SysRq access is limited to either a physical keyboard or `/proc/sysrq-trigger`, which is root-only. So, definitely not unprivileged. I also need to make sure that `print_cpu` can only be called from `timer_list_show`. This confirms that access is limited to root-only.
Let's revisit the data race itself. Could concurrently reading `cpu_base->expires_next` during a write cause a crash? No, it's an 8-byte read on a 64-bit architecture. On most architectures, it is atomic, but even if it's torn, the result is merely a garbage value being printed. The KCSAN report confirms this: the value changes from one read to the next, which is exactly what we expect from a data race on a primitive type like this.
Okay, I've got a clear picture of what's going on here. Time to fill out the results.
|
| 56/2 |
2026/05/23 11:37 |
tool |
set-results |
0m
Args: map[DenialOfService:false Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:false Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 57/2 |
2026/05/23 11:37 |
llm |
expert |
0m
Model:
Tokens:
input: 15578
output: 383
thoughts: 179
Thoughts: **Analyzing a Benign KCSAN Data-Race Report**
Okay, so I've got this KCSAN data-race report to look at. The core of it seems to be between the `hrtimer_interrupt` function, which is writing to `cpu_base->expires_next`, and `print_cpu`, which is reading it. `print_cpu` gets called when we look at `/proc/timer_list` or when SysRq-Q is triggered. The crucial thing here is that `/proc/timer_list` is created with mode 0400, meaning it's only readable by root. That immediately limits the scope; unprivileged users and user namespaces can't even get to this data.
Given that restriction, this data race is basically harmless. `print_cpu` is just reading the value to then print it to a sequential file. Even if it gets a torn read or some intermediate value, the worst that happens is a bit of garbage gets printed. It's not exploitable, there's no way this turns into a denial-of-service, and it has no security ramifications. I'll document my analysis to be thorough and state this clearly.
|
| 58/1 |
2026/05/23 11:37 |
action |
format-explanation |
0m
Results: map[Explanation:The reported bug is a KCSAN data-race between a write to
`cpu_base->expires_next` in `hrtimer_interrupt` and a read of the same variable
in `print_cpu`.
**Analysis:**
1. **Trigger mechanism:** The read occurs in `print_cpu`, which is invoked by
`timer_list_show`. This function is executed when reading the `/proc/timer_list`
file or when triggering the SysRq-Q command.
2. **Privilege level:** The `/proc/timer_list` file is created with `0400`
permissions (`proc_create_seq_private("timer_list", 0400, ...)`), meaning it is
only readable by the global root user. Unprivileged users cannot read it.
Furthermore, it is not accessible from within an unprivileged user namespace
because the file is owned by the global root (UID 0), which is not mapped into
the user namespace, preventing `CAP_DAC_OVERRIDE` from bypassing the permission
check. SysRq triggers also require root privileges (writing to
`/proc/sysrq-trigger`) or physical access.
3. **Impact:** The data race is completely benign. `print_cpu` reads the 8-byte
`expires_next` value locklessly simply to print it for diagnostic purposes. If a
concurrent write occurs, the read might fetch an intermediate or torn value,
which would merely result in a garbage timestamp being printed to the seq_file.
This cannot cause memory corruption, control-flow hijacking, kernel crashes, or
any form of denial-of-service.
**Conclusion:**
This is a benign diagnostic data race restricted to the root user. It has no
security impact, is not exploitable, and cannot be triggered by unprivileged
users, network traffic, or other external vectors.]
|