Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp205573ybm; Mon, 20 May 2019 14:41:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4+cRWCTnSc/fZyTFmf82J23ufqT6cTUV9gCbHqTgrqEdnI+3btNus7BPns2bILy8ZH3Wa X-Received: by 2002:aa7:842f:: with SMTP id q15mr83542906pfn.161.1558388464537; Mon, 20 May 2019 14:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558388464; cv=none; d=google.com; s=arc-20160816; b=RugpugHFC9rcG/eoIlPMe4zxWil+IOGWYDzeR8s0Gll/uSZblzCjD1gnQXeCUoniiH 9Hbdt5f8YBSJrO5vgvO5K3n6zHjfLDNNgxfUkb321HJ9nmudp6uvacJ1SSXXiMgpHK/P xQ9ZPeIgB/0TXkIfLHbR3fJiLG8zn6rKWFfg7dlpK+6jX6t2rze20uBxsazCxV/5YuGl jgu7VzpAPkKwZNdsmd9g9hoSXiQ8Ytrtf7hVGYbRoKa+jWpZKXHPAKjD1/gKaRPvuNcO o2+V6n5XwGby42H+hwAF4QGdYr/Kc+ug9wkY27L4OJEvzUHxopW9NrPT+wmn7hgWt38r ltBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Zd980gpV9PYTPAkNk0jmH+Dxt57b3kPFm2elwLeB218=; b=rO69DHOUPX3Uanaw0fNEZzqtHPKxdELeLqb61B2qzB71xmALPStlwQEHZAKhsETrNq KubHZQa1pE5BQFZwsymmwxgDCEE+5mLNwSV7JJ39PiZGcByap+OSuJ8lG3PA3mbeqAuA QAUUS4JiX/t0iVTWQYPeVeVV5sDDe0vgk3QkVJ+g9b/vRKVWgK1pAkCmUx+6lmFYSwvR eoAv5xuQvelP3WNjBhpM+yQHqBdUF7FvOplzGnnxdYhrBkjqCGKMxawbt5j7d4XreYbx UsQS0JzsGBZLeUpJcVUiCHlFIVBayvryHu7JelVBkrh6Hcuis95n7kKCLKSchV+HTq2j YtCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12si19847199pfd.79.2019.05.20.14.40.49; Mon, 20 May 2019 14:41:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726692AbfETVjO (ORCPT + 99 others); Mon, 20 May 2019 17:39:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:48436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbfETVjN (ORCPT ); Mon, 20 May 2019 17:39:13 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0548D2171F; Mon, 20 May 2019 21:39:11 +0000 (UTC) Date: Mon, 20 May 2019 17:39:10 -0400 From: Steven Rostedt To: Josh Poimboeuf Cc: Johannes Erdfelt , Joe Lawrence , Jessica Yu , Jiri Kosina , Miroslav Benes , Ingo Molnar , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Oops caused by race between livepatch and ftrace Message-ID: <20190520173910.6da9ddaf@gandalf.local.home> In-Reply-To: <20190520211931.vokbqxkx5kb6k2bz@treble> References: <20190520194915.GB1646@sventech.com> <90f78070-95ec-ce49-1641-19d061abecf4@redhat.com> <20190520210905.GC1646@sventech.com> <20190520211931.vokbqxkx5kb6k2bz@treble> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 20 May 2019 16:19:31 -0500 Josh Poimboeuf wrote: > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index a12aff849c04..8259d4ba8b00 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -34,6 +34,7 @@ > #include > #include > #include > +#include > > #include > > @@ -2610,10 +2611,12 @@ static void ftrace_run_update_code(int command) > { > int ret; > > + mutex_lock(&text_mutex); > + Hmm, this may blow up with lockdep, as I believe we already have a locking dependency of: text_mutex -> ftrace_lock And this will reverses it. (kprobes appears to take the locks in this order). Perhaps have live kernel patching grab ftrace_lock? -- Steve > ret = ftrace_arch_code_modify_prepare(); > FTRACE_WARN_ON(ret); > if (ret) > - return; > + goto out_unlock; > > /* > * By default we use stop_machine() to modify the code. > @@ -2625,6 +2628,9 @@ static void ftrace_run_update_code(int command) > > ret = ftrace_arch_code_modify_post_process(); > FTRACE_WARN_ON(ret); > + > +out_unlock: > + mutex_unlock(&text_mutex); > } > > static void ftrace_run_modify_code(struct ftrace_ops *ops, int command, > @@ -5776,6 +5782,7 @@ void ftrace_module_enable(struct module *mod) > struct ftrace_page *pg; > > mutex_lock(&ftrace_lock); > + mutex_lock(&text_mutex); > > if (ftrace_disabled) > goto out_unlock; > @@ -5837,6 +5844,7 @@ void ftrace_module_enable(struct module *mod) > ftrace_arch_code_modify_post_process(); > > out_unlock: > + mutex_unlock(&text_mutex); > mutex_unlock(&ftrace_lock); > > process_cached_mods(mod->name);