Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp824308pxb; Thu, 5 Nov 2020 14:07:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5hUJ+4UpgkavU5iFT17Na7kM8//sPHP2r2cTIuW1RmejRbFXyK28GydGyKyct/FvnfjiJ X-Received: by 2002:a50:ace6:: with SMTP id x93mr5010472edc.368.1604614058650; Thu, 05 Nov 2020 14:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604614058; cv=none; d=google.com; s=arc-20160816; b=MRJZBcOoieAjJrI3DpwNYWfDUm4uoC5IxyK0gK3ImdLTIv4hmXUPpjM/ESxIeyQlJQ 81m58Xa9mT7GqqR/j6EUq8HCq3g0rRnp3Ct5KUFzrPcG9oaWXep+V5731453C5pGTFeB 3VZ1Z/yUncSgMGQD8mqFXQd1K07N5TQN5C1oij/+Jz3ZnidaXJ8Bs7AxmJ1zab73wKPl OZ27+qMH84JzkLrxls9tBi8VWVDjPwBlPDQGHSagzXir8BiCKl0coW6OPQTrH49klW2f uUPyo4SrkBJICAyIqJZdlpBhS1Dd+H0glp49PUwrTgit+XtY9hk8FLwxKwpoEGJp7W0S 8/IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=xKMULEpOfBI04klAXWZHIkY2FMbwD1Yaxglwahy21Yw=; b=FHNKDxbzfjXKgDfNmCXxgTElvqDfEunZiRv4HpUIq45rc9/r2/hX49yL1ZdDOspOgi KOPNQj08BxHyBdUg+uRFGbKA70huIxyy9e3e1LujI32e6U1jz2Rjpt8LYccYzxzpTp+6 Me0kQNwBptzV4suWaqjpEqe3K3gNJ4dkKbEDPZjPPZGbtanxGnCdrGbwvAzxhwSaCNSH bfMDrmVoWg3xkodFDax+B8Zmc+EBOBcpGOABsz0qVD6c0xI7LSZvh+ZVBu+J30d4Lnq1 Ab698P5LCY/h2fo9rJCl/D130oRoi/ojE8R8p//lh5AFotbMK3Nbu4cHC+THtj+Nuqo/ fuPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jpi8vFYw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id u20si2033039eja.75.2020.11.05.14.07.16; Thu, 05 Nov 2020 14:07:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jpi8vFYw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1732636AbgKEWD1 (ORCPT + 99 others); Thu, 5 Nov 2020 17:03:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:59894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732600AbgKEWD0 (ORCPT ); Thu, 5 Nov 2020 17:03:26 -0500 Received: from paulmck-ThinkPad-P72.home (50-39-104-11.bvtn.or.frontiernet.net [50.39.104.11]) (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 9AB5120936; Thu, 5 Nov 2020 22:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604613805; bh=2+HotQE+QHTjPInTwscwXtw7Cu74cQYbDgwRy6uoWSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jpi8vFYw5w/SN0IHCGdTyQJsnIPAR4C0X0VjvEEmyz5eQPKGKJ/9TfjN1oYSAy/1o Qon0nuKQxKXefanlgU/UJuv4j7CWrAVrwMEwtooMLQqXZQ6f8XZrr/2Fku4PYfCa6t 8YBx2o49UrD6sn7/fB5nzKNEdRQOYbmQjTjF31h4= 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 2/3] kcsan: Never set up watchpoints on NULL pointers Date: Thu, 5 Nov 2020 14:03:23 -0800 Message-Id: <20201105220324.15808-2-paulmck@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20201105220302.GA15733@paulmck-ThinkPad-P72> References: <20201105220302.GA15733@paulmck-ThinkPad-P72> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marco Elver Avoid setting up watchpoints on NULL pointers, as otherwise we would crash inside the KCSAN runtime (when checking for value changes) instead of the instrumented code. Because that may be confusing, skip any address less than PAGE_SIZE. Reviewed-by: Dmitry Vyukov Signed-off-by: Marco Elver Signed-off-by: Paul E. McKenney --- kernel/kcsan/encoding.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/kcsan/encoding.h b/kernel/kcsan/encoding.h index 1a6db2f..4f73db6 100644 --- a/kernel/kcsan/encoding.h +++ b/kernel/kcsan/encoding.h @@ -48,7 +48,11 @@ static inline bool check_encodable(unsigned long addr, size_t size) { - return size <= MAX_ENCODABLE_SIZE; + /* + * While we can encode addrs= PAGE_SIZE && size <= MAX_ENCODABLE_SIZE; } static inline long -- 2.9.5