[PATCH v3 4/5] lib/vsprintf: Use in_task() for restricted pointer context check
From: Thomas Weißschuh
Date: Wed May 20 2026 - 04:45:21 EST
in_task() is a easier to read and slightly more efficient variant of
the existing tests.
Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Link: https://lore.kernel.org/lkml/20260504130044.GU3126523@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
---
lib/vsprintf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 021db95087fe..69dbd22f0e9e 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -882,7 +882,7 @@ char *restricted_pointer(char *buf, char *end, const void *ptr,
* kptr_restrict==1 cannot be used in IRQ context
* because its test for CAP_SYSLOG would be meaningless.
*/
- if (in_hardirq() || in_serving_softirq() || in_nmi()) {
+ if (!in_task()) {
if (spec.field_width == -1)
spec.field_width = 2 * sizeof(ptr);
return error_string(buf, end, "pK-error", spec);
--
2.54.0