Skip to contentSkip to conversation

Yama: use atomic allocations when reporting

PATCH In review Sasha Levin 2 participants 2 messages May 4, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Yama: use atomic allocations when reporting

Access reporting often happens from atomic contexes. Avoid lockups when allocating memory for command lines.

Fixes 8a56038c2ae ("Yama: consolidate error reporting")
---
 security/yama/yama_lsm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/yama/yama_lsm.c +2 -2
index c19f6e5..9b756b1 100644
@@ -47,8 +47,8 @@ static void report_access(const char *access, struct task_struct *target,
 {
 	char *target_cmd, *agent_cmd;
 
-	target_cmd = kstrdup_quotable_cmdline(target, GFP_KERNEL);
-	agent_cmd = kstrdup_quotable_cmdline(agent, GFP_KERNEL);
+	target_cmd = kstrdup_quotable_cmdline(target, GFP_ATOMIC);
+	agent_cmd = kstrdup_quotable_cmdline(agent, GFP_ATOMIC);
 
 	pr_notice_ratelimited(
 		"ptrace %s of \"%s\"[%d] was attempted by \"%s\"[%d]\n",
Signature · 1 line
1.9.1
#1 lore raw
Quoted 5 lines · Sasha Levin

Access reporting often happens from atomic contexes. Avoid lockups when allocating memory for command lines.

Fixes 8a56038c2ae ("Yama: consolidate error reporting")

Thanks for catching this! Applied.

-Kees

Quoted 22 lines
---
 security/yama/yama_lsm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/yama/yama_lsm.c +2 -3
index c19f6e5..9b756b1 100644
@@ -47,8 +47,8 @@ static void report_access(const char *access, struct task_struct *target,
 {
        char *target_cmd, *agent_cmd;
 
-       target_cmd = kstrdup_quotable_cmdline(target, GFP_KERNEL);
-       agent_cmd = kstrdup_quotable_cmdline(agent, GFP_KERNEL);
+       target_cmd = kstrdup_quotable_cmdline(target, GFP_ATOMIC);
+       agent_cmd = kstrdup_quotable_cmdline(agent, GFP_ATOMIC);
 
        pr_notice_ratelimited(
                "ptrace %s of \"%s\"[%d] was attempted by \"%s\"[%d]\n",
--

1.9.1

Signature · 2 lines
Kees Cook
Chrome OS & Brillo Security