Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2745448ybh; Mon, 9 Mar 2020 12:07:56 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtE1+YkvoeM3RBizlnP8RThCeuYRMISfp59VU0zMU42PSogxl/AoTW2zdUOjWgRQP867hnU X-Received: by 2002:aca:ac46:: with SMTP id v67mr41189oie.62.1583780876288; Mon, 09 Mar 2020 12:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583780876; cv=none; d=google.com; s=arc-20160816; b=HDUpWCsbFq3OWShe+2nYe6GhA/8Rx4cgZq+txCl6Ud2XpW5jNd74Ix0ZRqf0oeHcV9 MzILAg0NCBgtnYPfaWRlhTSa4p65jDTLxyzY3oI1FjN/u3lrYjq4lBR4igJ7VkXMeCiL UqFbf2kQjK1iqUbX681Azta6jCZpZF3Wnxm9WpeioWlhTrvmkccnCMuoPWJ2JYAZXKnQ Gd4KaYafB2qNd+jUIbBPu77xgawBMHiboB6cEpQybpHhd1os7L1g9vH/uYZSpPraVYDb 8UI/ev6mMHiInTsuLJsyp/DNuU3/f+FlHgzJbMiayT02AHastcu69SH387GBTRa6ZKR8 SwWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=OjNDtsGIpga5S9MOnXexdGMHy+4NqHcErxXZGV+lrvc=; b=FFo974bR1PioK9xuYk9xjODi+XY7FeVXas8v1Hxk+TXHNf/kdgJLy22kbkdhF5WiE0 TNoobVNlpEye1S7Jax5+z4qV/k7oGJl0lCZ4sW2028Bd02s0qcylSvD/uthHmK6BG+yC i/p5KTQD9ipapDjzSX8xSX5BAvAF1ah4up9qlCaMEyu/9Eo4/2mKi0kWnU2Lv9jASnec wL6//U2CjsExIeOkdOaWgJVDlaYTDqzOGe8iYGr1KgQdnq90iWqBysbhN9ozv4ZzXawP 30ncqlisqVJZZQ9W+UM0GIRvLl+zHPYToOCEazTjV7oup8l6wPZJuEsAdR+X7MrTYW/s ZI0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B0g67XEe; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si3951964oir.130.2020.03.09.12.07.44; Mon, 09 Mar 2020 12:07:56 -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; dkim=pass header.i=@kernel.org header.s=default header.b=B0g67XEe; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727552AbgCITFz (ORCPT + 99 others); Mon, 9 Mar 2020 15:05:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:47662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727446AbgCITEZ (ORCPT ); Mon, 9 Mar 2020 15:04:25 -0400 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 952C524656; Mon, 9 Mar 2020 19:04:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583780664; bh=ukpScdr/IBgKHT9ol7CmXugjm6McPESPv9J1yjfJ/z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B0g67XEeyc8XUdpfd73I5W25pxNyCcTHvATMXJwveKJV3kAPwNI3nC3tsvNcvTUjz AKW8J6ZPH2xVEkBwFyp/RXQTDbrncZsqbwQ2HvsIyTz7SBFxOvP82nT317WyHDPHbI iUqvEzW51W1wwYaRnETyIkZXYjC9VBoe/47C6Cuc= From: paulmck@kernel.org To: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, kernel-team@fb.com, mingo@kernel.org Cc: elver@google.com, andreyknvl@google.com, glider@google.com, dvyukov@google.com, cai@lca.pw, boqun.feng@gmail.com, "Paul E . McKenney" Subject: [PATCH kcsan 10/32] copy_to_user, copy_from_user: Use generic instrumented.h Date: Mon, 9 Mar 2020 12:03:58 -0700 Message-Id: <20200309190420.6100-10-paulmck@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200309190359.GA5822@paulmck-ThinkPad-P72> References: <20200309190359.GA5822@paulmck-ThinkPad-P72> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marco Elver This replaces the KASAN instrumentation with generic instrumentation, implicitly adding KCSAN instrumentation support. For KASAN no functional change is intended. Suggested-by: Arnd Bergmann Signed-off-by: Marco Elver Signed-off-by: Paul E. McKenney --- include/linux/uaccess.h | 14 +++++++------- lib/usercopy.c | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index 67f01601..8a215c5 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -2,9 +2,9 @@ #ifndef __LINUX_UACCESS_H__ #define __LINUX_UACCESS_H__ +#include #include #include -#include #define uaccess_kernel() segment_eq(get_fs(), KERNEL_DS) @@ -58,7 +58,7 @@ static __always_inline __must_check unsigned long __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n) { - kasan_check_write(to, n); + instrument_copy_from_user(to, from, n); check_object_size(to, n, false); return raw_copy_from_user(to, from, n); } @@ -67,7 +67,7 @@ static __always_inline __must_check unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n) { might_fault(); - kasan_check_write(to, n); + instrument_copy_from_user(to, from, n); check_object_size(to, n, false); return raw_copy_from_user(to, from, n); } @@ -88,7 +88,7 @@ __copy_from_user(void *to, const void __user *from, unsigned long n) static __always_inline __must_check unsigned long __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n) { - kasan_check_read(from, n); + instrument_copy_to_user(to, from, n); check_object_size(from, n, true); return raw_copy_to_user(to, from, n); } @@ -97,7 +97,7 @@ static __always_inline __must_check unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n) { might_fault(); - kasan_check_read(from, n); + instrument_copy_to_user(to, from, n); check_object_size(from, n, true); return raw_copy_to_user(to, from, n); } @@ -109,7 +109,7 @@ _copy_from_user(void *to, const void __user *from, unsigned long n) unsigned long res = n; might_fault(); if (likely(access_ok(from, n))) { - kasan_check_write(to, n); + instrument_copy_from_user(to, from, n); res = raw_copy_from_user(to, from, n); } if (unlikely(res)) @@ -127,7 +127,7 @@ _copy_to_user(void __user *to, const void *from, unsigned long n) { might_fault(); if (access_ok(to, n)) { - kasan_check_read(from, n); + instrument_copy_to_user(to, from, n); n = raw_copy_to_user(to, from, n); } return n; diff --git a/lib/usercopy.c b/lib/usercopy.c index cbb4d9e..4bb1c5e 100644 --- a/lib/usercopy.c +++ b/lib/usercopy.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 -#include #include +#include +#include /* out-of-line parts */ @@ -10,7 +11,7 @@ unsigned long _copy_from_user(void *to, const void __user *from, unsigned long n unsigned long res = n; might_fault(); if (likely(access_ok(from, n))) { - kasan_check_write(to, n); + instrument_copy_from_user(to, from, n); res = raw_copy_from_user(to, from, n); } if (unlikely(res)) @@ -25,7 +26,7 @@ unsigned long _copy_to_user(void __user *to, const void *from, unsigned long n) { might_fault(); if (likely(access_ok(to, n))) { - kasan_check_read(from, n); + instrument_copy_to_user(to, from, n); n = raw_copy_to_user(to, from, n); } return n; -- 2.9.5