Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1445021imm; Tue, 15 May 2018 20:31:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpe+yEUh/1RVX2bNdYSFHvoUyblxrMHf+D08Jii1bVY9QCr/mvAK80aLbq/cXYWtbZOVEyn X-Received: by 2002:a62:ca98:: with SMTP id y24-v6mr17764510pfk.187.1526441487453; Tue, 15 May 2018 20:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526441487; cv=none; d=google.com; s=arc-20160816; b=j67ClFhlExFP17GPWOKdGKuCV1NQDVQmLmlcucBBkkay62A5BVw88Npgoxbq0HoZGe kRc9h7ykTJJKSWamgGSotEdG0L2Ptqnhk0I23kWlX6PUGmXSoIaYh1LRgLzje++Y9cPq WR3dIhwzAgJQt5PTXPcw4aPo6kvGku7Ib8DVlmP+pqnqZm6v1V5E5UNgv990DITijEa9 uMjbTuSjsrd122BBlDVKU7RfEnObQjT/7dun5r4Q/r/mgq7rpIKkWoyng9DA87ivlN/m b2AItqrtBmT6E7Mwv3qzAjZmFaguz33CZpMorqsJyDhvD0adKQlE5bPVLV0E8vWvwHy2 0/Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=ODnK9xa/vLM5p4SgVnB/sdXyvuoAO/dlAtj+SsDwEq0=; b=XY4P09Y/LpFb0PCyQmPfPUaGDkcdzsnh+RwVWXbU6ivCpAvp9btVG4NI/B60C+AjEy LLjMZcrXneF42HCzb6JKn/yYUD4tPHcNXQv/EU3HBhAeMuULFh5lk0mvn1xLMTWNrB1s UWiP30Z6rtfB02fQzSNrSCjjL8MgER0woYjWM2iCkvI+CNzk4qj28rzD6W9XUKSNXBkl rmYoJJxoFUpglOMwEmThshdGgyzHcBortL7O5Uo9TVRIOuS/PKZ8OpCR6wils42aAyZE UgT6U9v8e+j28ilaMsW7pqcOY4fK9ru2Hnj8UxYj082DCItg6JoWao9X73Kg4sn3MufJ 2VnQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z31-v6si1587456plb.200.2018.05.15.20.30.58; Tue, 15 May 2018 20:31:27 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752338AbeEPDat (ORCPT + 99 others); Tue, 15 May 2018 23:30:49 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51588 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752172AbeEPDas (ORCPT ); Tue, 15 May 2018 23:30:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 23121C12A7; Wed, 16 May 2018 03:30:47 +0000 (UTC) Received: from treble (ovpn-120-21.rdu2.redhat.com [10.10.120.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 11E2D2024CBB; Wed, 16 May 2018 03:30:46 +0000 (UTC) Date: Tue, 15 May 2018 22:30:44 -0500 From: Josh Poimboeuf To: Linus Torvalds Cc: Alexey Dobriyan , Peter Anvin , kernel test robot , Ingo Molnar , Thomas Gleixner , Andrew Lutomirski , Borislav Petkov , Brian Gerst , Denys Vlasenko , Peter Zijlstra , Linux Kernel Mailing List , Peter Anvin , tipbuild@zytor.com, LKP Subject: Re: [lkp-robot] [x86/asm] 51bad67ffb: int3:#[##] Message-ID: <20180516033044.odb74pdgcn5nacwb@treble> References: <20180515080033.GA7714@yexl-desktop> <20180515210757.GA12225@avx2> <20180515214337.GA18021@avx2> <20180515222211.ods5hzne46hozojq@treble> <20180515224354.zmygmsnlqj5lrdbo@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180323 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 16 May 2018 03:30:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 16 May 2018 03:30:47 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jpoimboe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 15, 2018 at 04:05:33PM -0700, Linus Torvalds wrote: > I wonder if there's some way to add a test for "ENTRY only works in a code > section"? I suppose we could add a discardable annotation to the ENTRY macro and have objtool validate that it's in a text section. I'm not sure whether it's worth it, but I could do it if you think it's a good idea. Below is a tentative objtool patch which catches asm code falling through to INT3 padding, though objtool is 64-bit only so there won't be any 32-bit coverage. It found zero hits on my config. I'll clean it up and submit it tomorrow-ish. diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index 8344dd2f310a..3ed8cec6e765 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -285,11 +285,9 @@ ENTRY(early_idt_handler_array) .endif pushq $i # 72(%rsp) Vector number jmp early_idt_handler_common - UNWIND_HINT_IRET_REGS i = i + 1 .fill early_idt_handler_array + i*EARLY_IDT_HANDLER_SIZE - ., 1, 0xcc .endr - UNWIND_HINT_IRET_REGS offset=16 END(early_idt_handler_array) early_idt_handler_common: diff --git a/tools/objtool/arch.h b/tools/objtool/arch.h index b0d7dc3d71b5..6eb058a8ac00 100644 --- a/tools/objtool/arch.h +++ b/tools/objtool/arch.h @@ -33,7 +33,8 @@ #define INSN_STACK 8 #define INSN_BUG 9 #define INSN_NOP 10 -#define INSN_OTHER 11 +#define INSN_PADDING 11 +#define INSN_OTHER 12 #define INSN_LAST INSN_OTHER enum op_dest_type { diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index 7e86a743f851..82b41bb93c02 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -421,7 +421,7 @@ int arch_decode_instruction(struct elf *elf, struct section *sec, case 0xcc: /* int3: used for asm function padding by the __ALIGN macro */ - *type = INSN_NOP; + *type = INSN_PADDING; break; case 0xe3: diff --git a/tools/objtool/check.c b/tools/objtool/check.c index f4bbce838433..8a83a0d1693a 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1936,6 +1936,14 @@ static int validate_branch(struct objtool_file *file, struct instruction *first, } return 0; + case INSN_PADDING: + if (!func) { + WARN_FUNC("code falls through to INT3 padding", + insn->sec, insn->offset); + return 1; + } + break; + case INSN_STACK: if (update_insn_state(insn, &state)) return 1; @@ -2032,7 +2040,8 @@ static bool ignore_unreachable_insn(struct instruction *insn) { int i; - if (insn->ignore || insn->type == INSN_NOP) + if (insn->ignore || insn->type == INSN_NOP || + insn->type == INSN_PADDING) return true; /*