Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2094999ybe; Tue, 3 Sep 2019 07:57:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCHO8Ic5FT6/XCVrljk/d9OmheTSjXgv2DO+5T1esCUrDLqPK8ldH0dzdJDLfPGcT7DY+5 X-Received: by 2002:a63:c03:: with SMTP id b3mr31380429pgl.23.1567522623141; Tue, 03 Sep 2019 07:57:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567522623; cv=none; d=google.com; s=arc-20160816; b=Pdh9VpqUv/d2vKlctr7Xz69t9rWu0zcx5gaC+acCT9ypv6Pf5MysY3g1ofVrC9Fej6 1MJ93aRKieQWr37gEr1xhPo0RbMqSooaYiuRZa6UGx2flOy/ngOCtiKno5M0QeSx3w3y Ouy012d09RlnRorYSmBTmibhLXnHX37eTgZxWKOqBIXwU/2u8/8xrcejQ7+UHogvqSuB WmbwmWxcJmRXEFB7rM/gLQZXJdAKEy6ZgwGjwCXbmDwkh83HxYRFU9IpiWUsf3N01WdC 0FbjH62APnCBz/qlT6kNXp8Hj+CiPNBcIluuH/+e8+7aITwOiGBvCZdbPVETCH/364WC X5+Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HNDV9DT7O32N2h9l7CrACdWJSzNVfR3Dv9pnUT55kOg=; b=F1/As5GwQu6UzjC3GTPsfsDwRAeZlHiXMtxS2LjPehwL5wgbR2g+Dpqa1Du4ae9gBw KHHZ+BjOo6fUQ2674BogDVpw4k+fojWsFdvA+lzLUzXo82ul+8Yhje8qo4zvwiutZ5Fc KI/67dWlgrDbYbya9iagzm8Wl5nPeF0God8e1TbNPV/YKV2zINcYKCSkQHB4w/LE0zTH rmfLCf6P5H7wHy9Dlv7zi3emWOaJc18uCYQj8J1+0NNQs4HsQ0MjQ0JTuSUtoTzCIai4 MhgC6OYHbT/zso9ZCy/uBiSMj6xQZd7jbXrVnmSo1o2obv0ba+PRe4jDBouhzBFLChLo U8nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=FR2A8WMD; 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 s11si14566605pgm.412.2019.09.03.07.56.47; Tue, 03 Sep 2019 07:57:03 -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=@axtens.net header.s=google header.b=FR2A8WMD; 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 S1729644AbfICOzx (ORCPT + 99 others); Tue, 3 Sep 2019 10:55:53 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36452 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbfICOzw (ORCPT ); Tue, 3 Sep 2019 10:55:52 -0400 Received: by mail-pf1-f195.google.com with SMTP id y22so5308525pfr.3 for ; Tue, 03 Sep 2019 07:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HNDV9DT7O32N2h9l7CrACdWJSzNVfR3Dv9pnUT55kOg=; b=FR2A8WMD+DnhNMxW/AdS1tEdkZRXiPpMUgFAehGpzfwPiADje+HGwN/tXiTSg49kjs 8axf1yK6lckfmwIzBX6evzvsGC+UBpSQ5lgI/sc1uFwoQLHw2slgHM1nEaZg/UP3PXxr 2SPS4jhPXzi9sV3nsNx99PY1dXpjYVpzCMVE4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HNDV9DT7O32N2h9l7CrACdWJSzNVfR3Dv9pnUT55kOg=; b=pz9OFYPqbiaaBgXQ2SSJ2YsJZzvbXvsHKNM4ydpYCZz0Q51FTt6Mr/iCjMYZxel4O9 70dUSfks0sLJJCuUDpkGMUe0ms9gWgGwOT/VQYnB42yXE8eFIpfZwuypfeMHNgExelv/ G9xlP4/p0FVUcM7dzfijnBCQIgWGTNdPnoI07iOUBo3A3x8M64DOEg3Bxqo5uYuoZVs4 +Jz9O/kgR3LfrUezRCpA4g2MQ9yz1lA7OfHXbVCYielysBw0Kd1PDZesXCRwATtODaLh VkWM2sUMl+oSDNApVvWQlressZmij7RF4sfsbJ2c9jKt88Gr5tOu2Bh3uPbzWRnchkZI Hlow== X-Gm-Message-State: APjAAAUEYucE5FruCwAA7er+xlyum+0pakECKR0lEZlzhImLX6+8Slyw x+uZtOHB/lcADGDOiG5yI8TaCQ== X-Received: by 2002:a17:90a:fe0e:: with SMTP id ck14mr466805pjb.78.1567522551845; Tue, 03 Sep 2019 07:55:51 -0700 (PDT) Received: from localhost (ppp167-251-205.static.internode.on.net. [59.167.251.205]) by smtp.gmail.com with ESMTPSA id b19sm16216868pgs.10.2019.09.03.07.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:55:51 -0700 (PDT) From: Daniel Axtens To: kasan-dev@googlegroups.com, linux-mm@kvack.org, x86@kernel.org, aryabinin@virtuozzo.com, glider@google.com, luto@kernel.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com, dvyukov@google.com, christophe.leroy@c-s.fr Cc: linuxppc-dev@lists.ozlabs.org, gor@linux.ibm.com, Daniel Axtens Subject: [PATCH v7 2/5] kasan: add test for vmalloc Date: Wed, 4 Sep 2019 00:55:33 +1000 Message-Id: <20190903145536.3390-3-dja@axtens.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190903145536.3390-1-dja@axtens.net> References: <20190903145536.3390-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Test kasan vmalloc support by adding a new test to the module. Signed-off-by: Daniel Axtens -- v5: split out per Christophe Leroy --- lib/test_kasan.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 49cc4d570a40..328d33beae36 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -748,6 +749,30 @@ static noinline void __init kmalloc_double_kzfree(void) kzfree(ptr); } +#ifdef CONFIG_KASAN_VMALLOC +static noinline void __init vmalloc_oob(void) +{ + void *area; + + pr_info("vmalloc out-of-bounds\n"); + + /* + * We have to be careful not to hit the guard page. + * The MMU will catch that and crash us. + */ + area = vmalloc(3000); + if (!area) { + pr_err("Allocation failed\n"); + return; + } + + ((volatile char *)area)[3100]; + vfree(area); +} +#else +static void __init vmalloc_oob(void) {} +#endif + static int __init kmalloc_tests_init(void) { /* @@ -793,6 +818,7 @@ static int __init kmalloc_tests_init(void) kasan_strings(); kasan_bitops(); kmalloc_double_kzfree(); + vmalloc_oob(); kasan_restore_multi_shot(multishot); -- 2.20.1