From: Andrew Morton <akpm@linux-foundation.org> To: akpm@linux-foundation.org, anil.s.keshavamurthy@intel.com, davem@davemloft.net, linux-mm@kvack.org, mhiramat@kernel.org, mm-commits@vger.kernel.org, naveen.n.rao@linux.ibm.com, rostedt@goodmis.org, songliubraving@fb.com, songmuchun@bytedance.com, stable@vger.kernel.org, torvalds@linux-foundation.org, zhouchengming@bytedance.com Subject: [patch 08/15] kprobes: fix kill kprobe which has been marked as gone Date: Fri, 18 Sep 2020 21:20:21 -0700 Message-ID: <20200919042021.X10NZatlE%akpm@linux-foundation.org> (raw) In-Reply-To: <20200918211925.7e97f0ef63d92f5cfe5ccbc5@linux-foundation.org> From: Muchun Song <songmuchun@bytedance.com> Subject: kprobes: fix kill kprobe which has been marked as gone If a kprobe is marked as gone, we should not kill it again. Otherwise, we can disarm the kprobe more than once. In that case, the statistics of kprobe_ftrace_enabled can unbalance which can lead to that kprobe do not work. Link: https://lkml.kernel.org/r/20200822030055.32383-1-songmuchun@bytedance.com Fixes: e8386a0cb22f ("kprobes: support probing module __exit function") Signed-off-by: Muchun Song <songmuchun@bytedance.com> Co-developed-by: Chengming Zhou <zhouchengming@bytedance.com> Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Cc: "Naveen N . Rao" <naveen.n.rao@linux.ibm.com> Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Cc: David S. Miller <davem@davemloft.net> Cc: Song Liu <songliubraving@fb.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- kernel/kprobes.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/kernel/kprobes.c~kprobes-fix-kill-kprobe-which-has-been-marked-as-gone +++ a/kernel/kprobes.c @@ -2140,6 +2140,9 @@ static void kill_kprobe(struct kprobe *p lockdep_assert_held(&kprobe_mutex); + if (WARN_ON_ONCE(kprobe_gone(p))) + return; + p->flags |= KPROBE_FLAG_GONE; if (kprobe_aggrprobe(p)) { /* @@ -2419,7 +2422,10 @@ static int kprobes_module_callback(struc mutex_lock(&kprobe_mutex); for (i = 0; i < KPROBE_TABLE_SIZE; i++) { head = &kprobe_table[i]; - hlist_for_each_entry(p, head, hlist) + hlist_for_each_entry(p, head, hlist) { + if (kprobe_gone(p)) + continue; + if (within_module_init((unsigned long)p->addr, mod) || (checkcore && within_module_core((unsigned long)p->addr, mod))) { @@ -2436,6 +2442,7 @@ static int kprobes_module_callback(struc */ kill_kprobe(p); } + } } if (val == MODULE_STATE_GOING) remove_module_kprobe_blacklist(mod); _
next prev parent reply index Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-19 4:19 incoming Andrew Morton 2020-09-19 4:20 ` [patch 01/15] mailmap: add older email addresses for Kees Cook Andrew Morton 2020-09-19 4:20 ` [patch 02/15] ksm: reinstate memcg charge on copied pages Andrew Morton 2020-09-19 4:20 ` [patch 03/15] mm: migration of hugetlbfs page skip memcg Andrew Morton 2020-09-19 4:20 ` [patch 04/15] shmem: shmem_writepage() split unlikely i915 THP Andrew Morton 2020-09-19 4:20 ` [patch 05/15] mm: fix check_move_unevictable_pages() on THP Andrew Morton 2020-09-19 4:20 ` [patch 06/15] mlock: fix unevictable_pgs event counts " Andrew Morton 2020-09-19 4:20 ` [patch 07/15] tmpfs: restore functionality of nr_inodes=0 Andrew Morton 2020-09-19 4:20 ` Andrew Morton [this message] 2020-09-19 4:20 ` [patch 09/15] mm/thp: fix __split_huge_pmd_locked() for migration PMD Andrew Morton 2020-09-19 4:20 ` [patch 10/15] selftests/vm: fix display of page size in map_hugetlb Andrew Morton 2020-09-19 4:20 ` [patch 11/15] mm/memory_hotplug: drain per-cpu pages again during memory offline Andrew Morton 2020-09-19 4:20 ` [patch 12/15] ftrace: let ftrace_enable_sysctl take a kernel pointer buffer Andrew Morton 2020-09-19 4:20 ` [patch 13/15] stackleak: let stack_erasing_sysctl " Andrew Morton 2020-09-19 4:20 ` [patch 14/15] fs/fs-writeback.c: adjust dirtytime_interval_handler definition to match prototype Andrew Morton 2020-09-19 4:20 ` [patch 15/15] kcsan: kconfig: move to menu 'Generic Kernel Debugging Instruments' Andrew Morton
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200919042021.X10NZatlE%akpm@linux-foundation.org \ --to=akpm@linux-foundation.org \ --cc=anil.s.keshavamurthy@intel.com \ --cc=davem@davemloft.net \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mhiramat@kernel.org \ --cc=mm-commits@vger.kernel.org \ --cc=naveen.n.rao@linux.ibm.com \ --cc=rostedt@goodmis.org \ --cc=songliubraving@fb.com \ --cc=songmuchun@bytedance.com \ --cc=stable@vger.kernel.org \ --cc=torvalds@linux-foundation.org \ --cc=zhouchengming@bytedance.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
mm-commits Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/mm-commits/0 mm-commits/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 mm-commits mm-commits/ https://lore.kernel.org/mm-commits \ mm-commits@vger.kernel.org public-inbox-index mm-commits Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.mm-commits AGPL code for this site: git clone https://public-inbox.org/public-inbox.git