coresight: etm4x: Don't use virtual contextID for non-root PID namespace
authorLeo Yan <leo.yan@linaro.org>
Fri, 4 Feb 2022 15:24:01 +0000 (23:24 +0800)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Tue, 22 Feb 2022 16:00:26 +0000 (16:00 +0000)
commit058c09abfe3d9f8e9c5d43a7183c1d8c0fad298c
tree00aa743fc438d3e21f1e7d5e14316e5986df2054
parentad9331e45185e1a966df5147237ec987924874ea
coresight: etm4x: Don't use virtual contextID for non-root PID namespace

As commented in the function ctxid_pid_store(), it can cause the PID
values mismatching between context ID tracing and PID allocated in a
non-root namespace.

For this reason, when a process runs in non-root PID namespace, the
driver doesn't allow PID tracing and returns failure when access
contextID related sysfs nodes.

VMID works for virtual contextID when the kernel runs in EL2 mode with
VHE; on the other hand, the driver doesn't prevent users from accessing
it when programs run in the non-root namespace.  Thus this can lead
to same issues with contextID described above.

This patch imposes the checking on VMID related sysfs knobs and returns
failure if current process runs in non-root PID namespace.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20220204152403.71775-3-leo.yan@linaro.org
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c