Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1560389ybb; Thu, 26 Mar 2020 03:09:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuPijA5XUKgjnOU9k8xMhspJf5aFyv1R9AAOJ2Dt5Nw3e1NN1mEVS7wmFmzK6xNUXOszmJc X-Received: by 2002:aca:abcd:: with SMTP id u196mr1252384oie.86.1585217375770; Thu, 26 Mar 2020 03:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585217375; cv=none; d=google.com; s=arc-20160816; b=GIpGCe+sbEzvAU9xruNK2UA+uonuKNqqzlV9fQls1YHGDm8DU9K0ppnNcuWfb4fIt3 k1/2Kqyo2uFK5BCVG+mJahdeUKOpX0Pkh1k+1KNl5Dwij7IhEQXySe/RmDsLWjAMM82q cFbjVEjRF8dwKgMHEGDBxFjaODMwZTz3Qzwkzc0VATv5ocFDltUa8jIk9AfbTC/LF6+a D4JNEF0KIMVoBDq3LXI3Jc0U0Z849DegsQ/ZBypjkU9Bwqx1VhET3Lz8fYA/9vrvAEGf MYaDCfas3Jz+g9jVJoecy0t+UOmZXc03voUh4keun0/rzhY+mBAwzNo7QSuhihZo1Q8G Ev8A== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=6F2mlBU9t/vEqrAoOKih1pN1I84eeVnfgwU459P+LLs=; b=WZOO/mwauIAUgQCR53AW4ldIgcUUdCJiZRJs4lDLmEELFGV0yC+ZbrbG8xq4Ff93KU HK7Sg5RNbJmQi7/Yx9DAh34o0eNhE7BSjyPPrchnfbHCI+N/4GEfRjZEn6uvTgMxI1Ud l6Xa7IWq+sTzS31H8fV94xP8cPPaKZh+TLj53fjPl4lv3G2nzzLcYq/NebFyf7GTc1D3 g7FEw4/gt352upzI6eQMY50VjihTBSwTx+XVXmgEqSH8tFHdHZGzehq+773fVJQN7Ipl 90fYqT0ZMBICwuKQ951pBkgIySr53aBWA6S7VGCmrGnmRrVWsBWX+D5pMqm8FHUR3lNK iSnw== 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 w10si823736oti.165.2020.03.26.03.09.23; Thu, 26 Mar 2020 03:09:35 -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 S1727998AbgCZKIs (ORCPT + 99 others); Thu, 26 Mar 2020 06:08:48 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:50232 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727967AbgCZKIq (ORCPT ); Thu, 26 Mar 2020 06:08:46 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jHPRI-00049r-Tp; Thu, 26 Mar 2020 11:08:41 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id A56E31C0494; Thu, 26 Mar 2020 11:08:39 +0100 (CET) Date: Thu, 26 Mar 2020 10:08:39 -0000 From: "tip-bot2 for Peter Zijlstra" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/objtool] objtool: Introduce validate_return() Cc: "Peter Zijlstra (Intel)" , Miroslav Benes , Josh Poimboeuf , x86 , LKML In-Reply-To: <20200324160923.963996225@infradead.org> References: <20200324160923.963996225@infradead.org> MIME-Version: 1.0 Message-ID: <158521731933.28353.7307768837288463941.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the core/objtool branch of tip: Commit-ID: a92e92d1a749e9bae9828f34f632d56ac2c6d2c3 Gitweb: https://git.kernel.org/tip/a92e92d1a749e9bae9828f34f632d56ac2c6d2c3 Author: Peter Zijlstra AuthorDate: Tue, 10 Mar 2020 18:07:44 +01:00 Committer: Peter Zijlstra CommitterDate: Wed, 25 Mar 2020 18:28:27 +01:00 objtool: Introduce validate_return() Trivial 'cleanup' to save one indentation level and match validate_call(). Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Miroslav Benes Acked-by: Josh Poimboeuf Link: https://lkml.kernel.org/r/20200324160923.963996225@infradead.org --- tools/objtool/check.c | 64 +++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 6b6178e..da17b5a 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1975,6 +1975,41 @@ static int validate_sibling_call(struct instruction *insn, struct insn_state *st return validate_call(insn, state); } +static int validate_return(struct symbol *func, struct instruction *insn, struct insn_state *state) +{ + if (state->uaccess && !func_uaccess_safe(func)) { + WARN_FUNC("return with UACCESS enabled", + insn->sec, insn->offset); + return 1; + } + + if (!state->uaccess && func_uaccess_safe(func)) { + WARN_FUNC("return with UACCESS disabled from a UACCESS-safe function", + insn->sec, insn->offset); + return 1; + } + + if (state->df) { + WARN_FUNC("return with DF set", + insn->sec, insn->offset); + return 1; + } + + if (func && has_modified_stack_frame(state)) { + WARN_FUNC("return with modified stack frame", + insn->sec, insn->offset); + return 1; + } + + if (state->bp_scratch) { + WARN("%s uses BP as a scratch register", + func->name); + return 1; + } + + return 0; +} + /* * Follow the branch starting at the given instruction, and recursively follow * any other branches (jumps). Meanwhile, track the frame pointer state at @@ -2090,34 +2125,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, switch (insn->type) { case INSN_RETURN: - if (state.uaccess && !func_uaccess_safe(func)) { - WARN_FUNC("return with UACCESS enabled", sec, insn->offset); - return 1; - } - - if (!state.uaccess && func_uaccess_safe(func)) { - WARN_FUNC("return with UACCESS disabled from a UACCESS-safe function", sec, insn->offset); - return 1; - } - - if (state.df) { - WARN_FUNC("return with DF set", sec, insn->offset); - return 1; - } - - if (func && has_modified_stack_frame(&state)) { - WARN_FUNC("return with modified stack frame", - sec, insn->offset); - return 1; - } - - if (state.bp_scratch) { - WARN("%s uses BP as a scratch register", - func->name); - return 1; - } - - return 0; + return validate_return(func, insn, &state); case INSN_CALL: case INSN_CALL_DYNAMIC: