From patchwork Tue Dec 11 13:34:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153460 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp623468ljp; Tue, 11 Dec 2018 05:35:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uhu6NqtlKFhbTTqzSgvqzw2UOWFs5ca5HQwG3PVjSfW9Wq/xN05LLxSTpntIlscLlqs0LQ X-Received: by 2002:a62:2044:: with SMTP id g65mr16224169pfg.127.1544535308924; Tue, 11 Dec 2018 05:35:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544535308; cv=none; d=google.com; s=arc-20160816; b=Nxecx5lP+aY2PeUnUKPod+wvSLRhum8BBalZpl+UF1IWAV3VefrYAtr7ecypXFlK9C +OyUtFw/c/ygJoHiIyCjX/BdXuv5G+9ps6jMTfBej6ysvXNLkG8NVtMs6tAVyuBZibnZ zY31TVBvEYimuPt0JcbWx24HQh1hOxoSZZBxupZd78ymtbnBSpC7w94iiT/HIwAGSMg1 F4Wsv79JtbRYPdlDtLstZG00JCjKFfCCqGqVD8jM7AND6dy7ku+BhzvKcN8EDXuoEsRA JOUycpnYt9PPfcJ2PNUXBumkUqe83ZdTIdhAhTyVsCJgaV9IN4QYKiouYS6JQyoTWbkE 0BYg== 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:mime-version :message-id:date:subject:cc:to:from; bh=Pp6D2Xqk4Fo9g4wHZxLytPHo90HHhuuC90Gfi2XsVKk=; b=pRA0vyr9hDlWc4El/NAhSWGo6JYl7YFX8iUKouhfyNEXYC7BUvWtI6aYDUcbFYfDgt 7b31jw3MCEFbqSXgbddGHn4bB3WNkPwMp/lUlDA0kULYO/F3nPNM3qp+MWpDxkhWSzoW ulxndUOCFEOwJab86GPDk5UGwJCrRsqcTzsmvAsM2bYwe63ZYnQYqiHtXYnc8uPxj7qe 1w2erylF4OtfSobCOsbSpFOuIvj39LiwVCoFK++jdQs8q574xOO0IRNtWXtoT8XxJaH9 h+KsnsX8U4sN/zIAbLtDL/NFofDM82Bm2oVv9xTcgZBnUuzNYlu7QMW7+gw/3aC4BX09 RfdA== 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 e136si14052048pfh.17.2018.12.11.05.35.08; Tue, 11 Dec 2018 05:35:08 -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 S1726525AbeLKNfG (ORCPT + 31 others); Tue, 11 Dec 2018 08:35:06 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:38207 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbeLKNfG (ORCPT ); Tue, 11 Dec 2018 08:35:06 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1MXp1Q-1gyDNP1nyu-00Y9S6; Tue, 11 Dec 2018 14:34:59 +0100 From: Arnd Bergmann To: Andrew Morton , Andrey Ryabinin Cc: Anders Roxell , Ard Biesheuvel , Will Deacon , Mark Rutland , Arnd Bergmann , Alexander Potapenko , Dmitry Vyukov , Andrey Konovalov , Stephen Rothwell , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] kasan: fix kasan_check_read/write definitions Date: Tue, 11 Dec 2018 14:34:35 +0100 Message-Id: <20181211133453.2835077-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:3NV4RcGQl1HBnCrKLlXV1Xu+qAbG+2o5BPe28qfau76/IQ0XUDe n1qHTrKjyqCnVLqJMeEafcYAZY1kcBx/unMD152Ef0ZO+O3iZHUl9HrecaJ8pR5/mXT+obu 1NNCkPg4DSuRJJneMlbLJkrTFL77BFtyjiCtjwUAo/1O0lEiZKPpo5BHF2YyTEsMNhwRsD2 CkQxxuYJMeAy2hAd0/Lzw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:rPwv5eM93nI=:p9zfN6yHNp8eRXxLlpjRvw KP660BQb2bNcXujATOGQ7MgKuNO9LS4uie+hacaxL7eZCvoiIPwB3mCtnfiYGl68fqC//Dxv1 zBmAU5+oHkqxW/SfB9bobbPFGpcEo6f6h2GMdtwSwy9clqfJm8vs1QA7yuRNxRWLzMsqAsbyZ sPp2BByri/fi/lWTNLk7BIa4v85sWm/5vwZTTsFtf1MwQh9IMVVsdfulUFhNxiUGE+cJ6/k2b 3hb9IJqt4mooyt9W2J2hlUxrFZ3Hr4EV1YHhM94q271WDtvpg24H3EfBD4UU/LYtXIRDJGI5g YtEgoZ3Xdq/9qWAcd1tVHnI9NVuErY7+m00Ii1niH6Hld1Hyjm5420rn3uLvznl7gMb4z7/IU If11wn66EJ/kGLrhXbSxCHxe9+EOAulTcaMmi2n19CyIeFrtAqoV+/8BS5AOKrR7XyiCg3Iwb lTz4ShQYLdBEsHn5Pejj5tcj5wsAe7I6YAtvsiur60wDVSpkz+1YwhqbJMuaVUH23FZw4qDe1 jpAp+6y01rIXj2/MwNv/WCjVmPme4XM9Q7MXir1u6EihfJXAtwBbC1c1lGHdjeD8pAQwEtFOv QemUHy8/SSmUed140DH4RNLfO5Zl1VcPnbi9yX4kuE+mk9sZtb1FmBxTMVesesZHD1a8SY2/n rzz0e93LfLJ07zPLotFvUem5w45U3OZ3i9rrkwFt6L6dvsR4jMmxKD5sUw68o3AkVQxsNo5Tj a1EvntzjtiT5jrgy32k0mpI1zOimV0c5/YqKQQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Building little-endian allmodconfig kernels on arm64 started failing with the generated atomic.h implementation, since we now try to call kasan helpers from the EFI stub: aarch64-linux-gnu-ld: drivers/firmware/efi/libstub/arm-stub.stub.o: in function `atomic_set': include/generated/atomic-instrumented.h:44: undefined reference to `__efistub_kasan_check_write' I suspect that we get similar problems in other files that explicitly disable KASAN for some reason but call atomic_t based helper functions. We can fix this by checking the predefined __SANITIZE_ADDRESS__ macro that the compiler sets instead of checking CONFIG_KASAN, but this in turn requires a small hack in mm/kasan/common.c so we do see the extern declaration there instead of the inline function. Fixes: b1864b828644 ("locking/atomics: build atomic headers as required") Reported-by: Anders Roxell Signed-off-by: Arnd Bergmann --- include/linux/kasan-checks.h | 2 +- mm/kasan/common.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) -- 2.20.0 Reviewed-by: Alexander Potapenko Acked-by: Andrey Ryabinin diff --git a/include/linux/kasan-checks.h b/include/linux/kasan-checks.h index d314150658a4..a61dc075e2ce 100644 --- a/include/linux/kasan-checks.h +++ b/include/linux/kasan-checks.h @@ -2,7 +2,7 @@ #ifndef _LINUX_KASAN_CHECKS_H #define _LINUX_KASAN_CHECKS_H -#ifdef CONFIG_KASAN +#if defined(__SANITIZE_ADDRESS__) || defined(__KASAN_INTERNAL) void kasan_check_read(const volatile void *p, unsigned int size); void kasan_check_write(const volatile void *p, unsigned int size); #else diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 03d5d1374ca7..51a7932c33a3 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -14,6 +14,8 @@ * */ +#define __KASAN_INTERNAL + #include #include #include