| 0/0 |
2026/05/12 23:19 |
flow |
assessment-security |
40m
Results: map[DenialOfService:true Explanation:**Analysis of the Bug**
The bug is a counter leak in the AFS (Andrew File System) client code,
specifically in `afs_alloc_cell()` located in `fs/afs/cell.c`.
When a new AFS cell is allocated, the function increments the
`net->cells_outstanding` counter before attempting to allocate an ID for the
cell using `idr_alloc_cyclic()`:
```c
atomic_inc(&net->cells_outstanding);
ret = idr_alloc_cyclic(&net->cells_dyn_ino, cell,
2, INT_MAX / 2, GFP_KERNEL);
if (ret < 0)
goto error;
```
If `idr_alloc_cyclic()` fails (for example, due to memory pressure returning
`-ENOMEM`), the code jumps to the `error` label where it frees the partially
constructed cell and returns an error. However, it fails to decrement the
`net->cells_outstanding` counter, permanently leaking the reference.
When a network namespace is destroyed, `cleanup_net()` is executed on the global
`netns_wq` workqueue. This calls `afs_net_exit()`, which in turn calls
`afs_cell_purge()`. `afs_cell_purge()` waits for all outstanding cells to be
destroyed by waiting for `net->cells_outstanding` to reach 0:
```c
wait_var_event(&net->cells_outstanding,
!atomic_read(&net->cells_outstanding));
```
Because of the leaked counter, this condition will never be met, causing
`afs_cell_purge()` to hang indefinitely. Since `cleanup_net()` processes all
network namespace cleanups sequentially on a single-threaded workqueue, this
hang completely blocks the destruction of any other network namespaces on the
system, resulting in a system-wide Denial of Service (DoS) and resource
exhaustion.
**Triggering the Bug**
An unprivileged user can trigger this bug by creating a new user namespace and a
corresponding network namespace. Within their own network namespace, they gain
root privileges, which grants them write access to `/proc/net/afs/cells`.
By writing to this proc file (e.g., `echo "add mycell 1.2.3.4" >
/proc/net/afs/cells`), the user can trigger `afs_lookup_cell()` and subsequently
`afs_alloc_cell()`. By constraining their process using a memory cgroup with a
low limit or by generating severe memory pressure, they can force the
`idr_alloc_cyclic()` call (which uses `GFP_KERNEL`) to fail. Once the leak
occurs, the user simply exits the namespace, triggering the cleanup routine and
hanging the `netns_wq` workqueue.
The provided syzkaller reproducer triggers this via a different path: it mounts
an AFS filesystem with the `dyn` (dynamic root) option and performs a lookup for
a non-existent file (`"cpuacct.usage_user"`). In a dynamic root, lookups
automatically attempt to create a cell with the given name. The reproducer uses
fault injection (`inject_fault(10)`) to artificially fail the
`idr_alloc_cyclic()` allocation, achieving the exact same leak.
**Security Impact**
- **Exploitable:** No. This is a pure logic bug (counter leak) leading to a
hang. It does not cause memory corruption, use-after-free, or out-of-bounds
accesses, so it cannot be exploited for privilege escalation.
- **Denial of Service:** Yes. It permanently hangs the global network namespace
cleanup workqueue.
- **Accessible From Unprivileged Processes / User Namespaces:** Yes.
Unprivileged users can create user/network namespaces and interact with
`/proc/net/afs/cells` to trigger the bug. Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/05/12 23:19 |
action |
syz-repro-to-c-repro |
0m
Results: map[SimplifiedCRepro:// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/loop.h>
#ifndef __NR_memfd_create
#define __NR_memfd_create 319
#endif
static unsigned long long procid;
static bool write_file(const char* file, const char* what, ...)
{
char buf[1024];
va_list args;
va_start(args, what);
vsnprintf(buf, sizeof(buf), what, args);
va_end(args);
buf[sizeof(buf) - 1] = 0;
int len = strlen(buf);
int fd = open(file, O_WRONLY | O_CLOEXEC);
if (fd == -1)
return false;
if (write(fd, buf, len) != len) {
int err = errno;
close(fd);
errno = err;
return false;
}
close(fd);
return true;
}
//% This code is derived from puff.{c,h}, found in the zlib development. The
//% original files come with the following copyright notice:
//% Copyright (C) 2002-2013 Mark Adler, all rights reserved
//% version 2.3, 21 Jan 2013
//% This software is provided 'as-is', without any express or implied
//% warranty. In no event will the author be held liable for any damages
//% arising from the use of this software.
//% Permission is granted to anyone to use this software for any purpose,
//% including commercial applications, and to alter it and redistribute it
//% freely, subject to the following restrictions:
//% 1. The origin of this software must not be misrepresented; you must not
//% claim that you wrote the original software. If you use this software
//% in a product, an acknowledgment in the product documentation would be
//% appreciated but is not required.
//% 2. Altered source versions must be plainly marked as such, and must not be
//% misrepresented as being the original software.
//% 3. This notice may not be removed or altered from any source distribution.
//% Mark Adler madler@alumni.caltech.edu
//% BEGIN CODE DERIVED FROM puff.{c,h}
#define MAXBITS 15
#define MAXLCODES 286
#define MAXDCODES 30
#define MAXCODES (MAXLCODES + MAXDCODES)
#define FIXLCODES 288
struct puff_state {
unsigned char* out;
unsigned long outlen;
unsigned long outcnt;
const unsigned char* in;
unsigned long inlen;
unsigned long incnt;
int bitbuf;
int bitcnt;
jmp_buf env;
};
static int puff_bits(struct puff_state* s, int need)
{
long val = s->bitbuf;
while (s->bitcnt < need) {
if (s->incnt == s->inlen)
longjmp(s->env, 1);
val |= (long)(s->in[s->incnt++]) << s->bitcnt;
s->bitcnt += 8;
}
s->bitbuf = (int)(val >> need);
s->bitcnt -= need;
return (int)(val & ((1L << need) - 1));
}
static int puff_stored(struct puff_state* s)
{
s->bitbuf = 0;
s->bitcnt = 0;
if (s->incnt + 4 > s->inlen)
return 2;
unsigned len = s->in[s->incnt++];
len |= s->in[s->incnt++] << 8;
if (s->in[s->incnt++] != (~len & 0xff) ||
s->in[s->incnt++] != ((~len >> 8) & 0xff))
return -2;
if (s->incnt + len > s->inlen)
return 2;
if (s->outcnt + len > s->outlen)
return 1;
for (; len--; s->outcnt++, s->incnt++) {
if (s->in[s->incnt])
s->out[s->outcnt] = s->in[s->incnt];
}
return 0;
}
struct puff_huffman {
short* count;
short* symbol;
};
static int puff_decode(struct puff_state* s, const struct puff_huffman* h)
{
int first = 0;
int index = 0;
int bitbuf = s->bitbuf;
int left = s->bitcnt;
int code = first = index = 0;
int len = 1;
short* next = h->count + 1;
while (1) {
while (left--) {
code |= bitbuf & 1;
bitbuf >>= 1;
int count = *next++;
if (code - count < first) {
s->bitbuf = bitbuf;
s->bitcnt = (s->bitcnt - len) & 7;
return h->symbol[index + (code - first)];
}
index += count;
first += count;
first <<= 1;
code <<= 1;
len++;
}
left = (MAXBITS + 1) - len;
if (left == 0)
break;
if (s->incnt == s->inlen)
longjmp(s->env, 1);
bitbuf = s->in[s->incnt++];
if (left > 8)
left = 8;
}
return -10;
}
static int puff_construct(struct puff_huffman* h, const short* length, int n)
{
int len;
for (len = 0; len <= MAXBITS; len++)
h->count[len] = 0;
int symbol;
for (symbol = 0; symbol < n; symbol++)
(h->count[length[symbol]])++;
if (h->count[0] == n)
return 0;
int left = 1;
for (len = 1; len <= MAXBITS; len++) {
left <<= 1;
left -= h->count[len];
if (left < 0)
return left;
}
short offs[MAXBITS + 1];
offs[1] = 0;
for (len = 1; len < MAXBITS; len++)
offs[len + 1] = offs[len] + h->count[len];
for (symbol = 0; symbol < n; symbol++)
if (length[symbol] != 0)
h->symbol[offs[length[symbol]]++] = symbol;
return left;
}
static int puff_codes(struct puff_state* s,
const struct puff_huffman* lencode,
const struct puff_huffman* distcode)
{
static const short lens[29] = {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258};
static const short lext[29] = {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0};
static const short dists[30] = {
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577};
static const short dext[30] = {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
12, 12, 13, 13};
int symbol;
do {
symbol = puff_decode(s, lencode);
if (symbol < 0)
return symbol;
if (symbol < 256) {
if (s->outcnt == s->outlen)
return 1;
if (symbol)
s->out[s->outcnt] = symbol;
s->outcnt++;
} else if (symbol > 256) {
symbol -= 257;
if (symbol >= 29)
return -10;
int len = lens[symbol] + puff_bits(s, lext[symbol]);
symbol = puff_decode(s, distcode);
if (symbol < 0)
return symbol;
unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]);
if (dist > s->outcnt)
return -11;
if (s->outcnt + len > s->outlen)
return 1;
while (len--) {
if (dist <= s->outcnt && s->out[s->outcnt - dist])
s->out[s->outcnt] = s->out[s->outcnt - dist];
s->outcnt++;
}
}
} while (symbol != 256);
return 0;
}
static int puff_fixed(struct puff_state* s)
{
static int virgin = 1;
static short lencnt[MAXBITS + 1], lensym[FIXLCODES];
static short distcnt[MAXBITS + 1], distsym[MAXDCODES];
static struct puff_huffman lencode, distcode;
if (virgin) {
lencode.count = lencnt;
lencode.symbol = lensym;
distcode.count = distcnt;
distcode.symbol = distsym;
short lengths[FIXLCODES];
int symbol;
for (symbol = 0; symbol < 144; symbol++)
lengths[symbol] = 8;
for (; symbol < 256; symbol++)
lengths[symbol] = 9;
for (; symbol < 280; symbol++)
lengths[symbol] = 7;
for (; symbol < FIXLCODES; symbol++)
lengths[symbol] = 8;
puff_construct(&lencode, lengths, FIXLCODES);
for (symbol = 0; symbol < MAXDCODES; symbol++)
lengths[symbol] = 5;
puff_construct(&distcode, lengths, MAXDCODES);
virgin = 0;
}
return puff_codes(s, &lencode, &distcode);
}
static int puff_dynamic(struct puff_state* s)
{
static const short order[19] =
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
int nlen = puff_bits(s, 5) + 257;
int ndist = puff_bits(s, 5) + 1;
int ncode = puff_bits(s, 4) + 4;
if (nlen > MAXLCODES || ndist > MAXDCODES)
return -3;
short lengths[MAXCODES];
int index;
for (index = 0; index < ncode; index++)
lengths[order[index]] = puff_bits(s, 3);
for (; index < 19; index++)
lengths[order[index]] = 0;
short lencnt[MAXBITS + 1], lensym[MAXLCODES];
struct puff_huffman lencode = {lencnt, lensym};
int err = puff_construct(&lencode, lengths, 19);
if (err != 0)
return -4;
index = 0;
while (index < nlen + ndist) {
int symbol;
int len;
symbol = puff_decode(s, &lencode);
if (symbol < 0)
return symbol;
if (symbol < 16)
lengths[index++] = symbol;
else {
len = 0;
if (symbol == 16) {
if (index == 0)
return -5;
len = lengths[index - 1];
symbol = 3 + puff_bits(s, 2);
} else if (symbol == 17)
symbol = 3 + puff_bits(s, 3);
else
symbol = 11 + puff_bits(s, 7);
if (index + symbol > nlen + ndist)
return -6;
while (symbol--)
lengths[index++] = len;
}
}
if (lengths[256] == 0)
return -9;
err = puff_construct(&lencode, lengths, nlen);
if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1]))
return -7;
short distcnt[MAXBITS + 1], distsym[MAXDCODES];
struct puff_huffman distcode = {distcnt, distsym};
err = puff_construct(&distcode, lengths + nlen, ndist);
if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1]))
return -8;
return puff_codes(s, &lencode, &distcode);
}
static int puff(
unsigned char* dest,
unsigned long* destlen,
const unsigned char* source,
unsigned long sourcelen)
{
struct puff_state s = {
.out = dest,
.outlen = *destlen,
.outcnt = 0,
.in = source,
.inlen = sourcelen,
.incnt = 0,
.bitbuf = 0,
.bitcnt = 0,
};
int err;
if (setjmp(s.env) != 0)
err = 2;
else {
int last;
do {
last = puff_bits(&s, 1);
int type = puff_bits(&s, 2);
err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1));
if (err != 0)
break;
} while (!last);
}
*destlen = s.outcnt;
return err;
}
//% END CODE DERIVED FROM puff.{c,h}
#define ZLIB_HEADER_WIDTH 2
static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd)
{
if (sourcelen < ZLIB_HEADER_WIDTH)
return 0;
source += ZLIB_HEADER_WIDTH;
sourcelen -= ZLIB_HEADER_WIDTH;
const unsigned long max_destlen = 132 << 20;
void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
if (ret == MAP_FAILED)
return -1;
unsigned char* dest = (unsigned char*)ret;
unsigned long destlen = max_destlen;
int err = puff(dest, &destlen, source, sourcelen);
if (err) {
munmap(dest, max_destlen);
errno = -err;
return -1;
}
if (write(dest_fd, dest, destlen) != (ssize_t)destlen) {
munmap(dest, max_destlen);
return -1;
}
return munmap(dest, max_destlen);
}
static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p)
{
int err = 0, loopfd = -1;
int memfd = syscall(__NR_memfd_create, "syzkaller", 0);
if (memfd == -1) {
err = errno;
goto error;
}
if (puff_zlib_to_file(data, size, memfd)) {
err = errno;
goto error_close_memfd;
}
loopfd = open(loopname, O_RDWR);
if (loopfd == -1) {
err = errno;
goto error_close_memfd;
}
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
if (errno != EBUSY) {
err = errno;
goto error_close_loop;
}
ioctl(loopfd, LOOP_CLR_FD, 0);
usleep(1000);
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
err = errno;
goto error_close_loop;
}
}
close(memfd);
*loopfd_p = loopfd;
return 0;
error_close_loop:
close(loopfd);
error_close_memfd:
close(memfd);
error:
errno = err;
return -1;
}
static void reset_loop_device(const char* loopname)
{
int loopfd = open(loopname, O_RDWR);
if (loopfd == -1) {
return;
}
if (ioctl(loopfd, LOOP_CLR_FD, 0)) {
}
close(loopfd);
}
static long syz_mount_image(
volatile long fsarg,
volatile long dir,
volatile long flags,
volatile long optsarg,
volatile long change_dir,
volatile unsigned long size,
volatile long image)
{
unsigned char* data = (unsigned char*)image;
int res = -1, err = 0, need_loop_device = !!size;
char* mount_opts = (char*)optsarg;
char* target = (char*)dir;
char* fs = (char*)fsarg;
char* source = NULL;
char loopname[64];
if (need_loop_device) {
int loopfd;
memset(loopname, 0, sizeof(loopname));
snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid);
if (setup_loop_device(data, size, loopname, &loopfd) == -1)
return -1;
close(loopfd);
source = loopname;
}
mkdir(target, 0777);
char opts[256];
memset(opts, 0, sizeof(opts));
if (strlen(mount_opts) > (sizeof(opts) - 32)) {
}
strncpy(opts, mount_opts, sizeof(opts) - 32);
if (strcmp(fs, "iso9660") == 0) {
flags |= MS_RDONLY;
} else if (strncmp(fs, "ext", 3) == 0) {
bool has_remount_ro = false;
char* remount_ro_start = strstr(opts, "errors=remount-ro");
if (remount_ro_start != NULL) {
char after = *(remount_ro_start + strlen("errors=remount-ro"));
char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1);
has_remount_ro = ((before == '\0' || before == ',') && (after == '\0' || after == ','));
}
if (strstr(opts, "errors=panic") || !has_remount_ro)
strcat(opts, ",errors=continue");
} else if (strcmp(fs, "xfs") == 0) {
strcat(opts, ",nouuid");
} else if (strncmp(fs, "gfs2", 4) == 0 && (strstr(opts, "errors=panic") || strstr(opts, "debug"))) {
strcat(opts, ",errors=withdraw");
}
res = mount(source, target, fs, flags, opts);
if (res == -1) {
err = errno;
goto error_clear_loop;
}
res = open(target, O_RDONLY | O_DIRECTORY);
if (res == -1) {
err = errno;
goto error_clear_loop;
}
if (change_dir) {
res = chdir(target);
if (res == -1) {
err = errno;
}
}
error_clear_loop:
if (need_loop_device)
reset_loop_device(loopname);
errno = err;
return res;
}
static int inject_fault(int nth)
{
int fd;
fd = open("/proc/thread-self/fail-nth", O_RDWR);
if (fd == -1)
exit(1);
char buf[16];
sprintf(buf, "%d", nth);
if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
exit(1);
return fd;
}
static const char* setup_fault()
{
int fd = open("/proc/self/make-it-fail", O_WRONLY);
if (fd == -1)
return "CONFIG_FAULT_INJECTION is not enabled";
close(fd);
fd = open("/proc/thread-self/fail-nth", O_WRONLY);
if (fd == -1)
return "kernel does not have systematic fault injection support";
close(fd);
static struct {
const char* file;
const char* val;
bool fatal;
} files[] = {
{"/sys/kernel/debug/failslab/ignore-gfp-wait", "N", true},
{"/sys/kernel/debug/fail_futex/ignore-private", "N", false},
{"/sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem", "N", false},
{"/sys/kernel/debug/fail_page_alloc/ignore-gfp-wait", "N", false},
{"/sys/kernel/debug/fail_page_alloc/min-order", "0", false},
};
unsigned i;
for (i = 0; i < sizeof(files) / sizeof(files[0]); i++) {
if (!write_file(files[i].file, files[i].val)) {
if (files[i].fatal)
return "failed to write fault injection file";
}
}
return NULL;
}
uint64_t r[1] = {0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
if ((reason = setup_fault()))
printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason);
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_mount_image$nilfs2 arguments: [
// fs: ptr[in, buffer] {
// buffer: {6e 69 6c 66 73 32 00} (length 0x7)
// }
// dir: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 33 00} (length 0x8)
// }
// flags: mount_flags = 0x0 (8 bytes)
// opts: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// }
// }
// chdir: int8 = 0x1 (1 bytes)
// size: len = 0xae1 (8 bytes)
// img: ptr[in, buffer] {
// buffer: (compressed buffer with length 0xae1)
// }
// ]
// returns fd_dir
memcpy((void*)0x200000000780, "nilfs2\000", 7);
memcpy((void*)0x200000000300, "./file3\000", 8);
memcpy((void*)0x200000000940, "\x78\x9c\xec\xdd\x5d\x88\x5c\x57\x01\x00\xe0\x73\x77\x77\x36\xbb\x69\x6b\xa6\x35\xb5\x6b\x1a\xdb\xa4\xd5\xb6\xfe\x74\xd3\x6c\xd6\xf8\x13\x34\x29\x09\x82\xa1\x29\xe2\x4b\xa1\xf8\x12\xd2\xb4\x06\x63\x04\x2b\xa8\xa5\xd0\x24\x4f\xbe\xd9\x52\x52\xf0\xc9\x1f\x7c\xea\x4b\xa9\x22\x58\x10\x09\x7d\xf2\xa5\x60\x03\x45\xe8\x53\x15\xf4\xa1\x21\x62\xc1\x87\x1a\x4d\x46\x76\xe7\x9c\x99\x3b\x27\x33\x99\x9d\xfd\x99\xbb\xbb\xf3\x7d\x70\xf7\xcc\xb9\xe7\xdc\x39\xe7\xce\xde\xb9\x73\xff\xce\x39\x01\x18\x59\x63\x8b\x7f\xe7\xe7\x67\x8a\x10\x2e\xbc\xf1\xf2\x91\xf7\x1f\xf8\xc7\xf4\xc2\x9c\x83\xad\x1c\xf5\xc5\xbf\x13\xa5\x58\x2d\x84\x50\xc4\xf8\x44\xf6\x7e\xef\x8d\x37\xc3\x6b\x1f\x3c\x7f\xa2\x5b\x58\x84\xb9\xc5\xbf\x29\x1e\x1e\xbf\xd2\x5a\xf6\x96\x10\xc2\xd9\xb0\x2b\x5c\x0c\xf5\xb0\xe3\xc2\xa5\x97\xde\x9a\x7b\xec\xd8\xb9\xa3\xe7\x77\xbf\xfd\xea\x81\xcb\x6b\xb3\xf6\x00\x00\x30\x5a\xbe\x71\xf1\xc0\xfc\x9d\x7f\xfd\xf3\xdd\xb7\x5f\x7d\xed\x9e\x43\x61\x4b\x6b\x7e\x3a\x3e\xaf\xa7\x19\x53\xcd\xe3\xfe\x43\xf1\xc0\x3f\x1d\xff\x8f\x85\xce\x78\x51\x9a\xca\x26\xb3\x7c\x13\x71\x1a\x9b\xee\xcc\x37\xde\x25\x5f\xb9\x9c\x5a\x96\x6f\xa2\x47\xf9\x93\x59\xf9\xb5\x1e\xf9\xb6\x84\x9b\x97\x3f\x5e\x9a\xd7\x6d\xbd\x61\x23\x4b\xdb\x71\x3d\x14\x63\xb3\x21\x84\xad\xad\xf8\xd8\xd8\xec\x6c\xf3\x9c\x3c\x2c\x9e\xd7\x4f\x16\xb3\x67\x4e\x9d\x7e\xfa\xd9\x8a\x2a\x0a\xac\xba\x7f\xdf\x1b\x42\xd8\x55\x9a\x0e\x9f\xef\x8c\xaf\xb7\xe9\xe0\x3a\xa8\xc3\x32\xa7\xc6\x3a\xa8\xc3\x86\x9c\x0e\x0d\xaf\xac\xab\x8d\xa6\xca\xd7\x79\x48\x53\x63\x5b\xd5\x7b\x20\x80\xa6\xfc\x7e\xe1\x0d\xce\xe6\x57\x16\x56\xa6\xf5\x6e\x13\x4b\x2b\xff\xca\xa3\x63\xdd\x97\x87\x55\x30\xec\xed\x7f\xa0\xf2\x27\x2b\x2e\x3f\x28\xff\xd7\xe7\xec\x71\x58\x3d\x9b\x75\x6b\x4a\xeb\x95\xbe\x47\xb7\xc6\x78\x7e\x1f\x21\x7f\x7e\xe9\x95\x3f\x74\x2e\xd7\x96\xdf\xe9\xe8\x9c\x9b\xdf\x8f\xa8\x2d\xb1\x9e\xbd\xee\x23\x6c\x94\xfb\x0b\xbd\xea\x39\x3e\xe4\x7a\x2c\x57\xaf\xfa\xe7\xdb\xc5\x66\xf5\x95\x18\xa6\xcf\xe1\xab\x1d\xa9\xf7\x76\x7c\x7f\xf2\xff\xe9\x46\xf9\x1f\x03\xdd\x7d\x98\x5f\xff\x37\x99\x4c\xeb\x7b\x0a\x1d\xf1\xda\x4a\xde\xab\x51\xf1\xfe\x07\x58\xbf\xf2\xe7\xe6\x1a\xe9\xfe\x68\x94\x3f\xd7\x97\xa7\x6f\xe9\x93\x3e\xd5\x27\x7d\xba\x4f\xfa\xd6\x3e\xe9\xb7\xf4\x49\x87\x51\xf6\xdb\x1f\xfc\x34\xbc\x58\xb4\xaf\x77\xe5\xe7\xf4\x83\x5e\x0f\x4f\xd7\xd9\x6e\x8b\xe1\x47\x06\xac\x4f\x7e\x3d\x72\xd0\xf2\xf3\xe7\x7e\x07\xb5\xd2\xf2\xf3\xe7\x89\x61\x3d\xfb\xfd\xf1\x27\x4e\x7e\xf1\xa9\x27\x2f\x35\x9f\xff\x2f\x5a\xdb\xff\xf5\xb8\xbd\xa7\xd3\x8d\x7a\xfc\x6e\x5d\x8c\x19\xd2\xf5\xc2\xfc\xba\x7a\xeb\xd9\xff\x7a\x67\x39\x63\x3d\xf2\xdd\x91\xd5\xe7\xb6\x2e\xf9\x17\x5f\x6f\xef\xcc\x57\x6c\x6f\xbf\x4f\x28\xed\x67\x6e\xa8\xc7\x4c\xe7\x72\xdb\x7a\xe5\xdb\xd9\x99\xaf\x9e\xe5\x9b\x8e\xd3\x54\x56\xdf\xfc\xf8\x64\x6b\xb6\x5c\x3a\xfe\x48\xfb\xd5\xf4\x79\x4d\x64\xeb\x5b\xcb\xd6\x63\x32\xab\x47\xda\xaf\xdc\x1e\xc3\xbc\x1e\xb0\x1c\x69\x7b\x4c\xcf\xff\xb7\xdb\x03\x34\x9f\xff\x4f\xdb\xe7\x4c\xa8\x15\x4f\x9f\x3a\x7d\xf2\x91\x18\x4f\xdb\xe9\x9f\xc6\x6b\x5b\x16\xe6\xef\x1d\x72\xbd\x81\xd5\xd3\xeb\xfb\x9f\x7e\xbf\x66\x42\x67\xfb\x9f\x5b\x5b\xf3\x6b\x63\xe5\xfd\xc2\xb6\xf6\xfc\xa2\xb9\x5f\x78\x3d\xbe\x5f\xe7\xfc\xb9\x56\x39\xa5\xf9\xa5\x1f\xb5\xf4\x3b\xf7\xed\xf1\xe9\xc5\xfc\xb3\x27\xbe\x77\xfa\xa9\x35\x58\x6f\x18\x65\xcf\xfe\xf8\xb9\xef\x1c\x3f\x7d\xfa\xe4\xf7\xbd\x58\xf6\x8b\xaf\xad\x8f\x6a\x0c\xf2\x22\x9d\xb6\xac\x97\xfa\x78\x31\xe8\x8b\x5d\x6b\x5d\x44\xc5\x3b\x26\x60\xcd\xed\x79\xa1\x79\x10\xf0\xf0\xa9\xef\x1e\x7f\xe6\xe4\x33\x27\xcf\xec\xdb\xbf\x7f\xdf\xdc\xdc\xfe\x2f\xed\x9b\xdf\xb3\x78\x5c\xbf\xa7\x7c\x74\x5f\x76\xb6\x82\xda\x02\xab\xa9\xfd\xa3\x5f\x75\x4d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xa5\xfa\xe1\xd1\x23\x97\xde\x79\xf3\x0b\xef\x36\xdb\xff\xb7\xdb\xff\xa5\xf6\xff\xe9\xc9\xdf\xd4\xfe\xff\x27\x59\xfb\xff\xbc\x9d\x7c\x6a\x07\x9f\xda\x01\xde\xde\x25\x7d\x31\x4f\xd6\xc1\xea\x64\x96\xaf\x16\xa7\x8f\x66\xf5\x4d\xdd\x00\x14\x2f\x34\xc3\x3b\xb3\xe5\x3e\x16\xc3\xd6\x38\x7e\xb1\xfd\x7f\x2a\x2e\xef\xd7\x35\xd5\xe7\xae\x6c\x7e\xad\x47\x34\xeb\x4e\xe0\x86\xfe\x52\x26\xb3\x3e\x48\xf2\xf1\x02\xef\x8b\xe1\xf9\x18\xfe\x2a\x40\x85\x8a\xe9\xee\xb3\x63\x78\x93\xfe\xad\x8b\x0f\x4b\xdb\x7a\xea\x9f\xa2\xd4\x84\xb7\xa1\x7f\xe0\x8d\x23\xfd\xdf\xf2\xfe\x8b\x52\xfb\xef\xae\xfd\x3a\x75\x69\xaf\xcd\xc6\x32\x8c\x16\x8b\x55\xaf\x23\xd0\xdd\x3f\x47\xaa\xff\xef\x7f\xb5\x57\xbc\xf2\xba\x98\x7a\x4f\x13\xc3\x2d\xef\x67\xa3\xbb\x4d\x34\x7a\x1e\xa5\x2f\x75\x04\x1b\x80\xd5\x51\xf5\xf8\x9f\x7f\x0f\xcd\x72\xd3\xf5\xcf\x33\x7f\xfc\xfa\xd4\xc2\x94\xb2\x5d\x79\xb4\x73\x7f\x99\xf7\x5f\x0a\x83\xf8\xcb\x3b\x9d\xf1\xf5\x3e\xfe\xe4\x5a\x97\x9f\x8f\xdb\x37\xec\xf2\xab\x5e\xff\x61\x8f\xff\xd9\x1a\xff\x2e\xee\xff\xd2\x7e\xaf\xf7\xfe\x2f\x1b\x31\xaf\xbe\xbc\x72\xff\xf3\xf3\xcb\xef\x96\x8a\x0d\x3b\x96\x5a\x7e\xbe\xfe\xa9\x1f\xe8\xed\x83\x95\x7f\x35\x96\x9f\xd6\xe6\xc1\xb0\xb4\xf2\x1b\xbf\xcc\xca\xcf\x6f\x08\x2d\xd1\x7f\xb3\xf2\xb7\x2e\xb1\xfc\x1b\xd6\x7f\xe7\xf2\xca\xff\x5f\x2c\x3f\x7d\x6c\x0f\xdd\xbf\xd4\xf2\x9b\x35\x2e\xc6\x3a\xeb\x31\x9d\xad\x47\xba\xff\x97\x5f\x37\x4e\xae\x65\xeb\x9f\xfa\xf6\xbc\x49\xf9\xdf\x7c\xae\xdb\xfa\x2f\x73\xa0\xc6\xeb\xb1\x7c\x18\x65\x1b\x65\x9c\xd9\x41\x65\xc7\x11\xad\x83\xf6\x7e\xe3\xff\x0e\xfa\xfb\xbf\xd2\xf1\x7f\x5b\x95\xcd\x76\x6b\xf9\x73\x18\x9f\x8f\xf1\xb4\x23\x4e\xcf\x39\xe4\xe3\x9d\x0c\x5a\xff\xf4\x7c\x45\xfa\x1d\xb8\x33\x7b\xff\xa2\xcf\xef\x9b\xf1\x7f\x37\xb6\x2f\xc7\xb0\xdf\xf7\x21\x8d\xff\x9b\xb6\xc7\x7a\xfc\xc9\x2f\xc5\x17\x3f\xcb\x14\xaf\x75\xf9\x6c\x37\xeb\xbe\x06\x36\xaa\xf7\x46\xea\xfe\xdf\xb0\xa6\xcb\xcd\xd3\xa0\xe5\x2d\x3f\x55\x7d\xfd\x47\x6a\x1a\x5f\xc1\xff\x6a\x61\x6a\x8c\x2f\x63\xb9\xd6\x73\x56\x15\xaf\x7f\xa3\xd1\x58\xdb\x0b\x5a\x7d\x54\x5a\x38\x95\x7f\xfe\x55\xdf\x7d\xae\xfa\x3c\xe5\xbe\x8a\xcb\xef\x27\x1f\xff\x37\x3f\x86\xcf\xc7\xff\xcd\xd3\xf3\xf1\x7f\xf3\xf4\x7c\xfc\xdf\x3c\x7d\x3a\xfe\x87\xde\xef\x91\x9e\x8f\xff\x9b\x6f\xcf\xf9\xf8\xbf\x79\xfa\x5d\xd9\xfb\xe6\xe3\x03\xcf\xf4\x49\xff\x78\x97\xf4\x22\xb4\xd3\x77\x74\x5f\xbe\x75\xda\x7e\x77\x9f\xf7\xdf\xd9\x27\xfd\x13\x7d\xd2\x77\xb7\xd2\x0f\x76\xe4\x48\xe9\xf7\xdc\x74\xf9\x76\xbe\x5e\xef\x7f\x47\x9f\xf4\xfb\xfb\xa4\x7f\xb2\x4f\xfa\xa7\xfa\xa4\x3f\xd0\x27\xfd\xa1\x52\x7a\x79\x0c\xe8\x94\xfe\xe9\x6c\xf9\x22\x4b\xdf\xec\xd2\xfe\xa7\xd7\xe7\x07\x6c\x5e\x79\xfb\x3c\xdf\x7f\x18\x1d\xe9\xfe\x4f\xaf\xef\xff\xf6\x76\xfa\x64\x39\xcb\x70\x6b\x09\xac\x85\x57\x5e\xdb\x7b\xf8\xc9\xdf\x7c\xab\xde\x6c\xff\x3f\xd9\xba\x1e\x92\xee\xe3\x1d\x8a\xf1\x5a\x3c\x37\xfa\x51\x8c\xe7\xf7\xbd\x43\x29\xbe\x90\xf6\x66\x8c\xff\x2d\x4b\xaf\xfa\x7a\x13\xd0\x96\xf7\x9f\x91\xff\xfe\x3f\xd8\x27\x1d\xd8\xb8\xd2\x73\x5e\xbe\xdf\x30\x82\x8a\xa9\xee\xb3\x63\xd8\xaf\xdf\xaa\x5e\xc7\xf9\x6c\x2c\x9f\x89\xe1\x67\x63\xf8\xb9\x18\x3e\x1c\xc3\xd9\x18\xee\x89\xe1\xde\x18\xce\x0d\xa9\x7e\xac\x8d\xc3\xaf\xff\xee\xc0\x8b\x45\xfb\x7c\x7f\x5b\x96\xbe\xd4\xe7\xc9\xf3\xf6\x40\x1d\xfd\x44\x85\x10\xf6\x2d\xb1\x3e\xf9\xf5\x81\x41\x9f\x67\xcf\xfb\xf1\x1b\xd4\x4a\xcb\x5f\x66\x73\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xca\x8c\x2d\xfe\x9d\x9f\x9f\x29\x42\xb8\xf0\xc6\xcb\x47\x9e\x38\x76\x6a\xcf\xc2\x9c\x83\xad\x1c\xf5\xc5\xbf\x13\xa5\x58\xad\xb5\x5c\x08\x8f\xc4\x70\x3c\x86\xbf\x88\x2f\xae\x7d\xf0\xfc\x89\x72\x78\x3d\x86\x45\x98\x0b\x45\x28\x5a\xf3\xc3\xe3\x57\x5a\x25\xdd\x12\x42\x38\x1b\x76\x85\x8b\xa1\x1e\x76\x5c\xb8\xf4\xd2\x5b\x73\x8f\x1d\x3b\x77\xf4\xfc\xee\xb7\x5f\x3d\x70\x79\xed\x3e\x01\x00\x00\x00\xd8\xfc\xfe\x1f\x00\x00\xff\xff\x94\xfa\x07\x1c", 2785);
syz_mount_image(/*fs=*/0x200000000780, /*dir=*/0x200000000300, /*flags=*/0, /*opts=*/0x200000001040, /*chdir=*/1, /*size=*/0xae1, /*img=*/0x200000000940);
// mount$afs arguments: [
// src: nil
// dst: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8)
// }
// type: ptr[in, buffer] {
// buffer: {61 66 73 00} (length 0x4)
// }
// flags: mount_flags = 0x0 (8 bytes)
// opts: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {64 79 6e} (length 0x3)
// }
// }
// }
// ]
memcpy((void*)0x2000000001c0, "./file0\000", 8);
memcpy((void*)0x2000000002c0, "afs\000", 4);
memcpy((void*)0x200000000200, "dyn", 3);
syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x2000000001c0ul, /*type=*/0x2000000002c0ul, /*flags=*/0ul, /*opts=*/0x200000000200ul);
// chdir arguments: [
// dir: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8)
// }
// ]
memcpy((void*)0x2000000000c0, "./file0\000", 8);
syscall(__NR_chdir, /*dir=*/0x2000000000c0ul);
// openat arguments: [
// fd: fd_dir (resource)
// file: ptr[in, buffer] {
// buffer: {2e 00} (length 0x2)
// }
// flags: open_flags = 0x0 (4 bytes)
// mode: open_mode = 0x0 (2 bytes)
// ]
// returns fd
memcpy((void*)0x200000000040, ".\000", 2);
res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000040ul, /*flags=*/0, /*mode=*/0);
if (res != -1)
r[0] = res;
// openat$cgroup_ro arguments: [
// fd: fd_cgroup (resource)
// file: ptr[in, buffer] {
// buffer: {63 70 75 61 63 63 74 2e 75 73 61 67 65 5f 75 73 65 72 00} (length 0x13)
// }
// flags: const = 0x0 (4 bytes)
// mode: const = 0x0 (2 bytes)
// ]
// returns fd
memcpy((void*)0x200000000000, "cpuacct.usage_user\000", 19);
inject_fault(10);
syscall(__NR_openat, /*fd=*/r[0], /*file=*/0x200000000000ul, /*flags=*/0, /*mode=*/0);
return 0;
}
]
|
| 2/1 |
2026/05/12 23:19 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/e08610c461f588d45ad77564f36da2c79fc501a6]
|
| 3/1 |
2026/05/12 23:21 |
action |
kernel-builder |
17m
Results: map[KernelObj:/app/workdir/cache/build/ca213da30007aab1e8053127250d3cb3be59ccad]
|
| 4/1 |
2026/05/12 23:38 |
action |
codesearch-prepare |
12m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/05/12 23:50 |
agent |
expert |
9m
Model:
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
Instruction:
You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by greeping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Don't make assumptions; verify them with source code access. Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption or elevated privileges.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completly wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control tranfers, that's also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitabability depends on how exactly the uninit value
is used in the code, and what it affects.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidetial Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
INFO: task kworker/u8:2:35 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/u8:2 state:D
stack:20800 pid:35 tgid:35 ppid:2 task_flags:0x4208160 flags:0x00080000
Workqueue: netns cleanup_net
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5295 [inline]
__schedule+0x1585/0x5340 kernel/sched/core.c:6907
__schedule_loop kernel/sched/core.c:6989 [inline]
schedule+0x164/0x360 kernel/sched/core.c:7004
afs_cell_purge+0x40d/0x580 fs/afs/cell.c:921
afs_net_exit+0x50/0x100 fs/afs/main.c:147
ops_exit_list net/core/net_namespace.c:199 [inline]
ops_undo_list+0x49f/0x940 net/core/net_namespace.c:252
cleanup_net+0x56b/0x800 net/core/net_namespace.c:704
process_one_work+0x949/0x1650 kernel/workqueue.c:3279
process_scheduled_works kernel/workqueue.c:3362 [inline]
worker_thread+0xb46/0x1140 kernel/workqueue.c:3443
kthread+0x388/0x470 kernel/kthread.c:467
ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Showing all locks held in the system:
1 lock held by khungtaskd/30:
#0: ffffffff8e7602e0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:312 [inline]
#0: ffffffff8e7602e0 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:850 [inline]
#0: ffffffff8e7602e0 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x2e/0x180 kernel/locking/lockdep.c:6775
3 locks held by kworker/u8:2/35:
#0: ffff88801c2ae948 ((wq_completion)netns){+.+.}-{0:0}, at: process_one_work+0x855/0x1650 kernel/workqueue.c:3254
#1: ffffc90000ab7c40 (net_cleanup_work){+.+.}-{0:0}, at: process_one_work+0x87c/0x1650 kernel/workqueue.c:3255
#2: ffffffff8fbbe770 (pernet_ops_rwsem){++++}-{4:4}, at: cleanup_net+0xf4/0x800 net/core/net_namespace.c:675
3 locks held by kworker/u8:6/143:
#0: ffff88801b0ac148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work+0x855/0x1650 kernel/workqueue.c:3254
#1: ffffc90002f67c40 ((linkwatch_work).work){+.+.}-{0:0}, at: process_one_work+0x87c/0x1650 kernel/workqueue.c:3255
#2: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: linkwatch_event+0xe/0x60 net/core/link_watch.c:313
2 locks held by kworker/u8:7/156:
2 locks held by getty/5582:
#0: ffff888037dc10a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x25/0x70 drivers/tty/tty_ldisc.c:243
#1: ffffc9000332b2f0 (&ldata->atomic_read_lock){+.+.}-{4:4}, at: n_tty_read+0x45c/0x13c0 drivers/tty/n_tty.c:2211
3 locks held by kworker/u8:9/7429:
#0: ffff8880326c8948 ((wq_completion)ipv6_addrconf){+.+.}-{0:0}, at: process_one_work+0x855/0x1650 kernel/workqueue.c:3254
#1: ffffc9000cd6fc40 ((work_completion)(&(&ifa->dad_work)->work)){+.+.}-{0:0}, at: process_one_work+0x87c/0x1650 kernel/workqueue.c:3255
#2: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_net_lock include/linux/rtnetlink.h:130 [inline]
#2: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: addrconf_dad_work+0x11e/0x14c0 net/ipv6/addrconf.c:4199
1 lock held by syz-executor/7852:
#0: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_net_lock include/linux/rtnetlink.h:130 [inline]
#0: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: inet_rtm_newaddr+0x404/0x1ad0 net/ipv4/devinet.c:978
3 locks held by syz-executor/7859:
#0: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock net/core/rtnetlink.c:80 [inline]
#0: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_nets_lock net/core/rtnetlink.c:341 [inline]
#0: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_newlink+0x8a1/0x1be0 net/core/rtnetlink.c:4071
#1: ffff8880580b5528 (&wg->device_update_lock){+.+.}-{4:4}, at: wg_open+0x227/0x420 drivers/net/wireguard/device.c:50
#2: ffffffff8e766578 (rcu_state.exp_mutex){+.+.}-{4:4}, at: exp_funnel_lock kernel/rcu/tree_exp.h:311 [inline]
#2: ffffffff8e766578 (rcu_state.exp_mutex){+.+.}-{4:4}, at: synchronize_rcu_expedited+0x2d0/0x770 kernel/rcu/tree_exp.h:961
2 locks held by syz-executor/7943:
#0: ffffffff8f309048 (&ops->srcu#2){.+.+}-{0:0}, at: rcu_lock_acquire include/linux/rcupdate.h:312 [inline]
#0: ffffffff8f309048 (&ops->srcu#2){.+.+}-{0:0}, at: rcu_read_lock include/linux/rcupdate.h:850 [inline]
#0: ffffffff8f309048 (&ops->srcu#2){.+.+}-{0:0}, at: rtnl_link_ops_get+0x23/0x250 net/core/rtnetlink.c:570
#1: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock net/core/rtnetlink.c:80 [inline]
#1: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_nets_lock net/core/rtnetlink.c:341 [inline]
#1: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_newlink+0x8a1/0x1be0 net/core/rtnetlink.c:4071
2 locks held by syz-executor/7974:
#0: ffffffff90136ea0 (&ops->srcu#2){.+.+}-{0:0}, at: rcu_lock_acquire include/linux/rcupdate.h:312 [inline]
#0: ffffffff90136ea0 (&ops->srcu#2){.+.+}-{0:0}, at: rcu_read_lock include/linux/rcupdate.h:850 [inline]
#0: ffffffff90136ea0 (&ops->srcu#2){.+.+}-{0:0}, at: rtnl_link_ops_get+0x23/0x250 net/core/rtnetlink.c:570
#1: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock net/core/rtnetlink.c:80 [inline]
#1: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_nets_lock net/core/rtnetlink.c:341 [inline]
#1: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_newlink+0x8a1/0x1be0 net/core/rtnetlink.c:4071
2 locks held by syz-executor/7981:
#0: ffffffff8fbbe770 (pernet_ops_rwsem){++++}-{4:4}, at: copy_net_ns+0x4f7/0x730 net/core/net_namespace.c:577
#1: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_net_lock include/linux/rtnetlink.h:130 [inline]
#1: ffffffff8fbcd588 (rtnl_mutex){+.+.}-{4:4}, at: register_netdevice_notifier_net+0x1a/0xa0 net/core/dev.c:2096
=============================================
NMI backtrace for cpu 0
CPU: 0 UID: 0 PID: 30 Comm: khungtaskd Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
nmi_cpu_backtrace+0x274/0x2d0 lib/nmi_backtrace.c:113
nmi_trigger_cpumask_backtrace+0x17a/0x300 lib/nmi_backtrace.c:62
trigger_all_cpu_backtrace include/linux/nmi.h:161 [inline]
__sys_info lib/sys_info.c:157 [inline]
sys_info+0x135/0x170 lib/sys_info.c:165
check_hung_uninterruptible_tasks kernel/hung_task.c:346 [inline]
watchdog+0xfd9/0x1030 kernel/hung_task.c:515
kthread+0x388/0x470 kernel/kthread.c:467
ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Sending NMI from CPU 0 to CPUs 1:
NMI backtrace for cpu 1
CPU: 1 UID: 0 PID: 7551 Comm: kworker/u8:10 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2026
Workqueue: events_unbound nsim_dev_trap_report_work
RIP: 0010:__orc_find arch/x86/kernel/unwind_orc.c:101 [inline]
RIP: 0010:orc_find arch/x86/kernel/unwind_orc.c:238 [inline]
RIP: 0010:unwind_next_frame+0x4db/0x23c0 arch/x86/kernel/unwind_orc.c:510
Code: 4c 8b 7c 24 50 48 bd 00 00 00 00 00 fc ff df 4c 8b 64 24 20 4c 8b 6c 24 48 0f 84 72 15 00 00 e9 03 02 00 00 49 89 d5 48 89 d5 <48> 89 d8 48 29 e8 48 89 c1 48 c1 f9 02 48 c1 e8 3f 48 01 c8 48 83
RSP: 0018:ffffc9000d4af4b8 EFLAGS: 00000297
RAX: ffffffff902d0014 RBX: ffffffff902d0014 RCX: ffffffff902d001c
RDX: ffffffff902d0010 RSI: ffffffff90aa9e52 RDI: ffffffff8c27aaa0
RBP: ffffffff902d0010 R08: 000000000000000c R09: ffffffff8e7602e0
R10: ffffc9000d4af5d8 R11: ffffffff81b0c580 R12: ffffffff81b0c518
R13: ffffffff902d0010 R14: ffffc9000d4af588 R15: ffffffff902d0018
FS: 0000000000000000(0000) GS:ffff888125560000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f1329d45000 CR3: 000000008888e000 CR4: 00000000003526f0
Call Trace:
<TASK>
arch_stack_walk+0x11b/0x150 arch/x86/kernel/stacktrace.c:25
stack_trace_save+0xa9/0x100 kernel/stacktrace.c:122
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2687 [inline]
slab_free mm/slub.c:6124 [inline]
kfree+0x1c1/0x630 mm/slub.c:6442
skb_kfree_head net/core/skbuff.c:1089 [inline]
skb_free_head net/core/skbuff.c:1101 [inline]
skb_release_data+0x6f0/0x940 net/core/skbuff.c:1128
skb_release_all net/core/skbuff.c:1203 [inline]
__kfree_skb+0x5d/0x210 net/core/skbuff.c:1217
nsim_dev_trap_report drivers/net/netdevsim/dev.c:892 [inline]
nsim_dev_trap_report_work+0x7cf/0xb80 drivers/net/netdevsim/dev.c:922
process_one_work+0x949/0x1650 kernel/workqueue.c:3279
process_scheduled_works kernel/workqueue.c:3362 [inline]
worker_thread+0xb46/0x1140 kernel/workqueue.c:3443
kthread+0x388/0x470 kernel/kthread.c:467
ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
It is reproducible with the followint program.
Keep in mind that it may lack the precise threading, sandboxing, and some arguments of a working reproducer.
But it should give an idea of the involved syscalls.
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/loop.h>
#ifndef __NR_memfd_create
#define __NR_memfd_create 319
#endif
static unsigned long long procid;
static bool write_file(const char* file, const char* what, ...)
{
char buf[1024];
va_list args;
va_start(args, what);
vsnprintf(buf, sizeof(buf), what, args);
va_end(args);
buf[sizeof(buf) - 1] = 0;
int len = strlen(buf);
int fd = open(file, O_WRONLY | O_CLOEXEC);
if (fd == -1)
return false;
if (write(fd, buf, len) != len) {
int err = errno;
close(fd);
errno = err;
return false;
}
close(fd);
return true;
}
//% This code is derived from puff.{c,h}, found in the zlib development. The
//% original files come with the following copyright notice:
//% Copyright (C) 2002-2013 Mark Adler, all rights reserved
//% version 2.3, 21 Jan 2013
//% This software is provided 'as-is', without any express or implied
//% warranty. In no event will the author be held liable for any damages
//% arising from the use of this software.
//% Permission is granted to anyone to use this software for any purpose,
//% including commercial applications, and to alter it and redistribute it
//% freely, subject to the following restrictions:
//% 1. The origin of this software must not be misrepresented; you must not
//% claim that you wrote the original software. If you use this software
//% in a product, an acknowledgment in the product documentation would be
//% appreciated but is not required.
//% 2. Altered source versions must be plainly marked as such, and must not be
//% misrepresented as being the original software.
//% 3. This notice may not be removed or altered from any source distribution.
//% Mark Adler madler@alumni.caltech.edu
//% BEGIN CODE DERIVED FROM puff.{c,h}
#define MAXBITS 15
#define MAXLCODES 286
#define MAXDCODES 30
#define MAXCODES (MAXLCODES + MAXDCODES)
#define FIXLCODES 288
struct puff_state {
unsigned char* out;
unsigned long outlen;
unsigned long outcnt;
const unsigned char* in;
unsigned long inlen;
unsigned long incnt;
int bitbuf;
int bitcnt;
jmp_buf env;
};
static int puff_bits(struct puff_state* s, int need)
{
long val = s->bitbuf;
while (s->bitcnt < need) {
if (s->incnt == s->inlen)
longjmp(s->env, 1);
val |= (long)(s->in[s->incnt++]) << s->bitcnt;
s->bitcnt += 8;
}
s->bitbuf = (int)(val >> need);
s->bitcnt -= need;
return (int)(val & ((1L << need) - 1));
}
static int puff_stored(struct puff_state* s)
{
s->bitbuf = 0;
s->bitcnt = 0;
if (s->incnt + 4 > s->inlen)
return 2;
unsigned len = s->in[s->incnt++];
len |= s->in[s->incnt++] << 8;
if (s->in[s->incnt++] != (~len & 0xff) ||
s->in[s->incnt++] != ((~len >> 8) & 0xff))
return -2;
if (s->incnt + len > s->inlen)
return 2;
if (s->outcnt + len > s->outlen)
return 1;
for (; len--; s->outcnt++, s->incnt++) {
if (s->in[s->incnt])
s->out[s->outcnt] = s->in[s->incnt];
}
return 0;
}
struct puff_huffman {
short* count;
short* symbol;
};
static int puff_decode(struct puff_state* s, const struct puff_huffman* h)
{
int first = 0;
int index = 0;
int bitbuf = s->bitbuf;
int left = s->bitcnt;
int code = first = index = 0;
int len = 1;
short* next = h->count + 1;
while (1) {
while (left--) {
code |= bitbuf & 1;
bitbuf >>= 1;
int count = *next++;
if (code - count < first) {
s->bitbuf = bitbuf;
s->bitcnt = (s->bitcnt - len) & 7;
return h->symbol[index + (code - first)];
}
index += count;
first += count;
first <<= 1;
code <<= 1;
len++;
}
left = (MAXBITS + 1) - len;
if (left == 0)
break;
if (s->incnt == s->inlen)
longjmp(s->env, 1);
bitbuf = s->in[s->incnt++];
if (left > 8)
left = 8;
}
return -10;
}
static int puff_construct(struct puff_huffman* h, const short* length, int n)
{
int len;
for (len = 0; len <= MAXBITS; len++)
h->count[len] = 0;
int symbol;
for (symbol = 0; symbol < n; symbol++)
(h->count[length[symbol]])++;
if (h->count[0] == n)
return 0;
int left = 1;
for (len = 1; len <= MAXBITS; len++) {
left <<= 1;
left -= h->count[len];
if (left < 0)
return left;
}
short offs[MAXBITS + 1];
offs[1] = 0;
for (len = 1; len < MAXBITS; len++)
offs[len + 1] = offs[len] + h->count[len];
for (symbol = 0; symbol < n; symbol++)
if (length[symbol] != 0)
h->symbol[offs[length[symbol]]++] = symbol;
return left;
}
static int puff_codes(struct puff_state* s,
const struct puff_huffman* lencode,
const struct puff_huffman* distcode)
{
static const short lens[29] = {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258};
static const short lext[29] = {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0};
static const short dists[30] = {
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577};
static const short dext[30] = {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
12, 12, 13, 13};
int symbol;
do {
symbol = puff_decode(s, lencode);
if (symbol < 0)
return symbol;
if (symbol < 256) {
if (s->outcnt == s->outlen)
return 1;
if (symbol)
s->out[s->outcnt] = symbol;
s->outcnt++;
} else if (symbol > 256) {
symbol -= 257;
if (symbol >= 29)
return -10;
int len = lens[symbol] + puff_bits(s, lext[symbol]);
symbol = puff_decode(s, distcode);
if (symbol < 0)
return symbol;
unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]);
if (dist > s->outcnt)
return -11;
if (s->outcnt + len > s->outlen)
return 1;
while (len--) {
if (dist <= s->outcnt && s->out[s->outcnt - dist])
s->out[s->outcnt] = s->out[s->outcnt - dist];
s->outcnt++;
}
}
} while (symbol != 256);
return 0;
}
static int puff_fixed(struct puff_state* s)
{
static int virgin = 1;
static short lencnt[MAXBITS + 1], lensym[FIXLCODES];
static short distcnt[MAXBITS + 1], distsym[MAXDCODES];
static struct puff_huffman lencode, distcode;
if (virgin) {
lencode.count = lencnt;
lencode.symbol = lensym;
distcode.count = distcnt;
distcode.symbol = distsym;
short lengths[FIXLCODES];
int symbol;
for (symbol = 0; symbol < 144; symbol++)
lengths[symbol] = 8;
for (; symbol < 256; symbol++)
lengths[symbol] = 9;
for (; symbol < 280; symbol++)
lengths[symbol] = 7;
for (; symbol < FIXLCODES; symbol++)
lengths[symbol] = 8;
puff_construct(&lencode, lengths, FIXLCODES);
for (symbol = 0; symbol < MAXDCODES; symbol++)
lengths[symbol] = 5;
puff_construct(&distcode, lengths, MAXDCODES);
virgin = 0;
}
return puff_codes(s, &lencode, &distcode);
}
static int puff_dynamic(struct puff_state* s)
{
static const short order[19] =
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
int nlen = puff_bits(s, 5) + 257;
int ndist = puff_bits(s, 5) + 1;
int ncode = puff_bits(s, 4) + 4;
if (nlen > MAXLCODES || ndist > MAXDCODES)
return -3;
short lengths[MAXCODES];
int index;
for (index = 0; index < ncode; index++)
lengths[order[index]] = puff_bits(s, 3);
for (; index < 19; index++)
lengths[order[index]] = 0;
short lencnt[MAXBITS + 1], lensym[MAXLCODES];
struct puff_huffman lencode = {lencnt, lensym};
int err = puff_construct(&lencode, lengths, 19);
if (err != 0)
return -4;
index = 0;
while (index < nlen + ndist) {
int symbol;
int len;
symbol = puff_decode(s, &lencode);
if (symbol < 0)
return symbol;
if (symbol < 16)
lengths[index++] = symbol;
else {
len = 0;
if (symbol == 16) {
if (index == 0)
return -5;
len = lengths[index - 1];
symbol = 3 + puff_bits(s, 2);
} else if (symbol == 17)
symbol = 3 + puff_bits(s, 3);
else
symbol = 11 + puff_bits(s, 7);
if (index + symbol > nlen + ndist)
return -6;
while (symbol--)
lengths[index++] = len;
}
}
if (lengths[256] == 0)
return -9;
err = puff_construct(&lencode, lengths, nlen);
if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1]))
return -7;
short distcnt[MAXBITS + 1], distsym[MAXDCODES];
struct puff_huffman distcode = {distcnt, distsym};
err = puff_construct(&distcode, lengths + nlen, ndist);
if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1]))
return -8;
return puff_codes(s, &lencode, &distcode);
}
static int puff(
unsigned char* dest,
unsigned long* destlen,
const unsigned char* source,
unsigned long sourcelen)
{
struct puff_state s = {
.out = dest,
.outlen = *destlen,
.outcnt = 0,
.in = source,
.inlen = sourcelen,
.incnt = 0,
.bitbuf = 0,
.bitcnt = 0,
};
int err;
if (setjmp(s.env) != 0)
err = 2;
else {
int last;
do {
last = puff_bits(&s, 1);
int type = puff_bits(&s, 2);
err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1));
if (err != 0)
break;
} while (!last);
}
*destlen = s.outcnt;
return err;
}
//% END CODE DERIVED FROM puff.{c,h}
#define ZLIB_HEADER_WIDTH 2
static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd)
{
if (sourcelen < ZLIB_HEADER_WIDTH)
return 0;
source += ZLIB_HEADER_WIDTH;
sourcelen -= ZLIB_HEADER_WIDTH;
const unsigned long max_destlen = 132 << 20;
void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
if (ret == MAP_FAILED)
return -1;
unsigned char* dest = (unsigned char*)ret;
unsigned long destlen = max_destlen;
int err = puff(dest, &destlen, source, sourcelen);
if (err) {
munmap(dest, max_destlen);
errno = -err;
return -1;
}
if (write(dest_fd, dest, destlen) != (ssize_t)destlen) {
munmap(dest, max_destlen);
return -1;
}
return munmap(dest, max_destlen);
}
static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p)
{
int err = 0, loopfd = -1;
int memfd = syscall(__NR_memfd_create, "syzkaller", 0);
if (memfd == -1) {
err = errno;
goto error;
}
if (puff_zlib_to_file(data, size, memfd)) {
err = errno;
goto error_close_memfd;
}
loopfd = open(loopname, O_RDWR);
if (loopfd == -1) {
err = errno;
goto error_close_memfd;
}
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
if (errno != EBUSY) {
err = errno;
goto error_close_loop;
}
ioctl(loopfd, LOOP_CLR_FD, 0);
usleep(1000);
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
err = errno;
goto error_close_loop;
}
}
close(memfd);
*loopfd_p = loopfd;
return 0;
error_close_loop:
close(loopfd);
error_close_memfd:
close(memfd);
error:
errno = err;
return -1;
}
static void reset_loop_device(const char* loopname)
{
int loopfd = open(loopname, O_RDWR);
if (loopfd == -1) {
return;
}
if (ioctl(loopfd, LOOP_CLR_FD, 0)) {
}
close(loopfd);
}
static long syz_mount_image(
volatile long fsarg,
volatile long dir,
volatile long flags,
volatile long optsarg,
volatile long change_dir,
volatile unsigned long size,
volatile long image)
{
unsigned char* data = (unsigned char*)image;
int res = -1, err = 0, need_loop_device = !!size;
char* mount_opts = (char*)optsarg;
char* target = (char*)dir;
char* fs = (char*)fsarg;
char* source = NULL;
char loopname[64];
if (need_loop_device) {
int loopfd;
memset(loopname, 0, sizeof(loopname));
snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid);
if (setup_loop_device(data, size, loopname, &loopfd) == -1)
return -1;
close(loopfd);
source = loopname;
}
mkdir(target, 0777);
char opts[256];
memset(opts, 0, sizeof(opts));
if (strlen(mount_opts) > (sizeof(opts) - 32)) {
}
strncpy(opts, mount_opts, sizeof(opts) - 32);
if (strcmp(fs, "iso9660") == 0) {
flags |= MS_RDONLY;
} else if (strncmp(fs, "ext", 3) == 0) {
bool has_remount_ro = false;
char* remount_ro_start = strstr(opts, "errors=remount-ro");
if (remount_ro_start != NULL) {
char after = *(remount_ro_start + strlen("errors=remount-ro"));
char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1);
has_remount_ro = ((before == '\0' || before == ',') && (after == '\0' || after == ','));
}
if (strstr(opts, "errors=panic") || !has_remount_ro)
strcat(opts, ",errors=continue");
} else if (strcmp(fs, "xfs") == 0) {
strcat(opts, ",nouuid");
} else if (strncmp(fs, "gfs2", 4) == 0 && (strstr(opts, "errors=panic") || strstr(opts, "debug"))) {
strcat(opts, ",errors=withdraw");
}
res = mount(source, target, fs, flags, opts);
if (res == -1) {
err = errno;
goto error_clear_loop;
}
res = open(target, O_RDONLY | O_DIRECTORY);
if (res == -1) {
err = errno;
goto error_clear_loop;
}
if (change_dir) {
res = chdir(target);
if (res == -1) {
err = errno;
}
}
error_clear_loop:
if (need_loop_device)
reset_loop_device(loopname);
errno = err;
return res;
}
static int inject_fault(int nth)
{
int fd;
fd = open("/proc/thread-self/fail-nth", O_RDWR);
if (fd == -1)
exit(1);
char buf[16];
sprintf(buf, "%d", nth);
if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
exit(1);
return fd;
}
static const char* setup_fault()
{
int fd = open("/proc/self/make-it-fail", O_WRONLY);
if (fd == -1)
return "CONFIG_FAULT_INJECTION is not enabled";
close(fd);
fd = open("/proc/thread-self/fail-nth", O_WRONLY);
if (fd == -1)
return "kernel does not have systematic fault injection support";
close(fd);
static struct {
const char* file;
const char* val;
bool fatal;
} files[] = {
{"/sys/kernel/debug/failslab/ignore-gfp-wait", "N", true},
{"/sys/kernel/debug/fail_futex/ignore-private", "N", false},
{"/sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem", "N", false},
{"/sys/kernel/debug/fail_page_alloc/ignore-gfp-wait", "N", false},
{"/sys/kernel/debug/fail_page_alloc/min-order", "0", false},
};
unsigned i;
for (i = 0; i < sizeof(files) / sizeof(files[0]); i++) {
if (!write_file(files[i].file, files[i].val)) {
if (files[i].fatal)
return "failed to write fault injection file";
}
}
return NULL;
}
uint64_t r[1] = {0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
if ((reason = setup_fault()))
printf("the reproducer may not work as expected: fault injection setup failed: %s\n", reason);
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_mount_image$nilfs2 arguments: [
// fs: ptr[in, buffer] {
// buffer: {6e 69 6c 66 73 32 00} (length 0x7)
// }
// dir: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 33 00} (length 0x8)
// }
// flags: mount_flags = 0x0 (8 bytes)
// opts: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// }
// }
// chdir: int8 = 0x1 (1 bytes)
// size: len = 0xae1 (8 bytes)
// img: ptr[in, buffer] {
// buffer: (compressed buffer with length 0xae1)
// }
// ]
// returns fd_dir
memcpy((void*)0x200000000780, "nilfs2\000", 7);
memcpy((void*)0x200000000300, "./file3\000", 8);
memcpy((void*)0x200000000940, "\x78\x9c\xec\xdd\x5d\x88\x5c\x57\x01\x00\xe0\x73\x77\x77\x36\xbb\x69\x6b\xa6\x35\xb5\x6b\x1a\xdb\xa4\xd5\xb6\xfe\x74\xd3\x6c\xd6\xf8\x13\x34\x29\x09\x82\xa1\x29\xe2\x4b\xa1\xf8\x12\xd2\xb4\x06\x63\x04\x2b\xa8\xa5\xd0\x24\x4f\xbe\xd9\x52\x52\xf0\xc9\x1f\x7c\xea\x4b\xa9\x22\x58\x10\x09\x7d\xf2\xa5\x60\x03\x45\xe8\x53\x15\xf4\xa1\x21\x62\xc1\x87\x1a\x4d\x46\x76\xe7\x9c\x99\x3b\x27\x33\x99\x9d\xfd\x99\xbb\xbb\xf3\x7d\x70\xf7\xcc\xb9\xe7\xdc\x39\xe7\xce\xde\xb9\x73\xff\xce\x39\x01\x18\x59\x63\x8b\x7f\xe7\xe7\x67\x8a\x10\x2e\xbc\xf1\xf2\x91\xf7\x1f\xf8\xc7\xf4\xc2\x9c\x83\xad\x1c\xf5\xc5\xbf\x13\xa5\x58\x2d\x84\x50\xc4\xf8\x44\xf6\x7e\xef\x8d\x37\xc3\x6b\x1f\x3c\x7f\xa2\x5b\x58\x84\xb9\xc5\xbf\x29\x1e\x1e\xbf\xd2\x5a\xf6\x96\x10\xc2\xd9\xb0\x2b\x5c\x0c\xf5\xb0\xe3\xc2\xa5\x97\xde\x9a\x7b\xec\xd8\xb9\xa3\xe7\x77\xbf\xfd\xea\x81\xcb\x6b\xb3\xf6\x00\x00\x30\x5a\xbe\x71\xf1\xc0\xfc\x9d\x7f\xfd\xf3\xdd\xb7\x5f\x7d\xed\x9e\x43\x61\x4b\x6b\x7e\x3a\x3e\xaf\xa7\x19\x53\xcd\xe3\xfe\x43\xf1\xc0\x3f\x1d\xff\x8f\x85\xce\x78\x51\x9a\xca\x26\xb3\x7c\x13\x71\x1a\x9b\xee\xcc\x37\xde\x25\x5f\xb9\x9c\x5a\x96\x6f\xa2\x47\xf9\x93\x59\xf9\xb5\x1e\xf9\xb6\x84\x9b\x97\x3f\x5e\x9a\xd7\x6d\xbd\x61\x23\x4b\xdb\x71\x3d\x14\x63\xb3\x21\x84\xad\xad\xf8\xd8\xd8\xec\x6c\xf3\x9c\x3c\x2c\x9e\xd7\x4f\x16\xb3\x67\x4e\x9d\x7e\xfa\xd9\x8a\x2a\x0a\xac\xba\x7f\xdf\x1b\x42\xd8\x55\x9a\x0e\x9f\xef\x8c\xaf\xb7\xe9\xe0\x3a\xa8\xc3\x32\xa7\xc6\x3a\xa8\xc3\x86\x9c\x0e\x0d\xaf\xac\xab\x8d\xa6\xca\xd7\x79\x48\x53\x63\x5b\xd5\x7b\x20\x80\xa6\xfc\x7e\xe1\x0d\xce\xe6\x57\x16\x56\xa6\xf5\x6e\x13\x4b\x2b\xff\xca\xa3\x63\xdd\x97\x87\x55\x30\xec\xed\x7f\xa0\xf2\x27\x2b\x2e\x3f\x28\xff\xd7\xe7\xec\x71\x58\x3d\x9b\x75\x6b\x4a\xeb\x95\xbe\x47\xb7\xc6\x78\x7e\x1f\x21\x7f\x7e\xe9\x95\x3f\x74\x2e\xd7\x96\xdf\xe9\xe8\x9c\x9b\xdf\x8f\xa8\x2d\xb1\x9e\xbd\xee\x23\x6c\x94\xfb\x0b\xbd\xea\x39\x3e\xe4\x7a\x2c\x57\xaf\xfa\xe7\xdb\xc5\x66\xf5\x95\x18\xa6\xcf\xe1\xab\x1d\xa9\xf7\x76\x7c\x7f\xf2\xff\xe9\x46\xf9\x1f\x03\xdd\x7d\x98\x5f\xff\x37\x99\x4c\xeb\x7b\x0a\x1d\xf1\xda\x4a\xde\xab\x51\xf1\xfe\x07\x58\xbf\xf2\xe7\xe6\x1a\xe9\xfe\x68\x94\x3f\xd7\x97\xa7\x6f\xe9\x93\x3e\xd5\x27\x7d\xba\x4f\xfa\xd6\x3e\xe9\xb7\xf4\x49\x87\x51\xf6\xdb\x1f\xfc\x34\xbc\x58\xb4\xaf\x77\xe5\xe7\xf4\x83\x5e\x0f\x4f\xd7\xd9\x6e\x8b\xe1\x47\x06\xac\x4f\x7e\x3d\x72\xd0\xf2\xf3\xe7\x7e\x07\xb5\xd2\xf2\xf3\xe7\x89\x61\x3d\xfb\xfd\xf1\x27\x4e\x7e\xf1\xa9\x27\x2f\x35\x9f\xff\x2f\x5a\xdb\xff\xf5\xb8\xbd\xa7\xd3\x8d\x7a\xfc\x6e\x5d\x8c\x19\xd2\xf5\xc2\xfc\xba\x7a\xeb\xd9\xff\x7a\x67\x39\x63\x3d\xf2\xdd\x91\xd5\xe7\xb6\x2e\xf9\x17\x5f\x6f\xef\xcc\x57\x6c\x6f\xbf\x4f\x28\xed\x67\x6e\xa8\xc7\x4c\xe7\x72\xdb\x7a\xe5\xdb\xd9\x99\xaf\x9e\xe5\x9b\x8e\xd3\x54\x56\xdf\xfc\xf8\x64\x6b\xb6\x5c\x3a\xfe\x48\xfb\xd5\xf4\x79\x4d\x64\xeb\x5b\xcb\xd6\x63\x32\xab\x47\xda\xaf\xdc\x1e\xc3\xbc\x1e\xb0\x1c\x69\x7b\x4c\xcf\xff\xb7\xdb\x03\x34\x9f\xff\x4f\xdb\xe7\x4c\xa8\x15\x4f\x9f\x3a\x7d\xf2\x91\x18\x4f\xdb\xe9\x9f\xc6\x6b\x5b\x16\xe6\xef\x1d\x72\xbd\x81\xd5\xd3\xeb\xfb\x9f\x7e\xbf\x66\x42\x67\xfb\x9f\x5b\x5b\xf3\x6b\x63\xe5\xfd\xc2\xb6\xf6\xfc\xa2\xb9\x5f\x78\x3d\xbe\x5f\xe7\xfc\xb9\x56\x39\xa5\xf9\xa5\x1f\xb5\xf4\x3b\xf7\xed\xf1\xe9\xc5\xfc\xb3\x27\xbe\x77\xfa\xa9\x35\x58\x6f\x18\x65\xcf\xfe\xf8\xb9\xef\x1c\x3f\x7d\xfa\xe4\xf7\xbd\x58\xf6\x8b\xaf\xad\x8f\x6a\x0c\xf2\x22\x9d\xb6\xac\x97\xfa\x78\x31\xe8\x8b\x5d\x6b\x5d\x44\xc5\x3b\x26\x60\xcd\xed\x79\xa1\x79\x10\xf0\xf0\xa9\xef\x1e\x7f\xe6\xe4\x33\x27\xcf\xec\xdb\xbf\x7f\xdf\xdc\xdc\xfe\x2f\xed\x9b\xdf\xb3\x78\x5c\xbf\xa7\x7c\x74\x5f\x76\xb6\x82\xda\x02\xab\xa9\xfd\xa3\x5f\x75\x4d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xa5\xfa\xe1\xd1\x23\x97\xde\x79\xf3\x0b\xef\x36\xdb\xff\xb7\xdb\xff\xa5\xf6\xff\xe9\xc9\xdf\xd4\xfe\xff\x27\x59\xfb\xff\xbc\x9d\x7c\x6a\x07\x9f\xda\x01\xde\xde\x25\x7d\x31\x4f\xd6\xc1\xea\x64\x96\xaf\x16\xa7\x8f\x66\xf5\x4d\xdd\x00\x14\x2f\x34\xc3\x3b\xb3\xe5\x3e\x16\xc3\xd6\x38\x7e\xb1\xfd\x7f\x2a\x2e\xef\xd7\x35\xd5\xe7\xae\x6c\x7e\xad\x47\x34\xeb\x4e\xe0\x86\xfe\x52\x26\xb3\x3e\x48\xf2\xf1\x02\xef\x8b\xe1\xf9\x18\xfe\x2a\x40\x85\x8a\xe9\xee\xb3\x63\x78\x93\xfe\xad\x8b\x0f\x4b\xdb\x7a\xea\x9f\xa2\xd4\x84\xb7\xa1\x7f\xe0\x8d\x23\xfd\xdf\xf2\xfe\x8b\x52\xfb\xef\xae\xfd\x3a\x75\x69\xaf\xcd\xc6\x32\x8c\x16\x8b\x55\xaf\x23\xd0\xdd\x3f\x47\xaa\xff\xef\x7f\xb5\x57\xbc\xf2\xba\x98\x7a\x4f\x13\xc3\x2d\xef\x67\xa3\xbb\x4d\x34\x7a\x1e\xa5\x2f\x75\x04\x1b\x80\xd5\x51\xf5\xf8\x9f\x7f\x0f\xcd\x72\xd3\xf5\xcf\x33\x7f\xfc\xfa\xd4\xc2\x94\xb2\x5d\x79\xb4\x73\x7f\x99\xf7\x5f\x0a\x83\xf8\xcb\x3b\x9d\xf1\xf5\x3e\xfe\xe4\x5a\x97\x9f\x8f\xdb\x37\xec\xf2\xab\x5e\xff\x61\x8f\xff\xd9\x1a\xff\x2e\xee\xff\xd2\x7e\xaf\xf7\xfe\x2f\x1b\x31\xaf\xbe\xbc\x72\xff\xf3\xf3\xcb\xef\x96\x8a\x0d\x3b\x96\x5a\x7e\xbe\xfe\xa9\x1f\xe8\xed\x83\x95\x7f\x35\x96\x9f\xd6\xe6\xc1\xb0\xb4\xf2\x1b\xbf\xcc\xca\xcf\x6f\x08\x2d\xd1\x7f\xb3\xf2\xb7\x2e\xb1\xfc\x1b\xd6\x7f\xe7\xf2\xca\xff\x5f\x2c\x3f\x7d\x6c\x0f\xdd\xbf\xd4\xf2\x9b\x35\x2e\xc6\x3a\xeb\x31\x9d\xad\x47\xba\xff\x97\x5f\x37\x4e\xae\x65\xeb\x9f\xfa\xf6\xbc\x49\xf9\xdf\x7c\xae\xdb\xfa\x2f\x73\xa0\xc6\xeb\xb1\x7c\x18\x65\x1b\x65\x9c\xd9\x41\x65\xc7\x11\xad\x83\xf6\x7e\xe3\xff\x0e\xfa\xfb\xbf\xd2\xf1\x7f\x5b\x95\xcd\x76\x6b\xf9\x73\x18\x9f\x8f\xf1\xb4\x23\x4e\xcf\x39\xe4\xe3\x9d\x0c\x5a\xff\xf4\x7c\x45\xfa\x1d\xb8\x33\x7b\xff\xa2\xcf\xef\x9b\xf1\x7f\x37\xb6\x2f\xc7\xb0\xdf\xf7\x21\x8d\xff\x9b\xb6\xc7\x7a\xfc\xc9\x2f\xc5\x17\x3f\xcb\x14\xaf\x75\xf9\x6c\x37\xeb\xbe\x06\x36\xaa\xf7\x46\xea\xfe\xdf\xb0\xa6\xcb\xcd\xd3\xa0\xe5\x2d\x3f\x55\x7d\xfd\x47\x6a\x1a\x5f\xc1\xff\x6a\x61\x6a\x8c\x2f\x63\xb9\xd6\x73\x56\x15\xaf\x7f\xa3\xd1\x58\xdb\x0b\x5a\x7d\x54\x5a\x38\x95\x7f\xfe\x55\xdf\x7d\xae\xfa\x3c\xe5\xbe\x8a\xcb\xef\x27\x1f\xff\x37\x3f\x86\xcf\xc7\xff\xcd\xd3\xf3\xf1\x7f\xf3\xf4\x7c\xfc\xdf\x3c\x7d\x3a\xfe\x87\xde\xef\x91\x9e\x8f\xff\x9b\x6f\xcf\xf9\xf8\xbf\x79\xfa\x5d\xd9\xfb\xe6\xe3\x03\xcf\xf4\x49\xff\x78\x97\xf4\x22\xb4\xd3\x77\x74\x5f\xbe\x75\xda\x7e\x77\x9f\xf7\xdf\xd9\x27\xfd\x13\x7d\xd2\x77\xb7\xd2\x0f\x76\xe4\x48\xe9\xf7\xdc\x74\xf9\x76\xbe\x5e\xef\x7f\x47\x9f\xf4\xfb\xfb\xa4\x7f\xb2\x4f\xfa\xa7\xfa\xa4\x3f\xd0\x27\xfd\xa1\x52\x7a\x79\x0c\xe8\x94\xfe\xe9\x6c\xf9\x22\x4b\xdf\xec\xd2\xfe\xa7\xd7\xe7\x07\x6c\x5e\x79\xfb\x3c\xdf\x7f\x18\x1d\xe9\xfe\x4f\xaf\xef\xff\xf6\x76\xfa\x64\x39\xcb\x70\x6b\x09\xac\x85\x57\x5e\xdb\x7b\xf8\xc9\xdf\x7c\xab\xde\x6c\xff\x3f\xd9\xba\x1e\x92\xee\xe3\x1d\x8a\xf1\x5a\x3c\x37\xfa\x51\x8c\xe7\xf7\xbd\x43\x29\xbe\x90\xf6\x66\x8c\xff\x2d\x4b\xaf\xfa\x7a\x13\xd0\x96\xf7\x9f\x91\xff\xfe\x3f\xd8\x27\x1d\xd8\xb8\xd2\x73\x5e\xbe\xdf\x30\x82\x8a\xa9\xee\xb3\x63\xd8\xaf\xdf\xaa\x5e\xc7\xf9\x6c\x2c\x9f\x89\xe1\x67\x63\xf8\xb9\x18\x3e\x1c\xc3\xd9\x18\xee\x89\xe1\xde\x18\xce\x0d\xa9\x7e\xac\x8d\xc3\xaf\xff\xee\xc0\x8b\x45\xfb\x7c\x7f\x5b\x96\xbe\xd4\xe7\xc9\xf3\xf6\x40\x1d\xfd\x44\x85\x10\xf6\x2d\xb1\x3e\xf9\xf5\x81\x41\x9f\x67\xcf\xfb\xf1\x1b\xd4\x4a\xcb\x5f\x66\x73\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xca\x8c\x2d\xfe\x9d\x9f\x9f\x29\x42\xb8\xf0\xc6\xcb\x47\x9e\x38\x76\x6a\xcf\xc2\x9c\x83\xad\x1c\xf5\xc5\xbf\x13\xa5\x58\xad\xb5\x5c\x08\x8f\xc4\x70\x3c\x86\xbf\x88\x2f\xae\x7d\xf0\xfc\x89\x72\x78\x3d\x86\x45\x98\x0b\x45\x28\x5a\xf3\xc3\xe3\x57\x5a\x25\xdd\x12\x42\x38\x1b\x76\x85\x8b\xa1\x1e\x76\x5c\xb8\xf4\xd2\x5b\x73\x8f\x1d\x3b\x77\xf4\xfc\xee\xb7\x5f\x3d\x70\x79\xed\x3e\x01\x00\x00\x00\xd8\xfc\xfe\x1f\x00\x00\xff\xff\x94\xfa\x07\x1c", 2785);
syz_mount_image(/*fs=*/0x200000000780, /*dir=*/0x200000000300, /*flags=*/0, /*opts=*/0x200000001040, /*chdir=*/1, /*size=*/0xae1, /*img=*/0x200000000940);
// mount$afs arguments: [
// src: nil
// dst: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8)
// }
// type: ptr[in, buffer] {
// buffer: {61 66 73 00} (length 0x4)
// }
// flags: mount_flags = 0x0 (8 bytes)
// opts: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {64 79 6e} (length 0x3)
// }
// }
// }
// ]
memcpy((void*)0x2000000001c0, "./file0\000", 8);
memcpy((void*)0x2000000002c0, "afs\000", 4);
memcpy((void*)0x200000000200, "dyn", 3);
syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x2000000001c0ul, /*type=*/0x2000000002c0ul, /*flags=*/0ul, /*opts=*/0x200000000200ul);
// chdir arguments: [
// dir: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8)
// }
// ]
memcpy((void*)0x2000000000c0, "./file0\000", 8);
syscall(__NR_chdir, /*dir=*/0x2000000000c0ul);
// openat arguments: [
// fd: fd_dir (resource)
// file: ptr[in, buffer] {
// buffer: {2e 00} (length 0x2)
// }
// flags: open_flags = 0x0 (4 bytes)
// mode: open_mode = 0x0 (2 bytes)
// ]
// returns fd
memcpy((void*)0x200000000040, ".\000", 2);
res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000040ul, /*flags=*/0, /*mode=*/0);
if (res != -1)
r[0] = res;
// openat$cgroup_ro arguments: [
// fd: fd_cgroup (resource)
// file: ptr[in, buffer] {
// buffer: {63 70 75 61 63 63 74 2e 75 73 61 67 65 5f 75 73 65 72 00} (length 0x13)
// }
// flags: const = 0x0 (4 bytes)
// mode: const = 0x0 (2 bytes)
// ]
// returns fd
memcpy((void*)0x200000000000, "cpuacct.usage_user\000", 19);
inject_fault(10);
syscall(__NR_openat, /*fd=*/r[0], /*file=*/0x200000000000ul, /*flags=*/0, /*mode=*/0);
return 0;
}
Reply: **Analysis of the Bug**
The bug is a counter leak in the AFS (Andrew File System) client code, specifically in `afs_alloc_cell()` located in `fs/afs/cell.c`.
When a new AFS cell is allocated, the function increments the `net->cells_outstanding` counter before attempting to allocate an ID for the cell using `idr_alloc_cyclic()`:
```c
atomic_inc(&net->cells_outstanding);
ret = idr_alloc_cyclic(&net->cells_dyn_ino, cell,
2, INT_MAX / 2, GFP_KERNEL);
if (ret < 0)
goto error;
```
If `idr_alloc_cyclic()` fails (for example, due to memory pressure returning `-ENOMEM`), the code jumps to the `error` label where it frees the partially constructed cell and returns an error. However, it fails to decrement the `net->cells_outstanding` counter, permanently leaking the reference.
When a network namespace is destroyed, `cleanup_net()` is executed on the global `netns_wq` workqueue. This calls `afs_net_exit()`, which in turn calls `afs_cell_purge()`. `afs_cell_purge()` waits for all outstanding cells to be destroyed by waiting for `net->cells_outstanding` to reach 0:
```c
wait_var_event(&net->cells_outstanding,
!atomic_read(&net->cells_outstanding));
```
Because of the leaked counter, this condition will never be met, causing `afs_cell_purge()` to hang indefinitely. Since `cleanup_net()` processes all network namespace cleanups sequentially on a single-threaded workqueue, this hang completely blocks the destruction of any other network namespaces on the system, resulting in a system-wide Denial of Service (DoS) and resource exhaustion.
**Triggering the Bug**
An unprivileged user can trigger this bug by creating a new user namespace and a corresponding network namespace. Within their own network namespace, they gain root privileges, which grants them write access to `/proc/net/afs/cells`.
By writing to this proc file (e.g., `echo "add mycell 1.2.3.4" > /proc/net/afs/cells`), the user can trigger `afs_lookup_cell()` and subsequently `afs_alloc_cell()`. By constraining their process using a memory cgroup with a low limit or by generating severe memory pressure, they can force the `idr_alloc_cyclic()` call (which uses `GFP_KERNEL`) to fail. Once the leak occurs, the user simply exits the namespace, triggering the cleanup routine and hanging the `netns_wq` workqueue.
The provided syzkaller reproducer triggers this via a different path: it mounts an AFS filesystem with the `dyn` (dynamic root) option and performs a lookup for a non-existent file (`"cpuacct.usage_user"`). In a dynamic root, lookups automatically attempt to create a cell with the given name. The reproducer uses fault injection (`inject_fault(10)`) to artificially fail the `idr_alloc_cyclic()` allocation, achieving the exact same leak.
**Security Impact**
- **Exploitable:** No. This is a pure logic bug (counter leak) leading to a hang. It does not cause memory corruption, use-after-free, or out-of-bounds accesses, so it cannot be exploited for privilege escalation.
- **Denial of Service:** Yes. It permanently hangs the global network namespace cleanup workqueue.
- **Accessible From Unprivileged Processes / User Namespaces:** Yes. Unprivileged users can create user/network namespaces and interact with `/proc/net/afs/cells` to trigger the bug.
|
| 6/2 |
2026/05/12 23:50 |
llm |
expert |
0m
Model:
Tokens:
input: 27357
output: 41
thoughts: 269
Thoughts: **Analyzing a Persistent Kernel Hang**
Okay, so I've got this bug report, and the initial trace immediately flags a problem: a `kworker` thread has been blocked for over 143 seconds. That's a red flag, right there. The workqueue is `netns cleanup_net`, which isn't inherently alarming, but the call trace points to `afs_cell_purge`. *That* is interesting.
And then, looking closer, I see a secondary trace with an NMI backtrace on CPU 1, which appears during a free. This looks like a potentially corrupted memory region, a common issue, and the trace points through `nsim_dev_trap_report` back to `skb_free_head`. Okay, so there seems to be a KASAN detection happening here.
But wait, looking closer, that original "hung" task trace is *also* in `afs_cell_purge`. Huh. It looks like the primary problem is a task stuck within the AFS subsystem during cleanup. This *needs* looking into. I need to get a better handle on what `afs_cell_purge` is actually doing in this `netns` context. Time to dive into the code...
|
| 7/2 |
2026/05/12 23:50 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_cell_purge]
Results: map[SourceCode: 890: /*
891: * Purge in-memory cell database.
892: */
893: void afs_cell_purge(struct afs_net *net)
894: {
895: struct afs_cell *ws;
896: struct rb_node *cursor;
897:
898: _enter("");
899:
900: down_write(&net->cells_lock);
901: ws = rcu_replace_pointer(net->ws_cell, NULL,
902: lockdep_is_held(&net->cells_lock));
903: up_write(&net->cells_lock);
904: afs_unuse_cell(ws, afs_cell_trace_unuse_ws);
905:
906: _debug("kick cells");
907: down_read(&net->cells_lock);
908: for (cursor = rb_first(&net->cells); cursor; cursor = rb_next(cursor)) {
909: struct afs_cell *cell = rb_entry(cursor, struct afs_cell, net_node);
910:
911: afs_see_cell(cell, afs_cell_trace_purge);
912:
913: if (test_and_clear_bit(AFS_CELL_FL_NO_GC, &cell->flags))
914: afs_unuse_cell(cell, afs_cell_trace_unuse_pin);
915:
916: afs_queue_cell(cell, afs_cell_trace_queue_purge);
917: }
918: up_read(&net->cells_lock);
919:
920: _debug("wait");
921: wait_var_event(&net->cells_outstanding,
922: !atomic_read(&net->cells_outstanding));
923: _leave("");
924: }
SourceFile:fs/afs/cell.c]
|
| 8/2 |
2026/05/12 23:50 |
llm |
expert |
0m
Model:
Tokens:
input: 28510
output: 47
thoughts: 31
Thoughts: Okay, here's my interpretation of that thought process, as if I were thinking it myself, tailored for a field expert:
**Tracing Down a Synchronization Point**
Alright, I'm stuck here. The code's waiting, presumably in a loop or a blocking call, for a specific condition. Specifically, `net->cells_outstanding` needs to hit zero. I need to understand what's happening and why we're blocked.
My first thought is, let's trace this variable. Where is `cells_outstanding` being *modified*? I need to find all the read and write accesses to this memory location. Knowing the context of those modifications will tell me which async operations are in flight, what's pending, and, critically, why it's not decrementing to zero, or why it's potentially stuck there. This is a classic concurrency problem, and I'm treating it as such. Knowing the modifcations tells me the scope.
|
| 9/2 |
2026/05/12 23:50 |
tool |
codesearch-find-references |
0m
Error:
Args: map[ContextFile:fs/afs/cell.c IncludeSnippetLines:0 Name:cells_outstanding SourceTreePrefix:]
Results: map[References:<nil> TruncatedOutput:false]
|
| 10/2 |
2026/05/12 23:50 |
llm |
expert |
0m
Model:
Tokens:
input: 28812
output: 51
thoughts: 29
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience and presented in the first person:
**Navigating the AFS Kernel Codebase**
Alright, let's see. I'm looking at something in the `afs_net` structure, that much is clear. The context suggests we're dealing with AFS network code, so it makes sense to go straight to the structures involved. Specifically, I'm trying to remember what that `afs_net` struct contains; it's the central point for per-network AFS data. Now, the key here is what variable is it that's eluding me? Ah, right! I need to investigate `afs_net::cells_outstanding`. That's where I need to focus my attention. It should be directly relevant to the issue I'm debugging or the feature I'm implementing. I expect that I'll find its purpose relatively quickly.
|
| 11/2 |
2026/05/12 23:51 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeSnippetLines:0 Name:afs_net::cells_outstanding SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_alloc_cell SourceFile:fs/afs/cell.c SourceLine:208] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_cell_purge SourceFile:fs/afs/cell.c SourceLine:921] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_cell_purge SourceFile:fs/afs/cell.c SourceLine:921] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_cell_purge SourceFile:fs/afs/cell.c SourceLine:921] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_cell_purge SourceFile:fs/afs/cell.c SourceLine:921] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_dec_cells_outstanding SourceFile:fs/afs/cell.c SourceLine:29] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_dec_cells_outstanding SourceFile:fs/afs/cell.c SourceLine:30]] TruncatedOutput:false]
|
| 12/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 29482
output: 43
thoughts: 21
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience:
**Analyzing AFS Cell Allocation Metrics**
Alright, let's dive in. My immediate focus is on two key variables: `afs_dec_cells_outstanding` and `afs_alloc_cell`. I'm mentally parsing these, connecting them to their implications for AFS (Andrew File System) performance and resource management.
`afs_dec_cells_outstanding`... that represents the number of AFS cells that have been *requested* but haven't yet been *completed*. This directly speaks to contention in the system. A high value likely points to bottlenecks β slow disk I/O, potential network latency, or perhaps an overwhelmed cell server. I'm immediately considering what underlying cause could be. Could it be a particular client? Is it a server-side problem or a client-side problem? I need to look into this more!
And then there's `afs_alloc_cell`. This one, as I understand it, represents the allocation of the number of AFS cells used. This tells me about the overall load on a particular server, and how many resources are being used. So this one should be correlated to the other variable. My immediate thoughts go to correlating those with overall system load. I'm thinking about the ratio, the trends, the rate of change.
The interaction of these two metrics is where the interesting analysis lies. A stable ratio suggests a well-tuned system. A growing gap, however... that's a red flag. It begs further investigation. Are we seeing increased latency in cell allocation? Are we hitting resource limits? I'm already formulating questions to investigate. I'm thinking about how I'd approach diagnosing a performance issue based on these signals. I'd definitely be comparing these values with other relevant metrics like disk utilization, network throughput, and client request rates.
|
| 13/2 |
2026/05/12 23:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_dec_cells_outstanding]
Results: map[SourceCode: 27: static void afs_dec_cells_outstanding(struct afs_net *net)
28: {
29: if (atomic_dec_and_test(&net->cells_outstanding))
30: wake_up_var(&net->cells_outstanding);
31: }
SourceFile:fs/afs/cell.c]
|
| 14/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 30051
output: 41
thoughts: 11
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Analyzing `afs_alloc_cell`**
Alright, let's take a look at `afs_alloc_cell`. This functionβ¦ right, let's analyze how this plays out in the wider system. I need to refresh my understanding of the data structures involved, specifically how the cells are arranged within the overall `afs` framework. What's the allocation strategy here? Is it a simple contiguous allocation, or something more sophisticated like a buddy system or slab allocator tailored to the expected cell size and access patterns? Are we protecting against fragmentation? What happens if the system is under extreme load, or running out of memory? Is there graceful degradation built in? I need to look closely at the error handling β how are out-of-memory conditions handled, and are there fallback mechanisms in place? Are there any potential race conditions I should be looking for? I bet there are some mutexes involved, given it's shared memory. Right, let's see how they interact. Are we talking about internal/external fragmentation, and is it a significant consideration? It would also be good to find out what are the typical size ranges, and if there are any performance optimisations in place based on these typical cell sizes. I need to trace this function's use throughout the code; who's calling it, and when, and under what circumstances? That will give me context as to its criticalness. Time to put on my debugging hat, and get a better understanding of what the original designers were thinking.
|
| 15/2 |
2026/05/12 23:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_alloc_cell]
Results: map[SourceCode: 104: /*
105: * Set up a cell record and fill in its name, VL server address list and
106: * allocate an anonymous key
107: */
108: static struct afs_cell *afs_alloc_cell(struct afs_net *net,
109: const char *name, unsigned int namelen,
110: const char *addresses)
111: {
112: struct afs_vlserver_list *vllist = NULL;
113: struct afs_cell *cell;
114: int i, ret;
115:
116: ASSERT(name);
117: if (namelen == 0)
118: return ERR_PTR(-EINVAL);
119: if (namelen > AFS_MAXCELLNAME) {
120: _leave(" = -ENAMETOOLONG");
121: return ERR_PTR(-ENAMETOOLONG);
122: }
123:
124: /* Prohibit cell names that contain unprintable chars, '/' and '@' or
125: * that begin with a dot. This also precludes "@cell".
126: */
127: if (name[0] == '.')
128: return ERR_PTR(-EINVAL);
129: for (i = 0; i < namelen; i++) {
130: char ch = name[i];
131: if (!isprint(ch) || ch == '/' || ch == '@')
132: return ERR_PTR(-EINVAL);
133: }
134:
135: _enter("%*.*s,%s", namelen, namelen, name, addresses);
136:
137: cell = kzalloc(sizeof(struct afs_cell), GFP_KERNEL);
138: if (!cell) {
139: _leave(" = -ENOMEM");
140: return ERR_PTR(-ENOMEM);
141: }
142:
143: /* Allocate the cell name and the key name in one go. */
144: cell->name = kmalloc(1 + namelen + 1 +
145: 4 + namelen + 1, GFP_KERNEL);
146: if (!cell->name) {
147: kfree(cell);
148: return ERR_PTR(-ENOMEM);
149: }
150:
151: cell->name[0] = '.';
152: cell->name++;
153: cell->name_len = namelen;
154: for (i = 0; i < namelen; i++)
155: cell->name[i] = tolower(name[i]);
156: cell->name[i++] = 0;
157:
158: cell->key_desc = cell->name + i;
159: memcpy(cell->key_desc, "afs@", 4);
160: memcpy(cell->key_desc + 4, cell->name, cell->name_len + 1);
161:
162: cell->net = net;
163: refcount_set(&cell->ref, 1);
164: atomic_set(&cell->active, 0);
165: INIT_WORK(&cell->destroyer, afs_destroy_cell_work);
166: INIT_WORK(&cell->manager, afs_manage_cell_work);
167: timer_setup(&cell->management_timer, afs_cell_timer, 0);
168: init_rwsem(&cell->vs_lock);
169: cell->volumes = RB_ROOT;
170: INIT_HLIST_HEAD(&cell->proc_volumes);
171: seqlock_init(&cell->volume_lock);
172: cell->fs_servers = RB_ROOT;
173: init_rwsem(&cell->fs_lock);
174: rwlock_init(&cell->vl_servers_lock);
175: cell->flags = (1 << AFS_CELL_FL_CHECK_ALIAS);
176:
177: /* Provide a VL server list, filling it in if we were given a list of
178: * addresses to use.
179: */
180: if (addresses) {
181: vllist = afs_parse_text_addrs(net,
182: addresses, strlen(addresses), ':',
183: VL_SERVICE, AFS_VL_PORT);
184: if (IS_ERR(vllist)) {
185: ret = PTR_ERR(vllist);
186: vllist = NULL;
187: goto parse_failed;
188: }
189:
190: vllist->source = DNS_RECORD_FROM_CONFIG;
191: vllist->status = DNS_LOOKUP_NOT_DONE;
192: cell->dns_expiry = TIME64_MAX;
193: } else {
194: ret = -ENOMEM;
195: vllist = afs_alloc_vlserver_list(0);
196: if (!vllist)
197: goto error;
198: vllist->source = DNS_RECORD_UNAVAILABLE;
199: vllist->status = DNS_LOOKUP_NOT_DONE;
200: cell->dns_expiry = ktime_get_real_seconds();
201: }
202:
203: rcu_assign_pointer(cell->vl_servers, vllist);
204:
205: cell->dns_source = vllist->source;
206: cell->dns_status = vllist->status;
207: smp_store_release(&cell->dns_lookup_count, 1); /* vs source/status */
208: atomic_inc(&net->cells_outstanding);
209: ret = idr_alloc_cyclic(&net->cells_dyn_ino, cell,
210: 2, INT_MAX / 2, GFP_KERNEL);
211: if (ret < 0)
212: goto error;
213: cell->dynroot_ino = ret;
214: cell->debug_id = atomic_inc_return(&cell_debug_id);
215:
216: trace_afs_cell(cell->debug_id, 1, 0, afs_cell_trace_alloc);
217:
218: _leave(" = %p", cell);
219: return cell;
220:
221: parse_failed:
222: if (ret == -EINVAL)
223: printk(KERN_ERR "kAFS: bad VL server IP address\n");
224: error:
225: afs_put_vlserverlist(cell->net, vllist);
226: kfree(cell->name - 1);
227: kfree(cell);
228: _leave(" = %d", ret);
229: return ERR_PTR(ret);
230: }
SourceFile:fs/afs/cell.c]
|
| 16/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 32494
output: 51
thoughts: 43
Thoughts: Okay, here's my take on those thoughts, framed as an expert's inner monologue:
**Tracking Cell Allocation in the AFS Filesystem**
Alright, let's see, I'm thinking about `cells_outstanding`. This counter, ah yes, it's used to track the number of allocated cells within the AFS subsystem. I recall that `afs_alloc_cell` increases this counter, that makes sense. We're allocating a cell, so the outstanding count goes up. Simple enough.
The more interesting question, of course, is where it gets decremented. If cells are allocated, they need to be released eventually, which means calling `afs_dec_cells_outstanding`. I need to figure out the use-cases where cells are being deallocated. I'm going to have to do some deeper digging to find the callers of `afs_dec_cells_outstanding`. I'll need to consider all the possible scenarios, errors, and clean-up paths to get a comprehensive view of cell management in this thing. I suspect there are a number of potential edge-cases to be aware of. Let's start with a code search...
|
| 17/2 |
2026/05/12 23:51 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeSnippetLines:0 Name:afs_dec_cells_outstanding SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_cell_destroy SourceFile:fs/afs/cell.c SourceLine:584]] TruncatedOutput:false]
|
| 18/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 32902
output: 41
thoughts: 11
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Analyzing `afs_cell_destroy`**
Alright, let's take a look at this `afs_cell_destroy` function, shall we? My first instinct is to immediately think about what it *does*. It's responsible for destroying an AFS cell, right? So, what are the critical operations involved? We're certainly talking about resource deallocation. I'd expect memory to be freed, file system entries potentially removed, and any associated processes or services gracefully shut down. I need to keep in mind the potential cascading effects - what depends on this cell? Does this mean we also need to destroy its dependencies, or are we going to orphan them?
The implications for data integrity are also paramount. How does this function ensure that data loss is minimized during the destruction? Is there a backup or migration process involved? Are there any consistency checks before destruction to ensure the cell is in a known, stable state?
I'll be looking for potential race conditions here too. How is this destruction protected from concurrent access? Are there locks involved? If so, what are the lock hierarchies? And how is this handled in a distributed environment? We can't have a single point of failure in this process. What happens if this fails halfway through? How will we recover? Are there logging and auditing mechanisms in place? I need to know the specific steps of its implementation. I'll need to know what structures, data dependencies, and system calls are involved. Let's see how this works!
|
| 19/2 |
2026/05/12 23:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_cell_destroy]
Results: map[SourceCode: 562: /*
563: * Destroy a cell record
564: */
565: static void afs_cell_destroy(struct rcu_head *rcu)
566: {
567: struct afs_cell *cell = container_of(rcu, struct afs_cell, rcu);
568: struct afs_net *net = cell->net;
569: int r;
570:
571: _enter("%p{%s}", cell, cell->name);
572:
573: r = refcount_read(&cell->ref);
574: ASSERTCMP(r, ==, 0);
575: trace_afs_cell(cell->debug_id, r, atomic_read(&cell->active), afs_cell_trace_free);
576:
577: afs_put_vlserverlist(net, rcu_access_pointer(cell->vl_servers));
578: afs_unuse_cell(cell->alias_of, afs_cell_trace_unuse_alias);
579: key_put(cell->anonymous_key);
580: idr_remove(&net->cells_dyn_ino, cell->dynroot_ino);
581: kfree(cell->name - 1);
582: kfree(cell);
583:
584: afs_dec_cells_outstanding(net);
585: _leave(" [destroyed]");
586: }
SourceFile:fs/afs/cell.c]
|
| 20/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 33739
output: 49
thoughts: 58
Thoughts: Okay, here's my take on those thoughts, framed from my expert perspective:
**Debugging the afs_cell_destroy Function**
Alright, so I'm diving into this `afs_cell_destroy` function. My initial thought is that it's an RCU callback, which is standard procedure for freeing things in the kernel, especially when dealing with concurrent data structures. That's usually the go-to pattern in this neck of the woods. Then, the next thing I need to confirm is how this callback is actually *called*. Is it `call_rcu` that's initiating it, or are we dealing with a `kfree_rcu` scenario? That distinction matters greatly for understanding the memory lifecycle and potential locking implications. To properly debug or understand the context, I need to know the calling mechanism. The only way to find out for certain, is to find out where it is referenced.
|
| 21/2 |
2026/05/12 23:51 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeSnippetLines:0 Name:afs_cell_destroy SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_destroy_cell_work SourceFile:fs/afs/cell.c SourceLine:595]] TruncatedOutput:false]
|
| 22/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 34113
output: 43
thoughts: 13
Thoughts: Okay, let's dive into this `afs_destroy_cell_work` function. I need to understand its purpose and how it fits into the larger architecture. What's the context here? Is it related to destroying an AFS cell? If so, what exactly constitutes "destroying" a cell in this system? Does it involve unmounting volumes, removing user data, deleting configuration files, or something more?
I'm thinking about the potential implications. What resources does this function utilize? Does it interact with the network, storage, or other system components? Are there any concurrency considerations I need to keep in mind, like locking mechanisms or potential race conditions? What about error handling? How gracefully does it deal with failures? What happens if a volume can't be unmounted, or a file can't be deleted?
I need to quickly assess the risks involved. This function likely deals with critical operations. A misstep here could lead to data loss or system instability. I'll need to scrutinize the code closely. I'll be looking for potential vulnerabilities and edge cases. I'll pay close attention to the order of operations, resource cleanup, and any external dependencies. I need to make sure that whatever this function does, it's safe, reliable, and designed with proper error handling.
This is going to be interesting. Time to analyze.
|
| 23/2 |
2026/05/12 23:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_destroy_cell_work]
Results: map[SourceCode: 588: static void afs_destroy_cell_work(struct work_struct *work)
589: {
590: struct afs_cell *cell = container_of(work, struct afs_cell, destroyer);
591:
592: afs_see_cell(cell, afs_cell_trace_destroy);
593: timer_delete_sync(&cell->management_timer);
594: cancel_work_sync(&cell->manager);
595: call_rcu(&cell->rcu, afs_cell_destroy);
596: }
SourceFile:fs/afs/cell.c]
|
| 24/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 34643
output: 50
thoughts: 36
Thoughts: Okay, here's my interpretation of those thoughts, presented as my own mental process:
**Tracing the Lifecycle of a Cell Destruction**
Right, so I need to figure out the destruction process for a cell, specifically when `afs_destroy_cell_work` gets invoked. That's a work item, meaning it's likely part of an asynchronous task queue. I want to trace how this destruction happens and what triggers it.
The key is going to be finding where `cell->destroyer` is actually enqueued. That `destroyer` field likely holds some kind of pointer or handle related to the destruction process, so finding where that's scheduled is the logical next step. That should lead me to the root cause.
|
| 25/2 |
2026/05/12 23:51 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeSnippetLines:0 Name:afs_cell::destroyer SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_alloc_cell SourceFile:fs/afs/cell.c SourceLine:165] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_alloc_cell SourceFile:fs/afs/cell.c SourceLine:165] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_alloc_cell SourceFile:fs/afs/cell.c SourceLine:165] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_alloc_cell SourceFile:fs/afs/cell.c SourceLine:165] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_alloc_cell SourceFile:fs/afs/cell.c SourceLine:165] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:afs_destroy_cell_work SourceFile:fs/afs/cell.c SourceLine:590] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_put_cell SourceFile:fs/afs/cell.c SourceLine:627] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_unuse_cell SourceFile:fs/afs/cell.c SourceLine:676]] TruncatedOutput:false]
|
| 26/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 35325
output: 41
thoughts: 20
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Analyzing `afs_put_cell` and `afs_unuse_cell`**
Alright, I'm thinking about `afs_put_cell` and `afs_unuse_cell`. I immediately start dissecting their purpose within the context of the AFS filesystem. My brain kicks in, considering how these functions operate on the cell structure. I envision the data flow: `afs_put_cell`, obviously, handles inserting or updating cell information in the relevant data structures. But, I wonder, are we talking about the cell name, UUID, server lists, or all of the above? The details will be key to understanding its complete function. What locking mechanisms are in place during this operation? Concurrency control is paramount in a distributed system like AFS.
Then, my mind shifts to `afs_unuse_cell`. This is the counterpart, the cleanup function. I'm wondering what triggers this call, and what state the cell object is expected to be in when `afs_unuse_cell` is invoked. It's probably called when a client, or perhaps a server, no longer requires information about a cell. So, is it freeing resources, removing entries from caches, or just decrementing reference counts? I'm anticipating that memory management and resource cleanup will be crucial aspects to check here, considering the performance implications of not handling that correctly. Potential memory leaks are the first things that spring to mind. Then, I am considering the implications of error handling for both of these functions. What happens on failure? And, in particular, what are the implications on any state management, with this in mind?
Are these functions idempotent, or does calling them multiple times produce different results? Knowing the underlying mechanisms and what data structures they interact with is critical, for the purposes of optimization and debugging, too.
|
| 27/2 |
2026/05/12 23:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_put_cell]
Results: map[SourceCode: 610: /*
611: * Drop a reference on a cell record.
612: */
613: void afs_put_cell(struct afs_cell *cell, enum afs_cell_trace reason)
614: {
615: if (cell) {
616: unsigned int debug_id = cell->debug_id;
617: unsigned int a;
618: bool zero;
619: int r;
620:
621: a = atomic_read(&cell->active);
622: zero = __refcount_dec_and_test(&cell->ref, &r);
623: trace_afs_cell(debug_id, r - 1, a, reason);
624: if (zero) {
625: a = atomic_read(&cell->active);
626: WARN(a != 0, "Cell active count %u > 0\n", a);
627: WARN_ON(!queue_work(afs_wq, &cell->destroyer));
628: }
629: }
630: }
SourceFile:fs/afs/cell.c]
|
| 28/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 36133
output: 42
thoughts: 9
Thoughts: Okay, here's my attempt at summarizing the thought process, tailored for an expert audience, and written in the first person:
**Analyzing the `afs_unuse_cell` Function**
Alright, let's break down this `afs_unuse_cell` function. I'm immediately thinking about its role in the cell management within the AFS file system. My expertise tells me this function is critical for maintaining consistency and avoiding resource leaks, particularly regarding cached data and metadata associated with these cells.
The name itself, "unuse," suggests deallocation or at least marking a cell as no longer actively in use. That implies potential tasks like releasing associated memory, updating reference counts, invalidating caches, and potentially handling interactions with other AFS components like the volume server or the file server if the cell's data is no longer necessary. I want to look closely at its interactions with the cell struct to understand which fields are being modified and how the function handles concurrent access, especially if this function can be called from different threads or processes.
I'm imagining a complex dance of actions to be undertaken within that cell. Is there some sort of cleanup queue? Are any external resources being freed? Is it involved in a cell recycling mechanism that allows reuse? Do cells always need to be βun-usedβ when a volume is modified, or removed?
This function likely ties into a larger design which involves keeping track of active versus unused cells, and possibly cell aging, and potential garbage collection. I'll need to examine the surrounding code to determine how this is managed to verify its integrity, especially under load and during failure conditions. My main goal is to fully understand how the file system manages the life cycle of a cell. I want to see how these cells are managed at a low level, and how they relate to the VFS and the physical storage. Any insight on error handling, and potential races would be useful, as well.
|
| 29/2 |
2026/05/12 23:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_unuse_cell]
Results: map[SourceCode: 645: /*
646: * Record a cell becoming less active. When the active counter reaches 1, it
647: * is scheduled for destruction, but may get reactivated.
648: */
649: void afs_unuse_cell(struct afs_cell *cell, enum afs_cell_trace reason)
650: {
651: unsigned int debug_id;
652: time64_t now, expire_delay;
653: bool zero;
654: int r, a;
655:
656: if (!cell)
657: return;
658:
659: _enter("%s", cell->name);
660:
661: now = ktime_get_real_seconds();
662: cell->last_inactive = now;
663: expire_delay = 0;
664: if (cell->vl_servers->nr_servers)
665: expire_delay = afs_cell_gc_delay;
666:
667: debug_id = cell->debug_id;
668: a = atomic_dec_return(&cell->active);
669: if (!a)
670: /* 'cell' may now be garbage collected. */
671: afs_set_cell_timer(cell, expire_delay);
672:
673: zero = __refcount_dec_and_test(&cell->ref, &r);
674: trace_afs_cell(debug_id, r - 1, a, reason);
675: if (zero)
676: WARN_ON(!queue_work(afs_wq, &cell->destroyer));
677: }
SourceFile:fs/afs/cell.c]
|
| 30/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 37106
output: 41
thoughts: 337
Thoughts: **Analyzing the Cell Purge Operation**
Okay, so I'm looking at `afs_cell_purge`. My initial impression is that it looks like a clean-up function for network cells. The first part, it seems, is dealing with the *workstation cache*. It grabs a write lock on `net->cells_lock`, then atomically replaces the workstation cell pointer, `net->ws_cell`, with `NULL` using `rcu_replace_pointer`. Then it releases the write lock and calls `afs_unuse_cell` on the old workstation cell, probably to release some resources, which makes sense. The comment there also mentions using `lockdep`, which is good to see as it confirms that the lock's held status is being verified.
Next, it moves on to the *general cell cleanup*. Another debug message signals this. A read lock is taken on `net->cells_lock`. I see a loop here, iterating through all cells currently managed in a red-black tree, `net->cells`. For each cell, the code calls `afs_see_cell` and checks for the `AFS_CELL_FL_NO_GC` flag. If it's set, the cell is marked for un-use. The most important thing it appears to do is `afs_queue_cell` for each cell, which means this operation will continue after the lock is released. Finally, the read lock is released.
The final part involves a `wait_var_event`. This looks like a synchronization point, waiting for `net->cells_outstanding` to reach zero. My educated guess is that `net->cells_outstanding` is incremented by the `afs_queue_cell` call and decremented when the work queue tasks are completed. It's waiting for those pending tasks to finish.
Aha! `afs_queue_cell`... I need to look into this function because this is where the *actual* work to free the cells is *happening*. I'm going to look at that next to understand what's going on behind the scenes.
|
| 31/2 |
2026/05/12 23:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_queue_cell]
Results: map[SourceCode: 691: /*
692: * Queue a cell for management, giving the workqueue a ref to hold.
693: */
694: void afs_queue_cell(struct afs_cell *cell, enum afs_cell_trace reason)
695: {
696: queue_work(afs_wq, &cell->manager);
697: }
SourceFile:fs/afs/cell.c]
|
| 32/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 38060
output: 43
thoughts: 37
Thoughts: Okay, let me think this through.
**Analyzing the Queueing Mechanism**
Hold on a second...I need to re-examine how this `afs_queue_cell` function operates. It seems I made an incorrect assumption; it's not actually *referencing* the `cell` itself, is it? It looks like it's just queuing up `cell->manager`. Right, that's important. I need to understand what happens to this `manager` during the queuing process. Let me refresh my memory of `afs_manage_cell_work`. I need to ensure that the interactions there are consistent with this behavior. I'm guessing there's more logic that interacts with `cell->manager` directly, and that's the part that is queued.
|
| 33/2 |
2026/05/12 23:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_manage_cell_work]
Results: map[SourceCode: 878: static void afs_manage_cell_work(struct work_struct *work)
879: {
880: struct afs_cell *cell = container_of(work, struct afs_cell, manager);
881: bool final_put;
882:
883: afs_see_cell(cell, afs_cell_trace_manage);
884: final_put = afs_manage_cell(cell);
885: afs_see_cell(cell, afs_cell_trace_managed);
886: if (final_put)
887: afs_put_cell(cell, afs_cell_trace_put_final);
888: }
SourceFile:fs/afs/cell.c]
|
| 34/2 |
2026/05/12 23:51 |
llm |
expert |
0m
Model:
Tokens:
input: 38528
output: 41
thoughts: 11
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Analyzing `afs_manage_cell`**
Alright, let's get down to brass tacks and take a look at `afs_manage_cell`. Where does this fit in the grand scheme of things? Immediately, my mind starts considering the implications of this function or module. I'm already asking myself the key questions: What's its purpose within the AFS architecture? Is this related to cell configuration, management, security, or something else entirely?
I'm thinking about the low-level details of cell management. Am I looking at something that handles bootstrapping new cells, joining existing cells, or perhaps operational tasks such as monitoring, maintenance, and healing? Or is it more concerned with the high-level configuration parameters of the cell itself? Perhaps it encompasses cell-wide security policies, like authentication methods or access control lists.
My experience immediately kicks in. I'm already referencing internal APIs and associated code. My brain is cross-referencing this with the documentation I've read and the practical use of the cell. I want to build a mental map of its context.
|
| 35/2 |
2026/05/12 23:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_manage_cell]
Results: map[SourceCode: 788: /*
789: * Manage a cell record, initialising and destroying it, maintaining its DNS
790: * records.
791: */
792: static bool afs_manage_cell(struct afs_cell *cell)
793: {
794: struct afs_net *net = cell->net;
795: time64_t next_manage = TIME64_MAX;
796: int ret;
797:
798: _enter("%s", cell->name);
799:
800: _debug("state %u", cell->state);
801: switch (cell->state) {
802: case AFS_CELL_SETTING_UP:
803: goto set_up_cell;
804: case AFS_CELL_UNLOOKED:
805: case AFS_CELL_ACTIVE:
806: goto cell_is_active;
807: case AFS_CELL_REMOVING:
808: WARN_ON_ONCE(1);
809: return false;
810: case AFS_CELL_DEAD:
811: return false;
812: default:
813: _debug("bad state %u", cell->state);
814: WARN_ON_ONCE(1); /* Unhandled state */
815: return false;
816: }
817:
818: set_up_cell:
819: ret = afs_activate_cell(net, cell);
820: if (ret < 0) {
821: cell->error = ret;
822: goto remove_cell;
823: }
824:
825: afs_set_cell_state(cell, AFS_CELL_UNLOOKED);
826:
827: cell_is_active:
828: if (afs_has_cell_expired(cell, &next_manage))
829: goto remove_cell;
830:
831: if (test_and_clear_bit(AFS_CELL_FL_DO_LOOKUP, &cell->flags)) {
832: ret = afs_update_cell(cell);
833: if (ret < 0)
834: cell->error = ret;
835: if (cell->state == AFS_CELL_UNLOOKED)
836: afs_set_cell_state(cell, AFS_CELL_ACTIVE);
837: }
838:
839: if (next_manage < TIME64_MAX && cell->net->live) {
840: time64_t now = ktime_get_real_seconds();
841:
842: if (next_manage - now <= 0)
843: afs_queue_cell(cell, afs_cell_trace_queue_again);
844: else
845: afs_set_cell_timer(cell, next_manage - now);
846: }
847: _leave(" [done %u]", cell->state);
848: return false;
849:
850: remove_cell:
851: down_write(&net->cells_lock);
852:
853: if (atomic_read(&cell->active)) {
854: up_write(&net->cells_lock);
855: goto cell_is_active;
856: }
857:
858: /* Make sure that the expiring server records are going to see the fact
859: * that the cell is caput.
860: */
861: afs_set_cell_state(cell, AFS_CELL_REMOVING);
862:
863: afs_deactivate_cell(net, cell);
864: afs_purge_servers(cell);
865:
866: rb_erase(&cell->net_node, &net->cells);
867: afs_see_cell(cell, afs_cell_trace_unuse_delete);
868: up_write(&net->cells_lock);
869:
870: /* The root volume is pinning the cell */
871: afs_put_volume(cell->root_volume, afs_volume_trace_put_cell_root);
872: cell->root_volume = NULL;
873:
874: afs_set_cell_state(cell, AFS_CELL_DEAD);
875: return true;
876: }
SourceFile:fs/afs/cell.c]
|
| 36/2 |
2026/05/12 23:52 |
llm |
expert |
0m
Model:
Tokens:
input: 40170
output: 43
thoughts: 352
Thoughts: **Analyzing Cell Management in AFS**
Okay, so `afs_manage_cell` is returning `true` when it removes a cell. Interesting. And when that happens, `afs_manage_cell_work` calls `afs_put_cell` with `afs_cell_trace_put_final`. Right, makes sense so far. Now, hang on... let's see what `afs_cell_purge` does.
It looks like `afs_cell_purge` iterates through the cells. Within that loop, we have `afs_see_cell`, then checks a flag: if `AFS_CELL_FL_NO_GC` is set, it calls `afs_unuse_cell` with `afs_cell_trace_unuse_pin`. Finally, it calls `afs_queue_cell` with `afs_cell_trace_queue_purge`. That's where it gets interesting, as it seems `afs_unuse_cell` is crucial here.
Right, `afs_unuse_cell`... let me think, yes, it decrements `cell->active` and `cell->ref`. If `cell->ref` hits zero, it queues `cell->destroyer`. That's a classic garbage collection trigger. Ah, I see a potential issue: `afs_unuse_cell` also decrements `cell->active`. If *that* drops to zero, it calls `afs_set_cell_timer`. Okay, so `active` indicates that the cell is in use, and `ref` looks like something else entirely. Further inspection is required.
Then, `afs_queue_cell` queues `cell->manager`. That seems to be a key element for managing those cells in the queue. And how does `afs_manage_cell` determine the next cell to manage? Right, it checks `afs_has_cell_expired(cell, &next_manage)`. Let's dig into that `afs_has_cell_expired` function; I need to understand its logic for the timeout mechanism.
|
| 37/2 |
2026/05/12 23:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_has_cell_expired]
Results: map[SourceCode: 766: static bool afs_has_cell_expired(struct afs_cell *cell, time64_t *_next_manage)
767: {
768: const struct afs_vlserver_list *vllist;
769: time64_t expire_at = cell->last_inactive;
770: time64_t now = ktime_get_real_seconds();
771:
772: if (atomic_read(&cell->active))
773: return false;
774: if (!cell->net->live)
775: return true;
776:
777: vllist = rcu_dereference_protected(cell->vl_servers, true);
778: if (vllist && vllist->nr_servers > 0)
779: expire_at += afs_cell_gc_delay;
780:
781: if (expire_at <= now)
782: return true;
783: if (expire_at < *_next_manage)
784: *_next_manage = expire_at;
785: return false;
786: }
SourceFile:fs/afs/cell.c]
|
| 38/2 |
2026/05/12 23:52 |
llm |
expert |
0m
Model:
Tokens:
input: 41364
output: 41
thoughts: 43
Thoughts: Okay, here's my interpretation of this scenario, focusing on the logical flow as if I were the one thinking through it:
**Deconstructing a Network Live State in AFS**
Alright, I'm looking at this bit of code, and it's got me thinking about how we determine if a cell's network connection is actually "live" within this AFS context. If `!cell->net->live` is true, then we're returning `true`. Seems straightforward enough: basically, if the cell network isn't live, weβre going to confirm this fact with a "true" result. This appears to be a check for a dead network, or some other failure scenario.
The next thing that jumps out is `afs_cell_purge`. I immediately suspect that the state of `net->live` is likely *false* within that context. That kind of function implies that something is being removed or deactivated, and a network that is not live is consistent with a "purge". Therefore, I need to check how the network's live status gets set up in the first place, or perhaps *de*activated. The place to go next is the `afs_net_exit` function, as that is the function where the connection would likely be torn down, and the "live" status would likely be set to false. This is where I would expect to find the actual mechanism for marking the network as no longer active. I need to understand what happens there.
|
| 39/2 |
2026/05/12 23:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/main.c IncludeLines:true Name:afs_net_exit]
Results: map[SourceCode: 138: /*
139: * Clean up and destroy an AFS network namespace record.
140: */
141: static void __net_exit afs_net_exit(struct net *net_ns)
142: {
143: struct afs_net *net = afs_net(net_ns);
144:
145: net->live = false;
146: afs_fs_probe_cleanup(net);
147: afs_cell_purge(net);
148: afs_wait_for_servers(net);
149: afs_close_socket(net);
150: afs_proc_cleanup(net);
151: afs_put_sysnames(net->sysnames);
152: idr_destroy(&net->cells_dyn_ino);
153: kfree_rcu(rcu_access_pointer(net->address_prefs), rcu);
154: }
SourceFile:fs/afs/main.c]
|
| 40/2 |
2026/05/12 23:52 |
llm |
expert |
0m
Model:
Tokens:
input: 42057
output: 49
thoughts: 1002
Thoughts: **Analysis of Potential Deadlock in AFS Cell Purge**
Okay, so I've been tracing through this cell purge logic and I think I see a serious issue. Initially, the code sets `net->live = false` before purging cells. This is crucial. My immediate thought was that this would cause `afs_has_cell_expired` to always return `true`, leading to all cells being marked for removal. But that's not quite right.
The removal process, initiated by `afs_manage_cell`, calls the `remove_cell` label. The crucial check inside `remove_cell` is `atomic_read(&cell->active)`. If this is true, the process jumps to `cell_is_active`. My initial assumption was a loop, but the code cleverly avoids a perpetual loop by calling `afs_has_cell_expired` again.
Here's the problem: *if* `cell->active` is true, then `afs_has_cell_expired` immediately returns `false`! That means the cell *isn't* immediately removed. It falls through to the logic within `cell_is_active`, including the `AFS_CELL_FL_DO_LOOKUP` flag and the subsequent conditional on `net->live`. This leads to the cell *not* being removed.
So, here's the deadlock: `afs_cell_purge` waits for `net->cells_outstanding` to hit zero. This counter is decremented when a cell is *destroyed* (in `afs_cell_destroy`). But, if `cell->active` is true and we're in `cell_is_active`, then the cell is *not* destroyed. The `cells_outstanding` counter never reaches zero! `afs_cell_purge` hangs indefinitely.
The key question is: **Why would `cell->active` be true after `net->live` is set to false?** In `afs_cell_purge`, it appears that if `AFS_CELL_FL_NO_GC` is set the cell is "un-used", decrementing `cell->active`. But, what if `cell->active` is greater than 1, or the flag is not set?
We need to understand how `cell->active` is incremented and decremented throughout the lifecycle of a cell. I have a hunch this might relate to how the volume is handled, since after the purge there is `afs_put_volume(cell->root_volume, afs_volume_trace_put_cell_root);` which suggests volume pinning. Any cell pinning will increment `cell->active`.
This warrants a much closer look at how the cell's "active" state is managed to fully understand how this deadlock is triggered. We really need to track down all the places where `cell->active` is incremented and decremented to be sure. This is an interesting problem!
|
| 41/2 |
2026/05/12 23:52 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeSnippetLines:0 Name:afs_cell::active SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_alloc_cell SourceFile:fs/afs/cell.c SourceLine:164] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_cell_destroy SourceFile:fs/afs/cell.c SourceLine:575] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_get_cell SourceFile:fs/afs/cell.c SourceLine:606] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_has_cell_expired SourceFile:fs/afs/cell.c SourceLine:772] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_manage_cell SourceFile:fs/afs/cell.c SourceLine:853] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_proc_cells_show SourceFile:fs/afs/proc.c SourceLine:51] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_put_cell SourceFile:fs/afs/cell.c SourceLine:621] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_put_cell SourceFile:fs/afs/cell.c SourceLine:625] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_see_cell SourceFile:fs/afs/cell.c SourceLine:687] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_unuse_cell SourceFile:fs/afs/cell.c SourceLine:668] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:afs_use_cell SourceFile:fs/afs/cell.c SourceLine:640]] TruncatedOutput:false]
|
| 42/2 |
2026/05/12 23:52 |
llm |
expert |
0m
Model:
Tokens:
input: 44334
output: 41
thoughts: 11
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Analyzing `afs_use_cell`**
Alright, so the initial thought is "Let's see `afs_use_cell`." My mind immediately jumps to a few key areas when I see that. It's almost a knee-jerk reaction. I'm immediately thinking about its potential implications within the context of the AFS file system. My expertise tells me this likely relates to how cells are utilized β are we talking about cell selection, cell usage policy, or something more fundamental to the AFS architecture? Perhaps it's a configuration option, or maybe even a subroutine call within the AFS kernel. I'm running through my mental checklist: Is it related to client-side behavior, server-side management, or potentially a hybrid approach? Iβm thinking about its role in replication, load balancing, or even security boundaries within the AFS environment. My years of experience tell me the nuances here could be critical to performance, scalability, and overall system integrity. Let's dig deeper.
|
| 43/2 |
2026/05/12 23:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_use_cell]
Results: map[SourceCode: 632: /*
633: * Note a cell becoming more active.
634: */
635: struct afs_cell *afs_use_cell(struct afs_cell *cell, enum afs_cell_trace reason)
636: {
637: int r, a;
638:
639: __refcount_inc(&cell->ref, &r);
640: a = atomic_inc_return(&cell->active);
641: trace_afs_cell(cell->debug_id, r + 1, a, reason);
642: return cell;
643: }
SourceFile:fs/afs/cell.c]
|
| 44/2 |
2026/05/12 23:52 |
llm |
expert |
0m
Model:
Tokens:
input: 44831
output: 49
thoughts: 10
Thoughts: Here's my thought process, as if I were analyzing that question:
**Deep Dive into `afs_use_cell`**
Okay, so the prompt is asking me to trace the call graph for `afs_use_cell`. My immediate reaction is, "Right, I need to understand where this function lives within the AFS kernel module and, more importantly, *why* it's being called."
My mind immediately starts forming a few pathways of investigation. First, Iβd want to quickly grep through the AFS source code. I'd be looking for all instances where `afs_use_cell` is invoked. This will give me a raw list of potential callers. But a plain text search isn't enough - I need to understand the *context* of each call.
Then I need to think like a system. What are the common tasks or events within AFS where a cell context might need to be explicitly managed? I'm visualizing the AFS architecture - is this related to volume mounts, authentication, name resolution, or something else entirely? Could it be a low-level operation, or something more related to user-space interactions?
I'm considering this from a perspective of security and performance. A function like `afs_use_cell` would be a key to cell isolation and management. It is important to know which processes are calling this function.
Next, I would consult the AFS documentation or relevant RFCs, looking for descriptions of how cells are handled and how the kernel interacts with them. This documentation would give me higher-level insights into the intended purpose of `afs_use_cell`. Am I dealing with a reference-counting mechanism, a context switch, or something more fundamental?
With that, I'd move onto deeper source code analysis, using the initial grep results as a starting point. I'd need to examine the calling functions and their call graphs to determine the logical flow. I might use a debugger, or source code navigation tools to trace execution paths. I'd be looking at how arguments are passed, what the function returns, and how the results are used to piece together the entire picture. I'm looking for the triggers.
Finally, I would use this to explain the different reasons and calling context for this function. This gives the necessary clarity and details for a report.
|
| 45/2 |
2026/05/12 23:52 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeSnippetLines:0 Name:afs_use_cell SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_alloc_sbi SourceFile:fs/afs/super.c SourceLine:512] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_cell_init SourceFile:fs/afs/cell.c SourceLine:452] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_compare_cell_roots SourceFile:fs/afs/vl_alias.c SourceLine:131] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_find_cell_locked SourceFile:fs/afs/cell.c SourceLine:86] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_lookup_cell SourceFile:fs/afs/cell.c SourceLine:309] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_lookup_cell SourceFile:fs/afs/cell.c SourceLine:387] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_mntpt_set_params SourceFile:fs/afs/mntpt.c SourceLine:128] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_query_for_alias SourceFile:fs/afs/vl_alias.c SourceLine:201] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_validate_fc SourceFile:fs/afs/super.c SourceLine:395]] TruncatedOutput:false]
|
| 46/2 |
2026/05/12 23:52 |
llm |
expert |
0m
Model:
Tokens:
input: 45852
output: 41
thoughts: 11
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Analyzing `afs_lookup_cell`**
Alright, `afs_lookup_cell`... let's break this down. My initial thought is to immediately start thinking about its role within the overall AFS architecture. Is this a core function, a utility, or something more specialized? I need to understand its context. I'm going to quickly consider the data structures it likely interacts with β cell databases, maybe volume location servers, certainly the client's local cache.
I'm already mentally running through the typical lookup scenarios. What are the key parameters it receives? A cell name, obviously. But what else? User credentials? Volume IDs? Filepaths (if it's related to path-based lookups)? I need to anticipate the different paths the execution might take, depending on these inputs and the state of the AFS environment.
Next, I'm thinking about error handling. What failure modes are relevant? Network outages, incorrect configuration, corrupted data, invalid credentials? I want to understand how robust this function is. Are there retries? Fallbacks? Error propagation? Understanding the edge cases is crucial.
Then, I'm moving on to performance considerations. Is it optimized for speed? Does it employ caching? Does it perform network requests serially or in parallel? Could it be a bottleneck under heavy load? The architecture is on my mind. Is this design scalable?
Finally, the security implications. How does this function protect against malicious actors attempting to exploit the lookup process? Are there input validation checks? Does it use secure communication protocols? It's essential that this function remains airtight.
|
| 47/2 |
2026/05/12 23:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_lookup_cell]
Results: map[SourceCode: 232: /*
233: * afs_lookup_cell - Look up or create a cell record.
234: * @net: The network namespace
235: * @name: The name of the cell.
236: * @namesz: The strlen of the cell name.
237: * @vllist: A colon/comma separated list of numeric IP addresses or NULL.
238: * @reason: The reason we're doing the lookup
239: * @trace: The reason to be logged if the lookup is successful.
240: *
241: * Look up a cell record by name and query the DNS for VL server addresses if
242: * needed. Note that that actual DNS query is punted off to the manager thread
243: * so that this function can return immediately if interrupted whilst allowing
244: * cell records to be shared even if not yet fully constructed.
245: */
246: struct afs_cell *afs_lookup_cell(struct afs_net *net,
247: const char *name, unsigned int namesz,
248: const char *vllist,
249: enum afs_lookup_cell_for reason,
250: enum afs_cell_trace trace)
251: {
252: struct afs_cell *cell, *candidate, *cursor;
253: struct rb_node *parent, **pp;
254: enum afs_cell_state state;
255: int ret, n;
256:
257: _enter("%s,%s,%u", name, vllist, reason);
258:
259: if (reason != AFS_LOOKUP_CELL_PRELOAD) {
260: cell = afs_find_cell(net, name, namesz, trace);
261: if (!IS_ERR(cell)) {
262: if (reason == AFS_LOOKUP_CELL_DYNROOT)
263: goto no_wait;
264: if (cell->state == AFS_CELL_SETTING_UP ||
265: cell->state == AFS_CELL_UNLOOKED)
266: goto lookup_cell;
267: goto wait_for_cell;
268: }
269: }
270:
271: /* Assume we're probably going to create a cell and preallocate and
272: * mostly set up a candidate record. We can then use this to stash the
273: * name, the net namespace and VL server addresses.
274: *
275: * We also want to do this before we hold any locks as it may involve
276: * upcalling to userspace to make DNS queries.
277: */
278: candidate = afs_alloc_cell(net, name, namesz, vllist);
279: if (IS_ERR(candidate)) {
280: _leave(" = %ld", PTR_ERR(candidate));
281: return candidate;
282: }
283:
284: /* Find the insertion point and check to see if someone else added a
285: * cell whilst we were allocating.
286: */
287: down_write(&net->cells_lock);
288:
289: pp = &net->cells.rb_node;
290: parent = NULL;
291: while (*pp) {
292: parent = *pp;
293: cursor = rb_entry(parent, struct afs_cell, net_node);
294:
295: n = strncasecmp(cursor->name, name,
296: min_t(size_t, cursor->name_len, namesz));
297: if (n == 0)
298: n = cursor->name_len - namesz;
299: if (n < 0)
300: pp = &(*pp)->rb_left;
301: else if (n > 0)
302: pp = &(*pp)->rb_right;
303: else
304: goto cell_already_exists;
305: }
306:
307: cell = candidate;
308: candidate = NULL;
309: afs_use_cell(cell, trace);
310: rb_link_node_rcu(&cell->net_node, parent, pp);
311: rb_insert_color(&cell->net_node, &net->cells);
312: up_write(&net->cells_lock);
313:
314: lookup_cell:
315: if (reason != AFS_LOOKUP_CELL_PRELOAD &&
316: reason != AFS_LOOKUP_CELL_ROOTCELL) {
317: set_bit(AFS_CELL_FL_DO_LOOKUP, &cell->flags);
318: afs_queue_cell(cell, afs_cell_trace_queue_new);
319: }
320:
321: wait_for_cell:
322: state = smp_load_acquire(&cell->state); /* vs error */
323: switch (state) {
324: case AFS_CELL_ACTIVE:
325: case AFS_CELL_DEAD:
326: break;
327: case AFS_CELL_UNLOOKED:
328: default:
329: if (reason == AFS_LOOKUP_CELL_PRELOAD ||
330: reason == AFS_LOOKUP_CELL_ROOTCELL)
331: break;
332: _debug("wait_for_cell");
333: afs_see_cell(cell, afs_cell_trace_wait);
334: wait_var_event(&cell->state,
335: ({
336: state = smp_load_acquire(&cell->state); /* vs error */
337: state == AFS_CELL_ACTIVE || state == AFS_CELL_DEAD;
338: }));
339: _debug("waited_for_cell %d %d", cell->state, cell->error);
340: }
341:
342: no_wait:
343: /* Check the state obtained from the wait check. */
344: state = smp_load_acquire(&cell->state); /* vs error */
345: if (state == AFS_CELL_DEAD) {
346: ret = cell->error;
347: goto error;
348: }
349: if (state == AFS_CELL_ACTIVE) {
350: switch (cell->dns_status) {
351: case DNS_LOOKUP_NOT_DONE:
352: if (cell->dns_source == DNS_RECORD_FROM_CONFIG) {
353: ret = 0;
354: break;
355: }
356: fallthrough;
357: default:
358: ret = -EIO;
359: goto error;
360: case DNS_LOOKUP_GOOD:
361: case DNS_LOOKUP_GOOD_WITH_BAD:
362: ret = 0;
363: break;
364: case DNS_LOOKUP_GOT_NOT_FOUND:
365: ret = -ENOENT;
366: goto error;
367: case DNS_LOOKUP_BAD:
368: ret = -EREMOTEIO;
369: goto error;
370: case DNS_LOOKUP_GOT_LOCAL_FAILURE:
371: case DNS_LOOKUP_GOT_TEMP_FAILURE:
372: case DNS_LOOKUP_GOT_NS_FAILURE:
373: ret = -EDESTADDRREQ;
374: goto error;
375: }
376: }
377:
378: _leave(" = %p [cell]", cell);
379: return cell;
380:
381: cell_already_exists:
382: _debug("cell exists");
383: cell = cursor;
384: if (reason == AFS_LOOKUP_CELL_PRELOAD) {
385: ret = -EEXIST;
386: } else {
387: afs_use_cell(cursor, trace);
388: ret = 0;
389: }
390: up_write(&net->cells_lock);
391: if (candidate)
392: afs_put_cell(candidate, afs_cell_trace_put_candidate);
393: if (ret == 0)
394: goto wait_for_cell;
395: goto error_noput;
396: error:
397: afs_unuse_cell(cell, afs_cell_trace_unuse_lookup_error);
398: error_noput:
399: _leave(" = %d [error]", ret);
400: return ERR_PTR(ret);
401: }
SourceFile:fs/afs/cell.c]
|
| 48/2 |
2026/05/12 23:52 |
llm |
expert |
0m
Model:
Tokens:
input: 48890
output: 42
thoughts: 78
Thoughts: Here's my understanding of the situation, distilled down to its core:
**Delving into the AFS Cell Lookup Process**
Okay, so I'm tracing the AFS cell lookup process, and it looks like `afs_lookup_cell` is the key function here. It's calling `afs_use_cell`, which is pretty straightforward: it's increasing both the `cell->active` and `cell->ref` counters. That makes perfect sense; `active` probably indicates that the cell is currently "in use" by some process, while `ref` is tracking the total number of references to the cell data structure, regardless of whether it's actively *being* used.
Now, if `afs_lookup_cell` returns without an error, the caller now has a firm grip on the cell: it's holding a reference count and an active count. That implies that once I'm done with the cell, I have to make sure to decrement these counters. I wonder if it's the `ref` count that determines when the cell can be removed?
The real question is: who *uses* `afs_lookup_cell`? I need to understand where this function fits into the bigger picture. I see `afs_alloc_sbi` in `super.c`. That must be where things start, so that's where I need to look.
|
| 49/2 |
2026/05/12 23:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/super.c IncludeLines:true Name:afs_alloc_sbi]
Results: map[SourceCode: 500: static struct afs_super_info *afs_alloc_sbi(struct fs_context *fc)
501: {
502: struct afs_fs_context *ctx = fc->fs_private;
503: struct afs_super_info *as;
504:
505: as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
506: if (as) {
507: as->net_ns = get_net(fc->net_ns);
508: as->flock_mode = ctx->flock_mode;
509: if (ctx->dyn_root) {
510: as->dyn_root = true;
511: } else {
512: as->cell = afs_use_cell(ctx->cell, afs_cell_trace_use_sbi);
513: as->volume = afs_get_volume(ctx->volume,
514: afs_volume_trace_get_alloc_sbi);
515: }
516: }
517: return as;
518: }
SourceFile:fs/afs/super.c]
|
| 50/2 |
2026/05/12 23:52 |
llm |
expert |
0m
Model:
Tokens:
input: 49651
output: 41
thoughts: 42
Thoughts: Here's my thought process, as it relates to the kernel code:
**Navigating AFS Contexts and Allocation**
Okay, so I'm digging into this AFS code. I've hit a point where `afs_alloc_sbi` is called. That's the allocation function for the superblock information. Right, and within `afs_alloc_sbi`, it calls `afs_use_cell`, which makes sense; we need to interact with the AFS cell context. The crucial question immediately pops into my head: where is this `ctx->cell` being populated? That context object is fundamental to interacting with the AFS server, so knowing where it gets the cell information is vital. I recall we are in the superblock setup path, which means I should revisit how the source is parsed. My immediate next step is to examine `afs_parse_source`, because that seems to be the logical point to trace back to.
|
| 51/2 |
2026/05/12 23:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/super.c IncludeLines:true Name:afs_parse_source]
Results: map[SourceCode: 210: /*
211: * Parse the source name to get cell name, volume name, volume type and R/W
212: * selector.
213: *
214: * This can be one of the following:
215: * "%[cell:]volume[.]" R/W volume
216: * "#[cell:]volume[.]" R/O or R/W volume (R/O parent),
217: * or R/W (R/W parent) volume
218: * "%[cell:]volume.readonly" R/O volume
219: * "#[cell:]volume.readonly" R/O volume
220: * "%[cell:]volume.backup" Backup volume
221: * "#[cell:]volume.backup" Backup volume
222: */
223: static int afs_parse_source(struct fs_context *fc, struct fs_parameter *param)
224: {
225: struct afs_fs_context *ctx = fc->fs_private;
226: struct afs_cell *cell;
227: const char *cellname, *suffix, *name = param->string;
228: int cellnamesz;
229:
230: _enter(",%s", name);
231:
232: if (fc->source)
233: return invalf(fc, "kAFS: Multiple sources not supported");
234:
235: if (!name) {
236: printk(KERN_ERR "kAFS: no volume name specified\n");
237: return -EINVAL;
238: }
239:
240: if ((name[0] != '%' && name[0] != '#') || !name[1]) {
241: /* To use dynroot, we don't want to have to provide a source */
242: if (strcmp(name, "none") == 0) {
243: ctx->no_cell = true;
244: return 0;
245: }
246: printk(KERN_ERR "kAFS: unparsable volume name\n");
247: return -EINVAL;
248: }
249:
250: /* determine the type of volume we're looking for */
251: if (name[0] == '%') {
252: ctx->type = AFSVL_RWVOL;
253: ctx->force = true;
254: }
255: name++;
256:
257: /* split the cell name out if there is one */
258: ctx->volname = strchr(name, ':');
259: if (ctx->volname) {
260: cellname = name;
261: cellnamesz = ctx->volname - name;
262: ctx->volname++;
263: } else {
264: ctx->volname = name;
265: cellname = NULL;
266: cellnamesz = 0;
267: }
268:
269: /* the volume type is further affected by a possible suffix */
270: suffix = strrchr(ctx->volname, '.');
271: if (suffix) {
272: if (strcmp(suffix, ".readonly") == 0) {
273: ctx->type = AFSVL_ROVOL;
274: ctx->force = true;
275: } else if (strcmp(suffix, ".backup") == 0) {
276: ctx->type = AFSVL_BACKVOL;
277: ctx->force = true;
278: } else if (suffix[1] == 0) {
279: } else {
280: suffix = NULL;
281: }
282: }
283:
284: ctx->volnamesz = suffix ?
285: suffix - ctx->volname : strlen(ctx->volname);
286:
287: _debug("cell %*.*s [%p]",
288: cellnamesz, cellnamesz, cellname ?: "", ctx->cell);
289:
290: /* lookup the cell record */
291: if (cellname) {
292: cell = afs_lookup_cell(ctx->net, cellname, cellnamesz,
293: NULL, AFS_LOOKUP_CELL_DIRECT_MOUNT,
294: afs_cell_trace_use_lookup_mount);
295: if (IS_ERR(cell)) {
296: pr_err("kAFS: unable to lookup cell '%*.*s'\n",
297: cellnamesz, cellnamesz, cellname ?: "");
298: return PTR_ERR(cell);
299: }
300: afs_unuse_cell(ctx->cell, afs_cell_trace_unuse_parse);
301: afs_see_cell(cell, afs_cell_trace_see_source);
302: ctx->cell = cell;
303: }
304:
305: _debug("CELL:%s [%p] VOLUME:%*.*s SUFFIX:%s TYPE:%d%s",
306: ctx->cell->name, ctx->cell,
307: ctx->volnamesz, ctx->volnamesz, ctx->volname,
308: suffix ?: "-", ctx->type, ctx->force ? " FORCE" : "");
309:
310: fc->source = param->string;
311: param->string = NULL;
312: return 0;
313: }
SourceFile:fs/afs/super.c]
|
| 52/2 |
2026/05/12 23:52 |
llm |
expert |
0m
Model:
Tokens:
input: 51580
output: 41
thoughts: 82
Thoughts: Here's my analysis of the provided code snippet:
**Double-Check on Cell Active Status**
Okay, so I'm tracing the cell activation and deactivation flow here. First, I see that `afs_lookup_cell` *definitely* increments `cell->active`. Right, that makes sense; we're establishing a connection or use case. And then, `ctx->cell` gets assigned the cell β we're storing the cell's pointer within the context. The crucial point seems to be when `afs_alloc_sbi` is called. It *then* calls `afs_use_cell`, which, if I understand the naming conventions correctly, *also* increments `cell->active` again. This is where I start to get a bit concerned; it seems like we're double-counting cell activations. So, if this is an error, then it is most likely released only once. And if we are double counting and releasing it just once, there are going to be problems. I need to now scrutinize `afs_free_fc`. I'll need to check the exact function to see how `ctx->cell` is handled during release, to ensure that the proper deactivation occurs.
|
| 53/2 |
2026/05/12 23:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/super.c IncludeLines:true Name:afs_free_fc]
Results: map[SourceCode: 601: static void afs_free_fc(struct fs_context *fc)
602: {
603: struct afs_fs_context *ctx = fc->fs_private;
604:
605: afs_destroy_sbi(fc->s_fs_info);
606: afs_put_volume(ctx->volume, afs_volume_trace_put_free_fc);
607: afs_unuse_cell(ctx->cell, afs_cell_trace_unuse_fc);
608: key_put(ctx->key);
609: kfree(ctx);
610: }
SourceFile:fs/afs/super.c]
|
| 54/2 |
2026/05/12 23:52 |
llm |
expert |
0m
Model:
Tokens:
input: 52169
output: 42
thoughts: 47
Thoughts: Here's my understanding, as if I were thinking it through:
**Deconstructing the Cell Usage**
Okay, so I'm looking at how cells are managed in this AFS implementation. It's becoming clear that the function `afs_free_fc` plays a role in cell deallocation β specifically, it calls `afs_unuse_cell(ctx->cell)`. This makes perfect sense; `fc` likely stands for "file context" or something similar, and when a file context is freed, the associated cell should no longer be in active use.
Further down, `afs_destroy_sbi` is also calling `afs_unuse_cell(as->cell)`. This suggests that the "sbi" or "super block information" is linked to a cell, and when the superblock is being destroyed, we need to release its associated cell using the `afs_unuse_cell` function. Seems a logical and consistent approach to cell management. This suggests a pattern and some careful considerations in this architecture.
|
| 55/2 |
2026/05/12 23:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/super.c IncludeLines:true Name:afs_destroy_sbi]
Results: map[SourceCode: 520: static void afs_destroy_sbi(struct afs_super_info *as)
521: {
522: if (as) {
523: afs_put_volume(as->volume, afs_volume_trace_put_destroy_sbi);
524: afs_unuse_cell(as->cell, afs_cell_trace_unuse_sbi);
525: put_net(as->net_ns);
526: kfree(as);
527: }
528: }
SourceFile:fs/afs/super.c]
|
| 56/2 |
2026/05/12 23:53 |
llm |
expert |
0m
Model:
Tokens:
input: 52659
output: 41
thoughts: 254
Thoughts: **Analyzing the Potential Vulnerability**
Okay, the active count seems to be in a balanced state at this point. I need to consider a crucial question: What happens if `afs_parse_source` isn't called? That could be a key point. Looking at this reproducer, the arguments to `mount$afs` are interesting. I've got a nil source, a destination buffer containing "./file0", the type is "afs", flags are zero, and the mount options are "dyn". Let's pay close attention to this "dyn" option, and the subsequent path through the code. I need to dive into `afs_parse_param` now to see how this dynamic option is handled and where it leads.
|
| 57/2 |
2026/05/12 23:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/super.c IncludeLines:true Name:afs_parse_param]
Results: map[SourceCode: 315: /*
316: * Parse a single mount parameter.
317: */
318: static int afs_parse_param(struct fs_context *fc, struct fs_parameter *param)
319: {
320: struct fs_parse_result result;
321: struct afs_fs_context *ctx = fc->fs_private;
322: int opt;
323:
324: opt = fs_parse(fc, afs_fs_parameters, param, &result);
325: if (opt < 0)
326: return opt;
327:
328: switch (opt) {
329: case Opt_source:
330: return afs_parse_source(fc, param);
331:
332: case Opt_autocell:
333: ctx->autocell = true;
334: break;
335:
336: case Opt_dyn:
337: ctx->dyn_root = true;
338: break;
339:
340: case Opt_flock:
341: ctx->flock_mode = result.uint_32;
342: break;
343:
344: default:
345: return -EINVAL;
346: }
347:
348: _leave(" = 0");
349: return 0;
350: }
SourceFile:fs/afs/super.c]
|
| 58/2 |
2026/05/12 23:53 |
llm |
expert |
0m
Model:
Tokens:
input: 53573
output: 43
thoughts: 185
Thoughts: **Analyzing the Dynamics of Dynamic Root in AFS Allocation**
Okay, let's break down this `dyn` behavior. The call to "dyn" triggers `ctx->dyn_root` to be set to `true`. Now, the crucial part: if `ctx->dyn_root` is indeed `true`, `afs_alloc_sbi` behaves differently. It appears that it sets `as->dyn_root = true` in this scenario, skipping the usual cell and volume assignment. Specifically, if `ctx->dyn_root` is true, then `as->cell` remains NULL.
This seems like a potential problem. If `as->dyn_root` is true, `as->cell` will never be populated. But then, if `as->cell` isn't assigned, how is it used later? Where does this come into play in the wider system? I'm missing a piece of the puzzle. I need to understand the implications of `as->cell` being NULL.
So, where is `ctx->cell` even *initialized*? A quick scan of the code leads me to `afs_init_fs_context`. I need to review what's going on in that function. What is the lifecycle of `ctx->cell` and how does it relate to the `dyn_root` flag? Is the assumption that in a dynamic root scenario, cell information isn't relevant? Or am I missing something crucial in how this code is supposed to function? I need to track the control flow from the `dyn` call through the rest of the relevant code path to fully understand this logic.
|
| 59/2 |
2026/05/12 23:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/super.c IncludeLines:true Name:afs_init_fs_context]
Results: map[SourceCode: 618: /*
619: * Set up the filesystem mount context.
620: */
621: static int afs_init_fs_context(struct fs_context *fc)
622: {
623: struct afs_fs_context *ctx;
624: struct afs_cell *cell;
625:
626: ctx = kzalloc(sizeof(struct afs_fs_context), GFP_KERNEL);
627: if (!ctx)
628: return -ENOMEM;
629:
630: ctx->type = AFSVL_ROVOL;
631: ctx->net = afs_net(fc->net_ns);
632:
633: /* Default to the workstation cell. */
634: cell = afs_find_cell(ctx->net, NULL, 0, afs_cell_trace_use_fc);
635: if (IS_ERR(cell))
636: cell = NULL;
637: ctx->cell = cell;
638:
639: fc->fs_private = ctx;
640: fc->ops = &afs_context_ops;
641: return 0;
642: }
SourceFile:fs/afs/super.c]
|
| 60/2 |
2026/05/12 23:53 |
llm |
expert |
0m
Model:
Tokens:
input: 54528
output: 41
thoughts: 28
Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue:
**Investigating the `afs_find_cell` Call**
Right, `afs_find_cell`... I see it's calling `afs_use_cell`. Interesting. That immediately flags a potential dependency. It's often the case that find methods use methods that interact with objects or data structures they've located. Let's dig into `afs_find_cell` specifically, then. I want to understand exactly what `afs_find_cell` is doing before I try to interpret the relationship. I need to understand the control flow. What context is it running in? What is it searching for? Why might this interaction be problematic? Is `afs_find_cell` designed to locate a specific data structure and return an object so it can later be modified/used by `afs_use_cell`? I need to analyze the code to truly understand this.
|
| 61/2 |
2026/05/12 23:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_find_cell]
Results: map[SourceCode: 89: /*
90: * Look up and get an activation reference on a cell record.
91: */
92: struct afs_cell *afs_find_cell(struct afs_net *net,
93: const char *name, unsigned int namesz,
94: enum afs_cell_trace reason)
95: {
96: struct afs_cell *cell;
97:
98: down_read(&net->cells_lock);
99: cell = afs_find_cell_locked(net, name, namesz, reason);
100: up_read(&net->cells_lock);
101: return cell;
102: }
SourceFile:fs/afs/cell.c]
|
| 62/2 |
2026/05/12 23:53 |
llm |
expert |
0m
Model:
Tokens:
input: 55028
output: 43
thoughts: 10
Thoughts: Okay, here's the summary, expressed as though I'm the one having these thoughts, targeting an expert audience:
**Delving into `afs_find_cell_locked`**
Alright, let's break down this function, `afs_find_cell_locked`. From what I'm seeing, this is likely a crucial piece of code, probably deep within the AFS (Andrew File System) implementation. It's almost certainly responsible for, as the name suggests, locating a specific "cell" within the AFS structure. The use of "locked" in the name is immediately telling. This implies that there's a concurrency aspect involved, likely critical to thread safety when multiple clients are accessing and modifying data within the AFS environment.
My initial assumption is that it takes a cell name or identifier as input. It then iterates through the known cell configurations, perhaps checking against some internal cache or directory, looking for a match. The "locked" part suggests that it *acquires* a lock β likely a mutex or semaphore β *before* traversing this data. This locking is essential to ensure that the cell data doesn't change from underneath it during the search, preventing race conditions.
I'd expect the function to return a pointer or handle to the found cell structure, or a NULL value if the cell is not present. There could be additional return codes indicating errors such as lock acquisition failure or invalid input parameters. The locking mechanism itself is of paramount interest to me: is it a simple mutex, a reader/writer lock, or something more sophisticated? This greatly affects the system's performance and scalability. Furthermore, I'd want to examine the scope of the lock. Does it protect a single cell lookup, or a broader data structure? Any potential deadlocks or lock contention issues would be major areas of concern. The efficiency of the search algorithm is also a factor, particularly if the number of cells is large. Finally, error handling is critical, if there is a problem finding the cell it must handle this elegantly, so that the users are not affected.
|
| 63/2 |
2026/05/12 23:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_find_cell_locked]
Results: map[SourceCode: 40: /*
41: * Look up and get an activation reference on a cell record. The caller must
42: * hold net->cells_lock at least read-locked.
43: */
44: static struct afs_cell *afs_find_cell_locked(struct afs_net *net,
45: const char *name, unsigned int namesz,
46: enum afs_cell_trace reason)
47: {
48: struct afs_cell *cell = NULL;
49: struct rb_node *p;
50: int n;
51:
52: _enter("%*.*s", namesz, namesz, name);
53:
54: if (name && namesz == 0)
55: return ERR_PTR(-EINVAL);
56: if (namesz > AFS_MAXCELLNAME)
57: return ERR_PTR(-ENAMETOOLONG);
58:
59: if (!name) {
60: cell = rcu_dereference_protected(net->ws_cell,
61: lockdep_is_held(&net->cells_lock));
62: if (!cell)
63: return ERR_PTR(-EDESTADDRREQ);
64: goto found;
65: }
66:
67: p = net->cells.rb_node;
68: while (p) {
69: cell = rb_entry(p, struct afs_cell, net_node);
70:
71: n = strncasecmp(cell->name, name,
72: min_t(size_t, cell->name_len, namesz));
73: if (n == 0)
74: n = cell->name_len - namesz;
75: if (n < 0)
76: p = p->rb_left;
77: else if (n > 0)
78: p = p->rb_right;
79: else
80: goto found;
81: }
82:
83: return ERR_PTR(-ENOENT);
84:
85: found:
86: return afs_use_cell(cell, reason);
87: }
SourceFile:fs/afs/cell.c]
|
| 64/2 |
2026/05/12 23:53 |
llm |
expert |
0m
Model:
Tokens:
input: 56173
output: 41
thoughts: 485
Thoughts: **Analyzing the AFS Filesystem Context Initialization**
Okay, let me break this down. `afs_init_fs_context` is the starting point. It calls `afs_find_cell`, which in turn, calls `afs_use_cell`. This increments both `cell->active` and `cell->ref`. So far, so good β we're establishing a connection to a cell, and the filesystem context (`ctx`) then stores a reference to that cell in `ctx->cell`.
Now, here's where it gets interesting. If `ctx->dyn_root` is true, which I believe can be set using the mount options, `afs_alloc_sbi` *doesn't* call `afs_use_cell`. Okay, got it.
Later, when the filesystem context is freed by `afs_free_fc`, we call `afs_unuse_cell(ctx->cell)`. This is called when the fs context is freed. But how is the fs context freed? Ah, right β `put_fs_context` eventually calls `fc->ops->free(fc)`. So at that point, `ctx->cell` is supposed to be unused.
Now, I'm thinking about the implications. What happens if `afs_parse_source` is called? I need to understand that call. Looking at the reproducer, I see a mount command. I think I see what's happening.
The key is `src` β it's NULL! This is really important. If `src` is NULL, `afs_parse_source` is *not* called. Because `afs_parse_source` is only called if `Opt_source` is passed. Since `src` is `NULL`, `Opt_source` is not passed. This is how the mount arguments are parsed.
So `ctx->cell` should remain the default workstation cell if it exists. Now, I need to check how the workstation cell is setup.
|
| 65/2 |
2026/05/12 23:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/main.c IncludeLines:true Name:afs_net_init]
Results: map[SourceCode: 62: /*
63: * Initialise an AFS network namespace record.
64: */
65: static int __net_init afs_net_init(struct net *net_ns)
66: {
67: struct afs_sysnames *sysnames;
68: struct afs_net *net = afs_net(net_ns);
69: int ret;
70:
71: net->net = net_ns;
72: net->live = true;
73: generate_random_uuid((unsigned char *)&net->uuid);
74:
75: INIT_WORK(&net->charge_preallocation_work, afs_charge_preallocation);
76: INIT_WORK(&net->rx_oob_work, afs_process_oob_queue);
77: mutex_init(&net->socket_mutex);
78:
79: net->cells = RB_ROOT;
80: idr_init(&net->cells_dyn_ino);
81: init_rwsem(&net->cells_lock);
82: mutex_init(&net->cells_alias_lock);
83: mutex_init(&net->proc_cells_lock);
84: INIT_HLIST_HEAD(&net->proc_cells);
85:
86: seqlock_init(&net->fs_lock);
87: INIT_LIST_HEAD(&net->fs_probe_fast);
88: INIT_LIST_HEAD(&net->fs_probe_slow);
89: INIT_HLIST_HEAD(&net->fs_proc);
90:
91: INIT_WORK(&net->fs_prober, afs_fs_probe_dispatcher);
92: timer_setup(&net->fs_probe_timer, afs_fs_probe_timer, 0);
93: atomic_set(&net->servers_outstanding, 1);
94:
95: ret = -ENOMEM;
96: sysnames = kzalloc(sizeof(*sysnames), GFP_KERNEL);
97: if (!sysnames)
98: goto error_sysnames;
99: sysnames->subs[0] = (char *)&afs_init_sysname;
100: sysnames->nr = 1;
101: refcount_set(&sysnames->usage, 1);
102: net->sysnames = sysnames;
103: rwlock_init(&net->sysnames_lock);
104:
105: /* Register the /proc stuff */
106: ret = afs_proc_init(net);
107: if (ret < 0)
108: goto error_proc;
109:
110: /* Initialise the cell DB */
111: ret = afs_cell_init(net, rootcell);
112: if (ret < 0)
113: goto error_cell_init;
114:
115: /* Create the RxRPC transport */
116: ret = afs_open_socket(net);
117: if (ret < 0)
118: goto error_open_socket;
119:
120: return 0;
121:
122: error_open_socket:
123: net->live = false;
124: afs_fs_probe_cleanup(net);
125: afs_cell_purge(net);
126: afs_wait_for_servers(net);
127: error_cell_init:
128: net->live = false;
129: afs_proc_cleanup(net);
130: error_proc:
131: afs_put_sysnames(net->sysnames);
132: error_sysnames:
133: idr_destroy(&net->cells_dyn_ino);
134: net->live = false;
135: return ret;
136: }
SourceFile:fs/afs/main.c]
|
| 66/2 |
2026/05/12 23:53 |
llm |
expert |
0m
Model:
Tokens:
input: 58257
output: 41
thoughts: 12
Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue:
**Cell DB Initialization: The Starting Point**
Right, so `afs_cell_init` is the function we're talking about. Seems pretty straightforward, but crucial. This is the entry point for getting the cell database up and running. It's where the groundwork is laid β the foundation upon which everything else related to cell management, access control, and metadata will depend. I need to make sure this initialization is robust and accounts for potential error conditions and various configuration scenarios.
I'll need to remember to check for existing database files, consider the implications of a clean start versus an upgrade scenario, and think through the implications of potentially conflicting configurations. Is there any provision for transactional integrity during initialization in case of system failures? It's vital that the cell DB is consistently set up and ready to serve requests as soon as possible after initialization concludes successfully.
|
| 67/2 |
2026/05/12 23:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_cell_init]
Results: map[SourceCode: 403: /*
404: * set the root cell information
405: * - can be called with a module parameter string
406: * - can be called from a write to /proc/fs/afs/rootcell
407: */
408: int afs_cell_init(struct afs_net *net, const char *rootcell)
409: {
410: struct afs_cell *old_root, *new_root;
411: const char *cp, *vllist;
412: size_t len;
413:
414: _enter("");
415:
416: if (!rootcell) {
417: /* module is loaded with no parameters, or built statically.
418: * - in the future we might initialize cell DB here.
419: */
420: _leave(" = 0 [no root]");
421: return 0;
422: }
423:
424: cp = strchr(rootcell, ':');
425: if (!cp) {
426: _debug("kAFS: no VL server IP addresses specified");
427: vllist = NULL;
428: len = strlen(rootcell);
429: } else {
430: vllist = cp + 1;
431: len = cp - rootcell;
432: }
433:
434: if (len == 0 || !rootcell[0] || rootcell[0] == '.' || rootcell[len - 1] == '.')
435: return -EINVAL;
436: if (memchr(rootcell, '/', len))
437: return -EINVAL;
438: cp = strstr(rootcell, "..");
439: if (cp && cp < rootcell + len)
440: return -EINVAL;
441:
442: /* allocate a cell record for the root/workstation cell */
443: new_root = afs_lookup_cell(net, rootcell, len, vllist,
444: AFS_LOOKUP_CELL_ROOTCELL,
445: afs_cell_trace_use_lookup_ws);
446: if (IS_ERR(new_root)) {
447: _leave(" = %ld", PTR_ERR(new_root));
448: return PTR_ERR(new_root);
449: }
450:
451: if (!test_and_set_bit(AFS_CELL_FL_NO_GC, &new_root->flags))
452: afs_use_cell(new_root, afs_cell_trace_use_pin);
453:
454: /* install the new cell */
455: down_write(&net->cells_lock);
456: old_root = rcu_replace_pointer(net->ws_cell, new_root,
457: lockdep_is_held(&net->cells_lock));
458: up_write(&net->cells_lock);
459:
460: afs_unuse_cell(old_root, afs_cell_trace_unuse_ws);
461: _leave(" = 0");
462: return 0;
463: }
SourceFile:fs/afs/cell.c]
|
| 68/2 |
2026/05/12 23:53 |
llm |
expert |
0m
Model:
Tokens:
input: 59481
output: 41
thoughts: 315
Thoughts: **Analyzing a Potential NULL Pointer Dereference**
Okay, let's break this down. It seems there's a possible NULL pointer dereference lurking in this `afs_alloc_sbi` code path. If `rootcell` is NULL, which leads to `net->ws_cell` being NULL, then `ctx->cell` is also going to be NULL. That's the setup. Then, when `ctx->cell` is NULL, `afs_alloc_sbi` seems to branch based on `ctx->dyn_root`. If `ctx->dyn_root` is true, fine, `as->cell` remains NULL which is expected.
But if `ctx->dyn_root` is false... *that's* where it gets interesting. It attempts to call `afs_use_cell` with a NULL `ctx->cell`. My initial thought was, "Oh, surely `afs_use_cell` checks for a NULL input." But wait... it doesn't. A quick review of `afs_use_cell` shows it immediately calls `__refcount_inc` on the input `cell` pointer. And `__refcount_inc` almost certainly does not check for NULL. That's a textbook crash scenario.
However, the code later appears to check `as->cell` for NULL in `afs_fill_super`. This seems confusing, so I'm going to carefully analyze `afs_fill_super` to see how this contradiction resolves. Is it possible that the crash is intended and handled upstream, or that this check is in the wrong place? This is definitely a place to focus my attention.
|
| 69/2 |
2026/05/12 23:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/super.c IncludeLines:true Name:afs_fill_super]
Results: map[SourceCode: 445: /*
446: * fill in the superblock
447: */
448: static int afs_fill_super(struct super_block *sb, struct afs_fs_context *ctx)
449: {
450: struct afs_super_info *as = AFS_FS_S(sb);
451: struct inode *inode = NULL;
452: int ret;
453:
454: _enter("");
455:
456: /* fill in the superblock */
457: sb->s_blocksize = PAGE_SIZE;
458: sb->s_blocksize_bits = PAGE_SHIFT;
459: sb->s_maxbytes = MAX_LFS_FILESIZE;
460: sb->s_magic = AFS_FS_MAGIC;
461: sb->s_op = &afs_super_ops;
462: if (!as->dyn_root)
463: sb->s_xattr = afs_xattr_handlers;
464: ret = super_setup_bdi(sb);
465: if (ret)
466: return ret;
467:
468: /* allocate the root inode and dentry */
469: if (as->dyn_root) {
470: inode = afs_dynroot_iget_root(sb);
471: } else {
472: sprintf(sb->s_id, "%llu", as->volume->vid);
473: afs_activate_volume(as->volume);
474: inode = afs_root_iget(sb, ctx->key);
475: }
476:
477: if (IS_ERR(inode))
478: return PTR_ERR(inode);
479:
480: ret = -ENOMEM;
481: sb->s_root = d_make_root(inode);
482: if (!sb->s_root)
483: goto error;
484:
485: if (as->dyn_root) {
486: set_default_d_op(sb, &afs_dynroot_dentry_operations);
487: } else {
488: set_default_d_op(sb, &afs_fs_dentry_operations);
489: rcu_assign_pointer(as->volume->sb, sb);
490: }
491:
492: _leave(" = 0");
493: return 0;
494:
495: error:
496: _leave(" = %d", ret);
497: return ret;
498: }
SourceFile:fs/afs/super.c]
|
| 70/2 |
2026/05/12 23:53 |
llm |
expert |
0m
Model:
Tokens:
input: 61001
output: 41
thoughts: 17
Thoughts: Okay, here's my interpretation of that thought process, from an expert's perspective:
**Connecting the Dots in the AFS Codebase**
Alright, let's see... *afs_get_tree*. Right, I remember that function. Now, a crucial part of the tree retrieval process would be validating the file context. And, ah yes, it's hitting me now, the code structure should reflect this. Wait, *afs_get_tree* explicitly calls *afs_validate_fc*. Yes, that makes perfect sense! So, the tree structure, which represents the AFS file system organization, depends on validated file context for it to be useful. *afs_validate_fc* is a core component. The data needs to be verified before anything else. This confirms my expectation that the design would include a crucial validation step before allowing a client to utilize the tree. Excellent. That's good design.
|
| 71/2 |
2026/05/12 23:53 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/super.c IncludeLines:true Name:afs_validate_fc]
Results: map[SourceCode: 352: /*
353: * Validate the options, get the cell key and look up the volume.
354: */
355: static int afs_validate_fc(struct fs_context *fc)
356: {
357: struct afs_fs_context *ctx = fc->fs_private;
358: struct afs_volume *volume;
359: struct afs_cell *cell;
360: struct key *key;
361: int ret;
362:
363: if (!ctx->dyn_root) {
364: if (ctx->no_cell) {
365: pr_warn("kAFS: Can only specify source 'none' with -o dyn\n");
366: return -EINVAL;
367: }
368:
369: if (!ctx->cell) {
370: pr_warn("kAFS: No cell specified\n");
371: return -EDESTADDRREQ;
372: }
373:
374: reget_key:
375: /* We try to do the mount securely. */
376: key = afs_request_key(ctx->cell);
377: if (IS_ERR(key))
378: return PTR_ERR(key);
379:
380: ctx->key = key;
381:
382: if (ctx->volume) {
383: afs_put_volume(ctx->volume, afs_volume_trace_put_validate_fc);
384: ctx->volume = NULL;
385: }
386:
387: if (test_bit(AFS_CELL_FL_CHECK_ALIAS, &ctx->cell->flags)) {
388: ret = afs_cell_detect_alias(ctx->cell, key);
389: if (ret < 0)
390: return ret;
391: if (ret == 1) {
392: _debug("switch to alias");
393: key_put(ctx->key);
394: ctx->key = NULL;
395: cell = afs_use_cell(ctx->cell->alias_of,
396: afs_cell_trace_use_fc_alias);
397: afs_unuse_cell(ctx->cell, afs_cell_trace_unuse_fc);
398: ctx->cell = cell;
399: goto reget_key;
400: }
401: }
402:
403: volume = afs_create_volume(ctx);
404: if (IS_ERR(volume))
405: return PTR_ERR(volume);
406:
407: ctx->volume = volume;
408: if (volume->type != AFSVL_RWVOL) {
409: ctx->flock_mode = afs_flock_mode_local;
410: fc->sb_flags |= SB_RDONLY;
411: }
412: }
413:
414: return 0;
415: }
SourceFile:fs/afs/super.c]
|
| 72/2 |
2026/05/12 23:53 |
llm |
expert |
0m
Model:
Tokens:
input: 62191
output: 49
thoughts: 1388
Thoughts: **Analyzing Cell Reference Counting and Potential Leaks**
Okay, let's break this down systematically. My initial thought process revolves around understanding the lifecycle of an AFS cell, particularly focusing on reference counting and how it relates to cell destruction.
Firstly, if `ctx->dyn_root` is true, then `afs_validate_fc` is skipped, so the cell check `ctx->cell` is ignored. `ctx->cell` is initialized via `afs_find_cell`, potentially resulting in a NULL value if no rootcell is defined. But, when dynamic root is true, in `afs_alloc_sbi`, the `as->cell` is set to NULL, and in `afs_free_fc`, we call `afs_unuse_cell(ctx->cell)`. If `ctx->cell` is NULL, `afs_unuse_cell` does nothing, which is fine. If rootcell was specified then, `ctx->cell` is the workstation cell, which gets decremented and incremented in `afs_init_fs_context`. Everything is balanced, in this case.
Next, I'm considering what happens if `afs_get_tree` succeeds. Does `afs_free_fc` still get called? Yes. And if `ctx->dyn_root` is true, then `as->cell` is NULL, and I confirm the context is released correctly when `fs_context` is freed.
Now, focusing on the hung task in `afs_cell_purge`. The problem is that `net->cells_outstanding` is not reaching 0, which means a cell isn't being destroyed because its reference count isn't going down to zero. The cell destruction hinges on `cell->ref` reaching 0. I examine the purge loop, where `afs_unuse_cell` is called if `AFS_CELL_FL_NO_GC` is set, but the key is that `afs_manage_cell` won't remove a cell if `cell->active` is > 0. This means someone has an active reference and didn't release it.
Let's dig deeper into where these active references are created. Looking at `afs_lookup_cell`, I see the allocation and usage process:
1. `afs_alloc_cell` sets `cell->active` to 0, and increments `cell->ref`.
2. `afs_use_cell` increments `cell->active` from 0 to 1, and `cell->ref`.
3. The caller gets a cell with active=1 and ref=2.
The key observation is: `afs_alloc_cell` only increments the reference count (`cell->ref`), not the active count (`cell->active`).
* I check `afs_alloc_cell`, and it's clear `cell->active` remains at 0 while `cell->ref` is set to 1.
* `afs_use_cell` then increments `cell->active`. So, the caller now has ref = 2 (incremented by `afs_use_cell`) and `active=1`
* When the caller is done, it will call `afs_unuse_cell` to decrement the reference count and active count, but who has the remaining reference?
The answer is, in this case: the network's cell tree.
* When `afs_manage_cell` removes the cell from the tree, the tree does *not* decrement `cell->ref` directly. The tree is removed with `rb_erase`, which only erases the item.
* Then I check `afs_manage_cell_work` calls `afs_put_cell` to decrement the reference.
So, the remaining reference from the tree is cleaned up with a call to `afs_put_cell` in `afs_manage_cell_work`.
In conclusion, a non-zero `cell->active` implies a missing `afs_unuse_cell` call, or the caller of `afs_lookup_cell` never released its reference by calling `afs_unuse_cell`. I should audit the callers of `afs_lookup_cell` to ensure proper usage and release. This becomes my priority.
|
| 73/2 |
2026/05/12 23:54 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeSnippetLines:0 Name:afs_lookup_cell SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_cell_init SourceFile:fs/afs/cell.c SourceLine:443] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_dynroot_lookup_cell SourceFile:fs/afs/dynroot.c SourceLine:111] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_mntpt_set_params SourceFile:fs/afs/mntpt.c SourceLine:110] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_parse_source SourceFile:fs/afs/super.c SourceLine:292] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_proc_cells_write SourceFile:fs/afs/proc.c SourceLine:125] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:yfs_check_canonical_cell_name SourceFile:fs/afs/vl_alias.c SourceLine:272]] TruncatedOutput:false]
|
| 74/2 |
2026/05/12 23:54 |
llm |
expert |
0m
Model:
Tokens:
input: 64865
output: 43
thoughts: 13
Thoughts: Okay, let's dive into this. Here's my thought process on checking `afs_proc_cells_write`:
**Analyzing `afs_proc_cells_write`**
Alright, so the task at hand is to analyze `afs_proc_cells_write`. This function immediately piques my interest, as anything related to `proc` filesystems and the `AFS` (Andrew File System) is usually a critical area to examine. It suggests we're dealing with how data is *written* to the AFS via the proc filesystem interface. That's a point where you often find interaction between the kernel and user space.
My initial thoughts are:
* **Potential security implications:** Anything that allows modification of AFS data through a non-standard interface (procfs) always warrants extra scrutiny. I'll need to look for any possible vulnerabilities like buffer overflows, improper input validation, or race conditions.
* **Performance overhead:** Writing through proc files can sometimes be slower than native kernel interfaces. I'll mentally note to look at the locking mechanisms and if there's any unnecessary copying or context switching involved.
* **Concurrency issues:** Given it's a multi-user system like AFS, I need to check how the function handles concurrent access. Does it use proper locks to prevent data corruption? Is it thread-safe?
* **Error handling:** I will certainly want to know how the function handles errors. Does it return appropriate error codes? Does it log information effectively if something goes wrong?
* **Dependencies:** What other functions or modules does this `afs_proc_cells_write` function depend on? Are there any upstream or downstream components that rely on its correct behavior? I need to understand its relationship to the rest of the AFS kernel module and any associated user-space utilities.
* **Documentation:** Let me first check the documentation and source code comments for this function. This should give me a quick understanding of its purpose, expected input, and output.
* **Testing:** How is this function tested? Are there unit tests or integration tests that cover different scenarios, including error conditions and edge cases?
I'll start by tracing the function's execution to understand its control flow and how it interacts with the AFS kernel code. My approach will be to follow the data path and identify any potential pitfalls. Right, let's get to it.
|
| 75/2 |
2026/05/12 23:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/proc.c IncludeLines:true Name:afs_proc_cells_write]
Results: map[SourceCode: 84: /*
85: * handle writes to /proc/fs/afs/cells
86: * - to add cells: echo "add <cellname> <IP>[:<IP>][:<IP>]"
87: */
88: static int afs_proc_cells_write(struct file *file, char *buf, size_t size)
89: {
90: struct seq_file *m = file->private_data;
91: struct afs_net *net = afs_seq2net(m);
92: char *name, *args;
93: int ret;
94:
95: /* trim to first NL */
96: name = memchr(buf, '\n', size);
97: if (name)
98: *name = 0;
99:
100: /* split into command, name and argslist */
101: name = strchr(buf, ' ');
102: if (!name)
103: goto inval;
104: do {
105: *name++ = 0;
106: } while(*name == ' ');
107: if (!*name)
108: goto inval;
109:
110: args = strchr(name, ' ');
111: if (args) {
112: do {
113: *args++ = 0;
114: } while(*args == ' ');
115: if (!*args)
116: goto inval;
117: }
118:
119: /* determine command to perform */
120: _debug("cmd=%s name=%s args=%s", buf, name, args);
121:
122: if (strcmp(buf, "add") == 0) {
123: struct afs_cell *cell;
124:
125: cell = afs_lookup_cell(net, name, strlen(name), args,
126: AFS_LOOKUP_CELL_PRELOAD,
127: afs_cell_trace_use_lookup_add);
128: if (IS_ERR(cell)) {
129: ret = PTR_ERR(cell);
130: goto done;
131: }
132:
133: if (test_and_set_bit(AFS_CELL_FL_NO_GC, &cell->flags))
134: afs_unuse_cell(cell, afs_cell_trace_unuse_no_pin);
135: } else {
136: goto inval;
137: }
138:
139: ret = 0;
140:
141: done:
142: _leave(" = %d", ret);
143: return ret;
144:
145: inval:
146: ret = -EINVAL;
147: printk("kAFS: Invalid Command on /proc/fs/afs/cells file\n");
148: goto done;
149: }
SourceFile:fs/afs/proc.c]
|
| 76/2 |
2026/05/12 23:54 |
llm |
expert |
0m
Model:
Tokens:
input: 66341
output: 45
thoughts: 1143
Thoughts: **Analyzing Cell Pinning and Reference Counting in AFS**
Okay, let's break this down. First, I noticed that `afs_proc_cells_write` calls `afs_lookup_cell`. The key here is that if `AFS_CELL_FL_NO_GC` isn't set, then `afs_unuse_cell` *isn't* called, meaning `cell->active` remains incremented after the call to `afs_lookup_cell`. I can see now that `afs_lookup_cell` itself increments `cell->active`. If `AFS_CELL_FL_NO_GC` *isn't* already set, `test_and_set_bit` returns 0, so `afs_unuse_cell` isn't called. Therefore, `cell->active` gets incremented by 1, and `AFS_CELL_FL_NO_GC` gets set. This pins the cell, which is good. The question then becomes, when is it unpinned?
Ah, looking at `afs_cell_purge`, I see the mechanism:
```c
if (test_and_clear_bit(AFS_CELL_FL_NO_GC, &cell->flags))
afs_unuse_cell(cell, afs_cell_trace_unuse_pin);
```
So `afs_cell_purge` clears `AFS_CELL_FL_NO_GC` and *then* calls `afs_unuse_cell`, which decrements `cell->active`. Perfect, that perfectly balances the initial increment in `afs_lookup_cell` in `afs_proc_cells_write`. This is correct.
Now, let's look at `afs_cell_init`. Here's the relevant code:
```c
new_root = afs_lookup_cell(net, rootcell, len, vllist,
AFS_LOOKUP_CELL_ROOTCELL,
afs_cell_trace_use_lookup_ws);
if (IS_ERR(new_root)) {
_leave(" = %ld", PTR_ERR(new_root));
return PTR_ERR(new_root);
}
if (!test_and_set_bit(AFS_CELL_FL_NO_GC, &new_root->flags))
afs_use_cell(new_root, afs_cell_trace_use_pin);
```
Wait a second. `afs_lookup_cell` increments `cell->active`. Then `afs_cell_init` calls `afs_use_cell` AGAIN if `AFS_CELL_FL_NO_GC` *wasn't* already set! So `cell->active` is incremented TWICE! Now I see what is happening! `afs_proc_cells_write` does:
```c
if (test_and_set_bit(AFS_CELL_FL_NO_GC, &cell->flags))
afs_unuse_cell(cell, afs_cell_trace_unuse_no_pin);
```
If `AFS_CELL_FL_NO_GC` was ALREADY set, it *does* call `afs_unuse_cell`. So `afs_proc_cells_write` ensures that the `AFS_CELL_FL_NO_GC` pin increment is done only ONCE.
But `afs_cell_init` does:
```c
if (!test_and_set_bit(AFS_CELL_FL_NO_GC, &new_root->flags))
afs_use_cell(new_root, afs_cell_trace_use_pin);
```
If `AFS_CELL_FL_NO_GC` was NOT set, it calls `afs_use_cell` as well.
So `cell->active` is incremented by `afs_lookup_cell`, AND THEN incremented by `afs_use_cell`!
So `cell->active` is incremented TWICE, yes.
Wait, `afs_cell_init` then does:
```c
old_root = rcu_replace_pointer(net->ws_cell, new_root,
lockdep_is_held(&net->cells_lock));
```
Aha! `net->ws_cell` holds the reference from `afs_lookup_cell`! And the `AFS_CELL_FL_NO_GC` pin holds the reference from `afs_use_cell`! So `new_root` has `active=2` (if it's a newly created cell).
When `afs_cell_purge` runs:
|
| 77/2 |
2026/05/12 23:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/dynroot.c IncludeLines:true Name:afs_dynroot_lookup_cell]
Results: map[SourceCode: 89: /*
90: * Try to automount the mountpoint with pseudo directory, if the autocell
91: * option is set.
92: */
93: static struct dentry *afs_dynroot_lookup_cell(struct inode *dir, struct dentry *dentry,
94: unsigned int flags)
95: {
96: struct afs_cell *cell = NULL;
97: struct afs_net *net = afs_d2net(dentry);
98: struct inode *inode = NULL;
99: const char *name = dentry->d_name.name;
100: size_t len = dentry->d_name.len;
101: bool dotted = false;
102: int ret = -ENOENT;
103:
104: /* Names prefixed with a dot are R/W mounts. */
105: if (name[0] == '.') {
106: name++;
107: len--;
108: dotted = true;
109: }
110:
111: cell = afs_lookup_cell(net, name, len, NULL,
112: AFS_LOOKUP_CELL_DYNROOT,
113: afs_cell_trace_use_lookup_dynroot);
114: if (IS_ERR(cell)) {
115: ret = PTR_ERR(cell);
116: goto out_no_cell;
117: }
118:
119: inode = afs_iget_pseudo_dir(dir->i_sb, cell->dynroot_ino * 2 + dotted);
120: if (IS_ERR(inode)) {
121: ret = PTR_ERR(inode);
122: goto out;
123: }
124:
125: dentry->d_fsdata = cell;
126: return d_splice_alias(inode, dentry);
127:
128: out:
129: afs_unuse_cell(cell, afs_cell_trace_unuse_lookup_dynroot);
130: out_no_cell:
131: if (!inode)
132: return d_splice_alias(inode, dentry);
133: return ret == -ENOENT ? NULL : ERR_PTR(ret);
134: }
SourceFile:fs/afs/dynroot.c]
|
| 78/2 |
2026/05/12 23:54 |
llm |
expert |
0m
Model:
Tokens:
input: 69261
output: 45
thoughts: 97
Thoughts: Okay, let me think this through.
**Analyzing the afs_dynroot Cell Lookup and Reference Counting**
Right, `afs_dynroot_lookup_cell` *definitely* calls `afs_lookup_cell`. That seems straightforward enough. And the key is, if `afs_lookup_cell` is successful, it assigns the returned `cell` to `dentry->d_fsdata`, and then returns `d_splice_alias`. Okay, got it. It's essentially "attaching" the cell to the dentry. But here's the kicker, and this is what's nagging at me: it *doesn't* call `afs_unuse_cell` directly after attaching it. Hmm. That's unusual. So, the `dentry` itself is now holding the *active* reference to the cell.
So now the million-dollar question is: when *does* that reference get dropped? Where's the matching `afs_unuse_cell` call? Is it in `afs_dynroot_d_release`? It had better be, or we've got a serious memory leak or reference counting issue on our hands! I need to double-check that release function to be sure it correctly releases the reference to the cell when the dentry is no longer needed. This needs to be bulletproof. I'll need to dig deeper into the locking semantics of those calls too to ensure it's thread-safe.
|
| 79/2 |
2026/05/12 23:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/dynroot.c IncludeLines:true Name:afs_dynroot_d_release]
Results: map[SourceCode: 167: static void afs_dynroot_d_release(struct dentry *dentry)
168: {
169: struct afs_cell *cell = dentry->d_fsdata;
170:
171: afs_unuse_cell(cell, afs_cell_trace_unuse_dynroot_mntpt);
172: }
SourceFile:fs/afs/dynroot.c]
|
| 80/2 |
2026/05/12 23:54 |
llm |
expert |
0m
Model:
Tokens:
input: 69849
output: 41
thoughts: 332
Thoughts: **My Line of Reasoning on AFS Cell Reference Management**
Okay, so `afs_dynroot_d_release` calls `afs_unuse_cell`. That makes sense; the dentry is being released, so the cell's reference should be, too. But wait... if the dentry *holds* the active reference, then as long as the dentry exists, the cell *should* remain active. That's a key observation.
Now, I remember `afs_cell_purge` gets called while `afs_net_exit` is running. And `afs_net_exit` is triggered when the network namespace is destroyed. But the network namespace destruction only happens when *all* references to it are dropped. That's the crux of it.
Does the superblock itself hold a reference to the network namespace? Ah, yes, in `afs_alloc_sbi`, `as->net_ns = get_net(fc->net_ns)` is called. And conversely, `afs_destroy_sbi` does a `put_net(as->net_ns)`. Therefore, the network namespace *cannot* be destroyed as long as the superblock exists!
So, the superblock's existence guarantees the network namespace's existence. Conversely, the destruction of the network namespace means the superblock *must* have been destroyed. If the superblock's destroyed, then all of its associated dentries must have been destroyed as well. That means that `afs_dynroot_d_release` would have had to be called for all those dentries. Consequently, no dentries can be holding active references to cells.
But... hang on. What if `afs_parse_source` is called, and that calls `afs_lookup_cell`, but then `afs_alloc_sbi` isn't called? Say, if `afs_get_tree` fails? We have to consider that.
In `afs_get_tree`:
|
| 81/2 |
2026/05/12 23:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/super.c IncludeLines:true Name:afs_get_tree]
Results: map[SourceCode: 545: /*
546: * Get an AFS superblock and root directory.
547: */
548: static int afs_get_tree(struct fs_context *fc)
549: {
550: struct afs_fs_context *ctx = fc->fs_private;
551: struct super_block *sb;
552: struct afs_super_info *as;
553: int ret;
554:
555: ret = afs_validate_fc(fc);
556: if (ret)
557: goto error;
558:
559: _enter("");
560:
561: /* allocate a superblock info record */
562: ret = -ENOMEM;
563: as = afs_alloc_sbi(fc);
564: if (!as)
565: goto error;
566: fc->s_fs_info = as;
567:
568: /* allocate a deviceless superblock */
569: sb = sget_fc(fc,
570: as->dyn_root ? afs_dynroot_test_super : afs_test_super,
571: afs_set_super);
572: if (IS_ERR(sb)) {
573: ret = PTR_ERR(sb);
574: goto error;
575: }
576:
577: if (!sb->s_root) {
578: /* initial superblock/root creation */
579: _debug("create");
580: ret = afs_fill_super(sb, ctx);
581: if (ret < 0)
582: goto error_sb;
583: sb->s_flags |= SB_ACTIVE;
584: } else {
585: _debug("reuse");
586: ASSERTCMP(sb->s_flags, &, SB_ACTIVE);
587: }
588:
589: fc->root = dget(sb->s_root);
590: trace_afs_get_tree(as->cell, as->volume);
591: _leave(" = 0 [%p]", sb);
592: return 0;
593:
594: error_sb:
595: deactivate_locked_super(sb);
596: error:
597: _leave(" = %d", ret);
598: return ret;
599: }
SourceFile:fs/afs/super.c]
|
| 82/2 |
2026/05/12 23:54 |
llm |
expert |
0m
Model:
Tokens:
input: 71402
output: 45
thoughts: 71
Thoughts: Okay, let me think this through.
**Analyzing the AFS Filesystem Cleanup Process**
Right, so if `afs_get_tree` goes belly up, the `fs_context` isn't left hanging. It's still properly freed by `afs_free_fc`, which is good. That's the expected behavior. And, *within* `afs_free_fc`, it calls `afs_unuse_cell(ctx->cell)`. That's important. It means the reference count on the cell is being decremented when we clean things up. This implies there's a strong mechanism of checking whether there's anything using the cell, and the count protects it from being prematurely destroyed.
But hold on a second... What about `afs_mntpt_set_params`? I need to consider how that function interacts with all this. Does it introduce any potential race conditions or other issues related to how the cell's reference count is managed? I need to ensure that process is thread-safe and properly handles any context changes. I need to dig into how that function works and figure out if it interacts properly with the cell references, because that's where I see a potential issue.
|
| 83/2 |
2026/05/12 23:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/mntpt.c IncludeLines:true Name:afs_mntpt_set_params]
Results: map[SourceCode: 68: /*
69: * Set the parameters for the proposed superblock.
70: */
71: static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt)
72: {
73: struct afs_fs_context *ctx = fc->fs_private;
74: struct afs_super_info *src_as = AFS_FS_S(mntpt->d_sb);
75: struct afs_vnode *vnode = AFS_FS_I(d_inode(mntpt));
76: struct afs_cell *cell;
77: const char *p;
78: int ret;
79:
80: if (fc->net_ns != src_as->net_ns) {
81: put_net(fc->net_ns);
82: fc->net_ns = get_net(src_as->net_ns);
83: }
84:
85: if (src_as->volume && src_as->volume->type == AFSVL_RWVOL) {
86: ctx->type = AFSVL_RWVOL;
87: ctx->force = true;
88: }
89: if (ctx->cell) {
90: afs_unuse_cell(ctx->cell, afs_cell_trace_unuse_mntpt);
91: ctx->cell = NULL;
92: }
93: if (test_bit(AFS_VNODE_PSEUDODIR, &vnode->flags)) {
94: /* if the directory is a pseudo directory, use the d_name */
95: unsigned size = mntpt->d_name.len;
96:
97: if (size < 2)
98: return -ENOENT;
99:
100: p = mntpt->d_name.name;
101: if (mntpt->d_name.name[0] == '.') {
102: size--;
103: p++;
104: ctx->type = AFSVL_RWVOL;
105: ctx->force = true;
106: }
107: if (size > AFS_MAXCELLNAME)
108: return -ENAMETOOLONG;
109:
110: cell = afs_lookup_cell(ctx->net, p, size, NULL,
111: AFS_LOOKUP_CELL_MOUNTPOINT,
112: afs_cell_trace_use_lookup_mntpt);
113: if (IS_ERR(cell)) {
114: pr_err("kAFS: unable to lookup cell '%pd'\n", mntpt);
115: return PTR_ERR(cell);
116: }
117: ctx->cell = cell;
118:
119: ctx->volname = afs_root_volume;
120: ctx->volnamesz = sizeof(afs_root_volume) - 1;
121: } else {
122: /* read the contents of the AFS special symlink */
123: DEFINE_DELAYED_CALL(cleanup);
124: const char *content;
125: loff_t size = i_size_read(d_inode(mntpt));
126:
127: if (src_as->cell)
128: ctx->cell = afs_use_cell(src_as->cell, afs_cell_trace_use_mntpt);
129:
130: if (size < 2 || size > PAGE_SIZE - 1)
131: return -EINVAL;
132:
133: content = afs_get_link(mntpt, d_inode(mntpt), &cleanup);
134: if (IS_ERR(content)) {
135: do_delayed_call(&cleanup);
136: return PTR_ERR(content);
137: }
138:
139: ret = -EINVAL;
140: if (content[size - 1] == '.')
141: ret = vfs_parse_fs_qstr(fc, "source",
142: &QSTR_LEN(content, size - 1));
143: do_delayed_call(&cleanup);
144: if (ret < 0)
145: return ret;
146:
147: /* Don't cross a backup volume mountpoint from a backup volume */
148: if (src_as->volume && src_as->volume->type == AFSVL_BACKVOL &&
149: ctx->type == AFSVL_BACKVOL)
150: return -ENODEV;
151: }
152:
153: return 0;
154: }
SourceFile:fs/afs/mntpt.c]
|
| 84/2 |
2026/05/12 23:54 |
llm |
expert |
0m
Model:
Tokens:
input: 73157
output: 48
thoughts: 58
Thoughts: Okay, let me think this through.
**Analyzing the Cell Parameter Setting in AFS**
Right, so `afs_mntpt_set_params` is crucial for, well, setting up the mount point parameters within AFS. It immediately calls `afs_lookup_cell`, which makes sense; we need to resolve the cell name first. And then, importantly, it sets `ctx->cell = cell`. This establishes the connection between the mount point context and the resolved cell. Good, so far, so predictable.
Now, I see the balancing act; `afs_free_fc` will be used to free things, likely after the context is no longer needed. Makes sense, that's clean memory management. Always important to keep the codebase tidy.
Hang on, though. What about `yfs_check_canonical_cell_name`? Where does that fit into this picture? I need to understand its role in relation to the `afs_mntpt_set_params` function. Is it a pre-check, a post-check, or something else entirely? Does it alter the cell name, validate it in some way, or provide more robustness in the cell resolution process? This needs more investigation! I need to determine how the canonicalization interacts with the parameter setting and cell lookup.
|
| 85/2 |
2026/05/12 23:54 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/vl_alias.c IncludeLines:true Name:yfs_check_canonical_cell_name]
Results: map[SourceCode: 253: static int yfs_check_canonical_cell_name(struct afs_cell *cell, struct key *key)
254: {
255: struct afs_cell *master;
256: size_t name_len;
257: char *cell_name;
258:
259: cell_name = afs_vl_get_cell_name(cell, key);
260: if (IS_ERR(cell_name))
261: return PTR_ERR(cell_name);
262:
263: if (strcmp(cell_name, cell->name) == 0) {
264: kfree(cell_name);
265: return 0;
266: }
267:
268: name_len = strlen(cell_name);
269: if (!name_len || name_len > AFS_MAXCELLNAME)
270: master = ERR_PTR(-EOPNOTSUPP);
271: else
272: master = afs_lookup_cell(cell->net, cell_name, name_len, NULL,
273: AFS_LOOKUP_CELL_ALIAS_CHECK,
274: afs_cell_trace_use_lookup_canonical);
275: kfree(cell_name);
276: if (IS_ERR(master))
277: return PTR_ERR(master);
278:
279: cell->alias_of = master; /* Transfer our ref */
280: return 1;
281: }
SourceFile:fs/afs/vl_alias.c]
|
| 86/2 |
2026/05/12 23:54 |
llm |
expert |
0m
Model:
Tokens:
input: 74013
output: 41
thoughts: 1943
Thoughts: **Analyzing Cell Management in AFS: A Deep Dive into Reference Counting and Lifecycle**
Okay, let's break this down. My initial thought process revolves around understanding how cell aliases and their references are managed within the AFS kernel module. The core of this seems to be centered around the `yfs_check_canonical_cell_name` function, which calls `afs_lookup_cell` to establish the alias relationship by setting `cell->alias_of = master`, effectively creating a dependent reference. The comment "Transfer our ref" is critical; it highlights that the alias now *depends* on the master.
My immediate question: when is `cell->alias_of` actually *released*? The code points to `afs_cell_destroy`, which calls `afs_unuse_cell(cell->alias_of, ...)`. This makes sense, the alias should release the master when it is destroyed. But, the destruction is triggered when `cell->ref` hits zero. This is the crux, because the alias maintains its own reference to the master. When `afs_cell_destroy` is called, it unuses the `alias_of`, which decrements `active` and `ref` on the `master` cell. If `cell` is an alias and gets destroyed, its `alias_of` is then unused. Then `afs_cell_purge` needs to wait for `net->cells_outstanding` to become 0 to ensure resources are handled correctly.
Following this, the implication is that if the `cell` is an alias, it possesses an *active* reference to the `master`. When `cell` is destroyed, this active reference to the `master` is released. Then `master`'s `active` count drops to 0, which allows it to be queued for management. The `master` will then be removed from `net->cells` and ultimately destroyed. Assuming no cyclic dependencies, this seems logically sound.
However, a critical question immediately arises: what happens if `afs_lookup_cell` *fails*? The code reveals that in the event of failure, if `state == AFS_CELL_DEAD` due to an error, `afs_unuse_cell(cell)` is called. But wait, if the `cell` is `AFS_CELL_DEAD`, it should already be dead and managed! Then `afs_manage_cell` has supposedly already removed it from `net->cells` and set its state! I immediately see the conflict. If `afs_lookup_cell` has an active reference, how can `afs_manage_cell` have already set the state to `AFS_CELL_DEAD`? Checking the code, if `cell->active > 0`, `afs_manage_cell` will *not* remove the cell!
The next scenario, and likely the critical one: What if `afs_lookup_cell` is waiting, and `afs_net_exit` is called? `afs_net_exit` sets `net->live = false` and subsequently calls `afs_cell_purge`. In `afs_cell_purge`, `AFS_CELL_FL_NO_GC` is cleared, and `afs_unuse_cell` is called. The issue here is the active reference that is held by `afs_lookup_cell`! The `cell->active` is still greater than 0, which prevents removal by `afs_manage_cell`! Thus, `state` will *never* become `AFS_CELL_DEAD`! Does this lead to a deadlock?
My concern becomes: if `state` never becomes `AFS_CELL_DEAD`, and `afs_lookup_cell` is waiting for `state == AFS_CELL_ACTIVE || state == AFS_CELL_DEAD`, will it wait *forever*? If `net->live` is false, `afs_manage_cell` checks if `afs_has_cell_expired`. This would return false if `cell->active` is greater than 0. The execution continues, and critically the module *will* set `state` to `AFS_CELL_ACTIVE` by calling `afs_update_cell`. This *solves* the deadlock: Then `afs_lookup_cell` wakes up! Then `afs_lookup_cell` checks the `cell->dns_status` and returns the cell, or returns an error. If it returns an error, `afs_unuse_cell` is called. If the cell is returned, the caller *will* eventually call `afs_unuse_cell`. So no, `afs_lookup_cell` does NOT hang.
Now, a new concern: what if `afs_update_cell` hangs? Time to analyze that function.
|
| 87/2 |
2026/05/12 23:55 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_update_cell]
Results: map[SourceCode: 465: /*
466: * Update a cell's VL server address list from the DNS.
467: */
468: static int afs_update_cell(struct afs_cell *cell)
469: {
470: struct afs_vlserver_list *vllist, *old = NULL, *p;
471: unsigned int min_ttl = READ_ONCE(afs_cell_min_ttl);
472: unsigned int max_ttl = READ_ONCE(afs_cell_max_ttl);
473: time64_t now, expiry = 0;
474: int ret = 0;
475:
476: _enter("%s", cell->name);
477:
478: vllist = afs_dns_query(cell, &expiry);
479: if (IS_ERR(vllist)) {
480: ret = PTR_ERR(vllist);
481:
482: _debug("%s: fail %d", cell->name, ret);
483: if (ret == -ENOMEM)
484: goto out_wake;
485:
486: vllist = afs_alloc_vlserver_list(0);
487: if (!vllist) {
488: if (ret >= 0)
489: ret = -ENOMEM;
490: goto out_wake;
491: }
492:
493: switch (ret) {
494: case -ENODATA:
495: case -EDESTADDRREQ:
496: vllist->status = DNS_LOOKUP_GOT_NOT_FOUND;
497: break;
498: case -EAGAIN:
499: case -ECONNREFUSED:
500: vllist->status = DNS_LOOKUP_GOT_TEMP_FAILURE;
501: break;
502: default:
503: vllist->status = DNS_LOOKUP_GOT_LOCAL_FAILURE;
504: break;
505: }
506: }
507:
508: _debug("%s: got list %d %d", cell->name, vllist->source, vllist->status);
509: cell->dns_status = vllist->status;
510:
511: now = ktime_get_real_seconds();
512: if (min_ttl > max_ttl)
513: max_ttl = min_ttl;
514: if (expiry < now + min_ttl)
515: expiry = now + min_ttl;
516: else if (expiry > now + max_ttl)
517: expiry = now + max_ttl;
518:
519: _debug("%s: status %d", cell->name, vllist->status);
520: if (vllist->source == DNS_RECORD_UNAVAILABLE) {
521: switch (vllist->status) {
522: case DNS_LOOKUP_GOT_NOT_FOUND:
523: /* The DNS said that the cell does not exist or there
524: * weren't any addresses to be had.
525: */
526: cell->dns_expiry = expiry;
527: break;
528:
529: case DNS_LOOKUP_BAD:
530: case DNS_LOOKUP_GOT_LOCAL_FAILURE:
531: case DNS_LOOKUP_GOT_TEMP_FAILURE:
532: case DNS_LOOKUP_GOT_NS_FAILURE:
533: default:
534: cell->dns_expiry = now + 10;
535: break;
536: }
537: } else {
538: cell->dns_expiry = expiry;
539: }
540:
541: /* Replace the VL server list if the new record has servers or the old
542: * record doesn't.
543: */
544: write_lock(&cell->vl_servers_lock);
545: p = rcu_dereference_protected(cell->vl_servers, true);
546: if (vllist->nr_servers > 0 || p->nr_servers == 0) {
547: rcu_assign_pointer(cell->vl_servers, vllist);
548: cell->dns_source = vllist->source;
549: old = p;
550: }
551: write_unlock(&cell->vl_servers_lock);
552: afs_put_vlserverlist(cell->net, old);
553:
554: out_wake:
555: smp_store_release(&cell->dns_lookup_count,
556: cell->dns_lookup_count + 1); /* vs source/status */
557: wake_up_var(&cell->dns_lookup_count);
558: _leave(" = %d", ret);
559: return ret;
560: }
SourceFile:fs/afs/cell.c]
|
| 88/2 |
2026/05/12 23:55 |
llm |
expert |
0m
Model:
Tokens:
input: 78490
output: 43
thoughts: 26
Thoughts: Here's my analysis of the situation:
**Investigating a Potential Hang in AFS DNS Query**
Okay, so `afs_update_cell` is calling `afs_dns_query`. That's the core of the problem, or at least, the potential problem. My initial thought is: could `afs_dns_query` be hanging? That's the most likely source of the issue based on this information alone. We're looking at a function call relationship, and the question that immediately arises is whether the callee, `afs_dns_query`, is blocking, slow, or otherwise not returning in a timely fashion. This connection is the place I need to focus my diagnostic efforts. I need to figure out what scenarios could cause `afs_dns_query` to hang, or at least block for an unacceptably long period. Perhaps there are network issues? Maybe it is a slow DNS server response? I need to gather more information to form a complete diagnosis.
|
| 89/2 |
2026/05/12 23:55 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/vl_alias.c IncludeLines:true Name:afs_dns_query]
Results: map[SourceCode: 247: /*
248: * Perform a DNS query for VL servers and build a up an address list.
249: */
250: struct afs_vlserver_list *afs_dns_query(struct afs_cell *cell, time64_t *_expiry)
251: {
252: struct afs_vlserver_list *vllist;
253: char *result = NULL;
254: int ret;
255:
256: _enter("%s", cell->name);
257:
258: ret = dns_query(cell->net->net, "afsdb", cell->name, cell->name_len,
259: "srv=1", &result, _expiry, true);
260: if (ret < 0) {
261: _leave(" = %d [dns]", ret);
262: return ERR_PTR(ret);
263: }
264:
265: if (*_expiry == 0)
266: *_expiry = ktime_get_real_seconds() + 60;
267:
268: if (ret > 1 && result[0] == 0)
269: vllist = afs_extract_vlserver_list(cell, result, ret);
270: else
271: vllist = afs_parse_text_addrs(cell->net, result, ret, ',',
272: VL_SERVICE, AFS_VL_PORT);
273: kfree(result);
274: if (IS_ERR(vllist) && vllist != ERR_PTR(-ENOMEM))
275: pr_err("Failed to parse DNS data %ld\n", PTR_ERR(vllist));
276:
277: return vllist;
278: }
SourceFile:fs/afs/addr_list.c]
|
| 90/2 |
2026/05/12 23:55 |
llm |
expert |
0m
Model:
Tokens:
input: 79320
output: 41
thoughts: 2507
Thoughts: **The AFS Cell Purge Hang: A Deep Dive**
Okay, so here's what's happening. I'm looking at a hang in `afs_cell_purge`. This function is part of `afs_net_exit`, which is called during network namespace cleanup. The hang seems to be caused by `net->cells_outstanding` not being zero. Naturally, that means some AFS cells are not being destroyed.
Why are they not destroyed? Because their reference count (`ref`) isn't zero. That means they're still in `net->cells`, or someone's actively referencing them. The code path that should clear them out, `afs_manage_cell`, isn't doing its job. This is because `cell->active` is greater than zero, indicating an active reference is still held.
After tracing the active reference's lifecycle within `afs_lookup_cell`, `afs_use_cell`, and `afs_unuse_cell` I've found a likely spot in the code.
The issue likely stems from the use of `dynroot` and how dentries are managed. With `dynroot`, any lookup creates a new cell, linked to a dentry. In the reproducer, this lookup is for `"cpuacct.usage_user"`.
Here's the critical sequence:
1. A cell is looked up via `afs_dynroot_lookup_cell` using `afs_lookup_cell`, creates a dentry and the dentry holds an active reference to the cell.
2. The program exits.
3. The mount namespace is destroyed, which is the problem.
4. The network namespace is destroyed.
5. `afs_net_exit` is called, and within that, `afs_cell_purge`.
Now, the reproducer uses the "dyn" option for the AFS mount, where the `dynroot` superblock is used. Here's where it gets interesting: the dentries in the dcache of this superblock are the key. They *hold* the active references. The mount namespace is destroyed, and the network namespace is destroyed *concurrently* within syzkaller.
Here's the race: If `cleanup_net` (and therefore `afs_net_exit`) runs *before* the mount namespace is fully cleaned up (specifically, before the `dynroot` superblock is unmounted), then the dentries still hold active references to the cells. `afs_cell_purge` then hangs indefinitely, waiting for `net->cells_outstanding` to reach zero.
The solution is that the superblock *will* be unmounted eventually when `delayed_mntput_work` runs. This is when the dcache is shrunk, releasing the dentries, and then `afs_dynroot_d_release` unuses the cells. Then, `afs_manage_cell_work` runs, removing the cells. So, there is a path to a non-hung system.
However, the hang's duration (143 seconds) seems excessive. The real question is why `delayed_mntput_work` wasn't able to run. What's blocking the process?
Ah, and I think I see the key: the `afs` superblock holds a reference to the network namespace. This explains why `cleanup_net` *could* be running while the superblock is still mounted! The `put_net` in `afs_destroy_sbi`, called from `afs_kill_super`, is the gatekeeper. So the network namespace cleanup cannot occur until the AFS superblock is gone. The fix here is to have a race condition such that the AFS code runs before the mount namepsace is cleaned up.
The fact that `afs_net_exit` runs too early is a race, which makes it a challenging bug to track down.
|
| 91/2 |
2026/05/12 23:55 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/super.c IncludeLines:true Name:afs_kill_super]
Results: map[SourceCode: 530: static void afs_kill_super(struct super_block *sb)
531: {
532: struct afs_super_info *as = AFS_FS_S(sb);
533:
534: /* Clear the callback interests (which will do ilookup5) before
535: * deactivating the superblock.
536: */
537: if (as->volume)
538: rcu_assign_pointer(as->volume->sb, NULL);
539: kill_anon_super(sb);
540: if (as->volume)
541: afs_deactivate_volume(as->volume);
542: afs_destroy_sbi(as);
543: }
SourceFile:fs/afs/super.c]
|
| 92/2 |
2026/05/12 23:55 |
llm |
expert |
0m
Model:
Tokens:
input: 82932
output: 45
thoughts: 6233
Thoughts: **Analyzing Potential Reference Count Issues in the AFS Filesystem Code**
Okay, let's break this down systematically. The initial concern seems to be about potential leaks, specifically regarding cell references in the AFS code, and how they might lead to `net->cells_outstanding` remaining non-zero after a network namespace cleanup.
First, I confirmed that `afs_kill_super` calls `afs_destroy_sbi`, which in turn calls `put_net`. This implies that if `cleanup_net` is running, `afs_kill_super` must have already completed, and therefore any related dentries should also be freed. If the dcache and dentries are cleared and `afs_dynroot_d_release` has been called, then all cells should be unused, which is what led to the suspicion.
However, the initial thought process focused on the scenario where `afs_dynroot_lookup_cell` might fail, specifically related to `afs_iget_pseudo_dir` and the subsequent handling of errors. I analyzed the error paths, confirming that in all failure cases, `afs_unuse_cell` *should* be called, preventing a leak. A similar analysis was applied to the case where `d_splice_alias` returns an error, concluding that the VFS mechanism correctly handles the dentry, and the reference to the cell is handled correctly.
The investigation then shifted to potential leaks in other parts of the code. I examined `afs_parse_source`, `afs_validate_fc`, and `afs_proc_cells_write` to understand how cells are looked up and used. The analysis confirmed that in these cases, `afs_unuse_cell` is called after use. The key point here was understanding the role of `AFS_CELL_FL_NO_GC`, `AFS_LOOKUP_CELL_PRELOAD`, and various cell states. A potential problem area was `afs_lookup_cell` with `AFS_LOOKUP_CELL_PRELOAD`, because it does not `afs_use_cell` if the cell already exists and the call returns with `-EEXIST`. However, since no reference is gained, no leak is possible. I then looked at the behavior when it *does* allocate a new cell with `AFS_LOOKUP_CELL_PRELOAD`. I determined that although the cell is initialized, it is eventually cleaned up by `afs_cell_purge`.
I then analyzed the flow for the `rootcell`, as initiated by `afs_cell_init` with `AFS_LOOKUP_CELL_ROOTCELL`, which is also fine.
I then looked at the `AFS_LOOKUP_CELL_DYNROOT` case, analyzing what happens when `afs_find_cell` returns an existing cell in the "unlooked" state. This path returns the cell without waiting, and then is associated with a dentry by `afs_dynroot_lookup_cell`. The code is correctly structured, so all is fine. This covers most cases, including failures in `afs_update_cell`, where an `afs_unuse_cell` is also issued.
I then considered what happens if the cell is still actively being "updated" via DNS query, and whether an interruption of the `dns_query` could create a leak. The code is structured in a way that handles the failures appropriately, and that an interrupt of the DNS query does not create a leak.
The key to finding the leak is to understand when the `active` counter of a cell remains greater than 0. I confirmed that the active count goes down to 0 and all is fine.
Finally, I analyzed the code where cells were used in `afs_mntpt_set_params` and `afs_cell_detect_alias`. I understood how these functions are structured.
I concluded the analysis by verifying there were no other code paths by which `afs_lookup_cell` might return an error without calling `afs_unuse_cell`.
The analysis concludes that *all* examined code paths related to cell handling, including error conditions and concurrency scenarios, correctly manage reference counts and deallocation of cells, and there is no obvious leak.
|
| 93/2 |
2026/05/12 23:56 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/vl_alias.c IncludeLines:true Name:afs_cell_detect_alias]
Results: map[SourceCode: 310: /*
311: * Check to see if a new cell is an alias of a cell we already have. At this
312: * point we have the cell's volume server list.
313: *
314: * Returns 0 if we didn't detect an alias, 1 if we found an alias and an error
315: * if we had problems gathering the data required. In the case the we did
316: * detect an alias, cell->alias_of is set to point to the assumed master.
317: */
318: int afs_cell_detect_alias(struct afs_cell *cell, struct key *key)
319: {
320: struct afs_net *net = cell->net;
321: int ret;
322:
323: if (mutex_lock_interruptible(&net->cells_alias_lock) < 0)
324: return -ERESTARTSYS;
325:
326: if (test_bit(AFS_CELL_FL_CHECK_ALIAS, &cell->flags)) {
327: ret = afs_do_cell_detect_alias(cell, key);
328: if (ret >= 0)
329: clear_bit_unlock(AFS_CELL_FL_CHECK_ALIAS, &cell->flags);
330: } else {
331: ret = cell->alias_of ? 1 : 0;
332: }
333:
334: mutex_unlock(&net->cells_alias_lock);
335:
336: if (ret == 1)
337: pr_notice("kAFS: Cell %s is an alias of %s\n",
338: cell->name, cell->alias_of->name);
339: return ret;
340: }
SourceFile:fs/afs/vl_alias.c]
|
| 94/2 |
2026/05/12 23:56 |
llm |
expert |
0m
Model:
Tokens:
input: 90640
output: 45
thoughts: 2879
Thoughts: **Analyzing a Potential Deadlock in AFS Cell Purging**
Okay, so I'm digging into this AFS cell purging issue. The code uses `net->cells_alias_lock` and the `afs_do_cell_detect_alias` calls functions `yfs_check_canonical_cell_name` or `afs_compare_cell_roots`. The logic seems straightforward; the alias setting and bit clearing are safe. The question is what happens if `afs_cell_purge` is triggered at the same time. `afs_cell_purge` itself doesn't use the `cells_alias_lock`, only waits for `cells_outstanding` to reach zero. So that appears safe.
The initial thought then focuses on work queues. The report mentions a blocked worker in `cleanup_net` and an `events_unbound` workqueue trace in a separate trace from kasan. I can verify that `afs_wq` is created as a normal workqueue. The concern here is if `afs_wq` itself is blocked and can't process `afs_manage_cell_work` requests. But it's a normal workqueue, so it can have multiple workers. The bug report is not conclusive, indicating that some other workqueue may be blocked.
Looking at `afs_cell_purge` closely, it iterates through cells, flags them for unuse/purge, and then calls `afs_queue_cell` which queues work on `afs_wq`. `afs_unuse_cell` does an atomic decrement of `cell->active` and calls `afs_set_cell_timer`. This is the crux. The timer function calls `afs_queue_cell` again if `net->live` is false, queuing the work twice. This is fine.
However, the problem arises if `cell->active` is *not* zero after `afs_unuse_cell`. Then `afs_set_cell_timer` isn't called, but `afs_queue_cell` *still* gets called. This means the `afs_manage_cell_work` *will* run but when it does, it will go to `cell_is_active`, and will return `false`, because `cell->active` is > 0. This is critical: that cell is *not* removed, `net->cells_outstanding` isn't decremented. So the `afs_cell_purge` will wait forever.
The deadlock only occurs if a cell's active count is greater than zero. The next question is who holds an active reference? The `dynroot` dentry is a key point to start analysis. The dentry, and therefore, the cell, isn't freed until the superblock is unmounted. Superblock unmounting itself is handled by `delayed_mntput_work` which is run on `system_unbound_wq`. The potential problem is that `cleanup_net`, which calls `afs_net_exit`, which calls `afs_cell_purge`, runs concurrently, and blocks waiting on `net->cells_outstanding` which will not go to zero if `cell->active` is > 0, so, `cleanup_net` will be blocked.
The superblock holds a reference to the network namespace. Thus, if the superblock is *not* unmounted, `cleanup_net` CANNOT run. The converse is also true: if `cleanup_net` *is* running, that means the superblock *must* have been unmounted and freed. That means the dentry should be freed, and any reference held to `dynroot` would also be gone.
`afs_kill_super` is called by `kill_anon_super` which frees all dentries and therefore calls `afs_dynroot_d_release`, unusing the cells. Thus, after `afs_kill_super` runs, everything *should* have been cleaned up and active references set to zero.
Are there other places active references are held? `afs_parse_source` appears to hold a reference, but it is always unused later, even if the mount or tree is successful.
Then I look at the `as->cell` reference, which is used if it's not a dynamic root mount. `as->cell` is unused in `afs_destroy_sbi`, which *is* called from `afs_kill_super`. So, again, `as->cell` should also be cleaned up.
The conclusion here is that no cells should be held by the superblock or dentries when `cleanup_net` runs. The `cell->active` *must* be greater than zero *somehow*.
I need to re-examine all callers of `afs_lookup_cell`, as that could indicate a way that
|
| 95/2 |
2026/05/12 23:57 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/vl_alias.c IncludeLines:true Name:afs_compare_cell_roots]
Results: map[SourceCode: 104: /*
105: * Compare root.cell volumes.
106: */
107: static int afs_compare_cell_roots(struct afs_cell *cell)
108: {
109: struct afs_cell *p;
110:
111: _enter("");
112:
113: rcu_read_lock();
114:
115: hlist_for_each_entry_rcu(p, &cell->net->proc_cells, proc_link) {
116: if (p == cell || p->alias_of)
117: continue;
118: if (!p->root_volume)
119: continue; /* Ignore cells that don't have a root.cell volume. */
120:
121: if (afs_compare_volume_slists(cell->root_volume, p->root_volume) != 0)
122: goto is_alias;
123: }
124:
125: rcu_read_unlock();
126: _leave(" = 0");
127: return 0;
128:
129: is_alias:
130: rcu_read_unlock();
131: cell->alias_of = afs_use_cell(p, afs_cell_trace_use_alias);
132: return 1;
133: }
SourceFile:fs/afs/vl_alias.c]
|
| 96/2 |
2026/05/12 23:57 |
llm |
expert |
0m
Model:
Tokens:
input: 95038
output: 45
thoughts: 54
Thoughts: Okay, let's break this down.
**Understanding Alias Handling in this Context**
Right, so we're looking at alias management, specifically how a cell's alias is established and destroyed. First, we have `cell->alias_of = afs_use_cell(p)`. That seems straightforward; we're assigning an alias, likely another `cell` structure, to the current `cell`. The function `afs_use_cell` probably handles reference counting or some other form of resource management, which makes sense. We want to ensure the alias doesn't get prematurely freed.
Now, the important part: `afs_cell_destroy` *unuses* the `cell->alias_of`. That confirms the earlier suspicion about resource management. When the main `cell` is destroyed, the alias is properly "released," preventing dangling pointers or memory leaks. That's good, expected behavior, and it aligns with best practices for garbage collection and memory safety in this type of environment.
To confirm the behavior, the next logical step would be to review the `afs_query_for_alias` to see how an alias might be established, to begin with.
|
| 97/2 |
2026/05/12 23:57 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/vl_alias.c IncludeLines:true Name:afs_query_for_alias]
Results: map[SourceCode: 182: /*
183: * Query the new cell for volumes we know exist in cells we're already using.
184: */
185: static int afs_query_for_alias(struct afs_cell *cell, struct key *key)
186: {
187: struct afs_cell *p;
188:
189: _enter("%s", cell->name);
190:
191: if (mutex_lock_interruptible(&cell->net->proc_cells_lock) < 0)
192: return -ERESTARTSYS;
193:
194: hlist_for_each_entry(p, &cell->net->proc_cells, proc_link) {
195: if (p == cell || p->alias_of)
196: continue;
197: if (RB_EMPTY_ROOT(&p->volumes))
198: continue;
199: if (p->root_volume)
200: continue; /* Ignore cells that have a root.cell volume. */
201: afs_use_cell(p, afs_cell_trace_use_check_alias);
202: mutex_unlock(&cell->net->proc_cells_lock);
203:
204: if (afs_query_for_alias_one(cell, key, p) != 0)
205: goto is_alias;
206:
207: if (mutex_lock_interruptible(&cell->net->proc_cells_lock) < 0) {
208: afs_unuse_cell(p, afs_cell_trace_unuse_check_alias);
209: return -ERESTARTSYS;
210: }
211:
212: afs_unuse_cell(p, afs_cell_trace_unuse_check_alias);
213: }
214:
215: mutex_unlock(&cell->net->proc_cells_lock);
216: _leave(" = 0");
217: return 0;
218:
219: is_alias:
220: cell->alias_of = p; /* Transfer our ref */
221: return 1;
222: }
SourceFile:fs/afs/vl_alias.c]
|
| 98/2 |
2026/05/12 23:57 |
llm |
expert |
0m
Model:
Tokens:
input: 96058
output: 47
thoughts: 205
Thoughts: **Analyzing the Alias Resolution Logic**
Okay, so I'm digging into this alias resolution code. The flow starts with `afs_use_cell(p)`. Straightforward enough, right? Then we hit `afs_query_for_alias_one`. If *that* returns 0, meaning no alias found, we clean up with `afs_unuse_cell(p)`. Makes sense; release the reference if there's no alias. If it's non-zero, bingo, we have an alias! `cell->alias_of` gets set to `p`, reference transferred, all good.
But wait a minute... what happens if `afs_query_for_alias_one` returns *less than* zero? That signifies an *error*! The code says:
```c
if (afs_query_for_alias_one(cell, key, p) != 0)
goto is_alias;
```
Whoa. If there's an error β say, `-ENOMEM` because we ran out of memory β the code actually *jumps* to the `is_alias` section! Then it sets `cell->alias_of = p` and returns 1! This is... suboptimal, to say the least. An error condition is being treated as an alias! That's a major flaw, I'd say. I need to understand this `afs_query_for_alias_one` function inside out. Time to examine that function.
|
| 99/2 |
2026/05/12 23:57 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/vl_alias.c IncludeLines:true Name:afs_query_for_alias_one]
Results: map[SourceCode: 135: /*
136: * Query the new cell for a volume from a cell we're already using.
137: */
138: static int afs_query_for_alias_one(struct afs_cell *cell, struct key *key,
139: struct afs_cell *p)
140: {
141: struct afs_volume *volume, *pvol = NULL;
142: int ret;
143:
144: /* Arbitrarily pick a volume from the list. */
145: read_seqlock_excl(&p->volume_lock);
146: if (!RB_EMPTY_ROOT(&p->volumes))
147: pvol = afs_get_volume(rb_entry(p->volumes.rb_node,
148: struct afs_volume, cell_node),
149: afs_volume_trace_get_query_alias);
150: read_sequnlock_excl(&p->volume_lock);
151: if (!pvol)
152: return 0;
153:
154: _enter("%s:%s", cell->name, pvol->name);
155:
156: /* And see if it's in the new cell. */
157: volume = afs_sample_volume(cell, key, pvol->name, pvol->name_len);
158: if (IS_ERR(volume)) {
159: afs_put_volume(pvol, afs_volume_trace_put_query_alias);
160: if (PTR_ERR(volume) != -ENOMEDIUM)
161: return PTR_ERR(volume);
162: /* That volume is not in the new cell, so not an alias */
163: return 0;
164: }
165:
166: /* The new cell has a like-named volume also - compare volume ID,
167: * server and address lists.
168: */
169: ret = 0;
170: if (pvol->vid == volume->vid) {
171: rcu_read_lock();
172: if (afs_compare_volume_slists(volume, pvol))
173: ret = 1;
174: rcu_read_unlock();
175: }
176:
177: afs_put_volume(volume, afs_volume_trace_put_query_alias);
178: afs_put_volume(pvol, afs_volume_trace_put_query_alias);
179: return ret;
180: }
SourceFile:fs/afs/vl_alias.c]
|
| 100/2 |
2026/05/12 23:57 |
llm |
expert |
0m
Model:
Tokens:
input: 97415
output: 43
thoughts: 845
Thoughts: **Analyzing the Alias Switching Logic in afs_validate_fc**
Okay, let's break this down. My initial thought was about how the alias resolution works when `afs_sample_volume` returns an error. It seems that if any error *other* than `-ENOMEDIUM` comes back from that function, the subsequent calls to `afs_query_for_alias` just see a non-zero return value, and jump straight to the alias processing. That's a little unusual, but it's important to verify it's handled right to avoid potential resource leaks. We jump to `is_alias`, return 1, and so on, eventually switching to the alias cell. From a quick glance, I didn't see any obvious reference leaks there.
But then I had a nagging question: what happens if the alias detection actually *fails*? If `afs_cell_detect_alias` returns a negative value, it looks like that error is propagated up the call stack and everything terminates cleanly. Again, no leak.
The core of my analysis revolves around the scenario where alias detection is *successful*. If `afs_do_cell_detect_alias` returns 1, that means the alias is detected. This triggers some other checks - `yfs_check_canonical_cell_name`, `afs_compare_cell_roots`, or `afs_query_for_alias`, and *if any of these return 1* (i.e., indicate an alias) `cell->alias_of` gets set to point to the alias. Then, `afs_validate_fc` proceeds to switch to the alias cell.
The tricky part is ensuring correct reference counting. So `afs_validate_fc` switches the context, dropping a reference to the original cell, and switching to the alias. The original cell (`cell`) is no longer being used. This drops its `active` count. Eventually the function `afs_manage_cell` is called, and `afs_put_cell` is called. Finally, `afs_cell_destroy` is called, and *this is where I have to be careful*. `afs_cell_destroy` calls `afs_unuse_cell(cell->alias_of)`. This is the point where we release the reference to the alias we had transferred. That call to `afs_use_cell` in the context switch *should* have increased the alias's active count, as it's being used. Therefore, when `afs_cell_destroy` calls `afs_unuse_cell(cell->alias_of)`, it decrements the transferred reference, and then `afs_free_fc` will be called, decrementing the reference count of the `ctx->cell` (the alias). So, the balance *should* be right. Everything is nicely balanced.
But! Let's cover the edge case. What if `cell->alias_of` is NULL in `afs_cell_destroy`? Then `afs_unuse_cell(NULL)` does nothing, so we're safe.
Now, I really need to double-check: is `afs_use_cell` being called *anywhere else*? I need to look for additional reference increments beyond the scope of `afs_validate_fc`. `afs_proc_cells_show` is another place that's likely.
|
| 101/2 |
2026/05/12 23:57 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/proc.c IncludeLines:true Name:afs_proc_cells_show]
Results: map[SourceCode: 31: /*
32: * Display the list of cells known to the namespace.
33: */
34: static int afs_proc_cells_show(struct seq_file *m, void *v)
35: {
36: struct afs_vlserver_list *vllist;
37: struct afs_cell *cell;
38:
39: if (v == SEQ_START_TOKEN) {
40: /* display header on line 1 */
41: seq_puts(m, "USE ACT TTL SV ST NAME\n");
42: return 0;
43: }
44:
45: cell = list_entry(v, struct afs_cell, proc_link);
46: vllist = rcu_dereference(cell->vl_servers);
47:
48: /* display one cell per line on subsequent lines */
49: seq_printf(m, "%3u %3u %6lld %2u %2u %s\n",
50: refcount_read(&cell->ref),
51: atomic_read(&cell->active),
52: cell->dns_expiry - ktime_get_real_seconds(),
53: vllist ? vllist->nr_servers : 0,
54: cell->state,
55: cell->name);
56: return 0;
57: }
SourceFile:fs/afs/proc.c]
|
| 102/2 |
2026/05/12 23:57 |
llm |
expert |
0m
Model:
Tokens:
input: 99441
output: 49
thoughts: 275
Thoughts: **Analyzing Cell Activation and References**
Okay, so I'm looking at this code and immediately I see `cell->active`. That seems straightforward. But what's the broader picture? I need to understand how the active state is managed in relation to the reference count. Let's dig deeper.
I see `afs_see_cell`... let me check that...
```c
void afs_see_cell(struct afs_cell *cell, enum afs_cell_trace reason)
{
int r, a;
if (cell) {
r = refcount_read(&cell->ref);
a = atomic_read(&cell->active);
trace_afs_cell(cell->debug_id, r, a, reason);
}
}
```
... no, that doesn't seem to modify either the refcount or the active state; it just reads them and traces them. Okay, on to `afs_get_cell`.
```c
struct afs_cell *afs_get_cell(struct afs_cell *cell, enum afs_cell_trace reason)
{
int r, a;
if (cell) {
__refcount_inc(&cell->ref, &r);
a = atomic_read(&cell->active);
trace_afs_cell(cell->debug_id, r + 1, a, reason);
}
return cell;
}
```
Aha! `afs_get_cell` *does* increment the reference count (`cell->ref`), but it *only* reads the active state (`cell->active`). This is important. So, the act of "getting" a cell, potentially for use, increases the reference count, but not necessarily its "active" state. Now, I need to know *who* calls `afs_get_cell`. I need to trace this back to the callers to fully understand the flow and the implications of this design.
|
| 103/2 |
2026/05/12 23:57 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeSnippetLines:0 Name:afs_get_cell SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_alloc_volume SourceFile:fs/afs/volume.c SourceLine:91] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_atcell_get_link SourceFile:fs/afs/dynroot.c SourceLine:235] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:afs_install_server SourceFile:fs/afs/server.c SourceLine:103]] TruncatedOutput:false]
|
| 104/2 |
2026/05/12 23:57 |
llm |
expert |
0m
Model:
Tokens:
input: 100369
output: 41
thoughts: 11
Thoughts: Okay, here's my summarized thought process, presented as if I'm thinking it:
**Checking `afs_alloc_volume`**
Alright, time to dive in. Let's see... the task at hand is definitely centered around volume allocation within the AFS context. This `afs_alloc_volume` function, right, that's where the rubber meets the road. It's the critical piece for understanding how new storage is brought online. I need to refresh my understanding of its role. Let's start by recalling the core functionality. I'm thinking this function will handle finding available space, configuring new volumes with the requisite metadata, and ensuring proper integration within the overall AFS namespace. Let me get into it and confirm the expected behavior and implementation. I want to check for any potential gotchas or edge cases I'm not immediately thinking of, especially around error handling and resource exhaustion. I'll focus on how it interacts with the underlying storage and configuration databases. Let's do this.
|
| 105/2 |
2026/05/12 23:57 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/volume.c IncludeLines:true Name:afs_alloc_volume]
Results: map[SourceCode: 73: /*
74: * Allocate a volume record and load it up from a vldb record.
75: */
76: static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params,
77: struct afs_vldb_entry *vldb,
78: struct afs_server_list **_slist)
79: {
80: struct afs_server_list *slist;
81: struct afs_volume *volume;
82: int ret = -ENOMEM, i;
83:
84: volume = kzalloc(sizeof(struct afs_volume), GFP_KERNEL);
85: if (!volume)
86: goto error_0;
87:
88: volume->debug_id = atomic_inc_return(&afs_volume_debug_id);
89: volume->vid = vldb->vid[params->type];
90: volume->update_at = ktime_get_real_seconds() + afs_volume_record_life;
91: volume->cell = afs_get_cell(params->cell, afs_cell_trace_get_vol);
92: volume->type = params->type;
93: volume->type_force = params->force;
94: volume->name_len = vldb->name_len;
95: volume->creation_time = TIME64_MIN;
96: volume->update_time = TIME64_MIN;
97:
98: refcount_set(&volume->ref, 1);
99: INIT_HLIST_NODE(&volume->proc_link);
100: INIT_WORK(&volume->destructor, afs_destroy_volume);
101: rwlock_init(&volume->servers_lock);
102: mutex_init(&volume->volsync_lock);
103: mutex_init(&volume->cb_check_lock);
104: rwlock_init(&volume->cb_v_break_lock);
105: INIT_LIST_HEAD(&volume->open_mmaps);
106: init_rwsem(&volume->open_mmaps_lock);
107: memcpy(volume->name, vldb->name, vldb->name_len + 1);
108:
109: for (i = 0; i < AFS_MAXTYPES; i++)
110: volume->vids[i] = vldb->vid[i];
111:
112: slist = afs_alloc_server_list(volume, params->key, vldb);
113: if (IS_ERR(slist)) {
114: ret = PTR_ERR(slist);
115: goto error_1;
116: }
117:
118: *_slist = slist;
119: rcu_assign_pointer(volume->servers, slist);
120: trace_afs_volume(volume->debug_id, volume->vid, 1, afs_volume_trace_alloc);
121: return volume;
122:
123: error_1:
124: afs_put_cell(volume->cell, afs_cell_trace_put_vol);
125: kfree(volume);
126: error_0:
127: return ERR_PTR(ret);
128: }
SourceFile:fs/afs/volume.c]
|
| 106/2 |
2026/05/12 23:57 |
llm |
expert |
0m
Model:
Tokens:
input: 101617
output: 41
thoughts: 866
Thoughts: **A Deep Dive into AFS Cell and Volume Lifecycle**
Okay, let's break down this AFS cell management logic. My initial concern is with how `afs_alloc_volume` interacts with cell lifecycle. I see that it calls `afs_get_cell`, which increments the cell's reference count (`cell->ref`). Importantly, this increment doesn't touch `cell->active`. This is where the potential problem arises. If `cell->active` were to drop to zero due to some other process, `afs_manage_cell` would remove it from `net->cells` and set its state to `AFS_CELL_DEAD`. However, and this is crucial, the cell *isn't* freed at this stage because `cell->ref` is still greater than zero. The volume's reference prevents immediate freeing.
Now, here's where it clicks: `afs_cell_purge` waits for `net->cells_outstanding` to become zero. `net->cells_outstanding` is decremented in `afs_cell_destroy`, and `afs_cell_destroy` is called *only* when `cell->ref` drops to zero. If the volume holds a reference (which, of course, it does), then `cell->ref` is > 0, and `net->cells_outstanding` remains untouched. This means that if there are volumes still in use, `afs_cell_purge` *will* hang, potentially causing serious issues during cleanup.
Hold on, does `afs_cell_purge` wait for volumes to be freed? Time to check `afs_net_exit`. Ah, yes, `afs_cell_purge` is called *before* `afs_wait_for_servers`. And there's no `afs_volume_purge`! This seems... problematic. Volumes are freed when their reference count drops to zero.
Right, who's holding the references to volumes? Superblocks! The superblock's `as->volume` holds a reference, and `afs_destroy_sbi` calls `afs_put_volume`. So, if the superblock is *not* unmounted, the volume remains in use, keeping the cell alive. This stops the counter, and `afs_cell_purge` hangs.
But... wait! I just realized something. If the superblock is NOT unmounted, it's holding a reference to `net_ns` through `as->net_ns = get_net(fc->net_ns)`. Crucially, `cleanup_net` cannot run if the superblock has a reference to `net_ns`. `cleanup_net` is only called when `net_ns`'s reference count drops to zero. Therefore, if `cleanup_net` *is* running, all superblocks *must* have been unmounted and destroyed! That means that when `cleanup_net` runs, `afs_destroy_sbi` was called. `afs_destroy_sbi` called `afs_put_volume(as->volume)`. This decrements the volume's reference count, leading to `afs_destroy_volume`. Which then calls `afs_put_cell(volume->cell)`. This causes the cell's reference count to go to zero, leading to `afs_cell_destroy` and the decrementing of `net->cells_outstanding`. So if `cleanup_net` is executing, it follows that *all* superblocks were destroyed, *all* volumes were freed, and *all* cells were freed. This seems like a consistent flow.
Hmm... just to be sure, is there any *other* place that holds a reference to a volume? Ah, `afs_create_volume` adds the volume to `cell->volumes`. Does `cell->volumes` hold a reference, or is this just a bookkeeping thing? Let's check `afs_create_volume`...
|
| 107/2 |
2026/05/12 23:58 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/volume.c IncludeLines:true Name:afs_create_volume]
Results: map[SourceCode: 174: /*
175: * Look up a volume in the VL server and create a candidate volume record for
176: * it.
177: *
178: * The volume name can be one of the following:
179: * "%[cell:]volume[.]" R/W volume
180: * "#[cell:]volume[.]" R/O or R/W volume (rwparent=0),
181: * or R/W (rwparent=1) volume
182: * "%[cell:]volume.readonly" R/O volume
183: * "#[cell:]volume.readonly" R/O volume
184: * "%[cell:]volume.backup" Backup volume
185: * "#[cell:]volume.backup" Backup volume
186: *
187: * The cell name is optional, and defaults to the current cell.
188: *
189: * See "The Rules of Mount Point Traversal" in Chapter 5 of the AFS SysAdmin
190: * Guide
191: * - Rule 1: Explicit type suffix forces access of that type or nothing
192: * (no suffix, then use Rule 2 & 3)
193: * - Rule 2: If parent volume is R/O, then mount R/O volume by preference, R/W
194: * if not available
195: * - Rule 3: If parent volume is R/W, then only mount R/W volume unless
196: * explicitly told otherwise
197: */
198: struct afs_volume *afs_create_volume(struct afs_fs_context *params)
199: {
200: struct afs_vldb_entry *vldb;
201: struct afs_volume *volume;
202: unsigned long type_mask = 1UL << params->type;
203:
204: vldb = afs_vl_lookup_vldb(params->cell, params->key,
205: params->volname, params->volnamesz);
206: if (IS_ERR(vldb))
207: return ERR_CAST(vldb);
208:
209: if (test_bit(AFS_VLDB_QUERY_ERROR, &vldb->flags)) {
210: volume = ERR_PTR(vldb->error);
211: goto error;
212: }
213:
214: /* Make the final decision on the type we want */
215: volume = ERR_PTR(-ENOMEDIUM);
216: if (params->force) {
217: if (!(vldb->flags & type_mask))
218: goto error;
219: } else if (test_bit(AFS_VLDB_HAS_RO, &vldb->flags)) {
220: params->type = AFSVL_ROVOL;
221: } else if (test_bit(AFS_VLDB_HAS_RW, &vldb->flags)) {
222: params->type = AFSVL_RWVOL;
223: } else {
224: goto error;
225: }
226:
227: volume = afs_lookup_volume(params, vldb);
228:
229: error:
230: kfree(vldb);
231: return volume;
232: }
SourceFile:fs/afs/volume.c]
|
| 108/2 |
2026/05/12 23:58 |
llm |
expert |
0m
Model:
Tokens:
input: 104365
output: 41
thoughts: 15
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Delving into the `afs_create_volume` Function**
Right, so I'm thinking about the low-level volume creation process within AFS. When `afs_create_volume` is invoked, my initial thought immediately jumps to the dependency β the lookup operation. *Of course*. Before I can actually *create* a new volume, I need to make sure I know where it *goes*. That implies a call to `afs_lookup_volume`. It's a fundamental part of the volume management, and I need to ensure the target location for the new volume is validated and accessible. This is the sequence: create command > lookup > create. I immediately connect the creation process with the lookup operation, and how they should be intertwined within the AFS architecture. It's the logical flow, isn't it? Without a validated location, creation can't even begin to happen.
|
| 109/2 |
2026/05/12 23:58 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/volume.c IncludeLines:true Name:afs_lookup_volume]
Results: map[SourceCode: 130: /*
131: * Look up or allocate a volume record.
132: */
133: static struct afs_volume *afs_lookup_volume(struct afs_fs_context *params,
134: struct afs_vldb_entry *vldb)
135: {
136: struct afs_server_list *slist;
137: struct afs_volume *candidate, *volume;
138:
139: candidate = afs_alloc_volume(params, vldb, &slist);
140: if (IS_ERR(candidate))
141: return candidate;
142:
143: volume = afs_insert_volume_into_cell(params->cell, candidate);
144: if (volume == candidate)
145: afs_attach_volume_to_servers(volume, slist);
146: else
147: afs_put_volume(candidate, afs_volume_trace_put_cell_dup);
148: return volume;
149: }
SourceFile:fs/afs/volume.c]
|
| 110/2 |
2026/05/12 23:58 |
llm |
expert |
0m
Model:
Tokens:
input: 104972
output: 45
thoughts: 20
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**My Perspective on Volume Insertion**
Alright, so I'm thinking about this `afs_insert_volume_into_cell` function. What it's fundamentally doing is fairly straightforward, but the implications within a distributed filesystem context are, as always, worth considering. Basically, itβs responsible for the core action of adding a volume to a `cell->volumes` data structure. I immediately think about the *how*: I need to consider what the actual data structure `cell->volumes` is. Is it a linked list, a hash table, a red-black tree, or something more specialized? The choice impacts the insertion time complexity and overall performance, especially when dealing with a large number of volumes. I'll need to know this structure to really get a sense of the system's performance.
I also wonder if there are any concurrency considerations. Is `cell` protected by a mutex or some other locking mechanism to prevent race conditions during concurrent volume insertions or deletions? If not, I'd immediately be concerned about data corruption. I need to ensure that the volume insertion is atomic, or at least that some form of locking is in place to guarantee data integrity.
Beyond that, I'm thinking about error handling. What happens if the volume already exists? Does the function return an error code, silently overwrite, or log a warning? What about memory allocation failures during the insertion process? And what kind of consistency guarantees are we assuming? Is this function part of a larger transaction or distributed operation? The wider context is key.
Finally, what's the purpose of a cell's 'volumes'? Is it primarily for metadata management, for access control, or something else entirely? The implications on performance and design are huge and will influence the use case for the operation. Understanding how this function fits into the bigger picture is what I'm focused on right now.
|
| 111/2 |
2026/05/12 23:58 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/volume.c IncludeLines:true Name:afs_insert_volume_into_cell]
Results: map[SourceCode: 17: /*
18: * Insert a volume into a cell. If there's an existing volume record, that is
19: * returned instead with a ref held.
20: */
21: static struct afs_volume *afs_insert_volume_into_cell(struct afs_cell *cell,
22: struct afs_volume *volume)
23: {
24: struct afs_volume *p;
25: struct rb_node *parent = NULL, **pp;
26:
27: write_seqlock(&cell->volume_lock);
28:
29: pp = &cell->volumes.rb_node;
30: while (*pp) {
31: parent = *pp;
32: p = rb_entry(parent, struct afs_volume, cell_node);
33: if (p->vid < volume->vid) {
34: pp = &(*pp)->rb_left;
35: } else if (p->vid > volume->vid) {
36: pp = &(*pp)->rb_right;
37: } else {
38: if (afs_try_get_volume(p, afs_volume_trace_get_cell_insert)) {
39: volume = p;
40: goto found;
41: }
42:
43: set_bit(AFS_VOLUME_RM_TREE, &volume->flags);
44: rb_replace_node_rcu(&p->cell_node, &volume->cell_node, &cell->volumes);
45: }
46: }
47:
48: rb_link_node_rcu(&volume->cell_node, parent, pp);
49: rb_insert_color(&volume->cell_node, &cell->volumes);
50: hlist_add_head_rcu(&volume->proc_link, &cell->proc_volumes);
51:
52: found:
53: write_sequnlock(&cell->volume_lock);
54: return volume;
55:
56: }
SourceFile:fs/afs/volume.c]
|
| 112/2 |
2026/05/12 23:58 |
llm |
expert |
0m
Model:
Tokens:
input: 106058
output: 41
thoughts: 49
Thoughts: Okay, let me think this through.
**Analyzing Volume Reference Counting in AFS**
Wait a minute, I need to clarify something about `afs_insert_volume_into_cell`. I was under the impression it was incrementing the volume's reference count related to the tree, but that's not right. It just *links* the volume into the tree structure. That means I need to re-examine the lifecycle of this volume.
So, the critical question becomes: when is this volume actually *removed* from the tree and the appropriate clean up performed? It's not when it's added. The next logical place to investigate is `afs_destroy_volume`. I need to ensure that the proper deallocation occurs there.
|
| 113/2 |
2026/05/12 23:58 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/volume.c IncludeLines:true Name:afs_destroy_volume]
Results: map[SourceCode: 234: /*
235: * Destroy a volume record
236: */
237: static void afs_destroy_volume(struct work_struct *work)
238: {
239: struct afs_volume *volume = container_of(work, struct afs_volume, destructor);
240: struct afs_server_list *slist = rcu_access_pointer(volume->servers);
241:
242: _enter("%p", volume);
243:
244: #ifdef CONFIG_AFS_FSCACHE
245: ASSERTCMP(volume->cache, ==, NULL);
246: #endif
247:
248: afs_detach_volume_from_servers(volume, slist);
249: afs_remove_volume_from_cell(volume);
250: afs_put_serverlist(volume->cell->net, slist);
251: afs_put_cell(volume->cell, afs_cell_trace_put_vol);
252: trace_afs_volume(volume->debug_id, volume->vid, refcount_read(&volume->ref),
253: afs_volume_trace_free);
254: kfree_rcu(volume, rcu);
255:
256: _leave(" [destroyed]");
257: }
SourceFile:fs/afs/volume.c]
|
| 114/2 |
2026/05/12 23:58 |
llm |
expert |
0m
Model:
Tokens:
input: 106717
output: 41
thoughts: 585
Thoughts: **Debugging a Potential AFS Kernel Hang**
Okay, so I'm digging into this AFS kernel hang, and let's break down my thought process. The initial assumption is that the volume is properly removed from the file system tree by `afs_remove_volume_from_cell`. That's good; it's *not* a reference we're holding onto directly. The volume's lifespan hinges on its reference count (`ref`), which, when dropping to zero, gets the volume freed. The volume's cell membership is cleaned up during volume destruction.
Then, I see this kernel message, which immediately makes me think about what process is holding things up. I see a `kworker` process blocked, and a call trace that includes `afs_cell_purge`, `afs_net_exit`, `cleanup_net`. It seems like `afs_cell_purge` could be waiting for `net->cells_outstanding` to reach zero. The key is in the code. I immediately think, what happens if this variable is already zero? Then, the code shouldn't block, as it calls `wait_var_event`. Since this is happening, it MUST be greater than zero.
Aha! So, what's contributing to the value being non-zero? Could there be a leak in `afs_alloc_cell`? I check the code; the `cells_outstanding` counter is incremented when we allocate cells using `atomic_inc(&net->cells_outstanding)`. `afs_dec_cells_outstanding` decrements it, and that code looks correct.
Hold on a minute, what if `afs_alloc_cell` fails? Let's trace that scenario. It increments `cells_outstanding`, attempts to allocate an ID using `idr_alloc_cyclic`, and then if the ID allocation fails, it goes to `error`. That's where it cleans up the allocated resources using `afs_put_vlserverlist`, `kfree`, etc.
The critical observation here, and where I think I've found the bug, is that *it does not decrement `net->cells_outstanding` in the error path*. The counter gets incremented, the allocation fails, we bail out, but the "outstanding" count is left high. That explains the blocked worker and the hang. I've got a pretty good lead here. I need to make sure this code is fixed.
|
| 115/2 |
2026/05/12 23:58 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/cell.c IncludeLines:true Name:afs_alloc_cell]
Results: map[SourceCode: 104: /*
105: * Set up a cell record and fill in its name, VL server address list and
106: * allocate an anonymous key
107: */
108: static struct afs_cell *afs_alloc_cell(struct afs_net *net,
109: const char *name, unsigned int namelen,
110: const char *addresses)
111: {
112: struct afs_vlserver_list *vllist = NULL;
113: struct afs_cell *cell;
114: int i, ret;
115:
116: ASSERT(name);
117: if (namelen == 0)
118: return ERR_PTR(-EINVAL);
119: if (namelen > AFS_MAXCELLNAME) {
120: _leave(" = -ENAMETOOLONG");
121: return ERR_PTR(-ENAMETOOLONG);
122: }
123:
124: /* Prohibit cell names that contain unprintable chars, '/' and '@' or
125: * that begin with a dot. This also precludes "@cell".
126: */
127: if (name[0] == '.')
128: return ERR_PTR(-EINVAL);
129: for (i = 0; i < namelen; i++) {
130: char ch = name[i];
131: if (!isprint(ch) || ch == '/' || ch == '@')
132: return ERR_PTR(-EINVAL);
133: }
134:
135: _enter("%*.*s,%s", namelen, namelen, name, addresses);
136:
137: cell = kzalloc(sizeof(struct afs_cell), GFP_KERNEL);
138: if (!cell) {
139: _leave(" = -ENOMEM");
140: return ERR_PTR(-ENOMEM);
141: }
142:
143: /* Allocate the cell name and the key name in one go. */
144: cell->name = kmalloc(1 + namelen + 1 +
145: 4 + namelen + 1, GFP_KERNEL);
146: if (!cell->name) {
147: kfree(cell);
148: return ERR_PTR(-ENOMEM);
149: }
150:
151: cell->name[0] = '.';
152: cell->name++;
153: cell->name_len = namelen;
154: for (i = 0; i < namelen; i++)
155: cell->name[i] = tolower(name[i]);
156: cell->name[i++] = 0;
157:
158: cell->key_desc = cell->name + i;
159: memcpy(cell->key_desc, "afs@", 4);
160: memcpy(cell->key_desc + 4, cell->name, cell->name_len + 1);
161:
162: cell->net = net;
163: refcount_set(&cell->ref, 1);
164: atomic_set(&cell->active, 0);
165: INIT_WORK(&cell->destroyer, afs_destroy_cell_work);
166: INIT_WORK(&cell->manager, afs_manage_cell_work);
167: timer_setup(&cell->management_timer, afs_cell_timer, 0);
168: init_rwsem(&cell->vs_lock);
169: cell->volumes = RB_ROOT;
170: INIT_HLIST_HEAD(&cell->proc_volumes);
171: seqlock_init(&cell->volume_lock);
172: cell->fs_servers = RB_ROOT;
173: init_rwsem(&cell->fs_lock);
174: rwlock_init(&cell->vl_servers_lock);
175: cell->flags = (1 << AFS_CELL_FL_CHECK_ALIAS);
176:
177: /* Provide a VL server list, filling it in if we were given a list of
178: * addresses to use.
179: */
180: if (addresses) {
181: vllist = afs_parse_text_addrs(net,
182: addresses, strlen(addresses), ':',
183: VL_SERVICE, AFS_VL_PORT);
184: if (IS_ERR(vllist)) {
185: ret = PTR_ERR(vllist);
186: vllist = NULL;
187: goto parse_failed;
188: }
189:
190: vllist->source = DNS_RECORD_FROM_CONFIG;
191: vllist->status = DNS_LOOKUP_NOT_DONE;
192: cell->dns_expiry = TIME64_MAX;
193: } else {
194: ret = -ENOMEM;
195: vllist = afs_alloc_vlserver_list(0);
196: if (!vllist)
197: goto error;
198: vllist->source = DNS_RECORD_UNAVAILABLE;
199: vllist->status = DNS_LOOKUP_NOT_DONE;
200: cell->dns_expiry = ktime_get_real_seconds();
201: }
202:
203: rcu_assign_pointer(cell->vl_servers, vllist);
204:
205: cell->dns_source = vllist->source;
206: cell->dns_status = vllist->status;
207: smp_store_release(&cell->dns_lookup_count, 1); /* vs source/status */
208: atomic_inc(&net->cells_outstanding);
209: ret = idr_alloc_cyclic(&net->cells_dyn_ino, cell,
210: 2, INT_MAX / 2, GFP_KERNEL);
211: if (ret < 0)
212: goto error;
213: cell->dynroot_ino = ret;
214: cell->debug_id = atomic_inc_return(&cell_debug_id);
215:
216: trace_afs_cell(cell->debug_id, 1, 0, afs_cell_trace_alloc);
217:
218: _leave(" = %p", cell);
219: return cell;
220:
221: parse_failed:
222: if (ret == -EINVAL)
223: printk(KERN_ERR "kAFS: bad VL server IP address\n");
224: error:
225: afs_put_vlserverlist(cell->net, vllist);
226: kfree(cell->name - 1);
227: kfree(cell);
228: _leave(" = %d", ret);
229: return ERR_PTR(ret);
230: }
SourceFile:fs/afs/cell.c]
|
| 116/2 |
2026/05/12 23:58 |
llm |
expert |
0m
Model:
Tokens:
input: 109907
output: 41
thoughts: 861
Thoughts: **The Root Cause: An AFS Cell Allocation Bug**
Okay, here's what's happening. I've pinpointed a critical flaw in how AFS cells are handled, and it's leading to a system-wide denial-of-service vulnerability. My analysis hinges on `idr_alloc_cyclic`, a crucial ID allocation function. If that function fails, specifically when allocating an AFS cell, we have a problem.
The sequence is this: First, `net->cells_outstanding` is incremented. Then, `idr_alloc_cyclic` attempts to allocate an ID for the cell. The code *should* decrement `net->cells_outstanding` if allocation fails, but the logic misses this step entirely! Because of the increment and no decrement, that leaves a counter permanently increased.
Consider this snippet:
```c
atomic_inc(&net->cells_outstanding);
ret = idr_alloc_cyclic(&net->cells_dyn_ino, cell,
2, INT_MAX / 2, GFP_KERNEL);
if (ret < 0)
goto error;
```
If `idr_alloc_cyclic` fails (returning a negative value, which is common), the code jumps to `error`, where the allocated cell is freed, but the `net->cells_outstanding` counter *remains incremented*. The code frees resources on failure, but it fails to decrement `net->cells_outstanding`.
Here's the problem: when the network namespace is destroyed, `afs_cell_purge` is called. This function *waits* for `net->cells_outstanding` to reach zero. Because the counter gets stuck at one (or more) due to the allocation failure, `afs_cell_purge` hangs indefinitely. This blocks `cleanup_net`, a single-threaded workqueue, effectively preventing other network namespaces from cleaning up, resulting in a system-wide denial-of-service (DoS) condition.
Crucially, this isn't a memory corruption or use-after-free issue; it's a counter leak. However, the system hangs, which is just as bad.
Now, the question is, can this be exploited? Absolutely. An unprivileged user can create a user namespace, a network namespace, mount AFS (with the `dyn` option). The vulnerability hinges on getting `idr_alloc_cyclic` to fail. While fault injection (`inject_fault(10)`) can trigger this directly, I realized there's another, more realistic path. `idr_alloc_cyclic` allocates from a range (2 to INT_MAX / 2). A user could theoretically exhaust the available IDs in that range by creating a massive number of cells (close to the integer maximum). This would take enormous amounts of memory and time and potentially fail due to memory constraints, but it *is* possible to trigger an `-ENOSPC` or `-ENOMEM` error, which would cause the allocation failure and trigger the bug. I also suspect that an out-of-memory condition caused by allocation pressure elsewhere in the system could also trigger this. Since mounting AFS requires some privileges, the ability for an unprivileged user to do this hinges on whether AFS can be mounted within a user namespace. The answer seems to be yes, which makes this vulnerability accessible from unprivileged processes. So it is possible for an unprivileged user to create this condition, and trigger a denial of service attack.
|
| 117/2 |
2026/05/12 23:58 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/super.c IncludeLines:true Name:afs_fs_type]
Results: map[SourceCode: 43: struct file_system_type afs_fs_type = {
44: .owner = THIS_MODULE,
45: .name = "afs",
46: .init_fs_context = afs_init_fs_context,
47: .parameters = afs_fs_parameters,
48: .kill_sb = afs_kill_super,
49: .fs_flags = FS_RENAME_DOES_D_MOVE,
50: };
SourceFile:fs/afs/super.c]
|
| 118/2 |
2026/05/12 23:58 |
llm |
expert |
0m
Model:
Tokens:
input: 111706
output: 43
thoughts: 246
Thoughts: **AFS and User Namespaces: A Deep Dive**
Okay, so `FS_USERNS_MOUNT` isn't set. That immediately tells me AFS *can't* be mounted within a user namespace. It's a fundamental restriction. But hold on... the reproducer code provided is trying to do just that:
```c
syz_mount_image(/*fs=*/0x200000000780, /*dir=*/0x200000000300, /*flags=*/0, /*opts=*/0x200000001040, /*chdir=*/1, /*size=*/0xae1, /*img=*/0x200000000940);
```
That's where I need to step back. Syzkaller runs as root in the initial namespace, or it has `CAP_SYS_ADMIN` in the initial namespace, so that's why the mount call doesn't fail.
So, if an unprivileged user can't mount AFS directly, how can they trigger an `afs_alloc_cell` call? Let's rethink this... wait, can they interact with AFS *without* mounting it? Yes, I think they can. What about writing to `/proc/fs/afs/cells`? That seems like a logical target to explore. I need to check the permissions on `/proc/fs/afs/cells`. That's where the vulnerability may be.
|
| 119/2 |
2026/05/12 23:59 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/proc.c IncludeLines:true Name:afs_proc_cells_ops]
Results: map[SourceCode: 77: static const struct seq_operations afs_proc_cells_ops = {
78: .start = afs_proc_cells_start,
79: .next = afs_proc_cells_next,
80: .stop = afs_proc_cells_stop,
81: .show = afs_proc_cells_show,
82: };
SourceFile:fs/afs/proc.c]
|
| 120/2 |
2026/05/12 23:59 |
llm |
expert |
0m
Model:
Tokens:
input: 112465
output: 41
thoughts: 7
Thoughts: Okay, here's my attempt at summarizing the thought process, speaking from a first-person expert perspective, and starting with a bolded header:
**The Crucial Question of Origin**
Alright, so I'm presented with this⦠whatever "it" is. My immediate reaction is a need for context, for understanding the fundamental mechanics. The first question that pops into my head, and the one that needs immediate resolution before I can even begin to assess its significance, its function, or its potential implications, is *where* is this thing even created? The location and method of its creation will define much of what follows. This is the cornerstone. Its origin will dictate material properties, design constraints, potential biases, and a whole slew of other factors that are critical to analyze. Without this foundational knowledge, I'm essentially operating in a vacuum, making educated guesses where informed deduction is required. "Where is it created?" is the essential question to provide that critical foundation of understanding.
|
| 121/2 |
2026/05/12 23:59 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/proc.c IncludeLines:true Name:afs_proc_init]
Results: map[SourceCode: 732: /*
733: * initialise the /proc/fs/afs/ directory
734: */
735: int afs_proc_init(struct afs_net *net)
736: {
737: struct proc_dir_entry *p;
738:
739: _enter("");
740:
741: p = proc_net_mkdir(net->net, "afs", net->net->proc_net);
742: if (!p)
743: goto error_dir;
744:
745: if (!proc_create_net_data_write("cells", 0644, p,
746: &afs_proc_cells_ops,
747: afs_proc_cells_write,
748: sizeof(struct seq_net_private),
749: NULL) ||
750: !proc_create_net_single_write("rootcell", 0644, p,
751: afs_proc_rootcell_show,
752: afs_proc_rootcell_write,
753: NULL) ||
754: !proc_create_net("servers", 0444, p, &afs_proc_servers_ops,
755: sizeof(struct seq_net_private)) ||
756: !proc_create_net_single("stats", 0444, p, afs_proc_stats_show, NULL) ||
757: !proc_create_net_data_write("sysname", 0644, p,
758: &afs_proc_sysname_ops,
759: afs_proc_sysname_write,
760: sizeof(struct seq_net_private),
761: NULL) ||
762: !proc_create_net_single_write("addr_prefs", 0644, p,
763: afs_proc_addr_prefs_show,
764: afs_proc_addr_prefs_write,
765: NULL))
766: goto error_tree;
767:
768: net->proc_afs = p;
769: _leave(" = 0");
770: return 0;
771:
772: error_tree:
773: proc_remove(p);
774: error_dir:
775: _leave(" = -ENOMEM");
776: return -ENOMEM;
777: }
SourceFile:fs/afs/proc.c]
|
| 122/2 |
2026/05/12 23:59 |
llm |
expert |
0m
Model:
Tokens:
input: 113466
output: 41
thoughts: 305
Thoughts: **A Potential Denial of Service Vulnerability in the AFS Filesystem Module**
Okay, so I'm looking at this `/proc/net/afs/cells` file and it's created with a `0644` permission, which is pretty standard. Anyone can read it, but only root can write to it. That seems⦠fine at first glance. But hang on, the code that creates it is `proc_create_net_data_write`, and that puts it in `net->net->proc_net`. Now things get interesting. An unprivileged user can create a new network namespace, and within that namespace, they *are* root. Suddenly, the write permissions become relevant.
So if an unprivileged user writes to `/proc/net/afs/cells` in their *own* network namespace, they'll trigger `afs_proc_cells_write`. This calls `afs_lookup_cell`, which calls `afs_alloc_cell`. Here's where it could get ugly. If that user can somehow trigger an Out-of-Memory (OOM) condition, `idr_alloc_cyclic` fails, and we leak `net->cells_outstanding`. Then, when they exit and the network namespace is destroyed, `cleanup_net` is called, and this hangs!
The kicker? `cleanup_net` is a *global* workqueue. If *that* hangs, it prevents *any* network namespace from being cleaned up. That's a system-wide Denial of Service! An unprivileged user can potentially bring the whole system down.
But I need to confirm this. Does `afs_proc_init` run in every network namespace? Ah, yes, `afs_net_init` is called for every new network namespace, because `afs_net_ops` is registered with `register_pernet_site`. Bingo! This is definitely worth looking into further.
|
| 123/2 |
2026/05/12 23:59 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/afs/main.c IncludeLines:true Name:afs_net_ops]
Results: map[SourceCode: 156: static struct pernet_operations afs_net_ops = {
157: .init = afs_net_init,
158: .exit = afs_net_exit,
159: .id = &afs_net_id,
160: .size = sizeof(struct afs_net),
161: };
SourceFile:fs/afs/main.c]
|
| 124/2 |
2026/05/12 23:59 |
llm |
expert |
0m
Model:
Tokens:
input: 114348
output: 66
thoughts: 2308
Thoughts: **AFS Cell Counter Leak - A System-Wide DoS Vulnerability**
Okay, so here's what I've figured out. `afs_net_init` gets called for every network namespace, that's crucial. An unprivileged user can leverage this. They can create a network namespace, write to `/proc/net/afs/cells` β that's the trigger β and then exit. That's the core of the problem. This action hangs `cleanup_net`, leading to a system-wide denial of service. The call trace in the bug report nails it: it's exactly what I'd expect given the analysis.
Now, I had to double-check that `idr_alloc_cyclic` failure is the *only* way the leak happens. Does it leak if `afs_alloc_cell` itself fails *before* `idr_alloc_cyclic`? I checked the code. The `kzalloc` might fail, but it doesn't cause a leak. The leak specifically hinges on `idr_alloc_cyclic` failing *after* the `atomic_inc`. No other possible places.
So, is there another way to trigger the `idr_alloc_cyclic` failure? I thought of memory exhaustion. If the user allocates enough cells, `idr_alloc_cyclic` can return `-ENOSPC`. But that needs a lot of memory. Then I thought about fault injection, which could make it easier. And, if the user puts themselves in a memory cgroup with a low limit, they might be able to create severe memory pressure. So the `kzalloc` might succeed, but the radix tree allocation within `idr_alloc_cyclic` might fail, leading to the leak.
The bug, fundamentally, is this: In `afs_alloc_cell`, the `net->cells_outstanding` counter is incremented *before* the `idr_alloc_cyclic` call. If `idr_alloc_cyclic` fails, the code jumps to the error path and returns, but *doesn't* decrement the counter. This leaks the `net->cells_outstanding` counter. When the network namespace is destroyed, `afs_cell_purge` waits for this leaked counter to become zero, but it never does. So, it hangs. Because `afs_cell_purge` is part of `cleanup_net` and the single threaded `netns_wq`, any hang here blocks all other network namespace cleanups. Bang, system DoS.
This can be exploited by an unprivileged user by creating a network namespace and memory pressure and writing to `/proc/net/afs/cells` to trigger the `afs_alloc_cell` function call and cell allocation.
Next, I looked for other potential leaks. What if `afs_alloc_cell` succeeds, but `afs_lookup_cell` fails later? I traced that path. The code in `afs_lookup_cell` *does* call `afs_put_cell` if the cell already exists and the refcount is decremented and destroyed by `afs_cell_destroy`, and then `afs_dec_cells_outstanding` is called. So, the counter gets decremented in that case. No leak there.
Therefore, the only leak is the error case in `afs_alloc_cell`.
So, the impact is: it's not an exploit for privilege escalation, it's a denial of service β a hang. It's accessible to unprivileged users through user namespaces and memory pressure. Not specific to VM guests, doesn't need a network trigger. It can be triggered via `/proc/net/afs/cells` without mounting.
Then, I looked at the reproducer β it uses `syz_mount_image` with the `dyn` option. If you mount AFS with `dyn`, every lookup in the root directory creates a cell. It looks up `"cpuacct.usage_user"`, that does the cell creation and triggers the problem. It uses `inject_fault(10)` β to fail the 10th allocation. This perfectly makes sense because it will likely fail at the `idr_alloc_cyclic` call!
Now, can unprivileged users mount AFS? I checked; `afs_fs_type` doesn't have `FS_USERNS_MOUNT`. No, they *cannot* mount AFS. But they *can* write to `/proc/net/afs/cells`! Because `/proc/net/afs/cells` is in `net->proc_net`. This is owned by the user namespace that created the network namespace. So, if an unprivileged user creates a user namespace and then a network namespace, they're root inside that user namespace. They can write. I verified this. `proc_create_net_data
|
| 125/2 |
2026/05/12 23:59 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 126/2 |
2026/05/12 23:59 |
llm |
expert |
0m
Model:
Tokens:
input: 117811
output: 823
thoughts: 394
Thoughts: **My Analysis of the AFS Cell Counter Leak**
Alright, the data's in, time to synthesize this into a clear response. This is a classic counter leak scenario, and it's a denial-of-service, plain and simple.
So, here's what's happening. We've got a bug in `afs_alloc_cell` within the AFS filesystem code, specifically in `fs/afs/cell.c`. When a new AFS cell is created, they're incrementing `net->cells_outstanding` *before* allocating an ID using `idr_alloc_cyclic`. The crucial bit is, if `idr_alloc_cyclic` fails β let's say due to a memory allocation issue (`GFP_KERNEL` failures are always fun in kernel land) β the code jumps to the `error` label, frees the cell, but completely forgets to *decrement* that `net->cells_outstanding` counter. This is the root of the problem.
Now, fast forward to network namespace destruction. When a network namespace is being torn down, `afs_net_exit` gets called, and it calls `afs_cell_purge`. This function essentially waits for `net->cells_outstanding` to hit zero. It's using `wait_var_event` to block until that happens:
```c
wait_var_event(&net->cells_outstanding,
!atomic_read(&net->cells_outstanding));
```
Because of the leak, this counter is *never* going to reach zero if `idr_alloc_cyclic` fails. That means `afs_cell_purge` hangs indefinitely. And since network namespace cleanup is handled serially through that global workqueue `netns_wq`, any hang blocks all subsequent namespace cleanup. The system just grinds to a halt.
What's really insidious is that an *unprivileged* user can trigger this. They just need to create a new user namespace, create a network namespace within it, and write to `/proc/net/afs/cells`. This triggers `afs_alloc_cell`, which is the entry point to our vulnerability. By carefully crafting memory conditions, like placing the namespace in a memory cgroup with a tight limit, or using memory pressure techniques, they can force `idr_alloc_cyclic` to fail. Boom. The counter leaks, and the system is eventually DoS'd on namespace cleanup.
It's important to note that this isn't exploitable for privilege escalation or memory corruption. Itβs just a DoS. A clever bug, no doubt, but ultimately just a nuisance.
|
| 127/1 |
2026/05/12 23:59 |
action |
format-explanation |
0m
Results: map[Explanation:**Analysis of the Bug**
The bug is a counter leak in the AFS (Andrew File System) client code,
specifically in `afs_alloc_cell()` located in `fs/afs/cell.c`.
When a new AFS cell is allocated, the function increments the
`net->cells_outstanding` counter before attempting to allocate an ID for the
cell using `idr_alloc_cyclic()`:
```c
atomic_inc(&net->cells_outstanding);
ret = idr_alloc_cyclic(&net->cells_dyn_ino, cell,
2, INT_MAX / 2, GFP_KERNEL);
if (ret < 0)
goto error;
```
If `idr_alloc_cyclic()` fails (for example, due to memory pressure returning
`-ENOMEM`), the code jumps to the `error` label where it frees the partially
constructed cell and returns an error. However, it fails to decrement the
`net->cells_outstanding` counter, permanently leaking the reference.
When a network namespace is destroyed, `cleanup_net()` is executed on the global
`netns_wq` workqueue. This calls `afs_net_exit()`, which in turn calls
`afs_cell_purge()`. `afs_cell_purge()` waits for all outstanding cells to be
destroyed by waiting for `net->cells_outstanding` to reach 0:
```c
wait_var_event(&net->cells_outstanding,
!atomic_read(&net->cells_outstanding));
```
Because of the leaked counter, this condition will never be met, causing
`afs_cell_purge()` to hang indefinitely. Since `cleanup_net()` processes all
network namespace cleanups sequentially on a single-threaded workqueue, this
hang completely blocks the destruction of any other network namespaces on the
system, resulting in a system-wide Denial of Service (DoS) and resource
exhaustion.
**Triggering the Bug**
An unprivileged user can trigger this bug by creating a new user namespace and a
corresponding network namespace. Within their own network namespace, they gain
root privileges, which grants them write access to `/proc/net/afs/cells`.
By writing to this proc file (e.g., `echo "add mycell 1.2.3.4" >
/proc/net/afs/cells`), the user can trigger `afs_lookup_cell()` and subsequently
`afs_alloc_cell()`. By constraining their process using a memory cgroup with a
low limit or by generating severe memory pressure, they can force the
`idr_alloc_cyclic()` call (which uses `GFP_KERNEL`) to fail. Once the leak
occurs, the user simply exits the namespace, triggering the cleanup routine and
hanging the `netns_wq` workqueue.
The provided syzkaller reproducer triggers this via a different path: it mounts
an AFS filesystem with the `dyn` (dynamic root) option and performs a lookup for
a non-existent file (`"cpuacct.usage_user"`). In a dynamic root, lookups
automatically attempt to create a cell with the given name. The reproducer uses
fault injection (`inject_fault(10)`) to artificially fail the
`idr_alloc_cyclic()` allocation, achieving the exact same leak.
**Security Impact**
- **Exploitable:** No. This is a pure logic bug (counter leak) leading to a
hang. It does not cause memory corruption, use-after-free, or out-of-bounds
accesses, so it cannot be exploited for privilege escalation.
- **Denial of Service:** Yes. It permanently hangs the global network namespace
cleanup workqueue.
- **Accessible From Unprivileged Processes / User Namespaces:** Yes.
Unprivileged users can create user/network namespaces and interact with
`/proc/net/afs/cells` to trigger the bug.]
|