Skip to content

Commit

Permalink
fuse: prevent folio use-after-free in readahead
Browse files Browse the repository at this point in the history
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cherry-picked-for: https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/issues/110
  • Loading branch information
tehcaster authored and heftig committed Feb 8, 2025
1 parent cb0787d commit 122edb4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,10 @@ static void fuse_readpages_end(struct fuse_mount *fm, struct fuse_args *args,
fuse_invalidate_atime(inode);
}

for (i = 0; i < ap->num_folios; i++)
for (i = 0; i < ap->num_folios; i++) {
folio_end_read(ap->folios[i], !err);
folio_put(ap->folios[i]);
}
if (ia->ff)
fuse_file_put(ia->ff, false);

Expand Down Expand Up @@ -1048,7 +1050,7 @@ static void fuse_readahead(struct readahead_control *rac)
ap = &ia->ap;

while (ap->num_folios < cur_pages) {
folio = readahead_folio(rac);
folio = __readahead_folio(rac);
ap->folios[ap->num_folios] = folio;
ap->descs[ap->num_folios].length = folio_size(folio);
ap->num_folios++;
Expand Down

0 comments on commit 122edb4

Please sign in to comment.