Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp559310ybg; Wed, 3 Jun 2020 07:50:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFqRFflSbgmotaOdL3+xmJ14Oqg0qUHUbXRBuXu4q5eN7s9e5FRQsbWPGB7zogRzf4rYVS X-Received: by 2002:aa7:c69a:: with SMTP id n26mr11494807edq.2.1591195815857; Wed, 03 Jun 2020 07:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591195815; cv=none; d=google.com; s=arc-20160816; b=j+saqObLQAGOJCwEMs8nbIlxFqG2nzx+pQgKvkLDuy+jKUjJDHy36dYpJAjUgPl8jp 7Mtr6tsOC2bRqXO1MiAw3s+PDzJzN0g+cEQXnPfRpEpQ73onnhhG3jtUFd7BTNKCvBL8 Bh+ziRDX3wj4hPxzoYq8tBdxqQg2If/y3gLA9p8YYQAeIxs1hRMIbrMzym/TUU5tZU5i RJoypiMYhfPXc26SurU75GysfENXXKUW7EoPtvRBhZWdevY2KVxSEerC4wT+7mcPnG9o LUiFc/dgCyCKY9EVBMBTRXy9+wKbZ0H/MqumBk4rtyqZfhYIhQYIokZnw82QIW3CHouP OZJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=K4mWQ9BO+ADAedoRkxDsxNn5p6Rl0+bZnTb72ellqDY=; b=YJFRIQfO9Ow0w9a1yGzeTwtadRT55yA1DqMmgQdqNUBPerFRj0sxYE7lKHOgYAQI8W nmCX04BhvUrtNlVkCNon54gFgHYB5RZ2h//vpe7MVD/9t/12vQaTzEmR0Ql17edCV+8Y AdEURk3iyNIFzy2K8EJUMc/cuvWO0KlvJaEk3mrtplihE4qrm6n5oYEdujhI91lQbXkw V/xxfaLjS2ValWJplrwu4BM49la95H8XsVOWeiW29Ixg0h8uYdAke4xCCbk73NwtPvSw WkBJH/Qoe8bI1p/p5FuY8+zWNntn9P11MS6e41nDKqwOtVi6vnrDxfSjPhh2adEzJ1R5 lobQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=MIkps4tW; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gv4si1041685ejb.565.2020.06.03.07.49.51; Wed, 03 Jun 2020 07:50:15 -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=pass header.i=@google.com header.s=20161025 header.b=MIkps4tW; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725986AbgFCOsI (ORCPT + 99 others); Wed, 3 Jun 2020 10:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgFCOsH (ORCPT ); Wed, 3 Jun 2020 10:48:07 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FBF4C08C5C0 for ; Wed, 3 Jun 2020 07:48:07 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id o13so2073796otl.5 for ; Wed, 03 Jun 2020 07:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=K4mWQ9BO+ADAedoRkxDsxNn5p6Rl0+bZnTb72ellqDY=; b=MIkps4tW3dJjh2gI+MkcQDiSeHA+/2kyUTQs223quN2IFGpE5XwbsFdY0xuq1Pinx/ 9Cur14MPWPsnKRuFW8iuEli5YlOWV4L03LVquMJk7w/RnWUT7vvxrEA0SgreCY9PlWQl SMIwYh4Okf4LTQAFjd5y3kIId4UHXRGMRyCHfEplkPLMbCIsVd/gDdfRVJaU284qpJPN pgdlDRfpzpnjzkb5jqg90mr2QxDPJfa4qpm8JhOka8ZbuQ4OydQUriTBWd4V7Zlm4vih 8lsA9I/2CyfiG+040dFG7EAbys/uwW8GgPkBBMyeQ0letlLHoWlPzOr3Y1V+NvTPLXnD 5xuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=K4mWQ9BO+ADAedoRkxDsxNn5p6Rl0+bZnTb72ellqDY=; b=Rg39aKp3L9EFZytRrwsvCyle9mBTXFSD17dVcOD4mSKu1u73CnGTrs1+lDHAuHWMy4 +ntZRHkiplsDHnY3h7SISGuq1XyASBx1+oiRUgT5OGbAGMdXMTemrN9PZTLeZcWoBrzt ppN7AUp1cY7BXyaNjqVD5DarzfZ/Pw894Wqt+0AJ5h6egV0AB6hw0HekUkRYkgJpkmpv 8dyBx+w5Nj/IM4TuE2h/s4RVv6hCSwc44Lp8o/jXzWR8waN27rBKHtJ0FP+1NrZKokkX UTSrd90EWuvedXV+TkPA7eUgkXabne7MJsLc/uHsmVSUfZg9ukhZtSV+M872jZQ/xnse D4Fw== X-Gm-Message-State: AOAM530bbkM+Oku/eWsmksgCmNChxWkulihkwjzbyHVgBog56r73Vh+J qOMrL/QKb8POG1duIhtKVMLRui3TDTBt4E3zERDX2A== X-Received: by 2002:a9d:6958:: with SMTP id p24mr256297oto.17.1591195686488; Wed, 03 Jun 2020 07:48:06 -0700 (PDT) MIME-Version: 1.0 References: <20200603114014.152292216@infradead.org> <20200603120037.GA2570@hirez.programming.kicks-ass.net> <20200603120818.GC2627@hirez.programming.kicks-ass.net> <20200603121815.GC2570@hirez.programming.kicks-ass.net> In-Reply-To: From: Marco Elver Date: Wed, 3 Jun 2020 16:47:54 +0200 Message-ID: Subject: Re: [PATCH 0/9] x86/entry fixes To: Peter Zijlstra Cc: Thomas Gleixner , "the arch/x86 maintainers" , "Paul E. McKenney" , kasan-dev , LKML , Will Deacon , Dmitry Vyukov , Alexander Potapenko , Andrey Konovalov 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 On Wed, 3 Jun 2020 at 15:32, Marco Elver wrote: > > On Wed, 3 Jun 2020 at 14:18, Peter Zijlstra wrote: > > > > On Wed, Jun 03, 2020 at 02:08:57PM +0200, Marco Elver wrote: > > > > > What is the .config you used? I somehow can't reproduce. I've applied > > > the patches on top of -tip/master. > > > > So tip/master, my patches, your patches, this series. > > > > $ make CC=/opt/llvm/bin/clang O=defconfig-build/ -j80 -s bzImage > > > > is what I used, with the below config. > > > > Thanks, can reproduce now. So far I haven't found any indication that > there is a missing check in Clang's instrumentation passes somewhere. > I'm a bit suspicious because both Clang and GCC have this behaviour. > I'll continue looking. This is fun: __always_inline functions inlined into __no_sanitize_undefined *do* get instrumented because apparently UBSan passes must run before the optimizer (before inlining), contrary to what [ATM]SAN instrumentation does. Both GCC and Clang do this. Some options to fix: 1. Add __no_sanitize_undefined to the problematic __always_inline functions. I don't know if a macro like '#define __always_inline_noinstr __always_inline __no_sanitize_undefined' is useful, but it's not an automatic fix either. This option isn't great, because it doesn't really scale. 2. If you look at the generated code for functions with __ubsan_handle_*, all the calls are actually guarded by a branch. So if we know that there is no UBSan violation in the function, AFAIK we're fine. What are the exact requirements for 'noinstr'? Is it only "do not call anything I didn't tell you to call?" If that's the case, and there is no bug in the function ;-), then for UBSan we're fine. With that in mind, you could whitelist "__ubsan_handle"-prefixed functions in objtool. Given the __always_inline+noinstr+__ubsan_handle case is quite rare, it might be reasonable. We could try to do better, and make __ubsan_handle_* 'noinstr' by checking if _RET_IP_ is in .noinstr.text and just return. Would that work? But that would only be useful if there is a UBSan bug. It might also slow-down regular UBSan, and if we assume that the __always_inline functions called from noinstr functions that end up with UBSan instrumentation don't have bugs (big assumption), then not much is gained either. Thoughts? Thanks, -- Marco