Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp7930934ybn; Mon, 30 Sep 2019 23:59:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsuAx/0tiVklonoZCnEJhqVk/f25AiMrU7GH8EVqWaKNHjjmnTCJw25lC2OjK3Lzyo3iHw X-Received: by 2002:aa7:d2c4:: with SMTP id k4mr23248468edr.169.1569913194295; Mon, 30 Sep 2019 23:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569913194; cv=none; d=google.com; s=arc-20160816; b=kuo/3xDFP4MtVtJayClykgEpQG0m4WdAk60NA6QHq1rE+9Ht3Hnk+HoV3htKZyohxh KFN5FOyHnd2brHV6tgUpHXn8o2ZJFLUxNHtvmuSldvVJ1jXFSMG+WhChY2EMWwfjx+tH gfLyyOVvZvcM3to2nPKc7smOiYO42pYMCj3YxQYme5gVBdQBqWAdNyTLjaruwJLatx6z X09hp47hLjkonaFXsr4yPyL2pvbNoP/k6PQBpO7wLygIbAu5jgOcXNA+UkNG81+1HRTR 00t8T7KkBqGzo1TOxILb42i0keSNsnPvng4/ouV0q8nYwqMsMUEc976arRN5mzMGJWG2 Z9xw== 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=unW2m0PJcbx/v7JJ5tplEUJVftqQi/rY0o2uIB5nHgBkNvHg+PVlIMTO5szF2HCEC4 ErwqBq2PHAaF9r5RpSeT/wIdYpBWUsR7CozNn6gObyShfD7pJIWnN+HCkfQpXP5A/Kwx a2yF7gqw5gt3J9EuDTbEP3/VjnaK8oyT3SPASci+Q4eZ1kRjPzxRSNJAvKJyBJgSs9/s DRuSc/r+CW5e6+OyiNe8b4CDzrFPeei7qPCmY/vyQW/gB1r69kNnQelt6Votb5iTOhSI /qtdTJ1PQpemyLSuacdW1HoPlxewCPv4AE8GYduoJJ3HsF+jFrWRtCGgUphUmCa8NMDs cBoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=Gx7gIW3x; 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 t10si8384623edd.447.2019.09.30.23.59.30; Mon, 30 Sep 2019 23:59:54 -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=Gx7gIW3x; 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 S1732732AbfJAG6z (ORCPT + 99 others); Tue, 1 Oct 2019 02:58:55 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37963 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725777AbfJAG6y (ORCPT ); Tue, 1 Oct 2019 02:58:54 -0400 Received: by mail-pf1-f195.google.com with SMTP id h195so7233169pfe.5 for ; Mon, 30 Sep 2019 23:58: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=Gx7gIW3x3squ3y11zfOfQ1ZBli6TkEOQ33zi9GFCPQK2YcyghC59kpCYg5f0EVyGRW q5wJ6EIFrf6eLWSrtM9s1W5+WKi46UaZlDGrSUbjgbVkcZhUI1EHLxyKyToDTMkth4My as7GtsfxQ+dR47o5chjl/YgN1PGNPlrHFNF4I= 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=ex74vzW8mrNfOYxfjr2/dFos5iWUA5n3IK8Q2O3B1/6TJFsB2HBSwxqpOXvDli7po3 XKQEgVfaWJqA19zTmRYR7Qm8g4uMPJyRTrLCE+Q4VY47HUz368eAGqcWcEuOIc/hn+ty qwiwwVkvdClfeG7DvjVfXsit1TITzcTP/A1mntW3G6Y9vsFRoqCQ4DTB1IjUBvb9CvLU KG/H01Q1trKr+W8EXIfZS9MpZivItdGwAd7g5kL8mXzdYcaqi1hdvnvag+qqa5lhKINV vJMsSWK/0mE1d+QGLpxuPICnnOBW6qxYwgx2DILSc8oiD/CzHbD/NSuB5tab7p1V9p/r +RHg== X-Gm-Message-State: APjAAAVYekfDEjyRmod/BXvVbkQreAR2tmpP6epg5rOICl8oHfLGLhkL /coluAXAyV+e0iWpnbN6wSmkTQ== X-Received: by 2002:aa7:9a5b:: with SMTP id x27mr25409842pfj.232.1569913132672; Mon, 30 Sep 2019 23:58:52 -0700 (PDT) Received: from localhost (ppp167-251-205.static.internode.on.net. [59.167.251.205]) by smtp.gmail.com with ESMTPSA id u31sm29081976pgn.93.2019.09.30.23.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 23:58: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 v8 2/5] kasan: add test for vmalloc Date: Tue, 1 Oct 2019 16:58:31 +1000 Message-Id: <20191001065834.8880-3-dja@axtens.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191001065834.8880-1-dja@axtens.net> References: <20191001065834.8880-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