linux-brain/fs/afs
David Howells f726817d6b afs: Fix tracepoint string placement with built-in AFS
[ Upstream commit 6c881ca0b3040f3e724eae513117ba4ddef86057 ]

To quote Alexey[1]:

    I was adding custom tracepoint to the kernel, grabbed full F34 kernel
    .config, disabled modules and booted whole shebang as VM kernel.

    Then did

	perf record -a -e ...

    It crashed:

	general protection fault, probably for non-canonical address 0x435f5346592e4243: 0000 [#1] SMP PTI
	CPU: 1 PID: 842 Comm: cat Not tainted 5.12.6+ #26
	Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-1.fc33 04/01/2014
	RIP: 0010:t_show+0x22/0xd0

    Then reproducer was narrowed to

	# cat /sys/kernel/tracing/printk_formats

    Original F34 kernel with modules didn't crash.

    So I started to disable options and after disabling AFS everything
    started working again.

    The root cause is that AFS was placing char arrays content into a
    section full of _pointers_ to strings with predictable consequences.

    Non canonical address 435f5346592e4243 is "CB.YFS_" which came from
    CM_NAME macro.

    Steps to reproduce:

	CONFIG_AFS=y
	CONFIG_TRACING=y

	# cat /sys/kernel/tracing/printk_formats

Fix this by the following means:

 (1) Add enum->string translation tables in the event header with the AFS
     and YFS cache/callback manager operations listed by RPC operation ID.

 (2) Modify the afs_cb_call tracepoint to print the string from the
     translation table rather than using the string at the afs_call name
     pointer.

 (3) Switch translation table depending on the service we're being accessed
     as (AFS or YFS) in the tracepoint print clause.  Will this cause
     problems to userspace utilities?

     Note that the symbolic representation of the YFS service ID isn't
     available to this header, so I've put it in as a number.  I'm not sure
     if this is the best way to do this.

 (4) Remove the name wrangling (CM_NAME) macro and put the names directly
     into the afs_call_type structs in cmservice.c.

Fixes: 8e8d7f13b6 ("afs: Add some tracepoints")
Reported-by: Alexey Dobriyan (SK hynix) <adobriyan@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
cc: Andrew Morton <akpm@linux-foundation.org>
cc: linux-afs@lists.infradead.org
Link: https://lore.kernel.org/r/YLAXfvZ+rObEOdc%2F@localhost.localdomain/ [1]
Link: https://lore.kernel.org/r/643721.1623754699@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/162430903582.2896199.6098150063997983353.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/162609463957.3133237.15916579353149746363.stgit@warthog.procyon.org.uk/ # v1 (repost)
Link: https://lore.kernel.org/r/162610726860.3408253.445207609466288531.stgit@warthog.procyon.org.uk/ # v2
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-28 13:30:58 +02:00
..
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile afs: do not send list of client addresses 2019-06-02 18:06:26 -07:00
addr_list.c Keyrings namespacing 2019-07-08 19:36:47 -07:00
afs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
afs_cm.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
afs_fs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
afs_vl.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
cache.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
callback.c afs: Fix possible assert with callbacks from yfs servers 2019-11-22 14:19:26 -08:00
cell.c afs: Fix storage of cell names 2020-06-30 15:37:02 -04:00
cmservice.c afs: Fix tracepoint string placement with built-in AFS 2021-07-28 13:30:58 +02:00
dir.c afs: Stop listxattr() from listing "afs.*" attributes 2021-03-24 11:26:37 +01:00
dir_edit.c afs: Remove set but not used variables 'before', 'after' 2020-01-26 10:01:08 +01:00
dir_silly.c afs: Fix race between post-modification dir edit and readdir/d_revalidate 2020-04-23 10:36:25 +02:00
dynroot.c afs: Fix NULL deref in afs_dynroot_depopulate() 2020-08-26 10:41:05 +02:00
file.c afs: Stop listxattr() from listing "afs.*" attributes 2021-03-24 11:26:37 +01:00
flock.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
fs_probe.c rxrpc: Make rxrpc_kernel_get_srtt() indicate validity 2020-09-09 19:12:23 +02:00
fsclient.c afs: Set error flag rather than return error from file status decode 2020-06-24 17:50:46 +02:00
inode.c afs: Stop listxattr() from listing "afs.*" attributes 2021-03-24 11:26:37 +01:00
internal.h afs: Stop listxattr() from listing "afs.*" attributes 2021-03-24 11:26:37 +01:00
main.c afs: Fix an IS_ERR() vs NULL check 2021-06-23 14:41:23 +02:00
misc.c afs: Fix the mapping of the UAEOVERFLOW abort code 2020-06-24 17:50:46 +02:00
mntpt.c afs: Stop listxattr() from listing "afs.*" attributes 2021-03-24 11:26:37 +01:00
proc.c afs: Fix memory leak in afs_put_sysnames() 2020-06-24 17:50:42 +02:00
protocol_uae.h afs: Add support for the UAE error table 2019-06-28 18:37:53 +01:00
protocol_yfs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00
rotate.c afs: Make record checking use TASK_UNINTERRUPTIBLE when appropriate 2020-05-02 08:48:43 +02:00
rxrpc.c afs: Set error flag rather than return error from file status decode 2020-06-24 17:50:46 +02:00
security.c afs: Support RCU pathwalk 2019-09-02 11:43:54 +01:00
server.c afs: Make record checking use TASK_UNINTERRUPTIBLE when appropriate 2020-05-02 08:48:43 +02:00
server_list.c AFS development 2019-07-10 20:55:33 -07:00
super.c afs: Fix memory leak when mounting with multiple source parameters 2020-12-30 11:50:54 +01:00
vl_list.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
vl_probe.c rxrpc: Make rxrpc_kernel_get_srtt() indicate validity 2020-09-09 19:12:23 +02:00
vl_rotate.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00
vlclient.c afs: Fix loop index mixup in afs_deliver_vl_get_entry_by_name_u() 2019-07-30 14:38:51 +01:00
volume.c afs: Make record checking use TASK_UNINTERRUPTIBLE when appropriate 2020-05-02 08:48:43 +02:00
write.c afs: afs_write_end() should change i_size under the right lock 2020-06-24 17:50:46 +02:00
xattr.c afs: Stop listxattr() from listing "afs.*" attributes 2021-03-24 11:26:37 +01:00
xdr_fs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00
yfsclient.c afs: Fix warning due to unadvanced marshalling pointer 2020-11-18 19:20:18 +01:00