From patchwork Fri Oct 18 09:42:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11197983 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54F1313B1 for ; Fri, 18 Oct 2019 09:43:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2264220820 for ; Fri, 18 Oct 2019 09:43:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Xbn4iZEx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2264220820 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 28A168E0024; Fri, 18 Oct 2019 05:43:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2165B8E0003; Fri, 18 Oct 2019 05:43:42 -0400 (EDT) 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 129458E0024; Fri, 18 Oct 2019 05:43:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id E04DD8E0003 for ; Fri, 18 Oct 2019 05:43:41 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 50DA318209A86 for ; Fri, 18 Oct 2019 09:43:41 +0000 (UTC) X-FDA: 76056418242.04.nest14_777656dd97c03 X-Spam-Summary: 2,0,0,0924994ee39413bc,d41d8cd98f00b204,3s4mpxqykcpyejgbcpemmejc.amkjglsv-kkityai.mpe@flex--glider.bounces.google.com,:glider@google.com:vegard.nossum@oracle.com:dvyukov@google.com:,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:1981:2194:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3868:3871:3872:3874:4250:4321:5007:6119:6120:6261:6653:7901:9969:10004:10400:11026:11232:11473:11658:11914:12043:12296:12297:12438:12555:12895:13069:13255:13311:13357:13846:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:30054:30064,0,RBL:209.85.221.73:@flex--glider.bounces.google.com:.lbl8.mailshell.net-62.18.175.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:30,LUA_SUMMARY:none X-HE-Tag: nest14_777656dd97c03 X-Filterd-Recvd-Size: 4572 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Oct 2019 09:43:40 +0000 (UTC) Received: by mail-wr1-f73.google.com with SMTP id v7so414908wrf.4 for ; Fri, 18 Oct 2019 02:43:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ykyUG9wjmMVlXZORIhUUUfbyzYBAOpIbtAYdLbQkt+k=; b=Xbn4iZEx2VhJhkoif/O5VzwdOh4wzkpmFcQOAtTaE3gbLTDkBwwCIXEJJCX+qd/rel LhBYj+qOugf2XFQTFsr1pX4xFuXVV2Uid9YvIA6kIMMx8ZJosB6xvBsL0Y/b33Wlzarb A2hb6GPyDGMD1JbbIFMT6kTTJCoSIfQxcoF76K3aww9aGQSz0AvLdgSFJZdYDLkU0YSn I1kC4AQkjZhChlV3lbEA3YAcU2qBkVmzFgpTYI+ry7Jx6HL+SdccwQrQvdC1zlG2F69t yLUeSArdjQgjiY7uC2mX8yDQT4QahifIYTdShm/l/lY9BAoP9yxoewDdswETvHWbJLmr UcAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ykyUG9wjmMVlXZORIhUUUfbyzYBAOpIbtAYdLbQkt+k=; b=rSqOPxGg4WPL1/WgemD9Bpk93Ks+dfMWAjKxdytmGeQommspbnXoGOcDlFlprVhQ7M 310AH1vZGxPjiKWd7T7F1EPdP/tB1C94KsmV6NPCOyQnEVeVdAncfkc7tgHuSoj+9ldP C272RLkX5aZNzwB3kOBdCghKU0GPGCzfVWNHhJl2M83qrTvF6KgDxSk5x8R+OxtBVZHP Z5hk5otyVwXfHYqcpIeoDMlKE/lXX2P74hi6QJ8pJ//Q0biOgSBqozQDBO4T1wb3tfPc Rk/zTuGbbQqkVVtcrgCSR5APrY+IzdTA6tfEpBvkNsAHtfvoG4NGAzjrAxsCPVI7jT9A dYIw== X-Gm-Message-State: APjAAAXDhHZ7pNhBwuBLe6ic6Q8JzLhDJK851cBicTk+GrZXx3SXdHIx 6WQ8YGq1+AW0Of6IG4h7ijEdOKlWoi0= X-Google-Smtp-Source: APXvYqyrkg8N0d8HRk2q40QlbsncMGiZ0Q5WEQRsdEynfiNi2jU4mq8U4SG6zmgYpVpKQmLNE/PhxAfkxnM= X-Received: by 2002:adf:e982:: with SMTP id h2mr4629886wrm.53.1571391819716; Fri, 18 Oct 2019 02:43:39 -0700 (PDT) Date: Fri, 18 Oct 2019 11:42:47 +0200 In-Reply-To: <20191018094304.37056-1-glider@google.com> Message-Id: <20191018094304.37056-10-glider@google.com> Mime-Version: 1.0 References: <20191018094304.37056-1-glider@google.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog Subject: [PATCH RFC v1 09/26] kmsan: introduce __no_sanitize_memory and __SANITIZE_MEMORY__ From: glider@google.com To: Alexander Potapenko Cc: Vegard Nossum , Dmitry Vyukov , linux-mm@kvack.org 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: __no_sanitize_memory is a function attribute that makes KMSAN ignore the uninitialized values coming from the function's inputs, and initialize the function's outputs. Functions marked with this attribute can't be inlined into functions not marked with it, and vice versa. __SANITIZE_MEMORY__ is a macro that's defined iff the file is instrumented with KMSAN. This is not the same as CONFIG_KMSAN, which is defined for every file. Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: linux-mm@kvack.org --- Change-Id: I1f1672652c8392f15f7ca8ac26cd4e71f9cc1e4b --- include/linux/compiler-clang.h | 8 ++++++++ include/linux/compiler-gcc.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index 333a6695a918..edba13a069a6 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -24,6 +24,14 @@ #define __no_sanitize_address #endif +/* KMSAN is a Clang-only tool, thus putting the defines here */ +#if __has_feature(memory_sanitizer) +# define __SANITIZE_MEMORY__ +# define __no_sanitize_memory __attribute__((no_sanitize("kernel-memory"))) +#else +# define __no_sanitize_memory +#endif + /* * Not all versions of clang implement the the type-generic versions * of the builtin overflow checkers. Fortunately, clang implements diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index d7ee4c6bad48..e5ebc788dde4 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -145,6 +145,11 @@ #define __no_sanitize_address #endif +/* + * GCC doesn't support KMSAN. + */ +#define __no_sanitize_memory + #if GCC_VERSION >= 50100 #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 #endif