Message ID | 286fcda449120b643e4665fc9848e81260a1300c.1537383101.git.andreyknvl@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-kbuild-owner@kernel.org> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA1076CB for <patchwork-linux-kbuild@patchwork.kernel.org>; Wed, 19 Sep 2018 18:56:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAEAF291B2 for <patchwork-linux-kbuild@patchwork.kernel.org>; Wed, 19 Sep 2018 18:56:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC4B32B840; Wed, 19 Sep 2018 18:56:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 773D2291B2 for <patchwork-linux-kbuild@patchwork.kernel.org>; Wed, 19 Sep 2018 18:56:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728282AbeITAfz (ORCPT <rfc822;patchwork-linux-kbuild@patchwork.kernel.org>); Wed, 19 Sep 2018 20:35:55 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34021 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387552AbeITAek (ORCPT <rfc822;linux-kbuild@vger.kernel.org>); Wed, 19 Sep 2018 20:34:40 -0400 Received: by mail-wr1-f68.google.com with SMTP id g33-v6so6897821wrd.1 for <linux-kbuild@vger.kernel.org>; Wed, 19 Sep 2018 11:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d1iMb39p1prK7niLwUfLvs3mbBI1WfSY9Tra+BtzAxQ=; b=op++z0BSZ/nwOadd89i0fho9uQZiZsdFy7N0GRCwHUqVvYMaWvDvVmYOPZbERPOPFx ad23W/MQBbvV3/GY7+tuqP2Of9HHtQ5OTJHZQdRaqHLIIauiwl5p5TPXuZcuLja8f+lg Gmg1pZr0oyuUyf5jFx3yO97RBema8RQDjlge5Vi/p9u6ZVJyeu/Q/b8sZe3wIn46oBTL 72/Sm5BUPocqr3OOPUjJ579q43JT4k5eYih4kkSQdo03+dbtwIDYkx5ncimrVvHA8k4o PG200V3W+tgEQO46uTpx3RAKoZvVLrCxJ5EK6vEUn1RxqZyP4JQ2BP9MlWsfD2UEcjEy JKhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d1iMb39p1prK7niLwUfLvs3mbBI1WfSY9Tra+BtzAxQ=; b=Df1o2w90e6SoWvsf9wc/yhCywxxLxypXmQhjfQJG+gOjnSW0XANsga6qygwv4VgpZI mXKLHXA8OSg445lrBBVtul0v6DRG2Pyo52zT335/MxE4GGJPjbpbUe4kWazGKaeGhGJ7 bngUWPPj5RCRTFAEPrNMxe4KjzxVzcPyfJcGorIFLMGWG4R013J3SdT1YHtPghNgqDY/ SOAPE8EIdjwdXYqouyWKaUVOLOZnF52CM8k+UC33WPrW8sVsm3oZtxS3U369QiewZZb5 MPhtXTSep8gj4lMQxz251hOhUNVze9s4cmxU7kHpCEJ+0zDZOXIHgBW47yJQxkCmcbNx sOKw== X-Gm-Message-State: APzg51Djfq1MC97I18eYeIsuAzRnfSsnHmLWqToXv5+SBaumU8ekQCdq wD0J9a+cR2eopKu7M93ZUNmKRQ== X-Google-Smtp-Source: ANB0Vdb5o820qjCsQHYsVlC6o405PmMuMtbuK7P7pWLgWe20tanCx9P4Y5oo2MG9QevgZjPd50wONQ== X-Received: by 2002:a05:6000:10d0:: with SMTP id b16mr30374902wrx.226.1537383324464; Wed, 19 Sep 2018 11:55:24 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id b10-v6sm8510065wmc.28.2018.09.19.11.55.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 11:55:23 -0700 (PDT) From: Andrey Konovalov <andreyknvl@google.com> To: Andrey Ryabinin <aryabinin@virtuozzo.com>, Alexander Potapenko <glider@google.com>, Dmitry Vyukov <dvyukov@google.com>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will.deacon@arm.com>, Christoph Lameter <cl@linux.com>, Andrew Morton <akpm@linux-foundation.org>, Mark Rutland <mark.rutland@arm.com>, Nick Desaulniers <ndesaulniers@google.com>, Marc Zyngier <marc.zyngier@arm.com>, Dave Martin <dave.martin@arm.com>, Ard Biesheuvel <ard.biesheuvel@linaro.org>, "Eric W . Biederman" <ebiederm@xmission.com>, Ingo Molnar <mingo@kernel.org>, Paul Lawrence <paullawrence@google.com>, Geert Uytterhoeven <geert@linux-m68k.org>, Arnd Bergmann <arnd@arndb.de>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Kate Stewart <kstewart@linuxfoundation.org>, Mike Rapoport <rppt@linux.vnet.ibm.com>, kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sparse@vger.kernel.org, linux-mm@kvack.org, linux-kbuild@vger.kernel.org Cc: Kostya Serebryany <kcc@google.com>, Evgeniy Stepanov <eugenis@google.com>, Lee Smith <Lee.Smith@arm.com>, Ramana Radhakrishnan <Ramana.Radhakrishnan@arm.com>, Jacob Bramley <Jacob.Bramley@arm.com>, Ruben Ayrapetyan <Ruben.Ayrapetyan@arm.com>, Jann Horn <jannh@google.com>, Mark Brand <markbrand@google.com>, Chintan Pandya <cpandya@codeaurora.org>, Vishwath Mohan <vishwath@google.com>, Andrey Konovalov <andreyknvl@google.com> Subject: [PATCH v8 13/20] kasan, mm: perform untagged pointers comparison in krealloc Date: Wed, 19 Sep 2018 20:54:52 +0200 Message-Id: <286fcda449120b643e4665fc9848e81260a1300c.1537383101.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog In-Reply-To: <cover.1537383101.git.andreyknvl@google.com> References: <cover.1537383101.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: <linux-kbuild.vger.kernel.org> X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
kasan: add software tag-based mode for arm64
|
expand
|
diff --git a/mm/slab_common.c b/mm/slab_common.c index 3abfa0f86118..221c1be3f45f 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1513,7 +1513,7 @@ void *krealloc(const void *p, size_t new_size, gfp_t flags) } ret = __do_krealloc(p, new_size, flags); - if (ret && p != ret) + if (ret && kasan_reset_tag(p) != kasan_reset_tag(ret)) kfree(p); return ret;
The krealloc function checks where the same buffer was reused or a new one allocated by comparing kernel pointers. Tag-based KASAN changes memory tag on the krealloc'ed chunk of memory and therefore also changes the pointer tag of the returned pointer. Therefore we need to perform comparison on untagged (with tags reset) pointers to check whether it's the same memory region or not. Signed-off-by: Andrey Konovalov <andreyknvl@google.com> --- mm/slab_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)