Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3744244ybi; Tue, 18 Jun 2019 05:57:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVo2DZu4gPdHH+SYBQKV/7PKSkbyiVVyp3AFEPx+SR9QS74mR1ciuQzgksGnF9wgagg7qK X-Received: by 2002:a17:902:b609:: with SMTP id b9mr34638050pls.8.1560862657965; Tue, 18 Jun 2019 05:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560862657; cv=none; d=google.com; s=arc-20160816; b=HQqB2F5Dk5WaZwQs4qtAvrOPzm/qMfCT+ZP5zsOgSs4CgJjRvCnKf6Ph/Za70mIcdk n93f4PH7Bd9Qc4tcSa0TjrV/FqujpxLfxawQFNmP1lpqwiXHeqpTDmqsMHjANOclzEHm YmPHChXJzMMWD+MMN9I91xQtKK7qM/WY2J8RhqkH/EjBO8CD+z/L+B2m+pLOFf5jjoTK gi3CtaL5ExcSz4GYTyqCFD++KLy1YEFzBOQCzRdogoAB0caazOMZWonH9I4tdRpBwT54 OhybLokm5I4U42Eawu54Lw7uvmI4bmgFVMBDx+3gaHvezUHn9HPPt7N3T4vhhMlMaDiT Tk9Q== 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; bh=fCf5iHrLfN/sCDfBuv4fsEiVMo3wKaNoIwbeEHLt/rc=; b=Ln282BuMJUq3/nGD6ydAonlealDTHz65PMC5ulH2K6xmac5awtsK+OdVffNCBzw66E XEWCJxoq485X9//EBfJ3O7SNsNShY4ETdOaud7eSgGL52Lu6+5N1gdKcloRGtqigwfGf rPxHakYvAB6OCeX2nl3XcN8DwLD2qYhFVil4F90mN5A6rKHcDCN0lTFAU/4TzIKw7fOX WUUoP/UNvAXM/yyGx1aarX7Up1DOhaoqFBdAsV1zqkh2E2aw6ImtYNwgKU3GecrNNPUf ZUC2TtL62ESxl/L0/VtGg/qtI8cZJxreOkRc62+bdQFWyyf9i5hT4QL0ElDECbMfu15K XfJA== 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 32si12982881plc.152.2019.06.18.05.57.23; Tue, 18 Jun 2019 05:57:37 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726739AbfFRM4Z (ORCPT + 99 others); Tue, 18 Jun 2019 08:56:25 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:40057 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725913AbfFRM4Z (ORCPT ); Tue, 18 Jun 2019 08:56:25 -0400 Received: by mail-qt1-f196.google.com with SMTP id a15so15085108qtn.7; Tue, 18 Jun 2019 05:56:24 -0700 (PDT) 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=fCf5iHrLfN/sCDfBuv4fsEiVMo3wKaNoIwbeEHLt/rc=; b=PT6Pa5D4n6l9kyKzExM2NFZe3+YbP5u3ymXhF58YTPTEVzVyC/cQUq3I5UyRs9e9KK IIU4AFvTFcxwSibJk2iTDRd1rq7aVptJFfBkTesyFFl4gAREmkyBm8qnrAjhdEK7Rc9X nJe0+HsA92fEOapnYSxVu/JyGrtucL0KzpFMclthtIdLG6JSqx4st/wdGSVaPU+mZwhy oqvbaIDKDWpRZwIIVLeWcgK6aZ6fts0ScOgi3JLe/PN4vF7YvtbDCar/X/TWK64IL5Eg jX+FYdK9XHSHYh5Dm7zb3kB64Y/kBv3ZooIEq+bIsQYA2B8lsuMa1UG+sviCNBX2BGs0 ymxg== X-Gm-Message-State: APjAAAXU3TDFruLNvyVp2nCCVH8eUshP8qtra7ZmSC1iI9f4SEtLahCQ dS1gmURlintfCcrRSjjpfifbYmE2EG2lq/Sg9eshoyPkBUY= X-Received: by 2002:a0c:b758:: with SMTP id q24mr27130440qve.45.1560862584288; Tue, 18 Jun 2019 05:56:24 -0700 (PDT) MIME-Version: 1.0 References: <20190617123109.667090-1-arnd@arndb.de> <20190617140210.GB3436@hirez.programming.kicks-ass.net> In-Reply-To: <20190617140210.GB3436@hirez.programming.kicks-ass.net> From: Arnd Bergmann Date: Tue, 18 Jun 2019 14:56:07 +0200 Message-ID: Subject: Re: [PATCH] ubsan: mark ubsan_type_mismatch_common inline To: Peter Zijlstra Cc: Andrey Ryabinin , Andrew Morton , Josh Poimboeuf , Linux Kernel Mailing List , "# 3.4.x" 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 Mon, Jun 17, 2019 at 4:02 PM Peter Zijlstra wrote: > > On Mon, Jun 17, 2019 at 02:31:09PM +0200, Arnd Bergmann wrote: > > objtool points out a condition that it does not like: > > > > lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch()+0x4a: call to stackleak_track_stack() with UACCESS enabled > > lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch_v1()+0x4a: call to stackleak_track_stack() with UACCESS enabled > > > > I guess this is related to the call ubsan_type_mismatch_common() > > not being inline before it calls user_access_restore(), though > > I don't fully understand why that is a problem. > > The rules are that when AC is set, one is not allowed to CALL schedule, > because scheduling does not save/restore AC. Preemption, through the > exceptions is fine, because the exceptions do save/restore AC. > > And while most functions do not appear to call into schedule, function > trace ensures that every single call does in fact call into schedule. > Therefore any CALL (with AC set) is invalid. I see that stackleak_track_stack is already marked 'notrace', since we must ensure we don't recurse when calling into it from any of the function trace logic. Does that mean we could just mark it as another safe call? --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -486,6 +486,7 @@ static const char *uaccess_safe_builtin[] = { "__ubsan_handle_type_mismatch", "__ubsan_handle_type_mismatch_v1", /* misc */ + "stackleak_track_stack", "csum_partial_copy_generic", "__memcpy_mcsafe", "ftrace_likely_update", /* CONFIG_TRACE_BRANCH_PROFILING */ > Maybe we should disable stackleak when building ubsan instead? We > already disable stack-protector when building ubsan. I couldn't find out how that is done. > > Fixes: 42440c1f9911 ("lib/ubsan: add type mismatch handler for new GCC/Clang") > > I don't think this is quite right, because back then there wasn't any > uaccess validation. Right. Arnd