From patchwork Tue Nov 10 22:10:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11895571 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 C5F2215E6 for ; Tue, 10 Nov 2020 22:12:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7C5C120674 for ; Tue, 10 Nov 2020 22:12:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="iJj1JmG/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C5C120674 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A85936B00B3; Tue, 10 Nov 2020 17:12:27 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A5E766B00B4; Tue, 10 Nov 2020 17:12:27 -0500 (EST) 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 975DF6B00B5; Tue, 10 Nov 2020 17:12:27 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id 65F776B00B3 for ; Tue, 10 Nov 2020 17:12:27 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1311B1EF2 for ; Tue, 10 Nov 2020 22:12:27 +0000 (UTC) X-FDA: 77469908334.12.ship58_130a6b1272f8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id E062418006FD0 for ; Tue, 10 Nov 2020 22:12:26 +0000 (UTC) X-Spam-Summary: 1,0,0,b84e47b3f6fecc48,d41d8cd98f00b204,3srcrxwokcbo0d3h4oadlb6ee6b4.2ecb8dkn-ccal02a.eh6@flex--andreyknvl.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:965:966:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3867:3870:3874:4250:4321:4385:4390:4395:5007:6261:6653:6742:7576:9969:10004:10400:11026:11232:11658:11914:12043:12297:12438:12555:12679:12895:12986:13069:13311:13357:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:30003:30054,0,RBL:209.85.222.202:@flex--andreyknvl.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yrs86k54kppg1rmdncgepjc1h38ycj8dgddkkmcpjrmfbbzcfwwspruiohg56.unjf5hyag4j837a5xetgifoiykot83h51dnehjhkq9j9edkj53qhwb4dhy7j8fe.a-lbl8.mailshell.net-223.238.255.100,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,LF X-HE-Tag: ship58_130a6b1272f8 X-Filterd-Recvd-Size: 4593 Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 22:12:26 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id j20so197013qkl.7 for ; Tue, 10 Nov 2020 14:12:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=l253EjoD9wZWKjcMl+HZL7Y/RWdoQT2M7P8mMLYHCko=; b=iJj1JmG/+/LGQYBNxNKzKQSzUcZ/JvHFynshxI+fvd2EdRizy6Qruvz5HpH1X+pS2s LmwzJtSEuxZdNM7E2Nh5KEEPhIUj0FyXndlJuLIyOmLIMLeKdsSwkG1Ct+kgofaJE2mE LkVwEUc0Kkd1419uEP7R6z+ZVqVv0rJnF59wCeuOwXWdzBVUoLHnajXG92tvPzyD3K0S Oo7dS5WPI9J3BbjlgBgEidOIyQbj6780q3v4oMiKj3CA3JSuCe1SQRDACZorbENHyR/m 233ANeiPkEhvGx/q1i/g7j4xUA2tRRuVUGpwN1JL+ziEL/Qu/TvjT58cy3lJpe58JfLH /zsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=l253EjoD9wZWKjcMl+HZL7Y/RWdoQT2M7P8mMLYHCko=; b=V3nNP1Akzl9N6bVebiUpESa4Mag/5MyR+zQZHxvtp7ANZEO14SkcIarOe6Jja/YdXR FqpOCUGPb/G1FapvpyprK1pxW6lYoAPgn0BCJxC/rj0uL1sx3A1HnokYtsv9CXwmVJCQ WJqHfpBNitAMgibEKRdcZF56RFInmX9egDHrNMCpC3vA65j+xoNd3kF7nTau77/SSDW/ 8PwPT8bUb40Eed2M6JmfE/eDcvubrFO/L1y2UfOrkmgsLHdaQmcKG7a/0z9nbpqxV/3E j8RqPkdQa0paCG3o0v6bTlm3CeQkI5ZnSSLT4tLsaplxFKtxFH8VtxDSvLxM0204FNd4 cUuA== X-Gm-Message-State: AOAM532iEaImK4x0FjNnpNXlefQjSttmrXSe0uqCvOwCpPfhJ8QYCRfk o6kfF/oGz3vFtoTlikH1fDBawty5AWZrf46u X-Google-Smtp-Source: ABdhPJxokFbxfHNUyx6ne+LPZby1L6L3HSAB4pfI6nXjJC22jzllXP35wpy1FIYaxIucTW79eSxVCqU7onN0ujaX X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a0c:aa8f:: with SMTP id f15mr20403403qvb.46.1605046345539; Tue, 10 Nov 2020 14:12:25 -0800 (PST) Date: Tue, 10 Nov 2020 23:10:30 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v9 33/44] kasan, mm: untag page address in free_reserved_area From: Andrey Konovalov To: Catalin Marinas Cc: Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , Andrew Morton , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov 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: From: Vincenzo Frascino free_reserved_area() memsets the pages belonging to a given memory area. As that memory hasn't been allocated via page_alloc, the KASAN tags that those pages have are 0x00. As the result the memset might result in a tag mismatch. Untag the address to avoid spurious faults. Cc: Andrew Morton Signed-off-by: Vincenzo Frascino Signed-off-by: Andrey Konovalov --- Change-Id: If12b4944383575b8bbd7d971decbd7f04be6748b --- mm/page_alloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 23f5066bd4a5..24b45261e2bd 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7593,6 +7593,11 @@ unsigned long free_reserved_area(void *start, void *end, int poison, const char * alias for the memset(). */ direct_map_addr = page_address(page); + /* + * Perform a kasan-unchecked memset() since this memory + * has not been initialized. + */ + direct_map_addr = kasan_reset_tag(direct_map_addr); if ((unsigned int)poison <= 0xFF) memset(direct_map_addr, poison, PAGE_SIZE);