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=-11.2 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_SANE_1 autolearn=unavailable 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 AEF66C5517A for ; Wed, 11 Nov 2020 19:18:51 +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 2A7EC207D3 for ; Wed, 11 Nov 2020 19:18:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YvMJ4y8o"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="JyMoM46i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A7EC207D3 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:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JP8yTjnrAN/FaBa2KJ1iHJgeKg9Dl67oa/syJdWsNZs=; b=YvMJ4y8or2T2QvtRAYWUoM1eQ HXNG4D0AmKbJhzoQuqH6HPqkyXuAZst5jtWPVXilV8dxM/zaoEC7X48PHnV8MtOyTHQ6QY0ty6eaD 9YBrKmcxCZOEYREHgtMXp0PNoNQh53ewoX5fd86O2MogZIolD/1Mcu4IfFy/URlJ0Km0fDhj66KLh EK8A7ikqOthNohT9AUzrSGCLv4PDKrDW5bgVoMwtx3jq7cSrYW0Y3DHuL/ko0eb+tI1/aLVAZCpKF Eym0jWuT3QcdkRKUzUodx4fjacMJjS6c9Diz5eFmKWVQ4ziaR2nmmM/zq3UqVpU2OkJPFwyaOY6Uy vx0uoDGnQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcvcj-0005mm-J3; Wed, 11 Nov 2020 19:17:41 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcvch-0005m5-07 for linux-arm-kernel@lists.infradead.org; Wed, 11 Nov 2020 19:17:39 +0000 Received: by mail-wr1-x444.google.com with SMTP id 23so3603793wrc.8 for ; Wed, 11 Nov 2020 11:17:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kMrBNTvUl7eFEy433Sc7HrH1xnZw22qMO0dPs+XlBag=; b=JyMoM46iSDFsiDKvjg0YoviV0jxdDbSXOIqKDrRqUpzPy5au4hhoa98Y41MM6Zvn69 7Jo7UIkvwH3Ssuk43BJjXiFJ30PzNeTzt6VQEDgS0UwANh5P/1eNNysQ7BCB1DU1ltNA 2w0SR9iG3ajokKf/91XnJPozzUdEco8sod6U2zQPgbxu+FpKcu1x7s6va8ks253wNNIe Jr5TSykdUc/F6Ev77gVW8ceTL9fJe/w9SWAp89YLMUEDCdO31Lx0CxCq2AmKxoBpNnBl zfhFcjuUBjC+N2SGYOmcib6r+rWZmpuUf6pSiFR0DbUaSYTtCPNSWeVXQXrv+I6hwBVK XHnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kMrBNTvUl7eFEy433Sc7HrH1xnZw22qMO0dPs+XlBag=; b=d9gcwHb7QABPZa1XmpiI7k3uHK7qYhRQhosF/3MU8N3g8ht05j5QB2nMece573Zb+L Rch0cwiomu3LrSeKWxoBWXKyEPPbXKbYhLiU43HBNWFS0vl9XDQ5hO5vEKwELQpHza8X FHBPEb8dR2IfJDA8ri6gMqR8g4Rub5qHeKswooP7seV3eFTpKu6aWssM7aGvbaFlqij+ GQcy13MmQr19CEyLbIqtyBlGQ9cypRCLsScACzUcPaRxi4uiqeYKlKUn6rb6ps+u3Fjr 2pbui0X7HsBKWumnI1yQDSygwwc3OJHGymszwLPpDw1g0SJCr8V1lm8zFtgO5a8rynsw aLdQ== X-Gm-Message-State: AOAM530wNRI5mA01bkoml4poJOMx3Z7kSjSiq/Tw1MrUU8jh+jth3w1r ZlUOwriWfMYKn16RfPozYLjZKw== X-Google-Smtp-Source: ABdhPJyDmF5o/EhHUlAWnTV5B9M/0BDsYvV61vd+CfOa8MeLPXuw8/vrzkyo+MVG1df4JWcvaJhoFg== X-Received: by 2002:adf:93e1:: with SMTP id 88mr30294553wrp.37.1605122257781; Wed, 11 Nov 2020 11:17:37 -0800 (PST) Received: from elver.google.com ([2a00:79e0:15:13:f693:9fff:fef4:2449]) by smtp.gmail.com with ESMTPSA id b1sm3833382wmd.43.2020.11.11.11.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 11:17:36 -0800 (PST) Date: Wed, 11 Nov 2020 20:17:31 +0100 From: Marco Elver To: Andrey Konovalov Subject: Re: [PATCH v2 16/20] kasan: simplify assign_tag and set_tag calls Message-ID: <20201111191731.GR517454@elver.google.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.14.6 (2020-07-11) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201111_141739_072453_16183688 X-CRM114-Status: GOOD ( 22.90 ) 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, Branislav Rankov , Catalin Marinas , Kevin Brodsky , Will Deacon , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , Andrew Morton , Vincenzo Frascino , Evgenii Stepanov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Nov 10, 2020 at 11:20PM +0100, Andrey Konovalov wrote: > set_tag() already ignores the tag for the generic mode, so just call it > as is. Add a check for the generic mode to assign_tag(), and simplify its > call in ____kasan_kmalloc(). > > Signed-off-by: Andrey Konovalov > Reviewed-by: Dmitry Vyukov > Link: https://linux-review.googlesource.com/id/I18905ca78fb4a3d60e1a34a4ca00247272480438 > --- > mm/kasan/common.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) Reviewed-by: Marco Elver > diff --git a/mm/kasan/common.c b/mm/kasan/common.c > index 69ab880abacc..40ff3ce07a76 100644 > --- a/mm/kasan/common.c > +++ b/mm/kasan/common.c > @@ -238,6 +238,9 @@ void __kasan_poison_object_data(struct kmem_cache *cache, void *object) > static u8 assign_tag(struct kmem_cache *cache, const void *object, > bool init, bool keep_tag) > { > + if (IS_ENABLED(CONFIG_KASAN_GENERIC)) > + return 0xff; > + Hopefully the compiler is clever enough to start inlining this function. > /* > * 1. When an object is kmalloc()'ed, two hooks are called: > * kasan_slab_alloc() and kasan_kmalloc(). We assign the > @@ -280,8 +283,8 @@ void * __must_check __kasan_init_slab_obj(struct kmem_cache *cache, > __memset(alloc_meta, 0, sizeof(*alloc_meta)); > } > > - if (IS_ENABLED(CONFIG_KASAN_SW_TAGS) || IS_ENABLED(CONFIG_KASAN_HW_TAGS)) > - object = set_tag(object, assign_tag(cache, object, true, false)); > + /* Tag is ignored in set_tag() without CONFIG_KASAN_SW/HW_TAGS */ > + object = set_tag(object, assign_tag(cache, object, true, false)); > > return (void *)object; > } > @@ -362,9 +365,7 @@ static void *____kasan_kmalloc(struct kmem_cache *cache, const void *object, > KASAN_GRANULE_SIZE); > redzone_end = round_up((unsigned long)object + cache->object_size, > KASAN_GRANULE_SIZE); > - > - if (IS_ENABLED(CONFIG_KASAN_SW_TAGS) || IS_ENABLED(CONFIG_KASAN_HW_TAGS)) > - tag = assign_tag(cache, object, false, keep_tag); > + tag = assign_tag(cache, object, false, keep_tag); > The definition of 'tag' at the start of ____kasan_kmalloc() no longer needs an initializer. > /* Tag is ignored in set_tag without CONFIG_KASAN_SW/HW_TAGS */ > kasan_unpoison_memory(set_tag(object, tag), size); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel