• David Howells's avatar
    cachefiles: Fix an assertion failure when trying to update a failed object · e6bc06fa
    David Howells authored
    If cachefiles gets an error other then ENOENT when trying to look up an
    object in the cache (in this case, EACCES), the object state machine will
    eventually transition to the DROP_OBJECT state.
    This state invokes fscache_drop_object() which tries to sync the auxiliary
    data with the cache (this is done lazily since commit 402cb8dd) on an
    incomplete cache object struct.
    The problem comes when cachefiles_update_object_xattr() is called to
    rewrite the xattr holding the data.  There's an assertion there that the
    cache object points to a dentry as we're going to update its xattr.  The
    assertion trips, however, as dentry didn't get set.
    Fix the problem by skipping the update in cachefiles if the object doesn't
    refer to a dentry.  A better way to do it could be to skip the update from
    the DROP_OBJECT state handler in fscache, but that might deny the cache the
    opportunity to update intermediate state.
    If this error occurs, the kernel log includes lines that look like the
     CacheFiles: Lookup failed error -13
     CacheFiles: Assertion failed
     ------------[ cut here ]------------
     kernel BUG at fs/cachefiles/xattr.c:138!
     Workqueue: fscache_object fscache_object_work_func [fscache]
     RIP: 0010:cachefiles_update_object_xattr.cold.4+0x18/0x1a [cachefiles]
     Call Trace:
      cachefiles_update_object+0xdd/0x1c0 [cachefiles]
      fscache_update_aux_data+0x23/0x30 [fscache]
      fscache_drop_object+0x18e/0x1c0 [fscache]
      fscache_object_work_func+0x74/0x2b0 [fscache]
      ? pwq_unbound_release_workfn+0xd0/0xd0
      ? kthread_bind+0x30/0x30
    Note that there are actually two issues here: (1) EACCES happened on a
    cache object and (2) an oops occurred.  I think that the second is a
    consequence of the first (it certainly looks like it ought to be).  This
    patch only deals with the second.
    Fixes: 402cb8dd ("fscache: Attach the index key and aux data to the cookie")
    Reported-by: default avatarZhibin Li <zhibli@redhat.com>
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
xattr.c 7.26 KB