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: 10723777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A4F6A159A for ; Tue, 11 Dec 2018 13:40:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9556D2ACDD for ; Tue, 11 Dec 2018 13:40:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 892C42ACD3; Tue, 11 Dec 2018 13:40:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 739C62ACDD for ; Tue, 11 Dec 2018 13:40:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 835698E008B; Tue, 11 Dec 2018 08:40:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7BB938E004D; Tue, 11 Dec 2018 08:40:22 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60FF68E008B; Tue, 11 Dec 2018 08:40:22 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by kanga.kvack.org (Postfix) with ESMTP id 0447A8E004D for ; Tue, 11 Dec 2018 08:40:22 -0500 (EST) Received: by mail-wm1-f69.google.com with SMTP id p16so683005wmc.5 for ; Tue, 11 Dec 2018 05:40:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; bh=Pp6D2Xqk4Fo9g4wHZxLytPHo90HHhuuC90Gfi2XsVKk=; b=l9FG/iE1HcYikS333NCeCvDraA6NlPuDa5iCSn4yXOZNTjMR8DCUkfiF2k/rCVqNm1 0uKdGhRpNVuIODMI9kLxqvBGFtFZASWkYyRr7uqZMbzYcZKnMZ8h4NnYiUZXFvnxAbbZ uTrCJ/Ic9cKS0I3IPWQYwVO2bNfWEsO+ySKKoZmGlRZ6DouEw/r63FxUikTjgX5SLDza AWA9O3+TtKACIfxDKACXCdwRelhkGwqTk4EJRiFx8unPMYADU5kqgwHIiRB5xA/HhO0b DtrsYzYpo1q3VpguCUG/mXEcUOyTCqWycmM3+1JLw/gfdRATqjOzkSbvla6uKVba8Kz8 7PNA== X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 212.227.126.130 is neither permitted nor denied by best guess record for domain of arnd@arndb.de) smtp.mailfrom=arnd@arndb.de X-Gm-Message-State: AA+aEWaM4/iofeO/VqL5mvrqZ4paf45gEz7gZ7KyYPkh3pVa3KanWtKq crST4YyJfU7P5fQSU/NIGVFLx98K/rqBilSOU45QER58GaGwtKxs7ENSDS/Tu80CO5tfRj392Fs kRxfezjX/pl5+E2TYxNbRj7VcRW3EWIl1UUzcuWU+YtCNRjlyuKZ8nI7fpXvjaEY= X-Received: by 2002:adf:f848:: with SMTP id d8mr14571641wrq.178.1544535621514; Tue, 11 Dec 2018 05:40:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/UPoGyjt3BCGdeYgJJOA0RxmP5PKuKXtP6gYCwOj8VLgdbyOMxTkLDJ03vSSN+n/5kmQGKJ X-Received: by 2002:adf:f848:: with SMTP id d8mr14571582wrq.178.1544535620598; Tue, 11 Dec 2018 05:40:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544535620; cv=none; d=google.com; s=arc-20160816; b=vtadeevleLF7FJaJX+K7F4i3GESBuqFysp5/SrOhNK6q+tL/NjVi5zyZICnZBIq05Y fH3FmRQMeSkMZgG5GopJRzfknjLQDCaQWvcCgg0sQh03FuVPY60JHgxvPf7EsZUaexB4 uSwfhPJHp85LPyEuO1eBIGqbrL9O3Qvka27pqCabQpOX8pqMslS2ziPygG8RbXz60Oh5 U0W4LF5Z9eLZ10HVcV+sy71Z1noVvrFppl1qMOBwP8v8165xEic2UlNW6ASDz+hilMgJ NmmMy3s6TGwVNagpqC8yvBIX6ZGNk1uaBQU266pYXqA5t+YIGfYd/dZaOCQzyxHlwEOl Xymg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=Pp6D2Xqk4Fo9g4wHZxLytPHo90HHhuuC90Gfi2XsVKk=; b=muiBB4bsIKTfllmKJUFBOeeVP5tVNXMoNoGL0/X9Cko7aD0pp8wUqJjWRR9hzTo4qO RN0pGNEqeRaA9gOcvQw85ZvIuSAGl5QlFfwPQN96kwL0hxC5LPxwgoVi4RuUXIKwLeNN Eu1sGwHvt6yM3V05pk7eoLN+rRL3mFYE3kIDDAPHneugctSoRKXcRX5K4AtFQ4t6mo8e nF2qFa3uLH7IdR/vnbZibOAT7vSkpv6Dml/jNOcMqLeb23Wr2MPY4sdphtWt3rPImzpZ Z4k35bYofSpkD2zC4IVmaAfLb7ZCvnDSeQKbA9UCrClMEpiHsOZZIrIosFlB7aOLasQm C9uQ== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 212.227.126.130 is neither permitted nor denied by best guess record for domain of arnd@arndb.de) smtp.mailfrom=arnd@arndb.de Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.130]) by mx.google.com with ESMTPS id a16si21214wmd.137.2018.12.11.05.40.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 05:40:20 -0800 (PST) Received-SPF: neutral (google.com: 212.227.126.130 is neither permitted nor denied by best guess record for domain of arnd@arndb.de) client-ip=212.227.126.130; Authentication-Results: mx.google.com; spf=neutral (google.com: 212.227.126.130 is neither permitted nor denied by best guess record for domain of arnd@arndb.de) smtp.mailfrom=arnd@arndb.de 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-UI-Out-Filterresults: notjunk:1;V03:K0:vwxLsMjcKNg=:fqudpQ5jmFSl3ZyO5WG/zc 4dJBOXOGOB/RgV3ruvoCU73HaqkT/vKOPbOBdWWmtTPF7oSRzFsWcFYehb2PhhWZpXdTvU0tI wjIo+I2lJjhy6nSQ0ocOerHy49ItLg+/BDTQku84FsjopAWXmbM9mHAsm8qWYyUr9szMyk0ng MElpxn5nf+S7gsoKOAx+cn1EBRxYJoNGbFkEw1RZ6N9OmGVrwEx/PHYY8r3AIiclWleZXuLOQ t38/THslPsUWuzNJfP/PVMg9GZgUenREgf7LnZNlGO4sjEOi0JQpcCXe+lsp1EEOfwcHQnyFo UjSe2rWIfXM87vRD0dazXQrSNcHqXedzDP9tOrDTFhJP0xngWzO6LlErTAHJ/MDUZDGWb9DAH QMkxEM5GjyaBhW7P8dusWQw6lxqB91Q79dDQh3pQAm6UZQzEoWyUdfMhqvef0t6COt381Z6NX cTg9yQY8DxenbIa16t8nqFRcehuYSGxxbFwbCCxG0+BEY+wEeR9LJ0LIw6a8stIPbz+2H0aCH 0+7l/xTIJF2noh1Wy9T6ZYUrQdQ9InUnNALE014HCLmzOGPK6mxJxRSIr98f1hHLOBLnWMVOG PsemoREwckrtwDrUNWiTIz4NdrbRgZGaY49oRsoFOIKr16vZTfVEJhLBmlvQygrdj+zNymF3X +gbP7ZUNbdG5u/D5q2XIVle5aSUXZAqIYdwKf6Qxa8iwsjaQ1lCW9jr7liDBW1CDS/ePVNFdo B7ZaONsg6hLXjF2K7mvFAIvA+eEu6YbQl93c6Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Alexander Potapenko Acked-by: Andrey Ryabinin --- include/linux/kasan-checks.h | 2 +- mm/kasan/common.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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