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: 11895803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B764C55ABD for ; Tue, 10 Nov 2020 23:32:26 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F0D7D20897 for ; Tue, 10 Nov 2020 23:32:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="d4/dnZX0"; 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 F0D7D20897 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kyy57kHNXQNA18yduCiMAW+XB5Gq6q6Ub+hbJ9oG/dM=; b=d4/dnZX0ZeSg1n3e828RRPThb kjAkuGxi30bpny/BZry5cXzg6Z06mfG7iKNF0bOUMQ+KzwamOP6C+EcdrzhdXq84enNFk06qliDJt lvAG+sI++v40KU8rRQYIjRvTj9+XIl26zdAGEEYO4tTcCgJmJ7+9iOk+1ydU4tTyMkGbpJMQX1/66 4gttrQfw2TWtvREqOL4MoTewniNBV8eyQYDk0fM7vovKOxuclcRqTp55Use5FcAp/res/wUepvslC sX363AIm1v9QWTHn6IzTxG96D9dW4DBh4EIRbWxj1X83kxtrNerwu2mUWlWDk5hDFsSuzuAZNZobO uA2x5oFaA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcd71-00009F-M7; Tue, 10 Nov 2020 23:31:43 +0000 Received: from mail-qk1-x749.google.com ([2607:f8b0:4864:20::749]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcbsN-0004xl-Dp for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 22:12:49 +0000 Received: by mail-qk1-x749.google.com with SMTP id x22so177768qkb.16 for ; Tue, 10 Nov 2020 14:12:27 -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=Y9P0hv/3H+Rs9o+zJkOx3us98M6JUQVy9Wss3GL/Iv6aCXhRrujmLafwVtB14MhQFh mSln+lvuGZ9IIgeTeSwgokgnHDuI2CvfwJSM1Uyp4R3NnrBcoeb4kFtjXdTuTWNFHF+A rsRoIUDyHsgR+IifOGpb+bRKpXIBQdWdJF3vjbVC5ClgIF1b31hBc53wN2FAYXUlkHWZ NAjkSnzk/SbSR+gIV98l/F6ttbTdmJWn+o4sxx6JCCK9wWOo0ec+Q+zaAXH4I0kkAQFA PRkugKsXGkeqYtqS3EmtgsYvVdy4WiLTSqppBeuZbu+nQbOXOJ7S1TtPeubrVZgVw+pS YU5A== X-Gm-Message-State: AOAM533+8GdyCUo93l5JpaXW5JRIjJ12g5Av5rjcom1b6T0MUJDZ3501 l3t4K2pIVhnqygWv6rb5erZ0OVVBYxAoDImf 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_171231_558498_1621005E X-CRM114-Status: GOOD ( 12.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Marco Elver , Andrey Konovalov , Kevin Brodsky , Will Deacon , Branislav Rankov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Potapenko , Evgenii Stepanov , Andrey Ryabinin , Andrew Morton , Vincenzo Frascino , Dmitry Vyukov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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);