Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1196989ybz; Sat, 25 Apr 2020 13:12:00 -0700 (PDT) X-Google-Smtp-Source: APiQypKhZj5oz8Jkcp5D2/0R9rP0W80rFrXOzxfZNSD07CmEEuWp4rMJbIOaNq2Lcu5FLKv5+h5H X-Received: by 2002:a05:6402:1d1c:: with SMTP id dg28mr12624371edb.315.1587845520260; Sat, 25 Apr 2020 13:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587845520; cv=none; d=google.com; s=arc-20160816; b=xeDJ6xpExVfiNPCig3iGQp5cpks/xC5xEhlFSiZKLVdr6O5zZAzvvk0vlCC2zTKhHG VsxKOtZ0KOCsvjFX3iZivX4wcMqEtmFdYtc/JulhBNG5aqI4M3WB/vTLSCC9ksV9mnjO yua5g2zYGzTa8O70msX++E1vFXdI4otmWHuu6TCNfIybnIIoDiWqta0b3e928eHDriFQ JKkRfFVMgJCfLLK2vaMSCkay5BiUj1fAZ/C07orfT7ob7Mc1dDB9rD0vNTKJT3LAHbpp qak96Ixk4Z7JMbJY2wEZ7sm2Sg8l5ZY2XO+8Uc9c54Q8FNlcVldDbuDKMkdWCiqFz/zT hFog== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=y0IGL0wQnsioL4agn4c4DRS773a5YjBvAsL0n8C1Fp0=; b=ys7Wv/XBJqvcMhqDeVai7l98v12DB/bGeR0x/jlW9HhQRN0bW3BUbJJGIGFHTpcd+d DIGHnbNhMscLCXuxqSh6mS5AsDpNw+XZunGvWJCnDayFnM1vWrjBsJtTcxn1wWJs8Rml E1ocKpdA6ZnLUv6cLk4WOWzkaqubbkpe5YJgTsm7X4eUoLTufbzEgjto+uQSFVTt3/5C mh8KZnhMvc33fDIzAWv4OsVE4csVGgvefkozpK0B6rIvnJGYoqLRtGmlivzkTTwWTGG9 xolRE1Tt3f67lTvTDOuOSUVOB31jLSxonrz4o/Ksiu3frft4s85Qc8DKon1wDkp7lSmB tEvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=AQn26i5m; 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 a31si5328872ede.290.2020.04.25.13.11.35; Sat, 25 Apr 2020 13:12:00 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=AQn26i5m; 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 S1726364AbgDYUIA (ORCPT + 99 others); Sat, 25 Apr 2020 16:08:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbgDYUIA (ORCPT ); Sat, 25 Apr 2020 16:08:00 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DD92C09B04D for ; Sat, 25 Apr 2020 13:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:References:Cc:To:From: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=y0IGL0wQnsioL4agn4c4DRS773a5YjBvAsL0n8C1Fp0=; b=AQn26i5m9yZrqnZxVm5g7UUOnt gj9iCN5/Tqc1H1bKfJVw5pZWEPkAQCCgoOemKas9Fy3lwaZGam9op0rB3PQDHAoo+ZIrrI/kYrZyF q6x7R/Zd6FvwY47PfMQxPm4gR0awJ1ZkgYNq5vXwGxuG6h8Nr/AWU7iTQYlhiSPA07HBQKRuYSe2Z 0VgFcQxV3bvzwBx2VGN4473EHhBPehKY/+w8opWaTBAAl6zmCxIk16p9BqHS39upGZhGwNAp1xaUF cmHYHdByqZh8tp0qqEvPUBQAVgcBBcylvFuUvZPH4a7L2enC0Kb7PA5mT24ursmP67vLy1ca5FXjT sCEESHhA==; Received: from [2601:1c0:6280:3f0::19c2] by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jSR5h-0003au-EZ; Sat, 25 Apr 2020 20:07:57 +0000 Subject: Re: [PATCH] objtool: Fix infinite loop in for_offset_range() From: Randy Dunlap To: Josh Poimboeuf , x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes , Julien Thierry References: <02b719674b031800b61e33c30b2e823183627c19.1587842122.git.jpoimboe@redhat.com> <844c4770-5e33-d02c-32d9-200dc7bc4146@infradead.org> Message-ID: Date: Sat, 25 Apr 2020 13:07:56 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <844c4770-5e33-d02c-32d9-200dc7bc4146@infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/25/20 1:04 PM, Randy Dunlap wrote: > On 4/25/20 12:19 PM, Josh Poimboeuf wrote: >> Randy reported that objtool got stuck in an infinite loop when >> processing drivers/i2c/busses/i2c-parport.o. It was caused by the >> following code: >> >> 00000000000001fd : >> 1fd: 48 b8 00 00 00 00 00 movabs $0x0,%rax >> 204: 00 00 00 >> 1ff: R_X86_64_64 .rodata-0x8 >> 207: 41 55 push %r13 >> 209: 41 89 f5 mov %esi,%r13d >> 20c: 41 54 push %r12 >> 20e: 49 89 fc mov %rdi,%r12 >> 211: 55 push %rbp >> 212: 48 89 d5 mov %rdx,%rbp >> 215: 53 push %rbx >> 216: 0f b6 5a 01 movzbl 0x1(%rdx),%ebx >> 21a: 48 8d 34 dd 00 00 00 lea 0x0(,%rbx,8),%rsi >> 221: 00 >> 21e: R_X86_64_32S .rodata >> 222: 48 89 f1 mov %rsi,%rcx >> 225: 48 29 c1 sub %rax,%rcx >> >> find_jump_table() saw the .rodata reference and tried to find a jump >> table associated with it (though there wasn't one). The -0x8 rela >> addend is unusual. It caused find_jump_table() to send a negative >> table_offset (unsigned 0xfffffffffffffff8) to find_rela_by_dest(). >> >> The negative offset should have been harmless, but it actually threw >> for_offset_range() for a loop... literally. When the mask value got >> incremented past the end value, it also wrapped to zero, causing the >> loop exit condition to remain true forever. >> >> Prevent this scenario from happening by ensuring the incremented value >> is always >= the starting value. >> >> Fixes: 74b873e49d92 ("objtool: Optimize find_rela_by_dest_range()") >> Reported-by: Randy Dunlap >> Signed-off-by: Josh Poimboeuf > > Hi Josh, > > When applied to linux-next 20200414 (where it was reported) and using > config-r2092, objtool still loops (I killed it after 6 minutes of CPU time). Nope, scratch that. Operator error. Sorry. > When applied to linux-next 20200424 and using the same config-r2092 file, > objtool appears to terminate normally and the entire build does also. > > Acked-by: Randy Dunlap > Tested-by: Randy Dunlap > > thanks. > >> --- -- ~Randy