Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5184849imb; Thu, 7 Mar 2019 09:31:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyVHU7qV3RECnrRheVofsTOu9Sl3IOQdRpT8G8Q37nWjHi+dTF0i7rB+ovL3u2G0kIBD/Sj X-Received: by 2002:a65:4549:: with SMTP id x9mr12600504pgr.3.1551979892005; Thu, 07 Mar 2019 09:31:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551979891; cv=none; d=google.com; s=arc-20160816; b=J6PLIxl1MjdvVSXp5VkJ6oFYtS3kPXNE6lX8E/KslIIZ6T5onHaMOP5WyuRc3Dguc/ LsbZ/DaybnnxAdJpopx0SJEQAM44P3B3fzwAwB6r+9drkX9qDeqqYRDinHj2zA3Gqgnu fc1Beo+6n0IiATO35wBvtYOd1TV1QOX4NRMALfn++FfGygEjDeQy9ZkUVmyWm1XfpYOO lEDceh9IUeyQt9GCwBo165dTirKxgSqsUXH9Iu6T0qpP9piegKDULcn/v+kEB2klYlRa aXXI77GemjY4bLss1bKrU7DV71zWNo05R2ASVbj4ot4v9b2WpDabGnqgYKlVIWNqpTiu Fm4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:from:cc:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date; bh=JnR69kXv7Cb/MOaYEWm13S62rDVe16xlHwuBl1Rgh0I=; b=HqpWYAPsQzs9RFCl5h/xbW8jKuqgwEz0MPJaXM6XAadcu4bChmcweD+C8f+yhsH33Z MlRVyqLXxVUcl2BVDOTMdnfn7G/VgX8xu82rjM1wPwlisfI26A47zjQtEs5hlTyo5OKc /0VhYLyNSjy3IEsrBs9MkKU9eo8rKAbbk125MT38ps5jJYr3K6PxTDmejVIr4Tn+H6m7 Mm3tvqp2pDCBU6kgH4pfPUTX4XEdvGfPwuoSspgjop+2R3KrT3gksdf+Vw/ex0w2n+RQ Ij4HcT3HBpXMdJ9/wO5y4x2Qb6HBA+qFal7/+KS1FX9HQDXykvywLEEzQhmgReqv6oNB taEg== 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 m26si4601171pfi.247.2019.03.07.09.31.16; Thu, 07 Mar 2019 09:31:31 -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 S1726358AbfCGRah convert rfc822-to-8bit (ORCPT + 99 others); Thu, 7 Mar 2019 12:30:37 -0500 Received: from terminus.zytor.com ([198.137.202.136]:47599 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726161AbfCGRag (ORCPT ); Thu, 7 Mar 2019 12:30:36 -0500 Received: from [172.19.131.165] ([8.46.77.96]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id x27HTSvi2273663 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Thu, 7 Mar 2019 09:30:00 -0800 Date: Thu, 07 Mar 2019 09:29:17 -0800 User-Agent: K-9 Mail for Android In-Reply-To: <20190307171829.xww7is5qja32r7ux@treble> References: <20190307114511.870090179@infradead.org> <20190307120317.GD32477@hirez.programming.kicks-ass.net> <20190307125526.GB32534@hirez.programming.kicks-ass.net> <20190307131312.GC32534@hirez.programming.kicks-ass.net> <20190307164705.qbu4ytdfdmsighas@treble> <2F80FC70-5D2F-425F-BEB5-D70E981CC684@zytor.com> <20190307171829.xww7is5qja32r7ux@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Subject: Re: [PATCH 00/20] objtool: UACCESS validation v3 To: Josh Poimboeuf CC: Peter Zijlstra , torvalds@linux-foundation.org, tglx@linutronix.de, julien.thierry@arm.com, will.deacon@arm.com, luto@amacapital.net, mingo@kernel.org, catalin.marinas@arm.com, james.morse@arm.com, valentin.schneider@arm.com, brgerst@gmail.com, luto@kernel.org, bp@alien8.de, dvlasenk@redhat.com, linux-kernel@vger.kernel.org, dvyukov@google.com, rostedt@goodmis.org From: hpa@zytor.com Message-ID: <714E9D57-CCAE-4A69-AC3E-E6AFC525834E@zytor.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On March 7, 2019 9:18:29 AM PST, Josh Poimboeuf wrote: >On Thu, Mar 07, 2019 at 09:04:36AM -0800, hpa@zytor.com wrote: >> On March 7, 2019 8:47:05 AM PST, Josh Poimboeuf >wrote: >> >On Thu, Mar 07, 2019 at 02:13:12PM +0100, Peter Zijlstra wrote: >> >> On Thu, Mar 07, 2019 at 01:55:26PM +0100, Peter Zijlstra wrote: >> >> > On Thu, Mar 07, 2019 at 01:03:17PM +0100, Peter Zijlstra wrote: >> >> >> >> >> >> > > 01be 20d3: 31 c0 xor %eax,%eax >> >> > > 01c0 20d5: 4c 39 eb cmp %r13,%rbx >> >> > > 01c3 20d8: 77 08 ja 20e2 >> ><__do_sys_waitid+0x1cd> >> >> >> >> randconfig-build/kernel/exit.o: warning: objtool: >> >__do_sys_waitid()+0x1c3: (branch) >> >> >> >> > > 01cd 20e2: 83 f0 01 xor $0x1,%eax >> >> > > 01d0 20e5: 48 89 c2 mov %rax,%rdx >> >> > > 01d3 20e8: 83 e2 01 and $0x1,%edx >> >> > > 01d6 20eb: 48 83 c2 02 add $0x2,%rdx >> >> > > 01da 20ef: 48 ff 04 d5 00 00 00 incq 0x0(,%rdx,8) >> >> > > 01e1 20f6: 00 >> >> > > 01de 20f3: R_X86_64_32S _ftrace_branch+0x148 >> >> > > 01e2 20f7: 84 c0 test %al,%al >> >> > > 01e4 20f9: 75 2d jne 2128 >> ><__do_sys_waitid+0x213> >> >> > >> >> > we do not take this branch and fall-through. >> >> >> >> And that is the error, I think. We should've taken it and went to: >> >> >> >> return -EFAULT; >> >> >> >> because: >> >> >> >> +1be xor %eax,%eax eax=0 >> >> +1cd xor $0x1,%eax eax=1 >> >> +1e2 test %al,%al 1&1==1 -> ZF=0 >> >> +1e4 jnz >> >> >> >> Is an unconditional code sequence, but there's no way objtool can >do >> >> that without becoming a full blown interpreter :/ >> >> >> >> > > 0213 2128: 49 c7 c7 f2 ff ff ff mov >> >$0xfffffffffffffff2,%r15 >> >> > > ffffffffffffe0eb } >> >> > > 021a 212f: 48 8d 65 d8 lea >-0x28(%rbp),%rsp >> >> > > 021e 2133: 4c 89 f8 mov %r15,%rax >> >> > > 0221 2136: 5b pop %rbx >> >> > > 0222 2137: 41 5c pop %r12 >> >> > > 0224 2139: 41 5d pop %r13 >> >> > > 0226 213b: 41 5e pop %r14 >> >> > > 0228 213d: 41 5f pop %r15 >> >> > > 022a 213f: 5d pop %rbp >> >> > > 022b 2140: c3 retq >> > >> >This "fixes" it, and also seems to help -Os make much code: >> > >> >diff --git a/include/linux/compiler.h b/include/linux/compiler.h >> >index 445348facea9..8de63db58fdd 100644 >> >--- a/include/linux/compiler.h >> >+++ b/include/linux/compiler.h >> >@@ -67,7 +67,7 @@ void ftrace_likely_update(struct >ftrace_likely_data >> >*f, int val, >> > .line = __LINE__, \ >> > }; \ >> > ______r = !!(cond); \ >> >- ______f.miss_hit[______r]++; \ >> >+ if (______r) ______f.miss_hit[1]++; else ______f.miss_hit[0]++; \ >> > ______r; \ >> > })) >> > #endif /* CONFIG_PROFILE_ALL_BRANCHES */ >> >> if (cond)? Or is ___r used elsewhere? > >______r is also the return value. And it's needed because cond should >only be evaluated once. So put a true; and false; inside the if. -- Sent from my Android device with K-9 Mail. Please excuse my brevity.