]> asedeno.scripts.mit.edu Git - linux.git/commit
afs: Fix permit refcounting
authorDavid Howells <dhowells@redhat.com>
Fri, 1 Dec 2017 11:40:43 +0000 (11:40 +0000)
committerDavid Howells <dhowells@redhat.com>
Fri, 1 Dec 2017 11:40:43 +0000 (11:40 +0000)
commit1bcab12521d9b23dbaa22ac71184778dcc43e2f6
treeb3b46f5710c091a5cf956d0a9deb95d470c7740a
parentdf8ba95c572a187ed2aa7403e97a7a7f58c01f00
afs: Fix permit refcounting

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: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Marc Dionne <marc.dionne@auristor.com>
fs/afs/security.c