Message ID | 02b5bcd692e912c27d484030f666b350ad7e4ae4.1611074450.git.andreyknvl@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=0ZpT=GX=lists.infradead.org=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@kernel.org> 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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,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 4B83CC433DB for <linux-arm-kernel@archiver.kernel.org>; Wed, 20 Jan 2021 00:04:48 +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 0004622CE3 for <linux-arm-kernel@archiver.kernel.org>; Wed, 20 Jan 2021 00:04:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0004622CE3 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:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=3VmrUiXAnsKI9tzW0EPGtTOLz7whCnEXTE2VGKgXjwA=; b=VlldDm+C2i9yIhQhc+vd7B/lp4 50LRzZ0tFZyBtsbanaq5Dn+O5+oQlFHiGc/QO8oGgwPm6oknNf0gbpEYxAi+YTb5+0xUZJsDXS7sW FTpVbTh7ZqJXusQ0RzmEObbWQdiUqGoRPm1sLxWnqnoYSOD7Zg8sjHjegyWjs/NHHCB634zuM2+wW rYAPM1pY6DQGOA8GfGMrOIBv0dFbImYsaeCxtCczO6Qd5vxRrdWMJl7/K98AguW6NGlOSO+islG6l kAW80mHPb+C9PCnteX5KQS22KiYiVWc0yVOReEaJKm4k7LEtClnQjr3XZC0BMsRt5Pk5nfW4rwxsM wk0xxpeQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l1u5z-0004mg-Pp; Tue, 19 Jan 2021 16:43:07 +0000 Received: from mail-ej1-x64a.google.com ([2a00:1450:4864:20::64a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l1u5w-0004kb-LM for linux-arm-kernel@lists.infradead.org; Tue, 19 Jan 2021 16:43:05 +0000 Received: by mail-ej1-x64a.google.com with SMTP id k3so6497809ejr.16 for <linux-arm-kernel@lists.infradead.org>; Tue, 19 Jan 2021 08:43:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=Mv8HVHZiqq2Y22lxEuv91PTBTzfF3aDqkg+FO9Cjpcc=; b=sMDi4o9tE+P0gYCKpCsgSYKKMzx29ksE7m2wjA+KO85uTUpDuhkfMFInQgjkr8yfsF 8Q+wFUdrqk1EjqshuBKCk2MukU8b+SsvgvMNkzJnFpZ+5+xUVt6Qs5dIMg0XCcXb6Xj9 cr8Iw+xLquN+FrQyE32gFCNctBztV8F5MODxfHff/reLdviDiImV9OzLV9zzug4jYnvd hF17mG0QYbtONfqRYQjQKFPKxcGV2jzBvZps2e8ZHAGz6D4Do0vmkmRj/HjOD6nE3x+L aA0t0N5rsw39WKKfziJ5TFLsw3wE91T0MTd0gcS7HUVFWjqxD/TcQfNwQsBXHLl6ZHjq qpXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=Mv8HVHZiqq2Y22lxEuv91PTBTzfF3aDqkg+FO9Cjpcc=; b=kfGH6LGDk+FM29JOYlNYaJfeNYvGrejeSr9D5WRYLwZbSDd4JwTlxqpHrzyCw8xMfW VmnpnYYVVfAWr2L3a/5RIqHvGgHS1NrK4KEgxXC/oLCtYZG1pksw2DUcj1I1feRO0njo BKqvIIADMYoAuL0+k0+zFT4jhWgVvdKzZRdweboMTbB6qp3KMsujJVq0hmCXZOBE/s99 u6N9hmkCKVe1WDyWK0F9TvBCUWnrSdAF28o1YZJtqLx32PqIhgjgYFbD32JpmXwZh01o zZ4Ql8HAD8sPxOmuX8roE9yHqJ0EWXvF4Ooa1El5F/4IJFeLgm4mRN3KblcVnFdgFeQZ JN3Q== X-Gm-Message-State: AOAM533A7MIa/8hwuxJoMma4IOHJ4RDDB0ICzviDDtdMxB7TAaSEZjDd 73MtGR8uOXD/D0j0MTFHnsGvw9AEEaMygDya X-Google-Smtp-Source: ABdhPJyYT38o1pemfEC7bTB5RG+igiwtCnzLyzGxVJxVdrDLqyO+4RuE/lsIuIfAvcyeoJO0lx0Pv/cE4W8trvGg X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a17:906:351a:: with SMTP id r26mr3406466eja.204.1611074581393; Tue, 19 Jan 2021 08:43:01 -0800 (PST) Date: Tue, 19 Jan 2021 17:42:55 +0100 Message-Id: <02b5bcd692e912c27d484030f666b350ad7e4ae4.1611074450.git.andreyknvl@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH] kasan, mm: fix resetting page_alloc tags for HW_TAGS From: Andrey Konovalov <andreyknvl@google.com> To: Andrew Morton <akpm@linux-foundation.org>, Dmitry Vyukov <dvyukov@google.com>, Alexander Potapenko <glider@google.com>, Marco Elver <elver@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210119_114304_750266_C7AC4641 X-CRM114-Status: GOOD ( 13.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Cc: Branislav Rankov <Branislav.Rankov@arm.com>, Catalin Marinas <catalin.marinas@arm.com>, Kevin Brodsky <kevin.brodsky@arm.com>, Will Deacon <will.deacon@arm.com>, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Andrey Konovalov <andreyknvl@google.com>, Andrey Ryabinin <aryabinin@virtuozzo.com>, Vincenzo Frascino <vincenzo.frascino@arm.com>, Peter Collingbourne <pcc@google.com>, Evgenii Stepanov <eugenis@google.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
kasan, mm: fix resetting page_alloc tags for HW_TAGS
|
expand
|
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bdbec4c98173..8ef6fc53962a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1207,8 +1207,10 @@ static void kernel_init_free_pages(struct page *page, int numpages) /* s390's use of memset() could override KASAN redzones. */ kasan_disable_current(); for (i = 0; i < numpages; i++) { + u8 tag = page_kasan_tag(page + i); page_kasan_tag_reset(page + i); clear_highpage(page + i); + page_kasan_tag_set(page + i, tag); } kasan_enable_current(); }
A previous commit added resetting KASAN page tags to kernel_init_free_pages() to avoid false-positives due to accesses to metadata with the hardware tag-based mode. That commit did reset page tags before the metadata access, but didn't restore them after. As the result, KASAN fails to detect bad accesses to page_alloc allocations on some configurations. Fix this by recovering the tag after the metadata access. Fixes: aa1ef4d7b3f6 ("kasan, mm: reset tags when accessing metadata") Signed-off-by: Andrey Konovalov <andreyknvl@google.com> --- mm/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+)