Skip to contentSkip to conversation

FAILED: patch "[PATCH] kprobes: Fix to protect kick_kprobe_optimizer() by" failed to apply to 4.9-stable tree

PATCH [email protected] 3 participants 4 messages Jun 23, 2020

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 1a0aa991a6274161c95a844c58cfb801d681eb59 Mon Sep 17 00:00:00 2001
From: Masami Hiramatsu <[email protected]>
Date: Tue, 12 May 2020 17:02:56 +0900
Subject: [PATCH] kprobes: Fix to protect kick_kprobe_optimizer() by
kprobe_mutex

In kprobe_optimizer() kick_kprobe_optimizer() is called without kprobe_mutex, but this can race with other caller which is protected by kprobe_mutex.

To fix that, expand kprobe_mutex protected area to protect kick_kprobe_optimizer() call.

Fixes cd7ebe2298ff ("kprobes: Use text_poke_smp_batch for optimizing")
Cc Ingo Molnar <[email protected]>
Cc "Gustavo A . R . Silva" <[email protected]>
Cc Anders Roxell <[email protected]>
Cc "Naveen N . Rao" <[email protected]>
Cc Anil S Keshavamurthy <[email protected]>
Cc David Miller <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ziqian SUN <[email protected]>
kernel/kprobes.c +2 -1
index ceb0e273bd69..0e185763578b 100644
@@ -592,11 +592,12 @@ static void kprobe_optimizer(struct work_struct *work)
 	mutex_unlock(&module_mutex);
 	mutex_unlock(&text_mutex);
 	cpus_read_unlock();
-	mutex_unlock(&kprobe_mutex);
 
 	/* Step 5: Kick optimizer again if needed */
 	if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list))
 		kick_kprobe_optimizer();
+
+	mutex_unlock(&kprobe_mutex);
 }
 
 /* Wait for completing optimization and unoptimization */
maintainer
#1 lore raw
Quoted 27 lines · On Tue, Jun 23, 2020 at 01:57:26PM +0200, [email protected] wrote:

The patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 1a0aa991a6274161c95a844c58cfb801d681eb59 Mon Sep 17 00:00:00 2001
From: Masami Hiramatsu <[email protected]>
Date: Tue, 12 May 2020 17:02:56 +0900
Subject: [PATCH] kprobes: Fix to protect kick_kprobe_optimizer() by kprobe_mutex

In kprobe_optimizer() kick_kprobe_optimizer() is called without kprobe_mutex, but this can race with other caller which is protected by kprobe_mutex.

To fix that, expand kprobe_mutex protected area to protect kick_kprobe_optimizer() call.

Quoted 13 lines
Fixes cd7ebe2298ff ("kprobes: Use text_poke_smp_batch for optimizing")
Cc Ingo Molnar <[email protected]>
Cc "Gustavo A . R . Silva" <[email protected]>
Cc Anders Roxell <[email protected]>
Cc "Naveen N . Rao" <[email protected]>
Cc Anil S Keshavamurthy <[email protected]>
Cc David Miller <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ziqian SUN <[email protected]>

The conflict happened because we don't have 2d1e38f56622 ("kprobes: Cure hotplug lock ordering issues") on 4.9 and 4.4. I've fixed it up and queued for both branches.

Signature · 2 lines
Thanks,
Sasha
#2 lore raw
Quoted 3 lines · On Tue, 23 Jun 2020 09:26:28 -0400 Sasha Levin <[email protected]> wrote:

The conflict happened because we don't have 2d1e38f56622 ("kprobes: Cure hotplug lock ordering issues") on 4.9 and 4.4. I've fixed it up and queued for both branches.

Thanks Sasha!

-- Steve

author maintainer
#3 lore raw
In reply to Sasha Levin
Quoted 42 lines · Sasha Levin
Quoted 27 lines · On Tue, Jun 23, 2020 at 01:57:26PM +0200, [email protected] wrote:

The patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

Quoted 1 line

From 1a0aa991a6274161c95a844c58cfb801d681eb59 Mon Sep 17 00:00:00 2001

From: Masami Hiramatsu <[email protected]>
Date: Tue, 12 May 2020 17:02:56 +0900
Subject: [PATCH] kprobes: Fix to protect kick_kprobe_optimizer() by kprobe_mutex

In kprobe_optimizer() kick_kprobe_optimizer() is called without kprobe_mutex, but this can race with other caller which is protected by kprobe_mutex.

To fix that, expand kprobe_mutex protected area to protect kick_kprobe_optimizer() call.

Quoted 13 lines
Fixes cd7ebe2298ff ("kprobes: Use text_poke_smp_batch for optimizing")
Cc Ingo Molnar <[email protected]>
Cc "Gustavo A . R . Silva" <[email protected]>
Cc Anders Roxell <[email protected]>
Cc "Naveen N . Rao" <[email protected]>
Cc Anil S Keshavamurthy <[email protected]>
Cc David Miller <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ziqian SUN <[email protected]>
Quoted 3 lines

The conflict happened because we don't have 2d1e38f56622 ("kprobes: Cure hotplug lock ordering issues") on 4.9 and 4.4. I've fixed it up and queued for both branches.

Thanks for fixing this, and the other FAILED patches up as well.

greg k-h