From mboxrd@z Thu Jan 1 00:00:00 1970 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.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,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 40FBEC4742C for ; Fri, 13 Nov 2020 22:17:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C2F20206F9 for ; Fri, 13 Nov 2020 22:17:32 +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="HJ+JRP0S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2F20206F9 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 5ED0D6B0073; Fri, 13 Nov 2020 17:17:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 59CFD6B0074; Fri, 13 Nov 2020 17:17:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A1456B00B1; Fri, 13 Nov 2020 17:17:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0052.hostedemail.com [216.40.44.52]) by kanga.kvack.org (Postfix) with ESMTP id 0DF696B0073 for ; Fri, 13 Nov 2020 17:17:32 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A870D824999B for ; Fri, 13 Nov 2020 22:17:31 +0000 (UTC) X-FDA: 77480807502.30.cream45_4516bd627312 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 873BE180B3C83 for ; Fri, 13 Nov 2020 22:17:31 +0000 (UTC) X-HE-Tag: cream45_4516bd627312 X-Filterd-Recvd-Size: 4588 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Fri, 13 Nov 2020 22:17:31 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id 3so4704818wms.9 for ; Fri, 13 Nov 2020 14:17:30 -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=OV4C+yTmsCF5UXfds4VROxbglfiyjt1Ckf945DDmnpkqeBDkreWTvECP5LLsr2R2AB Kh9p7Pz9RSkqCEZkSF9pIQ+mJ1bEOW/P7OzVeiwUzhxai7GrMkI1MHKcou9w36StgFc9 eM+/KZb9ThCGZgjt7O+euX5ylDk8QexZGKLTwMy0CbjrxVoKI8zA6zsmJIU6q0feRYCl tTSiuE7RhqcNdbX8yFF2BXWmbMD5QP8QCQ7xknXP3PmiDmiTaqfaQeTJ/qKSoRUOwi6O x5ydJo7dQDzy2CSM7iVgivYCr43rSiDx1YHtnKguPvWXbTwFgikmCZa56Owg0cN5Q7Tu b0qQ== X-Gm-Message-State: AOAM532JSuO4sLgoGYIQvUZnFG3ofTbjcmzO1UmuExDhTka/waFpUJRS cWoW6ZD0YiuUI1HgPz6zrsw9C+JkOTNYMfTK 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 Cc: Catalin Marinas , Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Content-Type: text/plain; charset="UTF-8" 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 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); -- 2.29.2.299.gdc1121823c-goog