From patchwork Fri Nov 13 22:15:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11905035 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 3310AC4742C for ; Fri, 13 Nov 2020 22:30:04 +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 C92E1207DE for ; Fri, 13 Nov 2020 22:30:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cC4KT25N"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="HJ+JRP0S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C92E1207DE 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=pa23DtXdOb/3wTodijQVxjJqMaCr+ZTFAf+d+EqCSEU=; b=cC4KT25N1gbVSHfcfQzdJY7EA bVZq8LC3WE6xSrL84kc9PKkrMeriG9rtUzgpbgYfhEtF42fZuHEv9As4E09ndMZQhViDTgow9U2Fo lN5KTfwVGLXlfgWM7LvsIEeNlJaqpVg0qrwdtX6Dc/jVs65ga6hdt6t50B03oxGvUnu9pBIkInbyG 3nPlT3aCNdR8s0G5TPEi2ay9UZ2XHS8L353EwN2PCJdq2YjYA6p5Ci+H6vqR8jArRlYAhnH6zBlRg cgAuVZYc1WXEOvACOXGM7Nx9WcnNLWjS4JAWwVzQupjMCuwgJlfYCJexA2U11O8NrASwwK25ghRLX 6kvhvfxDw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdhZF-0005bY-EA; Fri, 13 Nov 2020 22:29:17 +0000 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdhNu-0000Ki-Tf for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2020 22:17:45 +0000 Received: by mail-wm1-x349.google.com with SMTP id 14so4718160wmg.1 for ; Fri, 13 Nov 2020 14:17:31 -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=JnUxOJIynAj3uI1y+sO3DfMh7ir+WlJGNb++LFrX210=; b=HJ+JRP0S6+eUg+e42XlAvr5+D8XnjnXcbJcnVWKyhHfxILa7L2iAAlvDT5PboLOAMO kG1l/8RNcBki2ToFLLjfQpmCzzWJfCzByewGvOnmF8hNskzssMLs1TFn8KOSfIn4q3mY pqXygbWN2nTDadrTM0bUhB+aN9dG+MTmUm+b7pongo++WW3H8QKIgfaTwo+TKenrmk2i nlD1BSYO4cB+xw7HeTEqdLyArv5S/JBaydVJwVWBSXkRVtHUz7ohI73Tjtfd3g0F9zJF 3z/jlNDSL/2mC+BvmIrDgfdJWBSgYJ/3wqqvHcsqOpTgdsaUz3YDT58pfYhLOeacbTJ2 pi9w== 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=JnUxOJIynAj3uI1y+sO3DfMh7ir+WlJGNb++LFrX210=; b=OHxmUYxwaeHR7NngSVipLikw2rbYdrKN38nASJf9bAi4VDKQp3sunCy83c9RfzKp76 Bva2iPHya3XqMVEKrE0np8tFo5P20HNXDGrAH/zg1QuM6rWvh8oNZpv1PEH1kkfHEMd8 i1x6y3htZBvtQZQcpTUQgOCTzwW2KluiK47TGxUwLY/PFWMm6tchWmxagQBZ/TbhM9Om MDeDny0J29k1rUYSpSmcf+sJivyaMuQYdhr8pXcTmKAWI+zTXTLlbKsxbYjTuNLY2d8l hj4mRlmH8X7ICwN6c4sOxDCkZ+PCjqg5Npxp8Nc8jIhjHvfwONpbdVKL3hF4cF/9OCLR QyRw== X-Gm-Message-State: AOAM530M32AhYa+ABSFg/2QaIl+BT1OMLl+NlruTKoUPb7BFEGq+L8CI dMTtXuwZjzXT1WPMyymqzW4/fMAJ9+uRDqhe X-Google-Smtp-Source: ABdhPJwDJaLX/cxCmyUXAbVS/RQJ0TrA2KB4sujqSM5M2kIGaUl5fRFE83fHcKShMFNRZpNFvJCZuVmHOB0E6NxM X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a1c:1f05:: with SMTP id f5mr4382666wmf.98.1605305850004; Fri, 13 Nov 2020 14:17:30 -0800 (PST) Date: Fri, 13 Nov 2020 23:15:59 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [PATCH mm v10 31/42] kasan, mm: untag page address in free_reserved_area From: Andrey Konovalov To: Andrew Morton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201113_171735_100868_9DA71894 X-CRM114-Status: GOOD ( 12.52 ) 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 , Catalin Marinas , Kevin Brodsky , Will Deacon , Branislav Rankov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Potapenko , Evgenii Stepanov , Andrey Konovalov , Andrey Ryabinin , 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 Reviewed-by: Alexander Potapenko --- 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 855627e52f81..4a69fef13ac7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7653,6 +7653,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);