Skip to contentSkip to conversation

potential race in FUSE's readdir() + releasedir()?

DISCUSSION Nikolaus Rath 2 participants 3 messages Jul 3, 2022 – Jul 11, 2022 VFS

lore
Share & tools
lore
#0 lore raw

Hello,

I am seeing something that to me looks like a race between FUSE's readdir() and releasedir() handlers. On kernel 5.18, the FUSE daemon seems to (ocasionally) receive a releasedir() request while a readdir() request with the same struct fuse_file_info *fi->fh is still active (i.e., the FUSE daemon hasn't sent a reply to the kernel for this yet).

Could this be a bug in the kernel? Or is there something else that could explain this?

Best,
-Nikolaus

Signature · 3 lines
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«
#1 lore raw
Quoted 11 lines · Nikolaus Rath

Hello,

I am seeing something that to me looks like a race between FUSE's readdir() and releasedir() handlers. On kernel 5.18, the FUSE daemon seems to (ocasionally) receive a releasedir() request while a readdir() request with the same struct fuse_file_info *fi->fh is still active (i.e., the FUSE daemon hasn't sent a reply to the kernel for this yet).

Could this be a bug in the kernel? Or is there something else that could explain this?

Is there a log where this can be observed?

Thanks,
Miklos
\

#2 lore raw
Quoted 10 lines · Miklos Szeredi
Quoted 9 lines · Nikolaus Rath

Hello,

I am seeing something that to me looks like a race between FUSE's readdir() and releasedir() handlers. On kernel 5.18, the FUSE daemon seems to (ocasionally) receive a releasedir() request while a readdir() request with the same struct fuse_file_info *fi->fh is still active (i.e., the FUSE daemon hasn't sent a reply to the kernel for this yet).

Quoted 4 lines
Quoted 2 lines

Could this be a bug in the kernel? Or is there something else that could explain this?

Is there a log where this can be observed?

Not so far, I haven't been able to reproduce it with debug logging enabled.

The way that I'm inferring what's happening is from a crash due to writing to freed memory. My fi->fh points to a malloc'ed area that is free'd in releasedir(), and written to in readdir().

Best,
-Nikolaus

Signature · 3 lines
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«