• David Howells's avatar
    afs: Fix permit refcounting · 1bcab125
    David Howells authored
    Fix four refcount bugs in afs_cache_permit():
    
     (1) When checking the result of the kzalloc(), we can't just return, but
         must put 'permits'.
    
     (2) We shouldn't put permits immediately after hashing a new permit as we
         need to keep the pointer stable so that we can check to see if
         vnode->permit_cache has changed before we decide whether to assign to
         it.
    
     (3) 'permits' is being put twice.
    
     (4) We need to put either the replacement or the thing replaced after the
         assignment to vnode->permit_cache.
    
    Without this, lots of the following are seen:
    
      Kernel BUG at ffffffffa039857b [verbose debug info unavailable]
      ------------[ cut here ]------------
      Kernel BUG at ffffffffa039858a [verbose debug info unavailable]
      ------------[ cut here ]------------
    
    The addresses are in the .text..refcount section of the kafs.ko module.
    Following the relocation records for the __ex_table section shows one to be
    due to the decrement in afs_put_permits() and the other to be key_get() in
    afs_cache_permit().
    
    Occasionally, the following is seen:
    
      refcount_t overflow at afs_cache_permit+0x57d/0x5c0 [kafs] in cc1[562], uid/euid: 0/0
      WARNING: CPU: 0 PID: 562 at kernel/panic.c:657 refcount_error_report+0x9c/0xac
      ...
    Reported-by: default avatarMarc Dionne <marc.dionne@auristor.com>
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    Tested-by: default avatarMarc Dionne <marc.dionne@auristor.com>
    1bcab125
Name
Last commit
Last update
Documentation Loading commit data...
arch Loading commit data...
block Loading commit data...
certs Loading commit data...
crypto Loading commit data...
drivers Loading commit data...
firmware Loading commit data...
fs Loading commit data...
include Loading commit data...
init Loading commit data...
ipc Loading commit data...
kernel Loading commit data...
lib Loading commit data...
mm Loading commit data...
net Loading commit data...
samples Loading commit data...
scripts Loading commit data...
security Loading commit data...
sound Loading commit data...
tools Loading commit data...
usr Loading commit data...
virt Loading commit data...
.cocciconfig Loading commit data...
.get_maintainer.ignore Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README Loading commit data...