linux/fs/afs
David Howells 1bcab12521 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>
2017-12-01 11:40:43 +00:00
..
addr_list.c afs: Make use of the YFS service upgrade to fully support IPv6 2017-11-13 15:38:19 +00:00
afs_cm.h afs: support the CB.ProbeUuid RPC op 2008-04-29 08:06:26 -07:00
afs_fs.h afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00
afs_vl.h afs: Make use of the YFS service upgrade to fully support IPv6 2017-11-13 15:38:19 +00:00
afs.h afs: Overhaul permit caching 2017-11-13 15:38:18 +00:00
cache.c afs: Update the cache index structure 2017-11-13 15:38:17 +00:00
callback.c afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00
cell.c afs: cell: Remove unnecessary code in afs_lookup_cell 2017-11-24 13:55:45 +00:00
cmservice.c afs: Protect call->state changes against signals 2017-11-13 15:38:21 +00:00
dir.c afs: remove redundant assignment of dvnode to itself 2017-11-24 13:55:46 +00:00
file.c afs: Trace page dirty/clean 2017-11-13 15:38:21 +00:00
flock.c afs: Fix file locking 2017-11-17 10:06:13 +00:00
fsclient.c afs: Get rid of the afs_writeback record 2017-11-13 15:38:20 +00:00
inode.c afs: Get rid of the afs_writeback record 2017-11-13 15:38:20 +00:00
internal.h afs: Fix file locking 2017-11-17 10:06:13 +00:00
Kconfig fs/afs: remove depends on CONFIG_EXPERIMENTAL 2013-01-21 14:39:04 -08:00
main.c afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00
Makefile afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00
misc.c afs: Consolidate abort_to_error translators 2017-11-13 15:38:17 +00:00
mntpt.c afs: Add metadata xattrs 2017-07-09 14:40:12 -07:00
netdevices.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
proc.c afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00
rotate.c afs: Fix file locking 2017-11-17 10:06:13 +00:00
rxrpc.c afs: Protect call->state changes against signals 2017-11-13 15:38:21 +00:00
security.c afs: Fix permit refcounting 2017-12-01 11:40:43 +00:00
server_list.c afs: Fix file locking 2017-11-17 10:06:13 +00:00
server.c afs: Make use of the YFS service upgrade to fully support IPv6 2017-11-13 15:38:19 +00:00
super.c Rename superblock flags (MS_xyz -> SB_xyz) 2017-11-27 13:05:09 -08:00
vlclient.c afs: Trace the initiation and completion of client calls 2017-11-13 15:38:19 +00:00
volume.c afs: Make use of the YFS service upgrade to fully support IPv6 2017-11-13 15:38:19 +00:00
write.c afs: Make afs_write_begin() avoid writing to a page that's being stored 2017-11-24 10:56:51 +00:00
xattr.c afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00