Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp953544pxb; Thu, 5 Nov 2020 18:39:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGNI0X22jNUkMkVuiCPWZIP4RrXmUSJqWSngt7J13DJmIt7E2PRK2iN5nzPrNichuC0az/ X-Received: by 2002:a17:906:d79a:: with SMTP id pj26mr5314309ejb.378.1604630365330; Thu, 05 Nov 2020 18:39:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604630365; cv=none; d=google.com; s=arc-20160816; b=FL0dS3w8DKFnPM4Qk2GwGRvhoUorZ7Q2JDve704zaQ7ej0ebh0OxQukFMgj+hBmNyV IEm+HfbYkbLNlJp/mpwRHXIt53CcbxA7VniaEdh/WZsbS3b++1rl2K9wQgY7UMSKVLdr RtiiKZLKHCEBQcpfijHbKspdVJM6LQKpvq5yiW9cyJa1OMaHr3P7/ZibQoWAN/mL7U5c TOTULHvp2vTUZSkciRiCxJDyUHc2nDX9GI5eFZqcqeec8nSInIwo1gFk1R9s46iJ1aye KfC+FI3QEvG4XopZwnmF433Q65KzAd5l0bXHp2ramj1BpTykCX6yDOyAQQB8vTQSQGHH xZaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=nVgVNOuDp7aKhCV7zZ869ZOaBHNk74szyfILLEG/sck=; b=uQqRwVXcZkmL2YAYQ3iS15E4xLjvMlzREQJU+heei7BP9f/nx23yBc/QGBovSRH8mM 21FeXykYCTQfYAsdAWeMH+iFvCVxMDTEBTF/kapiPxX6tKlO4AboJRo69u0XKGB2CqI9 qd+OQxdRa8G99/CJ9ENPqzOJ9yvABv8wFSTdIid4VQF6CGL9PP3E41ZpdFbHR8TYXdhQ wd2edta70u6Ykmv0OxphnLIaimRGLnaD1pgDgSuhQc/gmbVpeUursZ1yc5FSAwgu8rO4 Sz0FuE6aRt9QUhFhx6NDUT5HZBM/6FcJ2vdPeYu7NlR9N22eoTn4R9bonMLOZ0SQB5le EHmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r15si2689556ejy.36.2020.11.05.18.39.03; Thu, 05 Nov 2020 18:39:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726090AbgKFCgW (ORCPT + 99 others); Thu, 5 Nov 2020 21:36:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:40884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbgKFCft (ORCPT ); Thu, 5 Nov 2020 21:35:49 -0500 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 D6C102224D; Fri, 6 Nov 2020 02:35:48 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.94) (envelope-from ) id 1karbP-007WMF-ET; Thu, 05 Nov 2020 21:35:47 -0500 Message-ID: <20201106023547.312639435@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 05 Nov 2020 21:32:42 -0500 From: Steven Rostedt (VMware) To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Andrew Morton , Peter Zijlstra , Ingo Molnar , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , live-patching@vger.kernel.org Subject: [PATCH 07/11 v3] livepatch: Trigger WARNING if livepatch function fails due to recursion References: <20201106023235.367190737@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Steven Rostedt (VMware)" If for some reason a function is called that triggers the recursion detection of live patching, trigger a warning. By not executing the live patch code, it is possible that the old unpatched function will be called placing the system into an unknown state. Link: https://lore.kernel.org/r/20201029145709.GD16774@alley Cc: Josh Poimboeuf Cc: Jiri Kosina Cc: Joe Lawrence Cc: live-patching@vger.kernel.org Suggested-by: Miroslav Benes Reviewed-by: Petr Mladek Signed-off-by: Steven Rostedt (VMware) --- Changes since v2: - Blame Miroslav instead of Petr ;-) kernel/livepatch/patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/livepatch/patch.c b/kernel/livepatch/patch.c index 6c0164d24bbd..15480bf3ce88 100644 --- a/kernel/livepatch/patch.c +++ b/kernel/livepatch/patch.c @@ -50,7 +50,7 @@ static void notrace klp_ftrace_handler(unsigned long ip, ops = container_of(fops, struct klp_ops, fops); bit = ftrace_test_recursion_trylock(); - if (bit < 0) + if (WARN_ON_ONCE(bit < 0)) return; /* * A variant of synchronize_rcu() is used to allow patching functions -- 2.28.0