From patchwork Tue Oct 29 04:20:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 11216953 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 ED2E11390 for ; Tue, 29 Oct 2019 04:21:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B89C12086A for ; Tue, 29 Oct 2019 04:21:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=axtens.net header.i=@axtens.net header.b="lcDyHdzU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B89C12086A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=axtens.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AF0176B000A; Tue, 29 Oct 2019 00:21:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A792F6B000C; Tue, 29 Oct 2019 00:21:16 -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 941496B000D; Tue, 29 Oct 2019 00:21:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0136.hostedemail.com [216.40.44.136]) by kanga.kvack.org (Postfix) with ESMTP id 6E7246B000A for ; Tue, 29 Oct 2019 00:21:16 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 000CB180AD81D for ; Tue, 29 Oct 2019 04:21:15 +0000 (UTC) X-FDA: 76095522552.03.chess81_7f657e982bd2c X-Spam-Summary: 2,0,0,67c97173d1ee7d71,d41d8cd98f00b204,dja@axtens.net,:kasan-dev@googlegroups.com::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:linuxppc-dev@lists.ozlabs.org:gor@linux.ibm.com:dja@axtens.net,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3874:4250:4321:4385:5007:6261:6653:7903:10004:11026:11473:11658:11914:12043:12048:12291:12297:12438:12517:12519:12555:12895:13069:13311:13357:13894:14181:14384:14394:14721:21080:21444:21451:21627:30054,0,RBL:209.85.214.196:@axtens.net:.lbl8.mailshell.net-62.2.0.100 66.100.201.201,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:24,LUA_SUMMARY:none X-HE-Tag: chess81_7f657e982bd2c X-Filterd-Recvd-Size: 4253 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Oct 2019 04:21:15 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id y24so6889928plr.12 for ; Mon, 28 Oct 2019 21:21:15 -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=lcDyHdzUacgOhucQ6b8IWgwE46Vlk8g9GsG0YiqbvSuRh0midPQjkKTH8pqXZ6eSlf M1yH4o7rgNX40yBq5M4PAJVge7qa26A++93dTOcRGcNCrIQhxh5QfkU3EV2DF34ElmZk 63eYGshNT63iTFBqS5s6pvBKl+7JsqOxJf9F8= 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=GuyiYMhHbKurWgfpnenymF4dj6rNhcsnvlVFCPx3rnmDkHcYw+T2/HcrJqsc0f3p1d y4pV4MIjZEGkH+Krvvg1KJ8HzlQL1qpNv7DDpOF7sQ+1muqubESabsJJKS5zgLePlAOF AhbgNIzxue2pYs6CqESseKeuqwG6fjJblY9yF16k9X2Z75ZexKdTJiHPEl/mE9+/DvrZ CX2Rc/ZYBDqUhYb4e4ulAclk8mfH3gz+wiNnBJ9YQHaAmJPhEAoLKZ3s8Nf8J3fJgaYf ReBtsOls05DSARpfL2bgiFR7/ua6A1i4GlaS+QEWiEWJ1tMznwORBztf/Nmgnk5/8nF8 QB4Q== X-Gm-Message-State: APjAAAW7VxZ4xoAZCvKj/0BP7v99yNXu7CM/o3pkDukyFTKjlB2LSqo5 JEPc4yFrnOkgaxx7rmN5rXKSVA== X-Google-Smtp-Source: APXvYqxLsff9odhBvNICfK+D6Rfn6FtMiU4d244WqDyFRpWs6AJDTPdDv2j0OdBnEo98eZFpsfQ/6A== X-Received: by 2002:a17:902:68:: with SMTP id 95mr1661194pla.117.1572322874296; Mon, 28 Oct 2019 21:21:14 -0700 (PDT) Received: from localhost ([2001:44b8:802:1120:783a:2bb9:f7cb:7c3c]) by smtp.gmail.com with ESMTPSA id y11sm15418521pfq.1.2019.10.28.21.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 21:21:13 -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 v10 2/5] kasan: add test for vmalloc Date: Tue, 29 Oct 2019 15:20:56 +1100 Message-Id: <20191029042059.28541-3-dja@axtens.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191029042059.28541-1-dja@axtens.net> References: <20191029042059.28541-1-dja@axtens.net> MIME-Version: 1.0 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: Test kasan vmalloc support by adding a new test to the module. Signed-off-by: Daniel Axtens Reviewed-by: Andrey Ryabinin --- 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);