| 0/0 |
2026/06/28 00:02 |
flow |
assessment-security |
33m
Results: map[DenialOfService:true Explanation:Based on the analysis of the bug report and the kernel source code, here is the
assessment of the vulnerability:
**Vulnerability Details:**
The bug is a NULL pointer dereference in `slot_get()` within the `gfs2`
filesystem code.
During the unmounting of a `gfs2` filesystem, `gfs2_put_super()` is called. This
function first cleans up the quota subsystem by calling
`gfs2_quota_cleanup(sdp)`, which frees `sdp->sd_quota_bitmap` and explicitly
sets it to `NULL`.
Later in the same function, `iput(sdp->sd_statfs_inode)` is called to release
the system `statfs` inode. If a maliciously crafted filesystem image is mounted
where this system inode has a link count of 0 (`i_nlink == 0`), the `iput()`
call will trigger the inode eviction path. The eviction process
(`gfs2_evict_inode` -> `evict_unlinked_inode` -> `gfs2_dinode_dealloc` ->
`gfs2_quota_hold` -> `qdsb_get` -> `slot_get`) attempts to acquire a quota slot
and accesses `sdp->sd_quota_bitmap`. Since the bitmap was already freed and set
to `NULL`, this results in a general protection fault (NULL pointer
dereference).
**Exploitability:**
The bug is a pure NULL pointer dereference (as indicated by the KASAN report
showing a fault on the shadow address `0xdffffc0000000000` corresponding to
`0x0000000000000000`). On modern systems with `mmap_min_addr` protections, NULL
pointer dereferences cannot be mapped by user-space and are therefore not
exploitable for memory corruption or privilege escalation. It strictly results
in a kernel panic.
**Accessibility:**
The `gfs2` filesystem does not have the `FS_USERNS_MOUNT` flag set, meaning it
cannot be mounted inside unprivileged user namespaces. Mounting a `gfs2` image
requires `CAP_SYS_ADMIN` in the initial (root) namespace. Therefore, the bug
cannot be triggered by an unprivileged local attacker.
**Trigger Vectors:**
The bug is triggered by mounting and subsequently unmounting (or failing to
mount) a maliciously crafted `gfs2` filesystem image. This classifies it as a
**Malicious Filesystem Trigger**. Consequently, it can also act as a
**Peripheral Trigger** in environments (like certain Desktop setups) where
external media (e.g., USB drives) are automatically mounted upon insertion. Exploitable:false FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/06/28 00:02 |
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 <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;
//% 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;
}
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*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=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_mount_image$gfs2 arguments: [
// fs: ptr[in, buffer] {
// buffer: {67 66 73 32 00} (length 0x5)
// }
// dir: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 00} (length 0xfa)
// }
// flags: mount_flags = 0x1010084 (8 bytes)
// opts: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {73 75 69 64 64 69 72 2c 6d 65 74 61 2c 64 69 73 63 61 72 64 2c 6e 6f 6c 6f 63 63 6f 6f 6b 69 65 2c 6e 6f 64 69 73 63 61 72 64 2c 71 75 6f 74 61 3d 61 63 63 6f 75 6e 74 2c 00 35 60 96 c0 35 a3 b7 05 b3 a4 a9 46 3d 3e e3 98 71 dd b7 00 35 7d 42 3e 7b 19 33 37 79 ae d9 03 38 c8 c1 bc 2c 08 96 88 cf 78 10 98 f8 55 69 ee 00 6e 49 eb ed 67 85 8f ae 45 1e 0d b0 08 1d 3e 13 3a 37 b1 ed 1d 97 67 0a 40 91 3e b9 94 e5 b6 03 75 c1 d8 2a f9 30 42 1f ae b3 eb 45 db 0b e0 64 4e 6f 5f a8 d2 76 22 b7 c8 c7 f6 69 ab b3 a0 a1 37 85 4b 69 c3 cb 3f 7c de fe a0 98 37 30 9b} (length 0xba)
// }
// }
// }
// chdir: int8 = 0x9 (1 bytes)
// size: len = 0x37f58 (8 bytes)
// img: ptr[in, buffer] {
// buffer: (compressed buffer with length 0x37f58)
// }
// ]
// returns fd_dir
memcpy((void*)0x200000037f40, "gfs2\000", 5);
memcpy((void*)0x2000000008c0, "... [truncated large byte array] ...", 250);
memcpy((void*)0x200000000480, "... [truncated large byte array] ...", 186);
memcpy((void*)0x20000006ff40, "... [truncated large byte array] ...", 229208);
syz_mount_image(/*fs=*/0x200000037f40, /*dir=*/0x2000000008c0, /*flags=MS_POSIXACL|MS_STRICTATIME|MS_NODEV|MS_DIRSYNC*/0x1010084, /*opts=*/0x200000000480, /*chdir=*/9, /*size=*/0x37f58, /*img=*/0x20000006ff40);
// mkdir arguments: [
// path: ptr[in, buffer] {
// buffer: {2e 2f 62 75 73 00} (length 0x6)
// }
// mode: open_mode = 0x0 (8 bytes)
// ]
memcpy((void*)0x2000000000c0, "./bus\000", 6);
syscall(__NR_mkdir, /*path=*/0x2000000000c0ul, /*mode=*/0ul);
// chdir arguments: [
// dir: ptr[in, buffer] {
// buffer: {2e 2f 62 75 73 00} (length 0x6)
// }
// ]
memcpy((void*)0x2000000003c0, "./bus\000", 6);
syscall(__NR_chdir, /*dir=*/0x2000000003c0ul);
// mkdirat arguments: [
// fd: fd_dir (resource)
// path: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8)
// }
// mode: open_mode = 0xe (8 bytes)
// ]
memcpy((void*)0x200000000180, "./file0\000", 8);
syscall(__NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x200000000180ul, /*mode=S_IWOTH|S_IROTH|S_IXGRP*/0xeul);
// mount$bind arguments: [
// src: ptr[in, buffer] {
// buffer: {2e 00} (length 0x2)
// }
// dst: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 2f 2e 2e 2f 66 69 6c 65 30 00} (length 0x11)
// }
// type: nil
// flags: mount_flags = 0x2151090 (8 bytes)
// data: const = 0x0 (8 bytes)
// ]
memcpy((void*)0x200000000100, ".\000", 2);
memcpy((void*)0x200000000300, "./file0/../file0\000", 17);
syscall(__NR_mount, /*src=*/0x200000000100ul, /*dst=*/0x200000000300ul, /*type=*/0ul, /*flags=MS_LAZYTIME|MS_SHARED|MS_PRIVATE|MS_POSIXACL|MS_SYNCHRONOUS|MS_DIRSYNC|0x1000*/0x2151090ul, /*data=*/0ul);
// mount$bind arguments: [
// src: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8)
// }
// dst: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 2f 66 69 6c 65 30 00} (length 0xe)
// }
// type: nil
// flags: mount_flags = 0x8b101a (8 bytes)
// data: const = 0x0 (8 bytes)
// ]
memcpy((void*)0x200000000040, "./file0\000", 8);
memcpy((void*)0x2000000000c0, "./file0/file0\000", 14);
syscall(__NR_mount, /*src=*/0x200000000040ul, /*dst=*/0x2000000000c0ul, /*type=*/0ul, /*flags=MS_I_VERSION|MS_SLAVE|MS_UNBINDABLE|MS_POSIXACL|MS_SYNCHRONOUS|MS_NOSUID|0x1008*/0x8b101aul, /*data=*/0ul);
return 0;
}
]
|
| 2/1 |
2026/06/28 00:02 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/47e5c938e968c987cd59d18f641da806b1465993]
|
| 3/1 |
2026/06/28 00:03 |
action |
kernel-builder |
17m
Results: map[KernelObj:/app/workdir/cache/build/84bbcf89a2757baf8e4f24712a6d6d688d84f1c0]
|
| 4/1 |
2026/06/28 00:20 |
action |
codesearch-prepare |
12m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/06/28 00:33 |
agent |
expert |
2m
Model:
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Instruction: You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption, elevated privileges, or an information leak.
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 completely 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 transfers, that 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 exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Information leaks are exploitable on their own and should be classified as such. A bug that copies kernel
memory contents to userspace (e.g. an out-of-bounds read whose result is returned to the caller, or
uninitialized stack/heap bytes written to a user buffer) is exploitable: it can reveal kernel pointer
values and defeat KASLR, expose sensitive data such as cryptographic keys or other processes' memory, and
serves as a necessary building block in most modern kernel privilege-escalation exploit chains. Do not classify
an information leak as non-exploitable solely because it does not directly cause a memory write or control-flow
hijack; the leak itself is the exploit primitive.
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 Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
CPU: 0 UID: 0 PID: 5755 Comm: syz-executor Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/09/2026
RIP: 0010:_find_first_zero_bit+0x29/0xb0 lib/find_bit.c:149
Code: 90 f3 0f 1e fa 41 57 41 56 41 55 41 54 53 48 85 f6 74 46 48 89 f3 49 89 fe 49 bf 00 00 00 00 00 fc ff df 48 89 f8 48 c1 e8 03 <42> 80 3c 38 00 74 08 4c 89 f7 e8 b8 55 7c fd 49 8b 06 48 83 f8 ff
RSP: 0018:ffffc9000365f6c0 EFLAGS: 00010256
RAX: 0000000000000000 RBX: 000000000000f800 RCX: 0000000000000000
RDX: ffff888034374c40 RSI: 000000000000f800 RDI: 0000000000000000
RBP: dffffc0000000000 R08: 0000000000000003 R09: 0000000000000004
R10: dffffc0000000000 R11: fffff520006cbecc R12: ffff888058d1d3f0
R13: ffff888034374c38 R14: 0000000000000000 R15: dffffc0000000000
FS: 0000000000000000(0000) GS:ffff888125223000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f8b8a06ea00 CR3: 000000000e746000 CR4: 0000000000350ef0
Call Trace:
<TASK>
find_first_zero_bit include/linux/find.h:391 [inline]
slot_get fs/gfs2/quota.c:355 [inline]
qdsb_get+0x133/0x340 fs/gfs2/quota.c:522
gfs2_quota_hold+0x191/0x5c0 fs/gfs2/quota.c:606
gfs2_dinode_dealloc+0x176/0x3f0 fs/gfs2/inode.c:488
evict_unlinked_inode fs/gfs2/super.c:1329 [inline]
gfs2_evict_inode+0x11cd/0x1400 fs/gfs2/super.c:1479
evict+0x624/0xb50 fs/inode.c:825
gfs2_put_super+0x300/0x860 fs/gfs2/super.c:618
generic_shutdown_super+0x13d/0x2d0 fs/super.c:647
kill_block_super+0x44/0x90 fs/super.c:1665
deactivate_locked_super+0xbc/0x130 fs/super.c:477
cleanup_mnt+0x3d3/0x460 fs/namespace.c:1317
task_work_run+0x1d9/0x270 kernel/task_work.c:233
exit_task_work include/linux/task_work.h:40 [inline]
do_exit+0x73a/0x2360 kernel/exit.c:1004
do_group_exit+0x22d/0x2f0 kernel/exit.c:1147
__do_sys_exit_group kernel/exit.c:1158 [inline]
__se_sys_exit_group kernel/exit.c:1156 [inline]
__x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1156
x64_sys_call+0x221a/0x2240 arch/x86/include/generated/asm/syscalls_64.h:232
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x174/0x580 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f8b89f9ce59
Code: Unable to access opcode bytes at 0x7f8b89f9ce2f.
RSP: 002b:00007ffc5b7df378 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007f8b8a03233c RCX: 00007f8b89f9ce59
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000001
RBP: 0000000000000016 R08: 0000000000000000 R09: 00007f8b8a0322ca
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffc5b7e0630
R13: 00007f8b8a0322ca R14: 0000555582f544e8 R15: 00007ffc5b7e49d0
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:_find_first_zero_bit+0x29/0xb0 lib/find_bit.c:149
Code: 90 f3 0f 1e fa 41 57 41 56 41 55 41 54 53 48 85 f6 74 46 48 89 f3 49 89 fe 49 bf 00 00 00 00 00 fc ff df 48 89 f8 48 c1 e8 03 <42> 80 3c 38 00 74 08 4c 89 f7 e8 b8 55 7c fd 49 8b 06 48 83 f8 ff
RSP: 0018:ffffc9000365f6c0 EFLAGS: 00010256
RAX: 0000000000000000 RBX: 000000000000f800 RCX: 0000000000000000
RDX: ffff888034374c40 RSI: 000000000000f800 RDI: 0000000000000000
RBP: dffffc0000000000 R08: 0000000000000003 R09: 0000000000000004
R10: dffffc0000000000 R11: fffff520006cbecc R12: ffff888058d1d3f0
R13: ffff888034374c38 R14: 0000000000000000 R15: dffffc0000000000
FS: 0000000000000000(0000) GS:ffff888125223000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f8b8a06ea00 CR3: 000000000e746000 CR4: 0000000000350ef0
----------------
Code disassembly (best guess):
0: 90 nop
1: f3 0f 1e fa endbr64
5: 41 57 push %r15
7: 41 56 push %r14
9: 41 55 push %r13
b: 41 54 push %r12
d: 53 push %rbx
e: 48 85 f6 test %rsi,%rsi
11: 74 46 je 0x59
13: 48 89 f3 mov %rsi,%rbx
16: 49 89 fe mov %rdi,%r14
19: 49 bf 00 00 00 00 00 movabs $0xdffffc0000000000,%r15
20: fc ff df
23: 48 89 f8 mov %rdi,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 80 3c 38 00 cmpb $0x0,(%rax,%r15,1) <-- trapping instruction
2f: 74 08 je 0x39
31: 4c 89 f7 mov %r14,%rdi
34: e8 b8 55 7c fd call 0xfd7c55f1
39: 49 8b 06 mov (%r14),%rax
3c: 48 83 f8 ff cmp $0xffffffffffffffff,%rax
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 <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;
//% 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;
}
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*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=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_mount_image$gfs2 arguments: [
// fs: ptr[in, buffer] {
// buffer: {67 66 73 32 00} (length 0x5)
// }
// dir: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 00} (length 0xfa)
// }
// flags: mount_flags = 0x1010084 (8 bytes)
// opts: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {73 75 69 64 64 69 72 2c 6d 65 74 61 2c 64 69 73 63 61 72 64 2c 6e 6f 6c 6f 63 63 6f 6f 6b 69 65 2c 6e 6f 64 69 73 63 61 72 64 2c 71 75 6f 74 61 3d 61 63 63 6f 75 6e 74 2c 00 35 60 96 c0 35 a3 b7 05 b3 a4 a9 46 3d 3e e3 98 71 dd b7 00 35 7d 42 3e 7b 19 33 37 79 ae d9 03 38 c8 c1 bc 2c 08 96 88 cf 78 10 98 f8 55 69 ee 00 6e 49 eb ed 67 85 8f ae 45 1e 0d b0 08 1d 3e 13 3a 37 b1 ed 1d 97 67 0a 40 91 3e b9 94 e5 b6 03 75 c1 d8 2a f9 30 42 1f ae b3 eb 45 db 0b e0 64 4e 6f 5f a8 d2 76 22 b7 c8 c7 f6 69 ab b3 a0 a1 37 85 4b 69 c3 cb 3f 7c de fe a0 98 37 30 9b} (length 0xba)
// }
// }
// }
// chdir: int8 = 0x9 (1 bytes)
// size: len = 0x37f58 (8 bytes)
// img: ptr[in, buffer] {
// buffer: (compressed buffer with length 0x37f58)
// }
// ]
// returns fd_dir
memcpy((void*)0x200000037f40, "gfs2\000", 5);
memcpy((void*)0x2000000008c0, "... [truncated large byte array] ...", 250);
memcpy((void*)0x200000000480, "... [truncated large byte array] ...", 186);
memcpy((void*)0x20000006ff40, "... [truncated large byte array] ...", 229208);
syz_mount_image(/*fs=*/0x200000037f40, /*dir=*/0x2000000008c0, /*flags=MS_POSIXACL|MS_STRICTATIME|MS_NODEV|MS_DIRSYNC*/0x1010084, /*opts=*/0x200000000480, /*chdir=*/9, /*size=*/0x37f58, /*img=*/0x20000006ff40);
// mkdir arguments: [
// path: ptr[in, buffer] {
// buffer: {2e 2f 62 75 73 00} (length 0x6)
// }
// mode: open_mode = 0x0 (8 bytes)
// ]
memcpy((void*)0x2000000000c0, "./bus\000", 6);
syscall(__NR_mkdir, /*path=*/0x2000000000c0ul, /*mode=*/0ul);
// chdir arguments: [
// dir: ptr[in, buffer] {
// buffer: {2e 2f 62 75 73 00} (length 0x6)
// }
// ]
memcpy((void*)0x2000000003c0, "./bus\000", 6);
syscall(__NR_chdir, /*dir=*/0x2000000003c0ul);
// mkdirat arguments: [
// fd: fd_dir (resource)
// path: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8)
// }
// mode: open_mode = 0xe (8 bytes)
// ]
memcpy((void*)0x200000000180, "./file0\000", 8);
syscall(__NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x200000000180ul, /*mode=S_IWOTH|S_IROTH|S_IXGRP*/0xeul);
// mount$bind arguments: [
// src: ptr[in, buffer] {
// buffer: {2e 00} (length 0x2)
// }
// dst: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 2f 2e 2e 2f 66 69 6c 65 30 00} (length 0x11)
// }
// type: nil
// flags: mount_flags = 0x2151090 (8 bytes)
// data: const = 0x0 (8 bytes)
// ]
memcpy((void*)0x200000000100, ".\000", 2);
memcpy((void*)0x200000000300, "./file0/../file0\000", 17);
syscall(__NR_mount, /*src=*/0x200000000100ul, /*dst=*/0x200000000300ul, /*type=*/0ul, /*flags=MS_LAZYTIME|MS_SHARED|MS_PRIVATE|MS_POSIXACL|MS_SYNCHRONOUS|MS_DIRSYNC|0x1000*/0x2151090ul, /*data=*/0ul);
// mount$bind arguments: [
// src: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8)
// }
// dst: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 2f 66 69 6c 65 30 00} (length 0xe)
// }
// type: nil
// flags: mount_flags = 0x8b101a (8 bytes)
// data: const = 0x0 (8 bytes)
// ]
memcpy((void*)0x200000000040, "./file0\000", 8);
memcpy((void*)0x2000000000c0, "./file0/file0\000", 14);
syscall(__NR_mount, /*src=*/0x200000000040ul, /*dst=*/0x2000000000c0ul, /*type=*/0ul, /*flags=MS_I_VERSION|MS_SLAVE|MS_UNBINDABLE|MS_POSIXACL|MS_SYNCHRONOUS|MS_NOSUID|0x1008*/0x8b101aul, /*data=*/0ul);
return 0;
}
Reply: Based on the analysis of the bug report and the kernel source code, here is the assessment of the vulnerability:
**Vulnerability Details:**
The bug is a NULL pointer dereference in `slot_get()` within the `gfs2` filesystem code.
During the unmounting of a `gfs2` filesystem, `gfs2_put_super()` is called. This function first cleans up the quota subsystem by calling `gfs2_quota_cleanup(sdp)`, which frees `sdp->sd_quota_bitmap` and explicitly sets it to `NULL`.
Later in the same function, `iput(sdp->sd_statfs_inode)` is called to release the system `statfs` inode. If a maliciously crafted filesystem image is mounted where this system inode has a link count of 0 (`i_nlink == 0`), the `iput()` call will trigger the inode eviction path. The eviction process (`gfs2_evict_inode` -> `evict_unlinked_inode` -> `gfs2_dinode_dealloc` -> `gfs2_quota_hold` -> `qdsb_get` -> `slot_get`) attempts to acquire a quota slot and accesses `sdp->sd_quota_bitmap`. Since the bitmap was already freed and set to `NULL`, this results in a general protection fault (NULL pointer dereference).
**Exploitability:**
The bug is a pure NULL pointer dereference (as indicated by the KASAN report showing a fault on the shadow address `0xdffffc0000000000` corresponding to `0x0000000000000000`). On modern systems with `mmap_min_addr` protections, NULL pointer dereferences cannot be mapped by user-space and are therefore not exploitable for memory corruption or privilege escalation. It strictly results in a kernel panic.
**Accessibility:**
The `gfs2` filesystem does not have the `FS_USERNS_MOUNT` flag set, meaning it cannot be mounted inside unprivileged user namespaces. Mounting a `gfs2` image requires `CAP_SYS_ADMIN` in the initial (root) namespace. Therefore, the bug cannot be triggered by an unprivileged local attacker.
**Trigger Vectors:**
The bug is triggered by mounting and subsequently unmounting (or failing to mount) a maliciously crafted `gfs2` filesystem image. This classifies it as a **Malicious Filesystem Trigger**. Consequently, it can also act as a **Peripheral Trigger** in environments (like certain Desktop setups) where external media (e.g., USB drives) are automatically mounted upon insertion.
|
| 6/2 |
2026/06/28 00:33 |
llm |
expert |
0m
Model:
Tokens:
input: 17647
output: 37
thoughts: 554
Thoughts: **Analyzing a Kernel Panic: A Deep Dive into a GFS2 Bug**
Okay, so I've got a kernel bug report here. It's an "Oops: general protection fault" and it looks like a null-pointer dereference triggered by a malicious GFS2 filesystem. The RIP points to `_find_first_zero_bit` in `lib/find_bit.c`, which is being called from `fs/gfs2/quota.c`. The KASAN output confirms the null pointer dereference, which is always fun. The call trace clearly shows the path: from quota operations to inode deallocation, ultimately leading to the superblock shutdown.
My immediate thought is, this is a filesystem bug, and a pretty nasty one at that. A malicious filesystem image is causing a kernel panic, likely due to a race condition or a flaw in how the quota structures are handled during inode deallocation and superblock shutdown. My focus is going to be on `fs/gfs2/quota.c` and `fs/gfs2/inode.c`, specifically around the `slot_get`, `qdsb_get`, `gfs2_quota_hold`, `gfs2_dinode_dealloc` and `gfs2_evict_inode` functions. I'll need to meticulously step through the code, looking for where a null pointer might be introduced, especially during those quota lookups and inode operations. I need to understand what's happening when the filesystem is being unmounted, as that's where the problem seems to be occurring, based on the `gfs2_put_super`, `generic_shutdown_super` and `kill_block_super` in the call trace. The `find_first_zero_bit` function is a classic trap for uninitialized or invalid bitmasks, so I'll be scrutinizing how those bitmasks are constructed and used within the quota structures.
|
| 7/2 |
2026/06/28 00:33 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/quota.c Name:qdsb_get]
Results: map[SourceCode: 513: static int qdsb_get(struct gfs2_sbd *sdp, struct kqid qid,
514: struct gfs2_quota_data **qdp)
515: {
516: int error;
517:
518: error = qd_get(sdp, qid, qdp);
519: if (error)
520: return error;
521:
522: error = slot_get(*qdp);
523: if (error)
524: goto fail;
525:
526: error = bh_get(*qdp);
527: if (error)
528: goto fail_slot;
529:
530: return 0;
531:
532: fail_slot:
533: slot_put(*qdp);
534: fail:
535: qd_put(*qdp);
536: return error;
537: }
SourceFile:fs/gfs2/quota.c]
|
| 8/2 |
2026/06/28 00:33 |
llm |
expert |
0m
Model:
Tokens:
input: 18977
output: 36
thoughts: 9
Thoughts: Okay, here's my interpretation of "Let's see `slot_get`" as a thought process, tailored for an expert audience and presented in the first person:
**Analyzing the Query: "Let's See `slot_get`"**
Right, so that's the prompt. "Let's see `slot_get`." Hmm, okay. My mind immediately jumps to `slot_get`. Itβs a pretty direct request. I need to figure out what context I'm operating within to fully understand what's being asked. This `slot_get`... are we talking about a specific system? A framework? Perhaps a particular data structure? The term itself is rather broad, but the implied imperative suggests a desire for *examination* or *demonstration* of this function or method. I'm assuming the person who entered this is an expert and likely wants me to provide an insightful overview rather than a basic explanation. I need to consider what information about `slot_get` is most relevant based on the likely user's level of expertise and the context they are most interested in. My primary instinct is to consider a few common examples and approaches. This could be anything from a database framework, a python package, an embedded system, even an NLP task. This is the place to start, so let's prepare to give them what they need and deliver a focused answer!
|
| 9/2 |
2026/06/28 00:33 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/quota.c Name:slot_get]
Results: map[SourceCode: 347: static int slot_get(struct gfs2_quota_data *qd)
348: {
349: struct gfs2_sbd *sdp = qd->qd_sbd;
350: unsigned int bit;
351: int error = 0;
352:
353: spin_lock(&sdp->sd_bitmap_lock);
354: if (qd->qd_slot_ref == 0) {
355: bit = find_first_zero_bit(sdp->sd_quota_bitmap,
356: sdp->sd_quota_slots);
357: if (bit >= sdp->sd_quota_slots) {
358: error = -ENOSPC;
359: goto out;
360: }
361: set_bit(bit, sdp->sd_quota_bitmap);
362: qd->qd_slot = bit;
363: }
364: qd->qd_slot_ref++;
365: out:
366: spin_unlock(&sdp->sd_bitmap_lock);
367: return error;
368: }
SourceFile:fs/gfs2/quota.c]
|
| 10/2 |
2026/06/28 00:33 |
llm |
expert |
0m
Model:
Tokens:
input: 19679
output: 57
thoughts: 24
Thoughts: Here's my thought process, as it is:
**Debugging a Null Pointer Exception**
Okay, so `sdp->sd_quota_bitmap` is showing up as NULL. That's a classic sign of a potential issue with quota management. My immediate instinct is to trace back the initialization of that specific structure member. I need to figure out where the `sd_quota_bitmap` is supposed to be allocated and populated within the broader system. I'll start by searching the codebase for assignments to this specific field, or anything that could be related to bitmap setup. This will likely involve cross-referencing with quota setup code. Time to dig in and follow the breadcrumbs!
|
| 11/2 |
2026/06/28 00:33 |
tool |
codesearch-find-references |
0m
Error:
Args: map[ContextFile:fs/gfs2/quota.c IncludeSnippetLines:2 Name:sd_quota_bitmap SourceTreePrefix:fs/gfs2/]
Results: map[References:<nil> TruncatedOutput:false]
|
| 12/2 |
2026/06/28 00:33 |
llm |
expert |
0m
Model:
Tokens:
input: 19924
output: 64
thoughts: 17
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and presented as if it were my own internal monologue:
**Diving into the GFS2 SBD Structure**
Right, so we're looking at something in `struct gfs2_sbd`. Okay, that tells me immediately we're deep within the heart of the GFS2 shared block device layer. That's good; it confirms my initial hunch that we're talking about something fundamental to cluster coordination. From my experience, anything tied directly to the `gfs2_sbd` is critical for things like quorum management, heartbeat, and likely lock table synchronization across the cluster. Now I need to figure out which *specific* field within that structure is the focus. Knowing that, and what the surrounding code context is, will guide my analysis.
|
| 13/2 |
2026/06/28 00:33 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/gfs2/quota.c IncludeSnippetLines:2 Name:gfs2_sbd::sd_quota_bitmap SourceTreePrefix:fs/gfs2/]
Results: map[References:[map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:gfs2_quota_cleanup SourceFile:fs/gfs2/quota.c SourceLine:1547 SourceSnippet:1545: fs_err(sdp, "%d left-over quota data objects\n", count);
1546:
1547: kvfree(sdp->sd_quota_bitmap);
1548: sdp->sd_quota_bitmap = NULL;
1549: }
] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:gfs2_quota_cleanup SourceFile:fs/gfs2/quota.c SourceLine:1548 SourceSnippet:1546:
1547: kvfree(sdp->sd_quota_bitmap);
1548: sdp->sd_quota_bitmap = NULL;
1549: }
] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:gfs2_quota_init SourceFile:fs/gfs2/quota.c SourceLine:1410 SourceSnippet:1408: bm_size *= sizeof(unsigned long);
1409: error = -ENOMEM;
1410: sdp->sd_quota_bitmap = kzalloc(bm_size, GFP_NOFS | __GFP_NOWARN);
1411: if (sdp->sd_quota_bitmap == NULL)
1412: sdp->sd_quota_bitmap = __vmalloc(bm_size, GFP_NOFS |
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:gfs2_quota_init SourceFile:fs/gfs2/quota.c SourceLine:1411 SourceSnippet:1409: error = -ENOMEM;
1410: sdp->sd_quota_bitmap = kzalloc(bm_size, GFP_NOFS | __GFP_NOWARN);
1411: if (sdp->sd_quota_bitmap == NULL)
1412: sdp->sd_quota_bitmap = __vmalloc(bm_size, GFP_NOFS |
1413: __GFP_ZERO);
] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:gfs2_quota_init SourceFile:fs/gfs2/quota.c SourceLine:1412 SourceSnippet:1410: sdp->sd_quota_bitmap = kzalloc(bm_size, GFP_NOFS | __GFP_NOWARN);
1411: if (sdp->sd_quota_bitmap == NULL)
1412: sdp->sd_quota_bitmap = __vmalloc(bm_size, GFP_NOFS |
1413: __GFP_ZERO);
1414: if (!sdp->sd_quota_bitmap)
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:gfs2_quota_init SourceFile:fs/gfs2/quota.c SourceLine:1414 SourceSnippet:1412: sdp->sd_quota_bitmap = __vmalloc(bm_size, GFP_NOFS |
1413: __GFP_ZERO);
1414: if (!sdp->sd_quota_bitmap)
1415: return error;
1416:
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:gfs2_quota_init SourceFile:fs/gfs2/quota.c SourceLine:1483 SourceSnippet:1481: continue;
1482: }
1483: BUG_ON(test_and_set_bit(slot, sdp->sd_quota_bitmap));
1484: list_add(&qd->qd_list, &sdp->sd_quota_list);
1485: atomic_inc(&sdp->sd_quota_count);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:slot_get SourceFile:fs/gfs2/quota.c SourceLine:355 SourceSnippet: 353: spin_lock(&sdp->sd_bitmap_lock);
354: if (qd->qd_slot_ref == 0) {
355: bit = find_first_zero_bit(sdp->sd_quota_bitmap,
356: sdp->sd_quota_slots);
357: if (bit >= sdp->sd_quota_slots) {
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:slot_get SourceFile:fs/gfs2/quota.c SourceLine:361 SourceSnippet: 359: goto out;
360: }
361: set_bit(bit, sdp->sd_quota_bitmap);
362: qd->qd_slot = bit;
363: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:slot_put SourceFile:fs/gfs2/quota.c SourceLine:387 SourceSnippet: 385: gfs2_assert(sdp, qd->qd_slot_ref);
386: if (!--qd->qd_slot_ref) {
387: BUG_ON(!test_and_clear_bit(qd->qd_slot, sdp->sd_quota_bitmap));
388: qd->qd_slot = -1;
389: }
]] TruncatedOutput:false]
|
| 14/2 |
2026/06/28 00:33 |
llm |
expert |
0m
Model:
Tokens:
input: 21694
output: 59
thoughts: 63
Thoughts: Okay, let's break this down.
**Investigating the Lifecycle of the Quota Bitmap**
Alright, my internal review has begun. I need to trace the allocation and deallocation of the `sdp->sd_quota_bitmap` in the GFS2 quota system. The text indicates that this structure, critical for quota management, is initialized within `gfs2_quota_init` and deallocated in `gfs2_quota_cleanup`. My next logical step is to pinpoint the exact calls to these two functions. I need to understand when, where, and under what conditions the quota bitmap is brought into existence and subsequently removed. This will provide a crucial understanding of resource management and potential leak points. I'll need to follow the execution paths to ensure this memory management is robust and well-defined.
|
| 15/2 |
2026/06/28 00:33 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/gfs2/quota.c IncludeSnippetLines:2 Name:gfs2_quota_init SourceTreePrefix:fs/gfs2/]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:gfs2_make_fs_rw SourceFile:fs/gfs2/super.c SourceLine:149 SourceSnippet: 147: }
148:
149: error = gfs2_quota_init(sdp);
150: if (!error && gfs2_withdrawn(sdp)) {
151: gfs2_quota_cleanup(sdp);
]] TruncatedOutput:false]
|
| 16/2 |
2026/06/28 00:33 |
llm |
expert |
0m
Model:
Tokens:
input: 22142
output: 59
thoughts: 37
Thoughts: Here's a summary of my mental process:
**Diving into GFS2 Quota Initialization and Cleanup**
Okay, so I'm tracing the quota initialization sequence within GFS2, and it looks like `gfs2_quota_init` is invoked during the `gfs2_make_fs_rw` operation. That makes sense; we want quota support ready to go as soon as the filesystem transitions to read/write mode. Now, I need to understand how the system manages the resources. Let's shift our focus and take a look at the cleanup routine, `gfs2_quota_cleanup`. Knowing how the system tears down quota facilities is essential for a complete understanding of the lifecycle. This should reveal how resources are released and any associated data structures are handled during shutdown or filesystem unmounting. Let's see what we can find in the cleanup function.
|
| 17/2 |
2026/06/28 00:33 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/gfs2/quota.c IncludeSnippetLines:2 Name:gfs2_quota_cleanup SourceTreePrefix:fs/gfs2/]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:gfs2_make_fs_ro SourceFile:fs/gfs2/super.c SourceLine:568 SourceSnippet: 566: gfs2_assert_warn(sdp, gfs2_log_is_empty(sdp));
567: }
568: gfs2_quota_cleanup(sdp);
569: }
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:gfs2_make_fs_rw SourceFile:fs/gfs2/super.c SourceLine:151 SourceSnippet: 149: error = gfs2_quota_init(sdp);
150: if (!error && gfs2_withdrawn(sdp)) {
151: gfs2_quota_cleanup(sdp);
152: error = -EIO;
153: }
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:gfs2_put_super SourceFile:fs/gfs2/super.c SourceLine:608 SourceSnippet: 606: gfs2_destroy_threads(sdp);
607:
608: gfs2_quota_cleanup(sdp);
609: }
610:
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:gfs2_quota_init SourceFile:fs/gfs2/quota.c SourceLine:1510 SourceSnippet:1508: brelse(bh);
1509: fail:
1510: gfs2_quota_cleanup(sdp);
1511: return error;
1512: }
]] TruncatedOutput:false]
|
| 18/2 |
2026/06/28 00:33 |
llm |
expert |
0m
Model:
Tokens:
input: 22945
output: 40
thoughts: 67
Thoughts: **Analyzing the Potential Root Cause of a GFS2 Crash**
Okay, so I'm seeing a crash report, and it looks like it's originating within `gfs2_put_super`. Line 618, specifically. Interesting. Let's see... I've just been reminded that `gfs2_quota_cleanup` gets called *right* before the crash, at line 608 of the same function. That's a strong correlation, and a key piece of information. This strongly suggests that there is a problem there. So, I need to dig into `gfs2_put_super` now, with a laser focus on what happens around those lines of code. This is the place to start, let's see what's going on!
|
| 19/2 |
2026/06/28 00:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/super.c Name:gfs2_put_super]
Results: map[SourceCode: 577: static void gfs2_put_super(struct super_block *sb)
578: {
579: struct gfs2_sbd *sdp = sb->s_fs_info;
580: struct gfs2_jdesc *jd;
581:
582: /* No more recovery requests */
583: set_bit(SDF_NORECOVERY, &sdp->sd_flags);
584: smp_mb();
585:
586: /* Wait on outstanding recovery */
587: restart:
588: spin_lock(&sdp->sd_jindex_spin);
589: list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
590: if (!test_bit(JDF_RECOVERY, &jd->jd_flags))
591: continue;
592: spin_unlock(&sdp->sd_jindex_spin);
593: wait_on_bit(&jd->jd_flags, JDF_RECOVERY,
594: TASK_UNINTERRUPTIBLE);
595: goto restart;
596: }
597: spin_unlock(&sdp->sd_jindex_spin);
598:
599: /* Wait for withdraw to complete */
600: flush_work(&sdp->sd_withdraw_work);
601:
602: if (!sb_rdonly(sb))
603: gfs2_make_fs_ro(sdp);
604: else {
605: if (gfs2_withdrawn(sdp))
606: gfs2_destroy_threads(sdp);
607:
608: gfs2_quota_cleanup(sdp);
609: }
610:
611: /* At this point, we're through modifying the disk */
612:
613: /* Release stuff */
614:
615: gfs2_freeze_unlock(sdp);
616:
617: iput(sdp->sd_jindex);
618: iput(sdp->sd_statfs_inode);
619: iput(sdp->sd_rindex);
620: iput(sdp->sd_quota_inode);
621:
622: gfs2_glock_put(sdp->sd_rename_gl);
623: gfs2_glock_put(sdp->sd_freeze_gl);
624:
625: if (!sdp->sd_args.ar_spectator) {
626: if (gfs2_holder_initialized(&sdp->sd_journal_gh))
627: gfs2_glock_dq_uninit(&sdp->sd_journal_gh);
628: if (gfs2_holder_initialized(&sdp->sd_jinode_gh))
629: gfs2_glock_dq_uninit(&sdp->sd_jinode_gh);
630: brelse(sdp->sd_sc_bh);
631: gfs2_glock_dq_uninit(&sdp->sd_sc_gh);
632: gfs2_glock_dq_uninit(&sdp->sd_qc_gh);
633: free_local_statfs_inodes(sdp);
634: iput(sdp->sd_qc_inode);
635: }
636:
637: gfs2_glock_dq_uninit(&sdp->sd_live_gh);
638: gfs2_clear_rgrpd(sdp);
639: gfs2_jindex_free(sdp);
640: /* Take apart glock structures and buffer lists */
641: gfs2_gl_hash_clear(sdp);
642: iput(sdp->sd_inode);
643: gfs2_delete_debugfs_file(sdp);
644:
645: gfs2_sys_fs_del(sdp);
646: free_sbd(sdp);
647: }
SourceFile:fs/gfs2/super.c]
|
| 20/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 24440
output: 40
thoughts: 173
Thoughts: **A Critical Race Condition in GFS2 Quota Cleanup**
Okay, here's what's bothering me. I'm looking at this code, specifically around the GFS2 quota cleanup process. I see that `gfs2_quota_cleanup(sdp)` is called β that's at line 608. Then, just ten lines later at 618, we've got an `iput(sdp->sd_statfs_inode)` call. The problem is that `iput` has the potential to trigger an eviction sequence.
Now, this eviction process is where things get really dicey. `iput` can call `evict`, which then calls `gfs2_evict_inode`, which further calls `gfs2_dinode_dealloc`, ultimately landing on `gfs2_quota_hold`. This `quota_hold` function is where the potential for a race condition arises because it calls `qdsb_get`, which itself calls `slot_get`, and that function tries to access `sdp->sd_quota_bitmap`.
The key issue is this: `sdp->sd_quota_bitmap` was already freed and set to `NULL` in that initial `gfs2_quota_cleanup(sdp)` call. So, we're in a situation where the quota bitmap could be accessed after it's been freed. This looks like a classic use-after-free scenario, or at least a very dangerous race condition, leading to potential corruption. I need to dive deeper into `gfs2_quota_cleanup` to confirm this theory and figure out the exact timing of events.
|
| 21/2 |
2026/06/28 00:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/quota.c Name:gfs2_quota_cleanup]
Results: map[SourceCode:1514: void gfs2_quota_cleanup(struct gfs2_sbd *sdp)
1515: {
1516: struct gfs2_quota_data *qd;
1517: LIST_HEAD(dispose);
1518: int count;
1519:
1520: BUG_ON(!test_bit(SDF_NORECOVERY, &sdp->sd_flags) &&
1521: test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags));
1522:
1523: spin_lock(&qd_lock);
1524: list_for_each_entry(qd, &sdp->sd_quota_list, qd_list) {
1525: spin_lock(&qd->qd_lockref.lock);
1526: if (qd->qd_lockref.count != 0) {
1527: spin_unlock(&qd->qd_lockref.lock);
1528: continue;
1529: }
1530: lockref_mark_dead(&qd->qd_lockref);
1531: spin_unlock(&qd->qd_lockref.lock);
1532:
1533: list_lru_del_obj(&gfs2_qd_lru, &qd->qd_lru);
1534: list_add(&qd->qd_lru, &dispose);
1535: }
1536: spin_unlock(&qd_lock);
1537:
1538: gfs2_qd_list_dispose(&dispose);
1539:
1540: wait_event_timeout(sdp->sd_kill_wait,
1541: (count = atomic_read(&sdp->sd_quota_count)) == 0,
1542: HZ * 60);
1543:
1544: if (count != 0)
1545: fs_err(sdp, "%d left-over quota data objects\n", count);
1546:
1547: kvfree(sdp->sd_quota_bitmap);
1548: sdp->sd_quota_bitmap = NULL;
1549: }
SourceFile:fs/gfs2/quota.c]
|
| 22/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 25632
output: 41
thoughts: 119
Thoughts: **Analyzing the Statfs Inode Eviction**
Okay, so I'm tracking the process. Right, `sdp->sd_quota_bitmap` is definitely freed and set to NULL. That's straightforward enough. Next, we call `iput(sdp->sd_statfs_inode)`. Now, here's where it gets interesting, and frankly, a bit concerning. If `sdp->sd_statfs_inode` has a link count of zero *after* that `iput`, it's going to get evicted. But wait, isn't `sd_statfs_inode` a *system* inode? It should absolutely *not* be unlinked under normal circumstances.
The problem, as I see it, is the potential for filesystem corruption. If the filesystem is damaged, its link count *could* be zero, which would trigger this eviction. So, we need to understand the implications of this. I should take a closer look at `gfs2_evict_inode` to understand the exact eviction process and the conditions that trigger it. Let's see if we can catch any edge cases.
|
| 23/2 |
2026/06/28 00:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/super.c Name:gfs2_evict_inode]
Results: map[SourceCode:1444: static void gfs2_evict_inode(struct inode *inode)
1445: {
1446: struct super_block *sb = inode->i_sb;
1447: struct gfs2_sbd *sdp = sb->s_fs_info;
1448: struct gfs2_inode *ip = GFS2_I(inode);
1449: struct gfs2_holder gh;
1450: enum evict_behavior behavior;
1451: int ret;
1452:
1453: gfs2_holder_mark_uninitialized(&gh);
1454: if (sb_rdonly(sb) || !ip->i_no_addr || !ip->i_gl)
1455: goto out;
1456:
1457: /*
1458: * In case of an incomplete mount, gfs2_evict_inode() may be called for
1459: * system files without having an active journal to write to. In that
1460: * case, skip the filesystem evict.
1461: */
1462: if (!sdp->sd_jdesc)
1463: goto out;
1464:
1465: behavior = evict_should_delete(inode, &gh);
1466: if (behavior == EVICT_SHOULD_DEFER_DELETE &&
1467: !test_bit(SDF_KILL, &sdp->sd_flags)) {
1468: struct gfs2_glock *io_gl = ip->i_iopen_gh.gh_gl;
1469:
1470: if (io_gl) {
1471: gfs2_glock_hold(io_gl);
1472: if (!gfs2_queue_verify_delete(io_gl, true))
1473: gfs2_glock_put(io_gl);
1474: goto out;
1475: }
1476: behavior = EVICT_SHOULD_SKIP_DELETE;
1477: }
1478: if (behavior == EVICT_SHOULD_DELETE)
1479: ret = evict_unlinked_inode(inode, &gh);
1480: else
1481: ret = evict_linked_inode(inode, &gh);
1482:
1483: if (gfs2_rs_active(&ip->i_res))
1484: gfs2_rs_deltree(&ip->i_res);
1485:
1486: if (ret && !gfs2_withdrawn(sdp) && ret != -EROFS)
1487: fs_warn(sdp, "gfs2_evict_inode: %d\n", ret);
1488: out:
1489: if (gfs2_holder_initialized(&gh))
1490: gfs2_glock_dq_uninit(&gh);
1491: gfs2_truncate_inode_pages_final(inode);
1492: if (ip->i_qadata)
1493: gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);
1494: gfs2_rs_deltree(&ip->i_res);
1495: gfs2_ordered_del_inode(ip);
1496: clear_inode(inode);
1497: gfs2_dir_hash_inval(ip);
1498: if (gfs2_holder_initialized(&ip->i_iopen_gh)) {
1499: struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
1500:
1501: glock_clear_object(gl, ip);
1502: gfs2_glock_hold(gl);
1503: ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
1504: gfs2_glock_dq_uninit(&ip->i_iopen_gh);
1505: gfs2_glock_put_eventually(gl);
1506: }
1507: if (ip->i_gl) {
1508: glock_clear_object(ip->i_gl, ip);
1509: wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
1510: gfs2_glock_put_eventually(ip->i_gl);
1511: rcu_assign_pointer(ip->i_gl, NULL);
1512: }
1513: }
SourceFile:fs/gfs2/super.c]
|
| 24/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 27337
output: 40
thoughts: 38
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Analyzing the Eviction Logic**
Alright, so the system is telling me that if a certain `behavior` flag is set to `EVICT_SHOULD_DELETE`, the function `evict_unlinked_inode` gets called. My brain immediately jumps to that function. Let's dig in and examine the inner workings of `evict_unlinked_inode`. I need to understand exactly what's going on within that call chain. What are the specific steps involved? What resources are being freed, and in what order? Are there any potential race conditions I should be considering related to concurrent unlink operations? I'm particularly interested in how the inode metadata is managed in this scenario. Are there any subtle interactions with the journal or other persistent storage layers that could lead to data loss or corruption if handled incorrectly? I want to know everything about its behavior.
|
| 25/2 |
2026/06/28 00:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/super.c Name:evict_unlinked_inode]
Results: map[SourceCode:1283: /**
1284: * evict_unlinked_inode - delete the pieces of an unlinked evicted inode
1285: * @inode: The inode to evict
1286: * @gh: The glock holder structure
1287: */
1288: static int evict_unlinked_inode(struct inode *inode, struct gfs2_holder *gh)
1289: {
1290: struct gfs2_inode *ip = GFS2_I(inode);
1291: struct gfs2_glock *gl = ip->i_gl;
1292: int ret;
1293:
1294: /* The inode glock must be held exclusively and be instantiated. */
1295: BUG_ON(!gfs2_holder_initialized(gh) ||
1296: test_bit(GLF_INSTANTIATE_NEEDED, &gl->gl_flags));
1297:
1298: if (S_ISDIR(inode->i_mode) &&
1299: (ip->i_diskflags & GFS2_DIF_EXHASH)) {
1300: ret = gfs2_dir_exhash_dealloc(ip);
1301: if (ret)
1302: goto out;
1303: }
1304:
1305: if (ip->i_eattr) {
1306: ret = gfs2_ea_dealloc(ip, true);
1307: if (ret)
1308: goto out;
1309: }
1310:
1311: if (!gfs2_is_stuffed(ip)) {
1312: ret = gfs2_file_dealloc(ip);
1313: if (ret)
1314: goto out;
1315: }
1316:
1317: /*
1318: * As soon as we clear the bitmap for the dinode, gfs2_create_inode()
1319: * can get called to recreate it, or even gfs2_inode_lookup() if the
1320: * inode was recreated on another node in the meantime.
1321: *
1322: * However, inserting the new inode into the inode hash table will not
1323: * succeed until the old inode is removed, and that only happens after
1324: * ->evict_inode() returns. The new inode is attached to its inode and
1325: * iopen glocks after inserting it into the inode hash table, so at
1326: * that point we can be sure that both glocks are unused.
1327: */
1328:
1329: ret = gfs2_dinode_dealloc(ip);
1330: if (!ret)
1331: gfs2_inode_remember_delete(gl, ip->i_no_formal_ino);
1332:
1333: out:
1334: return ret;
1335: }
SourceFile:fs/gfs2/super.c]
|
| 26/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 28478
output: 42
thoughts: 29
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing the Deallocation Path**
Okay, so the code's jumping into `gfs2_dinode_dealloc`. Naturally, my first instinct is to dive into *that* function and trace the execution flow. I need to understand exactly what's happening within `gfs2_dinode_dealloc`. This is likely where the core deallocation logic resides for GFS2 inodes, and I need to assess how it handles data blocks, metadata, and potentially the inode structure itself. I'll need to pay close attention to potential race conditions, lock interactions, and any checks for resource leaks or inconsistencies. This is the heart of the matter.
|
| 27/2 |
2026/06/28 00:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/inode.c Name:gfs2_dinode_dealloc]
Results: map[SourceCode: 474: int gfs2_dinode_dealloc(struct gfs2_inode *ip)
475: {
476: struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
477: struct gfs2_rgrpd *rgd;
478: struct gfs2_holder gh;
479: int error;
480:
481: if (gfs2_get_inode_blocks(&ip->i_inode) != 1) {
482: gfs2_consist_inode(ip);
483: return -EIO;
484: }
485:
486: gfs2_rindex_update(sdp);
487:
488: error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
489: if (error)
490: return error;
491:
492: rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
493: if (!rgd) {
494: gfs2_consist_inode(ip);
495: error = -EIO;
496: goto out_qs;
497: }
498:
499: error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE,
500: LM_FLAG_NODE_SCOPE, &gh);
501: if (error)
502: goto out_qs;
503:
504: error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA,
505: sdp->sd_jdesc->jd_blocks);
506: if (error)
507: goto out_rg_gunlock;
508:
509: gfs2_free_di(rgd, ip);
510:
511: gfs2_final_release_pages(ip);
512:
513: gfs2_trans_end(sdp);
514:
515: out_rg_gunlock:
516: gfs2_glock_dq_uninit(&gh);
517: out_qs:
518: gfs2_quota_unhold(ip);
519: return error;
520: }
SourceFile:fs/gfs2/inode.c]
|
| 28/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 29454
output: 40
thoughts: 25
Thoughts: Okay, here's my interpretation of those thoughts, crafted for an expert audience, presented in the first person:
**Analyzing the Quota Hold Function**
Right, so the code's calling `gfs2_quota_hold`. My immediate reaction is, "Okay, let's dive into *that* function." I need to understand what's happening at this point in the process. What's it holding? Are we talking about inodes? Disk blocks? User or group quota entries? The name itself suggests we're attempting to grab some sort of lock, but for what and why are key questions. We're obviously in a quota context. This suggests we're about to make, or have made, a change to the filesystem that needs to be accounted for. Now, let's get into the specifics of `gfs2_quota_hold` to see exactly what's being held and under what conditions.
|
| 29/2 |
2026/06/28 00:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/quota.c Name:gfs2_quota_hold]
Results: map[SourceCode: 584: int gfs2_quota_hold(struct gfs2_inode *ip, kuid_t uid, kgid_t gid)
585: {
586: struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
587: struct gfs2_quota_data **qd;
588: int error;
589:
590: if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
591: return 0;
592:
593: error = gfs2_qa_get(ip);
594: if (error)
595: return error;
596:
597: qd = ip->i_qadata->qa_qd;
598:
599: if (gfs2_assert_warn(sdp, !ip->i_qadata->qa_qd_num) ||
600: gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags))) {
601: error = -EIO;
602: gfs2_qa_put(ip);
603: goto out;
604: }
605:
606: error = qdsb_get(sdp, make_kqid_uid(ip->i_inode.i_uid), qd);
607: if (error)
608: goto out_unhold;
609: ip->i_qadata->qa_qd_num++;
610: qd++;
611:
612: error = qdsb_get(sdp, make_kqid_gid(ip->i_inode.i_gid), qd);
613: if (error)
614: goto out_unhold;
615: ip->i_qadata->qa_qd_num++;
616: qd++;
617:
618: if (!uid_eq(uid, NO_UID_QUOTA_CHANGE) &&
619: !uid_eq(uid, ip->i_inode.i_uid)) {
620: error = qdsb_get(sdp, make_kqid_uid(uid), qd);
621: if (error)
622: goto out_unhold;
623: ip->i_qadata->qa_qd_num++;
624: qd++;
625: }
626:
627: if (!gid_eq(gid, NO_GID_QUOTA_CHANGE) &&
628: !gid_eq(gid, ip->i_inode.i_gid)) {
629: error = qdsb_get(sdp, make_kqid_gid(gid), qd);
630: if (error)
631: goto out_unhold;
632: ip->i_qadata->qa_qd_num++;
633: qd++;
634: }
635:
636: out_unhold:
637: if (error)
638: gfs2_quota_unhold(ip);
639: out:
640: return error;
641: }
SourceFile:fs/gfs2/quota.c]
|
| 30/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 30663
output: 59
thoughts: 548
Thoughts: **Analyzing a GFS2 Kernel Panic**
Okay, let me break down what's happening here. The core issue revolves around a corrupted GFS2 image thatβs leading to a kernel panic. I'm following the call stack: `gfs2_quota_hold` calls `qdsb_get`, which calls `slot_get`, and that, in turn, accesses `sdp->sd_quota_bitmap`. This sequence is triggered when `iput(sdp->sd_statfs_inode)` gets called within `gfs2_put_super`, specifically when that inode's link count hits zero. That's the critical point.
Now, the question is *why* the `sd_statfs_inode` has a link count of zero. The reproducer mounts a corrupted GFS2 image. This image has a `sd_statfs_inode` that has `i_nlink == 0`. When `iput` evicts the inode, `gfs2_evict_inode` is activated, then `evict_unlinked_inode`, and this leads to attempting to deallocate the dinode. Part of that deallocation process tries to hold the quota, and *that's* where it tries to access the already freed `sd_quota_bitmap`. That's the crash.
So, this looks like a denial-of-service, a definite kernel panic, specifically a general protection fault triggered by a NULL pointer dereference. The KASAN report confirms this: "KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]". The crash at address `0xdffffc0000000000` is the KASAN shadow address for `0x0000000000000000`, so itβs a direct NULL dereference.
Now, the important question is exploitability. While a straight NULL pointer dereference isn't typically exploitable for privilege escalation or memory corruption on modern systems due to `mmap_min_addr`, it's a very effective denial-of-service.
Next, I need to know if an unprivileged user can trigger this. The reproducer uses `syz_mount_image`, which requires `CAP_SYS_ADMIN` in the initial user namespace. Or, if the filesystem allows user namespace mounts, then `CAP_SYS_ADMIN` in that user namespace. I need to check if GFS2 has `FS_USERNS_MOUNT` enabled. That will determine the impact.
|
| 31/2 |
2026/06/28 00:34 |
tool |
codesearch-find-references |
0m
Error:
Args: map[ContextFile:fs/gfs2/super.c IncludeSnippetLines:2 Name:FS_USERNS_MOUNT SourceTreePrefix:fs/gfs2/]
Results: map[References:<nil> TruncatedOutput:false]
|
| 32/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 31869
output: 40
thoughts: 25
Thoughts: Okay, let's dive into this. Here's my thought process on this:
**Examining `gfs2_fs_type` in `fs/gfs2/super.c`**
Alright, I need to understand something about the GFS2 filesystem implementation, specifically how it's defined and initialized. The mention of `gfs2_fs_type` immediately points me to the core of how the filesystem type is registered. My instinct says this is likely a `struct file_system_type` or similar data structure, and the `fs/gfs2/super.c` file is where the superblock operations and the filesystem type are probably defined and registered. I'm expecting to find the standard stuff here β the name, mount function, superblock operations, and likely the filesystem's magic number. I'll probably be looking to see if there's anything unusual or clever about how they handle the type registration, or any custom methods defined for their specific requirements. I need to understand how the kernel recognizes this as a GFS2 filesystem. Let's see... I'm expecting to either find it or be directed to where it's defined.
|
| 33/2 |
2026/06/28 00:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/super.c Name:gfs2_fs_type]
Results: map[SourceCode:1800: struct file_system_type gfs2_fs_type = {
1801: .name = "gfs2",
1802: .fs_flags = FS_REQUIRES_DEV,
1803: .init_fs_context = gfs2_init_fs_context,
1804: .parameters = gfs2_fs_parameters,
1805: .kill_sb = gfs2_kill_sb,
1806: .owner = THIS_MODULE,
1807: };
SourceFile:fs/gfs2/ops_fstype.c]
|
| 34/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 32356
output: 43
thoughts: 725
Thoughts: **My Analysis of the GFS2 Vulnerability**
Okay, so here's what I've got. The gist of it is this: this vulnerability hinges on a NULL pointer dereference within the `gfs2_put_super` function, specifically related to `sdp->sd_statfs_inode`. Because of how GFS2 is implemented, this is a real problem.
First off, GFS2 does *not* support `FS_USERNS_MOUNT`, meaning it's inherently restricted. A user needs `CAP_SYS_ADMIN` in the initial user namespace to even mount a GFS2 filesystem. That eliminates accessibility for unprivileged processes and user namespaces immediately.
The key question then becomes: can this be triggered without explicit privileges? The prompt's focus on auto-mounting is crucial. Could a malicious GFS2 image on a USB drive get plugged in and automatically mounted by a desktop environment? Yes, but auto-mounting is usually restricted to a whitelist of filesystems, such as vfat, exfat, ntfs, and ext4, or rely on udisks2. However, the driver being loaded might allow for the GFS2 filesystem.
The prompt, specifically, is asking about the possibility of an image with a malicious filesystem being auto-mounted. Bingo! That's a **Malicious Filesystem Trigger**. Even more concerning, the reproducer uses `syz_mount_image`, followed by a series of file system operations like `mkdir`, `chdir`, and binds, before the process exits which unmounts everything. The key part is the unmount operation; this triggers `gfs2_put_super`.
Let's make sure this is the only way we can get there. Could `gfs2_put_super` be triggered by *just* mounting a corrupted image, and then unmounting? Yup. It looks like the unmount operation itself does the trick, even if the mount fails and cleans up the structure.
Now, let's break down the answers to the questions.
* Exploitable? Yes, it's a NULL pointer dereference.
* Denial of Service? Absolutely, kernel panic.
* Accessible from Unprivileged Processes? No, requires `CAP_SYS_ADMIN`.
* Accessible from User Namespaces? No, `FS_USERNS_MOUNT` is missing.
* VM Guest Trigger? No, unrelated.
* VM Host Trigger in Confidential Computing? No.
* Ethernet Network Trigger? No.
* Other Remote Trigger? No.
* Peripheral Trigger? Yes, a USB drive with a malicious image.
* Malicious Filesystem Trigger? Yes.
I checked for the possibility of a use-after-free, where `sdp->sd_quota_bitmap` is not NULL but a freed pointer. But that's not the case. The code explicitly sets it to NULL. So it really is a plain NULL pointer dereference.
I also verified, once more, that no unprivileged users can mount GFS2 because `FS_USERNS_MOUNT` is not set.
Finally, I confirmed that `gfs2_put_super` and `gfs2_fill_super` (on error path) are the only two spots where `iput(sdp->sd_statfs_inode)` is called.
The bottom line is that the auto-mount scenario, especially with external media, is the critical vector here.
|
| 35/2 |
2026/06/28 00:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/ops_fstype.c Name:gfs2_fill_super]
Results: map[SourceCode:1105: /**
1106: * gfs2_fill_super - Read in superblock
1107: * @sb: The VFS superblock
1108: * @fc: Mount options and flags
1109: *
1110: * Returns: -errno
1111: */
1112: static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
1113: {
1114: struct gfs2_args *args = fc->fs_private;
1115: int silent = fc->sb_flags & SB_SILENT;
1116: struct gfs2_sbd *sdp;
1117: struct gfs2_holder mount_gh;
1118: struct address_space *mapping;
1119: int error;
1120:
1121: sdp = init_sbd(sb);
1122: if (!sdp) {
1123: pr_warn("can't alloc struct gfs2_sbd\n");
1124: return -ENOMEM;
1125: }
1126: sdp->sd_args = *args;
1127:
1128: if (sdp->sd_args.ar_spectator) {
1129: sb->s_flags |= SB_RDONLY;
1130: set_bit(SDF_RORECOVERY, &sdp->sd_flags);
1131: }
1132: if (sdp->sd_args.ar_posix_acl)
1133: sb->s_flags |= SB_POSIXACL;
1134: if (sdp->sd_args.ar_nobarrier)
1135: set_bit(SDF_NOBARRIERS, &sdp->sd_flags);
1136:
1137: sb->s_flags |= SB_NOSEC;
1138: sb->s_magic = GFS2_MAGIC;
1139: sb->s_op = &gfs2_super_ops;
1140:
1141: set_default_d_op(sb, &gfs2_dops);
1142: sb->s_export_op = &gfs2_export_ops;
1143: sb->s_qcop = &gfs2_quotactl_ops;
1144: sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
1145: sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;
1146: sb->s_time_gran = 1;
1147: sb->s_maxbytes = MAX_LFS_FILESIZE;
1148:
1149: /* Set up the buffer cache and fill in some fake block size values
1150: to allow us to read-in the on-disk superblock. */
1151: sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, SECTOR_SIZE);
1152: error = -EINVAL;
1153: if (!sdp->sd_sb.sb_bsize)
1154: goto fail_free;
1155: sdp->sd_sb.sb_bsize_shift = sb->s_blocksize_bits;
1156: sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - SECTOR_SHIFT;
1157: sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift);
1158:
1159: sdp->sd_tune.gt_logd_secs = sdp->sd_args.ar_commit;
1160: sdp->sd_tune.gt_quota_quantum = sdp->sd_args.ar_quota_quantum;
1161: if (sdp->sd_args.ar_statfs_quantum) {
1162: sdp->sd_tune.gt_statfs_slow = 0;
1163: sdp->sd_tune.gt_statfs_quantum = sdp->sd_args.ar_statfs_quantum;
1164: } else {
1165: sdp->sd_tune.gt_statfs_slow = 1;
1166: sdp->sd_tune.gt_statfs_quantum = 30;
1167: }
1168:
1169: /* Set up an address space for metadata writes */
1170: sdp->sd_inode = new_inode(sb);
1171: error = -ENOMEM;
1172: if (!sdp->sd_inode)
1173: goto fail_free;
1174: sdp->sd_inode->i_ino = GFS2_BAD_INO;
1175: sdp->sd_inode->i_size = OFFSET_MAX;
1176:
1177: mapping = gfs2_aspace(sdp);
1178: mapping->a_ops = &gfs2_rgrp_aops;
1179: gfs2_setup_inode(sdp->sd_inode);
1180:
1181: error = init_names(sdp, silent);
1182: if (error)
1183: goto fail_iput;
1184:
1185: snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s", sdp->sd_table_name);
1186:
1187: error = -ENOMEM;
1188: sdp->sd_glock_wq = alloc_workqueue("gfs2-glock/%s",
1189: WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_FREEZABLE | WQ_PERCPU,
1190: 0,
1191: sdp->sd_fsname);
1192: if (!sdp->sd_glock_wq)
1193: goto fail_iput;
1194:
1195: sdp->sd_delete_wq = alloc_workqueue("gfs2-delete/%s",
1196: WQ_MEM_RECLAIM | WQ_FREEZABLE | WQ_PERCPU, 0,
1197: sdp->sd_fsname);
1198: if (!sdp->sd_delete_wq)
1199: goto fail_glock_wq;
1200:
1201: error = gfs2_sys_fs_add(sdp);
1202: if (error)
1203: goto fail_delete_wq;
1204:
1205: gfs2_create_debugfs_file(sdp);
1206:
1207: error = gfs2_lm_mount(sdp, silent);
1208: if (error)
1209: goto fail_debug;
1210:
1211: INIT_WORK(&sdp->sd_withdraw_work, gfs2_withdraw_func);
1212:
1213: error = init_locking(sdp, &mount_gh, DO);
1214: if (error)
1215: goto fail_lm;
1216:
1217: error = init_sb(sdp, silent);
1218: if (error)
1219: goto fail_locking;
1220:
1221: /* Turn rgrplvb on by default if fs format is recent enough */
1222: if (!sdp->sd_args.ar_got_rgrplvb && sdp->sd_sb.sb_fs_format > 1801)
1223: sdp->sd_args.ar_rgrplvb = 1;
1224:
1225: error = wait_on_journal(sdp);
1226: if (error)
1227: goto fail_sb;
1228:
1229: /*
1230: * If user space has failed to join the cluster or some similar
1231: * failure has occurred, then the journal id will contain a
1232: * negative (error) number. This will then be returned to the
1233: * caller (of the mount syscall). We do this even for spectator
1234: * mounts (which just write a jid of 0 to indicate "ok" even though
1235: * the jid is unused in the spectator case)
1236: */
1237: if (sdp->sd_lockstruct.ls_jid < 0) {
1238: error = sdp->sd_lockstruct.ls_jid;
1239: sdp->sd_lockstruct.ls_jid = 0;
1240: goto fail_sb;
1241: }
1242:
1243: if (sdp->sd_args.ar_spectator)
1244: snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s.s",
1245: sdp->sd_table_name);
1246: else
1247: snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s.%u",
1248: sdp->sd_table_name, sdp->sd_lockstruct.ls_jid);
1249:
1250: error = init_inodes(sdp, DO);
1251: if (error)
1252: goto fail_sb;
1253:
1254: error = init_per_node(sdp, DO);
1255: if (error)
1256: goto fail_inodes;
1257:
1258: error = gfs2_statfs_init(sdp);
1259: if (error) {
1260: fs_err(sdp, "can't initialize statfs subsystem: %d\n", error);
1261: goto fail_per_node;
1262: }
1263:
1264: if (!sb_rdonly(sb)) {
1265: error = init_threads(sdp);
1266: if (error)
1267: goto fail_per_node;
1268: }
1269:
1270: error = gfs2_freeze_lock_shared(sdp);
1271: if (error)
1272: goto fail_per_node;
1273:
1274: if (!sb_rdonly(sb))
1275: error = gfs2_make_fs_rw(sdp);
1276:
1277: if (error) {
1278: gfs2_freeze_unlock(sdp);
1279: fs_err(sdp, "can't make FS RW: %d\n", error);
1280: goto fail_per_node;
1281: }
1282: gfs2_glock_dq_uninit(&mount_gh);
1283: gfs2_online_uevent(sdp);
1284: return 0;
1285:
1286: fail_per_node:
1287: init_per_node(sdp, UNDO);
1288: gfs2_destroy_threads(sdp);
1289: fail_inodes:
1290: init_inodes(sdp, UNDO);
1291: fail_sb:
1292: if (sdp->sd_root_dir)
1293: dput(sdp->sd_root_dir);
1294: if (sdp->sd_master_dir)
1295: dput(sdp->sd_master_dir);
1296: if (sb->s_root)
1297: dput(sb->s_root);
1298: sb->s_root = NULL;
1299: fail_locking:
1300: init_locking(sdp, &mount_gh, UNDO);
1301: fail_lm:
1302: complete_all(&sdp->sd_journal_ready);
1303: gfs2_gl_hash_clear(sdp);
1304: gfs2_lm_unmount(sdp);
1305: fail_debug:
1306: gfs2_delete_debugfs_file(sdp);
1307: gfs2_sys_fs_del(sdp);
1308: fail_delete_wq:
1309: destroy_workqueue(sdp->sd_delete_wq);
1310: fail_glock_wq:
1311: if (sdp->sd_glock_wq)
1312: destroy_workqueue(sdp->sd_glock_wq);
1313: fail_iput:
1314: iput(sdp->sd_inode);
1315: fail_free:
1316: free_sbd(sdp);
1317: return error;
1318: }
SourceFile:fs/gfs2/ops_fstype.c]
|
| 36/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 37488
output: 39
thoughts: 36
Thoughts: Here's my analysis of the provided thought process:
**Diving into GFS2 Initialization**
Okay, so I'm looking at `gfs2_fill_super`. It's occurred to me that on error, this function calls `init_inodes(sdp, UNDO)`. That's a critical detail because it suggests a specific cleanup or rollback mechanism is in place. I need to understand what `init_inodes` is doing in that error path. Let's dig into the `init_inodes` function itself to see what happens there.
|
| 37/2 |
2026/06/28 00:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/ops_fstype.c Name:init_inodes]
Results: map[SourceCode: 836: static int init_inodes(struct gfs2_sbd *sdp, int undo)
837: {
838: int error = 0;
839: struct inode *master = d_inode(sdp->sd_master_dir);
840:
841: if (undo)
842: goto fail_qinode;
843:
844: error = init_journal(sdp, undo);
845: complete_all(&sdp->sd_journal_ready);
846: if (error)
847: goto fail;
848:
849: /* Read in the resource index inode */
850: sdp->sd_rindex = gfs2_lookup_meta(master, "rindex");
851: if (IS_ERR(sdp->sd_rindex)) {
852: error = PTR_ERR(sdp->sd_rindex);
853: fs_err(sdp, "can't get resource index inode: %d\n", error);
854: goto fail_journal;
855: }
856: sdp->sd_rindex_uptodate = 0;
857:
858: /* Read in the quota inode */
859: sdp->sd_quota_inode = gfs2_lookup_meta(master, "quota");
860: if (IS_ERR(sdp->sd_quota_inode)) {
861: error = PTR_ERR(sdp->sd_quota_inode);
862: fs_err(sdp, "can't get quota file inode: %d\n", error);
863: goto fail_rindex;
864: }
865: /*
866: * i_rwsem on quota files is special. Since this inode is hidden system
867: * file, we are safe to define locking ourselves.
868: */
869: lockdep_set_class(&sdp->sd_quota_inode->i_rwsem,
870: &gfs2_quota_imutex_key);
871:
872: error = gfs2_rindex_update(sdp);
873: if (error)
874: goto fail_qinode;
875:
876: return 0;
877:
878: fail_qinode:
879: iput(sdp->sd_quota_inode);
880: fail_rindex:
881: gfs2_clear_rgrpd(sdp);
882: iput(sdp->sd_rindex);
883: fail_journal:
884: init_journal(sdp, UNDO);
885: fail:
886: return error;
887: }
SourceFile:fs/gfs2/ops_fstype.c]
|
| 38/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 38519
output: 41
thoughts: 20
Thoughts: Here's my understanding of the thought process, summarized as you requested:
**Navigating Initialization Sequences**
Okay, so I was double-checking where `sd_statfs_inode` gets initialized within this code. I thought it might be defined somewhere else, but now I recall that `init_per_node` is the key function here. That makes sense; it's the logical place to set up the per-node data structures. This confirms my initial understanding of the initialization flow. It's good to solidify these details, especially when dealing with such fundamental components.
|
| 39/2 |
2026/06/28 00:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/ops_fstype.c Name:init_per_node]
Results: map[SourceCode: 889: static int init_per_node(struct gfs2_sbd *sdp, int undo)
890: {
891: struct inode *pn = NULL;
892: char buf[30];
893: int error = 0;
894: struct gfs2_inode *ip;
895: struct inode *master = d_inode(sdp->sd_master_dir);
896:
897: if (sdp->sd_args.ar_spectator)
898: return 0;
899:
900: if (undo)
901: goto fail_qc_gh;
902:
903: pn = gfs2_lookup_meta(master, "per_node");
904: if (IS_ERR(pn)) {
905: error = PTR_ERR(pn);
906: fs_err(sdp, "can't find per_node directory: %d\n", error);
907: return error;
908: }
909:
910: sprintf(buf, "quota_change%u", sdp->sd_jdesc->jd_jid);
911: sdp->sd_qc_inode = gfs2_lookup_meta(pn, buf);
912: if (IS_ERR(sdp->sd_qc_inode)) {
913: error = PTR_ERR(sdp->sd_qc_inode);
914: fs_err(sdp, "can't find local \"qc\" file: %d\n", error);
915: goto fail_ut_i;
916: }
917:
918: iput(pn);
919: pn = NULL;
920:
921: ip = GFS2_I(sdp->sd_qc_inode);
922: error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_NOPID,
923: &sdp->sd_qc_gh);
924: if (error) {
925: fs_err(sdp, "can't lock local \"qc\" file: %d\n", error);
926: goto fail_qc_i;
927: }
928:
929: return 0;
930:
931: fail_qc_gh:
932: gfs2_glock_dq_uninit(&sdp->sd_qc_gh);
933: fail_qc_i:
934: iput(sdp->sd_qc_inode);
935: fail_ut_i:
936: iput(pn);
937: return error;
938: }
SourceFile:fs/gfs2/ops_fstype.c]
|
| 40/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 39523
output: 61
thoughts: 34
Thoughts: Okay, here's my interpretation of those thoughts, framed as my own:
**Initializing the Filesystem Statistics**
Hmm, something's not quite right. I was just reviewing the filesystem initialization process, specifically within the `init_per_node` function, and I've hit a snag. It appears that `sd_statfs_inode`, that critical inode for filesystem statistics, isn't being initialized in this particular function. That's a red flag. I need to figure out where the `sd_statfs_inode` variable *is* actually being initialized. This omission could lead to all sorts of problems β incorrect reporting, potential crashes, or, at best, uninitialized data causing unexpected behaviour. Time to trace this initialization and ensure there isn't a lurking bug.
|
| 41/2 |
2026/06/28 00:34 |
tool |
codesearch-find-references |
0m
Error:
Args: map[ContextFile:fs/gfs2/ops_fstype.c IncludeSnippetLines:2 Name:sd_statfs_inode SourceTreePrefix:fs/gfs2/]
Results: map[References:<nil> TruncatedOutput:false]
|
| 42/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 39804
output: 68
thoughts: 20
Thoughts: Here's my thought process, summarized as you requested:
**Investigating `gfs2_sbd::sd_statfs_inode`**
Okay, let's dive into this `gfs2_sbd::sd_statfs_inode` function. My first instinct is to understand its purpose within the GFS2 framework. Based on the name alone, I can guess it has something to do with retrieving file system statistics related to inodes, probably specifically in the context of the shared block device (SBD) β which, if I recall correctly, is the crucial component for fencing and ensuring data integrity in a clustered GFS2 setup.
So, I need to know: what *specifically* does this function report? Is it returning the typical `statfs` information? Does it interact with shared memory or some form of cluster-wide status? Is it reporting on a *specific* inode or an *aggregation* of inode-related statistics for the file system? Is there a subtle hint within the name to imply its use? I need to look closer.
My next step is to either:
1. **Search the GFS2 source code.** I need to locate where `gfs2_sbd::sd_statfs_inode` is defined and used. I'll need to understand the function signature (arguments and return value) and its calling context. That will provide crucial insights. I'll look for cross-references to understand what other parts of the system rely on this function.
2. **Refer to existing documentation (if available).** Hopefully, there's some documentation that explains the function's role in greater detail. I might be able to find this in the GFS2 source code comments, or the documentation I've seen in the past. If the documentation explains its use, I can be sure to not miss anything by inspecting the code later.
Once I have a clear understanding of its role, purpose and implementation, I can make a judgement on how it can affect or be influenced by the system as a whole.
|
| 43/2 |
2026/06/28 00:34 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/gfs2/ops_fstype.c IncludeSnippetLines:2 Name:gfs2_sbd::sd_statfs_inode SourceTreePrefix:fs/gfs2/]
Results: map[References:[map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:adjust_fs_space SourceFile:fs/gfs2/aops.c SourceLine:513 SourceSnippet: 511: {
512: struct gfs2_sbd *sdp = GFS2_SB(inode);
513: struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
514: struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
515: struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:gfs2_file_buffered_write SourceFile:fs/gfs2/file.c SourceLine:1052 SourceSnippet:1050:
1051: if (inode == sdp->sd_rindex) {
1052: struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
1053:
1054: ret = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE,
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:gfs2_put_super SourceFile:fs/gfs2/super.c SourceLine:618 SourceSnippet: 616:
617: iput(sdp->sd_jindex);
618: iput(sdp->sd_statfs_inode);
619: iput(sdp->sd_rindex);
620: iput(sdp->sd_quota_inode);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:gfs2_statfs_init SourceFile:fs/gfs2/super.c SourceLine:179 SourceSnippet: 177: int gfs2_statfs_init(struct gfs2_sbd *sdp)
178: {
179: struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
180: struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
181: struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:gfs2_statfs_sync SourceFile:fs/gfs2/super.c SourceLine:269 SourceSnippet: 267: {
268: struct gfs2_sbd *sdp = sb->s_fs_info;
269: struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
270: struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
271: struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:init_statfs SourceFile:fs/gfs2/ops_fstype.c SourceLine:614 SourceSnippet: 612: struct gfs2_inode *ip;
613:
614: sdp->sd_statfs_inode = gfs2_lookup_meta(master, "statfs");
615: if (IS_ERR(sdp->sd_statfs_inode)) {
616: error = PTR_ERR(sdp->sd_statfs_inode);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:init_statfs SourceFile:fs/gfs2/ops_fstype.c SourceLine:615 SourceSnippet: 613:
614: sdp->sd_statfs_inode = gfs2_lookup_meta(master, "statfs");
615: if (IS_ERR(sdp->sd_statfs_inode)) {
616: error = PTR_ERR(sdp->sd_statfs_inode);
617: fs_err(sdp, "can't read in statfs inode: %d\n", error);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:init_statfs SourceFile:fs/gfs2/ops_fstype.c SourceLine:616 SourceSnippet: 614: sdp->sd_statfs_inode = gfs2_lookup_meta(master, "statfs");
615: if (IS_ERR(sdp->sd_statfs_inode)) {
616: error = PTR_ERR(sdp->sd_statfs_inode);
617: fs_err(sdp, "can't read in statfs inode: %d\n", error);
618: goto out;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:init_statfs SourceFile:fs/gfs2/ops_fstype.c SourceLine:678 SourceSnippet: 676: iput(pn);
677: put_statfs:
678: iput(sdp->sd_statfs_inode);
679: out:
680: return error;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:recover_local_statfs SourceFile:fs/gfs2/recovery.c SourceLine:385 SourceSnippet: 383: /* First update the master statfs inode with the changes we
384: * found in the journal. */
385: error = update_statfs_inode(jd, head, sdp->sd_statfs_inode);
386: if (error)
387: goto out;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:uninit_statfs SourceFile:fs/gfs2/ops_fstype.c SourceLine:691 SourceSnippet: 689: free_local_statfs_inodes(sdp);
690: }
691: iput(sdp->sd_statfs_inode);
692: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:update_statfs SourceFile:fs/gfs2/super.c SourceLine:247 SourceSnippet: 245: void update_statfs(struct gfs2_sbd *sdp, struct buffer_head *m_bh)
246: {
247: struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
248: struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
249: struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
]] TruncatedOutput:false]
|
| 44/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 42327
output: 59
thoughts: 35
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm deep in the code:
**Debugging a StatFS Initialization Issue**
Alright, hang on a second. I'm seeing that `init_statfs` and `uninit_statfs` are being called *somewhere* in this mess. That's a good starting point, but without knowing *where* they're called, I'm just looking at noise. The issue must be in the initialization or deinitialization of this function. Let's start with `init_statfs`. I need to track down every single call to `init_statfs`. That'll give me a much better understanding of the overall control flow and where the actual issue might be rooted. I suspect the problem is there, somewhere, since I need to understand why it is misbehaving.
|
| 45/2 |
2026/06/28 00:34 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:fs/gfs2/ops_fstype.c IncludeSnippetLines:2 Name:init_statfs SourceTreePrefix:fs/gfs2/]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:init_journal SourceFile:fs/gfs2/ops_fstype.c SourceLine:779 SourceSnippet: 777:
778: /* Lookup statfs inodes here so journal recovery can use them. */
779: error = init_statfs(sdp);
780: if (error)
781: goto fail_jinode_gh;
]] TruncatedOutput:false]
|
| 46/2 |
2026/06/28 00:34 |
llm |
expert |
0m
Model:
Tokens:
input: 42751
output: 41
thoughts: 349
Thoughts: **My Analysis of a Potential GFS2 Vulnerability**
Okay, let's break this down. It seems like we have a potential use-after-free situation in the GFS2 file system. My initial thought process is starting with the function call chain: `init_statfs` gets called from `init_journal`, which itself is called from `init_inodes`. Interesting, so, if `init_journal` fails, it calls `init_journal` again, but this time with `UNDO`. This second call will then lead to `uninit_statfs` being invoked.
Now, during the unmount process, or when putting the superblock, `gfs2_put_super` calls `iput(sdp->sd_statfs_inode)`. But, hang on... what if this `sd_statfs_inode` is somehow corrupted? Specifically, what if it's been manipulated to have `i_nlink == 0`? That would mean, when `iput` is called, the inode is immediately evicted. Is there a way this statfs inode could be unlinked?
Yes, it's a metadata inode read from the disk and if someone can craft a malicious disk image, then this `statfs` inode could have `i_nlink == 0`. When `iput` is called, it triggers this eviction process. During eviction, `gfs2_evict_inode` calls `evict_unlinked_inode`, which in turn calls `gfs2_dinode_dealloc`. This then triggers a call to `gfs2_quota_hold`, which accesses `sdp->sd_quota_bitmap`. And that's where the problem arises.
We freed `sdp->sd_quota_bitmap` in `gfs2_quota_cleanup(sdp)`, which is called *earlier* in `gfs2_put_super`. So, we have a use-after-free because we're trying to access freed memory.
Hmm, but is there another way to trigger this? What if `iput(sdp->sd_statfs_inode)` is called in `uninit_statfs` if there's a mount failure? I need to check the code in `uninit_statfs` to confirm. This could be another attack vector.
|
| 47/2 |
2026/06/28 00:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/ops_fstype.c Name:uninit_statfs]
Results: map[SourceCode: 683: /* Uninitialize and free up memory used by the list of statfs inodes */
684: static void uninit_statfs(struct gfs2_sbd *sdp)
685: {
686: if (!sdp->sd_args.ar_spectator) {
687: brelse(sdp->sd_sc_bh);
688: gfs2_glock_dq_uninit(&sdp->sd_sc_gh);
689: free_local_statfs_inodes(sdp);
690: }
691: iput(sdp->sd_statfs_inode);
692: }
SourceFile:fs/gfs2/ops_fstype.c]
|
| 48/2 |
2026/06/28 00:35 |
llm |
expert |
0m
Model:
Tokens:
input: 43857
output: 40
thoughts: 310
Thoughts: **Analyzing a Potential Quota Crash Scenario**
Okay, so I'm digging into this potential crash during mount failures, specifically related to the GFS2 quota system. The core of the problem seems to be a race condition. If `uninit_statfs` gets called due to a failed mount, there's a risk that `gfs2_quota_cleanup` hasn't run yet, or even worse, that `gfs2_quota_init` hasn't completed. I know `gfs2_quota_init` is supposed to be handled in `gfs2_make_fs_rw`, so if the mount bails *before* that stage, we're in trouble.
Specifically, if the mount fails prematurely, `sdp->sd_quota_bitmap` ends up being NULL. Now, if we later call `iput(sdp->sd_statfs_inode)` as part of the cleanup, that's going to trigger inode eviction. Eviction, in turn, calls `gfs2_quota_hold`. The problem is that `gfs2_quota_hold` accesses `sdp->sd_quota_bitmap`, which, as we established, is currently NULL. Boom, NULL pointer dereference! A crash.
Let's check `gfs2_quota_hold` for defensive programming. Does it at least *check* if the quota system is initialized before accessing the bitmap? Looking at the code:
```c
if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
return 0;
```
Nope! It just checks if quotas are disabled, not if the quota bitmap has been properly initialized. So, if `iput(sdp->sd_statfs_inode)` gets called before `gfs2_quota_init` is even done, we're guaranteed a crash.
Wait, `gfs2_quota_hold` calls `gfs2_qa_get(ip)`.
|
| 49/2 |
2026/06/28 00:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/quota.c Name:gfs2_qa_get]
Results: map[SourceCode: 539: /**
540: * gfs2_qa_get - make sure we have a quota allocations data structure,
541: * if necessary
542: * @ip: the inode for this reservation
543: */
544: int gfs2_qa_get(struct gfs2_inode *ip)
545: {
546: struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
547: struct inode *inode = &ip->i_inode;
548:
549: if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
550: return 0;
551:
552: spin_lock(&inode->i_lock);
553: if (ip->i_qadata == NULL) {
554: struct gfs2_qadata *tmp;
555:
556: spin_unlock(&inode->i_lock);
557: tmp = kmem_cache_zalloc(gfs2_qadata_cachep, GFP_NOFS);
558: if (!tmp)
559: return -ENOMEM;
560:
561: spin_lock(&inode->i_lock);
562: if (ip->i_qadata == NULL)
563: ip->i_qadata = tmp;
564: else
565: kmem_cache_free(gfs2_qadata_cachep, tmp);
566: }
567: ip->i_qadata->qa_ref++;
568: spin_unlock(&inode->i_lock);
569: return 0;
570: }
SourceFile:fs/gfs2/quota.c]
|
| 50/2 |
2026/06/28 00:35 |
llm |
expert |
0m
Model:
Tokens:
input: 45162
output: 36
thoughts: 59
Thoughts: Okay, here's my interpretation of this code snippet, expressed as if it's my own thought process:
**Diving into the Quota Implementation**
Alright, so I'm looking at this `gfs2_quota_hold` function. It seems like the core of how GFS2 manages quotas. My initial thought is that it's designed to *acquire* a quota structure, probably related to a specific user (or group) on this filesystem. The code snippet shows `gfs2_quota_hold` making a crucial call: `qdsb_get(sdp, make_kqid_uid(ip->i_inode.i_uid), qd);`. So it's getting some kind of quota descriptor block. `sdp` is probably a pointer to the superblock data, and the `make_kqid_uid(ip->i_inode.i_uid)` part is interesting. It's constructing a unique quota ID based on the inode's user ID. So, we're likely tying the quota to the user who owns this inode. The `qd` is likely a pointer to a quota descriptor, which, from context, looks like where we'll be storing data about the quota we're holding.
This `qdsb_get` call then goes deeper, calling `qd_get(sdp, qid, qdp);`. Ah, it looks like `qdsb_get` is just a thin wrapper. The real work is being done by `qd_get`. We are passing the superblock data again (`sdp`), this unique quota ID (`qid`) we generated earlier, and finally the quota descriptor pointer (`qdp`) which looks like where the quota data will be retrieved and/or updated. I need to dig into the implementations of `qdsb_get` and `qd_get` to fully understand what's happening. I expect `qd_get` to perform the actual lookup and potentially allocation of the quota structure. It's likely checking some sort of cache or on-disk structure to find the relevant quota information.
|
| 51/2 |
2026/06/28 00:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:fs/gfs2/quota.c Name:qd_get]
Results: map[SourceCode: 279: static int qd_get(struct gfs2_sbd *sdp, struct kqid qid,
280: struct gfs2_quota_data **qdp)
281: {
282: struct gfs2_quota_data *qd, *new_qd;
283: unsigned int hash = gfs2_qd_hash(sdp, qid);
284:
285: rcu_read_lock();
286: *qdp = qd = gfs2_qd_search_bucket(hash, sdp, qid);
287: rcu_read_unlock();
288:
289: if (qd)
290: return 0;
291:
292: new_qd = qd_alloc(hash, sdp, qid);
293: if (!new_qd)
294: return -ENOMEM;
295:
296: spin_lock(&qd_lock);
297: spin_lock_bucket(hash);
298: *qdp = qd = gfs2_qd_search_bucket(hash, sdp, qid);
299: if (qd == NULL) {
300: *qdp = new_qd;
301: list_add(&new_qd->qd_list, &sdp->sd_quota_list);
302: hlist_bl_add_head_rcu(&new_qd->qd_hlist, &qd_hash_table[hash]);
303: atomic_inc(&sdp->sd_quota_count);
304: }
305: spin_unlock_bucket(hash);
306: spin_unlock(&qd_lock);
307:
308: if (qd) {
309: gfs2_glock_put(new_qd->qd_gl);
310: kmem_cache_free(gfs2_quotad_cachep, new_qd);
311: }
312:
313: return 0;
314: }
SourceFile:fs/gfs2/quota.c]
|
| 52/2 |
2026/06/28 00:35 |
llm |
expert |
0m
Model:
Tokens:
input: 46315
output: 66
thoughts: 782
Thoughts: **Analysis of the GFS2 NULL Pointer Dereference**
Okay, let's break this down. From the code, it's clear that the crash occurs within `qdsb_get` when it calls `slot_get(*qdp)`, which subsequently accesses `sdp->sd_quota_bitmap`. My immediate thought is, "Aha! If `sdp->sd_quota_bitmap` is NULL, we're going to crash."
The bug report confirms this: a general protection fault, a KASAN null-pointer dereference at address 0, which KASAN's shadow memory maps to. Classic. Definitely a NULL pointer dereference.
Now, the important questions: Is this exploitable? No, it's a NULL pointer dereference. Denial of service? Yes, it crashes the kernel. Unprivileged user trigger? No, mounting a GFS2 filesystem requires `CAP_SYS_ADMIN` in the initial namespace. User namespace trigger? No, GFS2 doesn't support `FS_USERNS_MOUNT`. Malicious filesystem trigger? Yes, definitely.
Let's quickly ensure there are no other ways to trigger this, other than mounting a GFS2 filesystem. Nope, this is firmly embedded in the GFS2 code.
Let's summarize the dimensions:
* Exploitable: No.
* Denial Of Service: Yes.
* Unprivileged Access: No.
* User Namespace Access: No.
* VM Guest Trigger: No.
* VM Host Trigger (Confidential Computing): No.
* Ethernet Network Trigger: No.
* Other Remote Trigger: No.
* Peripheral Trigger: Potentially, if someone plugs in a USB drive with a malicious GFS2 image and it's auto-mounted.
* Malicious Filesystem Trigger: Yes.
Now, is there a chance that `sdp->sd_quota_bitmap` is not NULL but pointing to an arbitrary memory location, a corrupted pointer? I'm going to quickly review the code where this field is managed. In `gfs2_quota_cleanup`, `sdp->sd_quota_bitmap` is explicitly freed and set to NULL. In `gfs2_quota_init`, if allocation fails, it will set `sdp->sd_quota_bitmap` to NULL. Therefore it can only be NULL or a valid pointer. Thus, it is a pure NULL pointer dereference.
Let me see if there are other fields which may be corrupted. The crash is in the line `find_first_zero_bit(sdp->sd_quota_bitmap, sdp->sd_quota_slots);`, where the code is dereferencing `sdp->sd_quota_bitmap` which is null. I don't see anything exploitable here.
Time to move on and set the results.
|
| 53/2 |
2026/06/28 00:35 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:false FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:true NetworkTrigger:false PeripheralTrigger:true RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 54/2 |
2026/06/28 00:35 |
llm |
expert |
0m
Model:
Tokens:
input: 47842
output: 573
thoughts: 346
Thoughts: **My Analysis of the GFS2 Filesystem Kernel Panic**
Okay, the analysis is complete, and it's time to summarize the findings. The root cause is a classic NULL pointer dereference in the `slot_get` function. This happens when the kernel attempts to access `sdp->sd_quota_bitmap` after it's been freed.
The key sequence that triggers this is: the filesystem's superblock (`gfs2_put_super`) calls `gfs2_quota_cleanup(sdp)`. This crucial function frees the quota bitmap associated with the superblock, setting `sdp->sd_quota_bitmap` to NULL. Later, within the same function (`gfs2_put_super`), `iput(sdp->sd_statfs_inode)` is called. If the filesystem itself is corrupted, specifically if the `statfs` inode has a link count of zero (a likely consequence of corruption), the `iput` call initiates inode eviction.
The eviction process, traced from `gfs2_evict_inode` down to `evict_unlinked_inode`, and then further down to `gfs2_dinode_dealloc`, ultimately leads to `gfs2_quota_hold`. This function eventually calls `qdsb_get` and, critically, `slot_get`. It's within `slot_get` that the NULL pointer dereference occurs when it tries to access the now-invalid `sdp->sd_quota_bitmap`.
The impact is a denial-of-service, a kernel panic. Thankfully, it's not directly exploitable for privilege escalation or memory corruption. It's a clean NULL pointer dereference, which is good from a security perspective. The bug cannot be triggered by unprivileged users or from user namespaces, because mounting a `gfs2` filesystem requires the `CAP_SYS_ADMIN` capability in the initial user namespace. This also means that `FS_USERNS_MOUNT` is not set for `gfs2`.
However, it's still a significant vulnerability because it can be triggered by a malicious filesystem image. This makes it relevant in scenarios involving peripheral triggers such as auto-mounting a compromised USB drive or similar automated filesystem handling scenarios.
|
| 55/1 |
2026/06/28 00:35 |
action |
format-explanation |
0m
Results: map[Explanation:Based on the analysis of the bug report and the kernel source code, here is the
assessment of the vulnerability:
**Vulnerability Details:**
The bug is a NULL pointer dereference in `slot_get()` within the `gfs2`
filesystem code.
During the unmounting of a `gfs2` filesystem, `gfs2_put_super()` is called. This
function first cleans up the quota subsystem by calling
`gfs2_quota_cleanup(sdp)`, which frees `sdp->sd_quota_bitmap` and explicitly
sets it to `NULL`.
Later in the same function, `iput(sdp->sd_statfs_inode)` is called to release
the system `statfs` inode. If a maliciously crafted filesystem image is mounted
where this system inode has a link count of 0 (`i_nlink == 0`), the `iput()`
call will trigger the inode eviction path. The eviction process
(`gfs2_evict_inode` -> `evict_unlinked_inode` -> `gfs2_dinode_dealloc` ->
`gfs2_quota_hold` -> `qdsb_get` -> `slot_get`) attempts to acquire a quota slot
and accesses `sdp->sd_quota_bitmap`. Since the bitmap was already freed and set
to `NULL`, this results in a general protection fault (NULL pointer
dereference).
**Exploitability:**
The bug is a pure NULL pointer dereference (as indicated by the KASAN report
showing a fault on the shadow address `0xdffffc0000000000` corresponding to
`0x0000000000000000`). On modern systems with `mmap_min_addr` protections, NULL
pointer dereferences cannot be mapped by user-space and are therefore not
exploitable for memory corruption or privilege escalation. It strictly results
in a kernel panic.
**Accessibility:**
The `gfs2` filesystem does not have the `FS_USERNS_MOUNT` flag set, meaning it
cannot be mounted inside unprivileged user namespaces. Mounting a `gfs2` image
requires `CAP_SYS_ADMIN` in the initial (root) namespace. Therefore, the bug
cannot be triggered by an unprivileged local attacker.
**Trigger Vectors:**
The bug is triggered by mounting and subsequently unmounting (or failing to
mount) a maliciously crafted `gfs2` filesystem image. This classifies it as a
**Malicious Filesystem Trigger**. Consequently, it can also act as a
**Peripheral Trigger** in environments (like certain Desktop setups) where
external media (e.g., USB drives) are automatically mounted upon insertion.]
|