Received: by 10.223.185.116 with SMTP id b49csp1014155wrg; Wed, 21 Feb 2018 10:34:43 -0800 (PST) X-Google-Smtp-Source: AH8x225qb0v/Of/NU1lSLA9DybCFoMmKuqg/WQYCVM/SEEq+iNl9/EICZ4jeEjzcW4mz9hx/E00G X-Received: by 2002:a17:902:b403:: with SMTP id x3-v6mr3949334plr.359.1519238083206; Wed, 21 Feb 2018 10:34:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238083; cv=none; d=google.com; s=arc-20160816; b=VgMq1FSkX7QUnSjq+joUX7zd3ixkMTry9PK0aMHnBQiAlwxLH604+hFHL4TC8ZzZPA CzgItLdPE4sDyf+AOOX6WP0X6q4Lud2C4DN8k/wSPGIolvXyS8onGbqludoXuafW7qCa rQnySw5DerL9x+iEqaD2MhNFbpODYqEGW17Sjww0L/61cBA3ql3CLTFHpr9Bf+sJDtay 4eq9ciG1E5KC0xFkbZwT9QShzHEYZJHwZ5STOZ/jx3n63n+5DhvfQE/0rSCVWi3Uymef AtOaiWi8H2umdTvAnMT07wjWl+2DJCxTuBuI8I25FRqLzXxwvZAL1dj+Kx3fhUDvBT8U rfcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=soWwpva6Mph8aUxK75EV+UNCCqS66qrGZyDuoM8iIVM=; b=fsrlCluGq74D+a+LHAh8oHyjQ3eNBfVPdjkgSqvv2XaDPY6orgWEnLwOgDyt5MwxMj OzGdawEkMR/P569KQch3jPtGnkp52VCbPLzBhMVjV8lRzRRFPHSjWA2gxSOShN7wMIIw RKHtekpi5jQlIzrVZTh1rRVMkdv/GuRGhcSFbRXelolNcgdr9CBulmS7AyMQdUo2EWIo pLtRCit1mgZB2yyKFMbjRUax6ozzNtsULnMZ58gjUYqpNbhN3HCOF0SUaYY9HY4icKjb 5hi0AVINACiZJXR6GslpX+JMFuUKLDYWn+PAZU8Z2yhBxncmak9CPC7PyEeGC4zuHF2g D6VQ== 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 1-v6si14552392plr.786.2018.02.21.10.34.27; Wed, 21 Feb 2018 10:34:43 -0800 (PST) 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 S965369AbeBUNJE (ORCPT + 99 others); Wed, 21 Feb 2018 08:09:04 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:42692 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936187AbeBUNJB (ORCPT ); Wed, 21 Feb 2018 08:09:01 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CC27C1029; Wed, 21 Feb 2018 13:09:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , Josh Poimboeuf , "Peter Zijlstra (Intel)" , Andy Lutomirski , Arjan van de Ven , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" , Linus Torvalds , Thomas Gleixner , kbuild test robot , Ingo Molnar Subject: [PATCH 4.15 076/163] objtool: Fix segfault in ignore_unreachable_insn() Date: Wed, 21 Feb 2018 13:48:25 +0100 Message-Id: <20180221124534.667702428@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josh Poimboeuf commit fe24e27128252c230a34a6c628da2bf1676781ea upstream. Peter Zijlstra's patch for converting WARN() to use UD2 triggered a bunch of false "unreachable instruction" warnings, which then triggered a seg fault in ignore_unreachable_insn(). The seg fault happened when it tried to dereference a NULL 'insn->func' pointer. Thanks to static_cpu_has(), some functions can jump to a non-function area in the .altinstr_aux section. That breaks ignore_unreachable_insn()'s assumption that it's always inside the original function. Make sure ignore_unreachable_insn() only follows jumps within the current function. Reported-by: Borislav Petkov Signed-off-by: Josh Poimboeuf Signed-off-by: Peter Zijlstra (Intel) Cc: Andy Lutomirski Cc: Arjan van de Ven Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: kbuild test robot Link: http://lkml.kernel.org/r/bace77a60d5af9b45eddb8f8fb9c776c8de657ef.1518130694.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- tools/objtool/check.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1935,13 +1935,19 @@ static bool ignore_unreachable_insn(stru if (is_kasan_insn(insn) || is_ubsan_insn(insn)) return true; - if (insn->type == INSN_JUMP_UNCONDITIONAL && insn->jump_dest) { - insn = insn->jump_dest; - continue; + if (insn->type == INSN_JUMP_UNCONDITIONAL) { + if (insn->jump_dest && + insn->jump_dest->func == insn->func) { + insn = insn->jump_dest; + continue; + } + + break; } if (insn->offset + insn->len >= insn->func->offset + insn->func->len) break; + insn = list_next_entry(insn, list); }