Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp943500ybs; Mon, 25 May 2020 03:15:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWahtgE3QF4jg1TRsM1iQGi5kJ5XByCyYGBLOIIXJeEuHjy0UDn/ifZxtfwFJ1tG8jZ6b1 X-Received: by 2002:a17:906:9249:: with SMTP id c9mr19114401ejx.173.1590401744163; Mon, 25 May 2020 03:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590401744; cv=none; d=google.com; s=arc-20160816; b=Q4QimsCF0yebZEYeaEmLd4HI8STmmbreC+0rcn6d+Ame9/mNFVxVLw4GR72rLTQoJP Y1Bb7mO0RgMce2Xmj9O2El5wECG6LPXQBUinosga7M4ViDL79da2iXcNXCD5Jxe8rZhg Sjc3SAnynbZZOmB8E+ioGR/HTOatnZImDvQVj1voqD/glS6uMSn3WJ54LODaOWYyPPiO iazmAynZPcL/7rJlA18YJBLMGmRIoqdIXEK2+TEnYdXH8L1t0essJp6sV6yPWVxk67ul gW0xSLbSdinG0fZPXTAcoLbLglnN+YaPK4pc61GLwFFPbkfY34K63ZmebmCaAP6EUlON f0zQ== 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 :message-id:in-reply-to:subject:cc:to:from:date; bh=cDgy65UiermAN1jkCWAK+AgXMM4ku+msdw3TIQCcMiE=; b=qbkJ35/aNjGIyIcb97W2UPSYfjrGnbNAbyNzTp/7ppeiSAvnFTjUnnwqyAPzhdSiiJ a3anlWelgPCPVvwwxw+370MkuFCbQ6lcyE+FdrdbZe003Syua1/wmY7hyMKhnar/rk8e rP3WFRfgljhbFTzHNRSQ4i4YdXLClNeX40oaVXZfBLA7uMK+7Q+Zr2Ryv9Hyncr2T+7Q F9aKfYQ//X8LdftrTebAvF3QwqJ/y97fHjvxuRy9mfjh+Ta3eRL5W52s7NSoRXk6H/gV 945BVWZJInSRefMq/9Ijw2u/y2H73wb5GvqIpvX5HGXcbvPDz/3fFq5C1iVO/Oo89VY/ NhAw== 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 a13si9223423edr.32.2020.05.25.03.15.21; Mon, 25 May 2020 03:15:44 -0700 (PDT) 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 S2389480AbgEYKKg (ORCPT + 99 others); Mon, 25 May 2020 06:10:36 -0400 Received: from mx2.suse.de ([195.135.220.15]:42446 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389356AbgEYKKg (ORCPT ); Mon, 25 May 2020 06:10:36 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3A29DAA35; Mon, 25 May 2020 10:10:37 +0000 (UTC) Date: Mon, 25 May 2020 12:10:33 +0200 (CEST) From: Miroslav Benes To: Randy Dunlap cc: Stephen Rothwell , Linux Next Mailing List , Linux Kernel Mailing List , Josh Poimboeuf , Peter Zijlstra Subject: Re: linux-next: Tree for May 21 (objtool warnings) In-Reply-To: <22332d9b-5e9f-5474-adac-9b3e39861aee@infradead.org> Message-ID: References: <20200522001209.07c19400@canb.auug.org.au> <22332d9b-5e9f-5474-adac-9b3e39861aee@infradead.org> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 May 2020, Randy Dunlap wrote: > On 5/21/20 7:12 AM, Stephen Rothwell wrote: > > Hi all, > > > > Changes since 20200519: > > These are indeed caused by -flive-patching > on x86_64: > > fs/open.o: warning: objtool: chmod_common()+0x104: unreachable instruction > fs/namei.o: warning: objtool: do_renameat2()+0x482: unreachable instruction Two "funny" ones. When CONFIG_FILE_LOCKING is not set, break_deleg_wait() is just BUG(). GCC decides to isra optimize it to break_deleg_wait.isra.0 and call it in chmod_common() and do_renameat2() instead of just inline it. chmod_common() with -flive-patching: 981: e8 f7 fe ff ff callq 87d 986: 41 89 c4 mov %eax,%r12d 989: 85 c0 test %eax,%eax 98b: 0f 84 76 ff ff ff je 907 991: 48 89 df mov %rbx,%rdi 994: e8 00 00 00 00 callq 999 995: R_X86_64_PLT32 __tsan_read8-0x4 without: 985: e8 f3 fe ff ff callq 87d 98a: 48 89 df mov %rbx,%rdi 98d: e8 00 00 00 00 callq 992 98e: R_X86_64_PLT32 __tsan_read8-0x4 The error checking of break_deleg_wait() is correctly compiled out, because it is unreachable. I wondered how come objtool (correctly) says the instructions are unreachable. It means it knows that break_deleg_wait.isra.0 is a dead end (dead_end_function() returns true while checking INSN_CALL). And of course "return 0;" in break_deleg_wait() is compiled out. 000000000000087d : 87d: 55 push %rbp 87e: 48 89 e5 mov %rsp,%rbp 881: 48 8b 7d 08 mov 0x8(%rbp),%rdi 885: e8 00 00 00 00 callq 88a 886: R_X86_64_PLT32 __tsan_func_entry-0x4 88a: 0f 0b ud2 One way to fix it is to mark break_deleg_wait() as __always_inline. Then it all works. Note: there are more functions calling break_deleg_wait() with this pattern. I'll try to find out which optimization does this, because it is a slightly different scenario than hiding __noreturn from the callees. Probably -fno-ipa-pure-const again. > kernel/exit.o: warning: objtool: __ia32_sys_exit_group()+0x2e: unreachable instruction Easy one. do_group_exit() is noreturn and should be marked as such. > Full randconfig file is attached. > > > -- > ~Randy > Reported-by: Randy Dunlap Thanks for reporting, Randy. Miroslav --- diff --git a/include/linux/fs.h b/include/linux/fs.h index ac8bd95b5fe8..2b79932e924d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2546,7 +2546,7 @@ static inline int try_break_deleg(struct inode *inode, struct inode **delegated_ return 0; } -static inline int break_deleg_wait(struct inode **delegated_inode) +static __always_inline int break_deleg_wait(struct inode **delegated_inode) { BUG(); return 0; diff --git a/kernel/exit.c b/kernel/exit.c index ed56917d50e3..9437c1ca37c5 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -876,7 +876,7 @@ SYSCALL_DEFINE1(exit, int, error_code) * Take down every thread in the group. This is called by fatal signals * as well as by sys_exit_group (below). */ -void +void __noreturn do_group_exit(int exit_code) { struct signal_struct *sig = current->signal;