linux-stable/drivers
David Howells 0837e49ab3 KEYS: Differentiate uses of rcu_dereference_key() and user_key_payload()
rcu_dereference_key() and user_key_payload() are currently being used in
two different, incompatible ways:

 (1) As a wrapper to rcu_dereference() - when only the RCU read lock used
     to protect the key.

 (2) As a wrapper to rcu_dereference_protected() - when the key semaphor is
     used to protect the key and the may be being modified.

Fix this by splitting both of the key wrappers to produce:

 (1) RCU accessors for keys when caller has the key semaphore locked:

	dereference_key_locked()
	user_key_payload_locked()

 (2) RCU accessors for keys when caller holds the RCU read lock:

	dereference_key_rcu()
	user_key_payload_rcu()

This should fix following warning in the NFS idmapper

  ===============================
  [ INFO: suspicious RCU usage. ]
  4.10.0 #1 Tainted: G        W
  -------------------------------
  ./include/keys/user-type.h:53 suspicious rcu_dereference_protected() usage!
  other info that might help us debug this:
  rcu_scheduler_active = 2, debug_locks = 0
  1 lock held by mount.nfs/5987:
    #0:  (rcu_read_lock){......}, at: [<d000000002527abc>] nfs_idmap_get_key+0x15c/0x420 [nfsv4]
  stack backtrace:
  CPU: 1 PID: 5987 Comm: mount.nfs Tainted: G        W       4.10.0 #1
  Call Trace:
    dump_stack+0xe8/0x154 (unreliable)
    lockdep_rcu_suspicious+0x140/0x190
    nfs_idmap_get_key+0x380/0x420 [nfsv4]
    nfs_map_name_to_uid+0x2a0/0x3b0 [nfsv4]
    decode_getfattr_attrs+0xfac/0x16b0 [nfsv4]
    decode_getfattr_generic.constprop.106+0xbc/0x150 [nfsv4]
    nfs4_xdr_dec_lookup_root+0xac/0xb0 [nfsv4]
    rpcauth_unwrap_resp+0xe8/0x140 [sunrpc]
    call_decode+0x29c/0x910 [sunrpc]
    __rpc_execute+0x140/0x8f0 [sunrpc]
    rpc_run_task+0x170/0x200 [sunrpc]
    nfs4_call_sync_sequence+0x68/0xa0 [nfsv4]
    _nfs4_lookup_root.isra.44+0xd0/0xf0 [nfsv4]
    nfs4_lookup_root+0xe0/0x350 [nfsv4]
    nfs4_lookup_root_sec+0x70/0xa0 [nfsv4]
    nfs4_find_root_sec+0xc4/0x100 [nfsv4]
    nfs4_proc_get_rootfh+0x5c/0xf0 [nfsv4]
    nfs4_get_rootfh+0x6c/0x190 [nfsv4]
    nfs4_server_common_setup+0xc4/0x260 [nfsv4]
    nfs4_create_server+0x278/0x3c0 [nfsv4]
    nfs4_remote_mount+0x50/0xb0 [nfsv4]
    mount_fs+0x74/0x210
    vfs_kern_mount+0x78/0x220
    nfs_do_root_mount+0xb0/0x140 [nfsv4]
    nfs4_try_mount+0x60/0x100 [nfsv4]
    nfs_fs_mount+0x5ec/0xda0 [nfs]
    mount_fs+0x74/0x210
    vfs_kern_mount+0x78/0x220
    do_mount+0x254/0xf70
    SyS_mount+0x94/0x100
    system_call+0x38/0xe0

Reported-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
2017-03-02 10:09:00 +11:00
..
accessibility
acpi pwm: Changes for v4.11-rc1 2017-03-01 09:46:02 -08:00
amba
android mm, fs: reduce fault, page_mkwrite, and pfn_mkwrite to take only vmf 2017-02-24 17:46:54 -08:00
ata scripts/spelling.txt: add "followings" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
atm Merge branch 'idr-4.11' of git://git.infradead.org/users/willy/linux-dax 2017-02-28 20:29:41 -08:00
auxdisplay
base memory-hotplug: use dev_online for memhp_auto_online 2017-02-24 17:46:56 -08:00
bcma
block Merge branch 'idr-4.11' of git://git.infradead.org/users/willy/linux-dax 2017-02-28 20:29:41 -08:00
bluetooth btmrvl: fix spelling mistake: "actived" -> "activated" 2017-02-19 00:26:37 +01:00
bus ARM: SoC driver updates 2017-02-23 15:57:04 -08:00
cdrom Merge branch 'for-4.11/next' into for-4.11/linus-merge 2017-02-17 14:08:19 -07:00
char This is a few small fixes to the main IPMI driver, make some 2017-02-28 21:06:30 -08:00
clk The usual collection of new drivers, non-critical fixes, and updates 2017-02-25 14:28:06 -08:00
clocksource Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-02-20 10:06:32 -08:00
connector
cpufreq ARM: SoC non-urgent fixes for merge window 2017-02-23 15:28:04 -08:00
cpuidle powerpc updates for 4.11 part 1. 2017-02-22 10:30:38 -08:00
crypto Merge branch 'akpm' (patches from Andrew) 2017-02-27 23:09:29 -08:00
dax mm: replace FAULT_FLAG_SIZE with parameter to huge_fault 2017-02-24 17:46:54 -08:00
dca
devfreq scripts/spelling.txt: add "followings" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
dio
dma TTY/Serial driver patches for 4.11-rc1 2017-02-22 12:17:25 -08:00
dma-buf dma-buf: add support for compat ioctl 2017-02-27 17:23:47 +05:30
edac Merge branch 'ras-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-02-20 12:47:44 -08:00
eisa
extcon scripts/spelling.txt: add "swithc" pattern and fix typo instances 2017-02-27 18:43:46 -08:00
firewire Merge branch 'idr-4.11' of git://git.infradead.org/users/willy/linux-dax 2017-02-28 20:29:41 -08:00
firmware ARM: SoC driver updates 2017-02-23 15:57:04 -08:00
fmc
fpga
fsi
gpio This is the bulk of GPIO changes for the v4.11 cycle 2017-02-23 08:46:04 -08:00
gpu AST 2500 support for v4.11 - new hardware 2017-03-01 09:42:42 -08:00
hid scripts/spelling.txt: add "comsume(r)" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
hsi mm, fs: reduce fault, page_mkwrite, and pfn_mkwrite to take only vmf 2017-02-24 17:46:54 -08:00
hv
hwmon scripts/spelling.txt: add "followings" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
hwspinlock
hwtracing mm, fs: reduce fault, page_mkwrite, and pfn_mkwrite to take only vmf 2017-02-24 17:46:54 -08:00
i2c Merge branch 'i2c/for-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2017-02-25 14:21:18 -08:00
ide Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide 2017-02-28 10:13:40 -08:00
idle
iio
infiniband Merge branch 'akpm' (patches from Andrew) 2017-02-27 23:09:29 -08:00
input Input: rmi4 - f30: detect INPUT_PROP_BUTTONPAD from the button count 2017-03-01 10:01:56 -08:00
iommu iommu/amd: Fix crash when accessing AMD-Vi sysfs entries 2017-02-28 15:48:23 +01:00
ipack
irqchip IOMMU Updates for Linux v4.11 2017-02-20 16:42:43 -08:00
isdn scripts/spelling.txt: add "followings" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
leds pwm: Changes for v4.11-rc1 2017-03-01 09:46:02 -08:00
lguest
lightnvm
macintosh driver core patches for 4.11-rc1 2017-02-22 11:44:32 -08:00
mailbox
mcb
md KEYS: Differentiate uses of rcu_dereference_key() and user_key_payload() 2017-03-02 10:09:00 +11:00
media lib/vsprintf.c: remove %Z support 2017-02-27 18:43:47 -08:00
memory ARM: SoC driver updates 2017-02-23 15:57:04 -08:00
memstick Merge branch 'for-4.11/next' into for-4.11/linus-merge 2017-02-17 14:08:19 -07:00
message SCSI misc on 20170220 2017-02-21 11:51:42 -08:00
mfd staging/iio driver patches for 4.11-rc1 2017-02-22 12:14:01 -08:00
misc powerpc updates for 4.11 part 2 2017-03-01 10:10:16 -08:00
mmc scripts/spelling.txt: add "intialization" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
mtd Merge branch 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm 2017-02-28 11:50:53 -08:00
net Merge branch 'idr-4.11' of git://git.infradead.org/users/willy/linux-dax 2017-02-28 20:29:41 -08:00
nfc scripts/spelling.txt: add "omited" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
ntb ntb: ntb_hw_intel: link_poll isn't clearing the pending status properly 2017-02-16 23:11:26 -05:00
nubus
nvdimm
nvme scripts/spelling.txt: add "embeded" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
nvmem
of DeviceTree updates for 4.11: 2017-02-22 19:23:14 -08:00
oprofile
parisc
parport lib/vsprintf.c: remove %Z support 2017-02-27 18:43:47 -08:00
pci powerpc updates for 4.11 part 2 2017-03-01 10:10:16 -08:00
pcmcia
perf
phy pci-v4.11-changes 2017-02-23 11:53:22 -08:00
pinctrl scripts/spelling.txt: add "overrided" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
platform platform-drivers-x86 for v4.11-1 2017-02-25 14:35:37 -08:00
pnp
power scripts/spelling.txt: add "intialization" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
powercap
pps
ps3
ptp 4.11 is going to be a relatively large release for KVM, with a little over 2017-02-22 18:22:53 -08:00
pwm pwm: Changes for v4.11-rc1 2017-03-01 09:46:02 -08:00
rapidio rapidio: use get_user_pages_unlocked() 2017-02-27 18:43:45 -08:00
ras
regulator regulator: Updates for v4.11 2017-02-20 17:23:57 -08:00
remoteproc remoteproc: qcom: mdt_loader: Use signed type for offset 2017-02-22 02:07:13 -08:00
reset ARM: SoC driver updates 2017-02-23 15:57:04 -08:00
rpmsg
rtc RTC for 4.11 2017-02-27 19:59:21 -08:00
s390 s390/dasd: fix spelling mistake: "supportet" -> "supported" 2017-02-23 13:01:20 +01:00
sbus
scsi lib/vsprintf.c: remove %Z support 2017-02-27 18:43:47 -08:00
sfi
sh
sn
soc ARM: SoC driver updates 2017-02-23 15:57:04 -08:00
spi ACPI updates for v4.11-rc1 2017-02-20 17:55:15 -08:00
spmi
ssb
staging pwm: Changes for v4.11-rc1 2017-03-01 09:46:02 -08:00
target Merge branch 'idr-4.11' of git://git.infradead.org/users/willy/linux-dax 2017-02-28 20:29:41 -08:00
tc
thermal Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux 2017-03-01 09:54:32 -08:00
thunderbolt
tty lib/vsprintf.c: remove %Z support 2017-02-27 18:43:47 -08:00
uio mm, fs: reduce fault, page_mkwrite, and pfn_mkwrite to take only vmf 2017-02-24 17:46:54 -08:00
usb lib/vsprintf.c: remove %Z support 2017-02-27 18:43:47 -08:00
uwb
vfio VFIO updates for v4.11 2017-02-23 11:26:09 -08:00
vhost
video lib/vsprintf.c: remove %Z support 2017-02-27 18:43:47 -08:00
virt
virtio mm balloon: umount balloon_mnt when removing vb device 2017-02-24 17:46:56 -08:00
vlynq
vme
w1
watchdog scripts/spelling.txt: add "partiton" pattern and fix typo instances 2017-02-27 18:43:46 -08:00
xen mm, fs: reduce fault, page_mkwrite, and pfn_mkwrite to take only vmf 2017-02-24 17:46:54 -08:00
zorro
Kconfig
Makefile pci-v4.11-changes 2017-02-23 11:53:22 -08:00