やるきなし

2020/04/03 22:18 / Linux 5.6.x fs/cachefiles/rdwr.c bug

The commit, cachefiles: drop direct usage of ->bmap method., included in v5.5 has a bug. The return value before list_for_each_entry_safe, that is ret = space ? -ENODATA : -ENOBUFS, overwritten by the return value of bmap. This bug exists in Linux 5.6.2 at least.

The following is a patch to fix this bug. This patch also includes https://lkml.org/lkml/2020/3/20/399.

--- a/fs/cachefiles/rdwr.c
+++ b/fs/cachefiles/rdwr.c
@@ -431,7 +431,7 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
    block <<= shift;
 
    ret = bmap(inode, &block);
-   ASSERT(ret < 0);
+   ASSERT(!ret);
 
    _debug("%llx -> %llx",
           (unsigned long long) (page->index << shift),
@@ -739,8 +739,8 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,
        block = page->index;
        block <<= shift;
 
-       ret = bmap(inode, &block);
-       ASSERT(!ret);
+       ret2 = bmap(inode, &block);
+       ASSERT(!ret2);
 
        _debug("%llx -> %llx",
               (unsigned long long) (page->index << shift),

Update (2020/5/24)

This bug has been fixed in Linux 5.6.14 while fixed in v5.7-rc6 as for the master branch.

Related articles