Message ID | 8ebe73c041d879639b1fb822578f247cccec91a6.1527259068.git.andreyknvl@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3DB0E602D8 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 25 May 2018 14:41:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3BA8297C8 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 25 May 2018 14:41:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E768E297C5; Fri, 25 May 2018 14:41:25 +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=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77091297C0 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 25 May 2018 14:41:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50EC76B026A; Fri, 25 May 2018 10:41:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4967D6B026B; Fri, 25 May 2018 10:41:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3362B6B026C; Fri, 25 May 2018 10:41:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr0-f197.google.com (mail-wr0-f197.google.com [209.85.128.197]) by kanga.kvack.org (Postfix) with ESMTP id CB6336B026A for <linux-mm@kvack.org>; Fri, 25 May 2018 10:41:02 -0400 (EDT) Received: by mail-wr0-f197.google.com with SMTP id r23-v6so4403983wrc.2 for <linux-mm@kvack.org>; Fri, 25 May 2018 07:41:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=XnqP4qREIz/AzHWVUpXPukuq/Rt7mS4cLZJXm7V/j8g=; b=UGdHJijITR7ckkFS6CdwCnvfPxD06FaK98s7oe8TlDpOUP3QIA4cxB9eN3mWnMSL/D otmij14qJ1Ib9QawWDeAbyEVYJF4beOI/ze0kaX3eqssgYlhiwGNvT9qsKSGGEOPqYrQ D7tMgJiqbr0MKqEusYlDonshUJhm2+FwZ26vf3BIxn5jspkKp5tojDYqpshkWKdYUbB4 yQPfHsT6i3vhmqZg57OZZlA0SXl/ZGMRRoXi3PjLNkTlBNAUG9KI9p8pjzr36AsNoLMn URELDTeboUutxYtXv9RvHGnFmyDzN8+brpAiehoBcqCyKD29eKSpI1uZ648qz5xgya0c 7CUw== X-Gm-Message-State: ALKqPwcjtlyr/X77ZssVAvxlefcmzVjtarXEuxCIvfevUVE70T2bjv6O Y0z/x9xSVUBKKyjWzz1nObg20boWsBq7ODAGT9BUxRC5JuL2c0JRs6tQY8NHxY3oMn3wgZUCs8I LVpbohOqT3QzXigjQU7U5IUd9U7BQ3Q88qRWREB6FtmoblZtTmCjrLC/whEoHsltSPN/5TNNKEx 4Ldiy1IgM5XES5u8gNCYaT4Qm1grl7L6qW1lDMbShr3jY6FqgxJr9T2tR3FwoOt92wk3xukQMeO Cf2PNCKiXTakd4fbWLbx9r+Phtd5rXkYRS3rYLdw1InCrWepyJEMDFbG7WYVemvc6X5KTaPvfGR K92J2ARncysKnG07Sfty2o+Qo+Lz+FuDi5YZqs3BKijDXQ9zDKHJBB+nerva9+vp+wTxYRpmc7Z g X-Received: by 2002:adf:8442:: with SMTP id 60-v6mr2806042wrf.138.1527259262373; Fri, 25 May 2018 07:41:02 -0700 (PDT) X-Received: by 2002:adf:8442:: with SMTP id 60-v6mr2806000wrf.138.1527259261560; Fri, 25 May 2018 07:41:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527259261; cv=none; d=google.com; s=arc-20160816; b=fJqo7sG9T+Ma+80IG4T6U7x4GiF7+tEvn6txS79DARNvxluA8Gau7H+Q7DDmxKOosL e7G4HrRLkeb+kbYSk/0KHQdzX866U/Drl4QCPPekTCdjxUuOSRhtE+k8QAgDuKQwrNOq DamTyKYu6v4Ivnrs9O/gXxIb81LtBYDtOlUhDwfevRO2i25tt7Y4WcfZ2dFDJ4S3TpuA Bh22AcitVhl82rqHGXvhWhNLCoo7wuWRqVWPNTW2tBTTzzEHOdmBXr5Sd7cUs65Rtx4P po7IMK3OFgktpvmWvhQ+GHMjOw8Gd5AY9Ukg2VKxFFledDUCm9q2R07aiSHuIMVIfRGE D50Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=XnqP4qREIz/AzHWVUpXPukuq/Rt7mS4cLZJXm7V/j8g=; b=pfTked4GU7LZbByGxdZTXmdnWgJeUNpe6eAxitswEkSZ9fbVPrdmpmRMx59Kcw3h+P qppNr/xem27ygsf/yfRVr10wlQTYjkfXQd+YI1YgMiznBK2+vz1WAH305R55T/nVUAaU ssqsNe6WHSMQihd84OSQA6Zr7p1aeYoyRYtYIcB0rYykcCdkjoMmotkIyoaiohnkZfwL qha8cBMxeftLqVa1g6O7tIy0brV0PrO5LgTFyNYQAlQ1G4NrGF+3X+5o9MC5F+EHVoJ5 036fV5lz74ZIUbW9xn2iDRQ8bH699Nirv5tmKeeGA0+q4HQkV/wiXJlqgWwgC6tSBeI4 FVGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FIyMh2HF; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n18-v6sor7335748wrm.29.2018.05.25.07.41.01 for <linux-mm@kvack.org> (Google Transport Security); Fri, 25 May 2018 07:41:01 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FIyMh2HF; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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; bh=XnqP4qREIz/AzHWVUpXPukuq/Rt7mS4cLZJXm7V/j8g=; b=FIyMh2HFOkP+4gJ7z+OPNpbLptY6NPiOn5+Ve/o9ipsA0h3CyfeYlM1GbPLT4iZg7W 2tluF42RGQMc3uVAf3/P7ngCkGLcJNGlTWBnQJ25gJLfIcnm5+Csw7bT5X4aNlVbUR0Y Kb3SAnLNGl9uj6yArdD96DctdplfNXmxmPPX81VAMIRfRM2luesFzq8vCBb+QEoIG1wi fBm4vkDRu5O+Qb8aHXmSryLsQ8TcDyH+XU4XzRUYryUaVlxEoU0XX58YGS6Qq/E/8IRG uQPHpCptcsv93q1qGP4vVCdR9CQyuRbP/J8s8oZecGYREDNmsJVFyedbC41XXCWC3FNm XeTw== X-Google-Smtp-Source: AB8JxZozI9Z24A1/f/0Q3gvplXSnCu0A7C84LgqgJBZRtQ3zOfW1W9vFspLslWzsAv+8Mp1HJrx5fw== X-Received: by 2002:adf:80d0:: with SMTP id 74-v6mr2698046wrl.273.1527259260620; Fri, 25 May 2018 07:41:00 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id q2-v6sm25293885wrm.26.2018.05.25.07.40.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 May 2018 07:40:59 -0700 (PDT) From: Andrey Konovalov <andreyknvl@google.com> To: Andrey Ryabinin <aryabinin@virtuozzo.com>, Alexander Potapenko <glider@google.com>, Dmitry Vyukov <dvyukov@google.com>, Jonathan Corbet <corbet@lwn.net>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will.deacon@arm.com>, Christopher Li <sparse@chrisli.org>, Christoph Lameter <cl@linux.com>, Pekka Enberg <penberg@kernel.org>, David Rientjes <rientjes@google.com>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Andrew Morton <akpm@linux-foundation.org>, Masahiro Yamada <yamada.masahiro@socionext.com>, Michal Marek <michal.lkml@markovi.net>, Andrey Konovalov <andreyknvl@google.com>, Mark Rutland <mark.rutland@arm.com>, Nick Desaulniers <ndesaulniers@google.com>, Yury Norov <ynorov@caviumnetworks.com>, Marc Zyngier <marc.zyngier@arm.com>, Kristina Martsenko <kristina.martsenko@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Punit Agrawal <punit.agrawal@arm.com>, Dave Martin <dave.martin@arm.com>, Ard Biesheuvel <ard.biesheuvel@linaro.org>, James Morse <james.morse@arm.com>, Michael Weiser <michael.weiser@gmx.de>, Julien Thierry <julien.thierry@arm.com>, Tyler Baicar <tbaicar@codeaurora.org>, "Eric W . Biederman" <ebiederm@xmission.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@kernel.org>, Kees Cook <keescook@chromium.org>, Sandipan Das <sandipan@linux.vnet.ibm.com>, David Woodhouse <dwmw@amazon.co.uk>, Paul Lawrence <paullawrence@google.com>, Herbert Xu <herbert@gondor.apana.org.au>, Josh Poimboeuf <jpoimboe@redhat.com>, Geert Uytterhoeven <geert@linux-m68k.org>, Tom Lendacky <thomas.lendacky@amd.com>, Arnd Bergmann <arnd@arndb.de>, Dan Williams <dan.j.williams@intel.com>, Michal Hocko <mhocko@suse.com>, Jan Kara <jack@suse.cz>, Ross Zwisler <ross.zwisler@linux.intel.com>, =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= <jglisse@redhat.com>, Matthew Wilcox <mawilcox@microsoft.com>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, Souptick Joarder <jrdr.linux@gmail.com>, Hugh Dickins <hughd@google.com>, Davidlohr Bueso <dave@stgolabs.net>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Philippe Ombredanne <pombredanne@nexb.com>, Kate Stewart <kstewart@linuxfoundation.org>, Laura Abbott <labbott@redhat.com>, Boris Brezillon <boris.brezillon@bootlin.com>, Vlastimil Babka <vbabka@suse.cz>, Pintu Agarwal <pintu.ping@gmail.com>, Doug Berger <opendmb@gmail.com>, Anshuman Khandual <khandual@linux.vnet.ibm.com>, Mike Rapoport <rppt@linux.vnet.ibm.com>, Mel Gorman <mgorman@suse.de>, Pavel Tatashin <pasha.tatashin@oracle.com>, Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>, 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>, Kees Cook <keescook@google.com>, Jann Horn <jannh@google.com>, Mark Brand <markbrand@google.com>, Chintan Pandya <cpandya@codeaurora.org> Subject: [PATCH v2 10/16] khwasan, mm: perform untagged pointers comparison in krealloc Date: Fri, 25 May 2018 16:40:26 +0200 Message-Id: <8ebe73c041d879639b1fb822578f247cccec91a6.1527259068.git.andreyknvl@google.com> X-Mailer: git-send-email 2.17.0.921.gf22659ad46-goog In-Reply-To: <cover.1527259068.git.andreyknvl@google.com> References: <cover.1527259068.git.andreyknvl@google.com> 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: <linux-mm.kvack.org> X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/mm/slab_common.c b/mm/slab_common.c index 0582004351c4..451b094b8c5b 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1478,7 +1478,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 && khwasan_reset_tag(p) != khwasan_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. KHWASAN 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(-)