From patchwork Tue Nov 10 22:20:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11895719 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.7 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_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 3E2D4C4742C for ; Tue, 10 Nov 2020 22:33:39 +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 D55852068D for ; Tue, 10 Nov 2020 22:33:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OiqzgGQW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="lCftT4m0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D55852068D 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:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uyc5xVNA0s3jISE79iqTTZ7EPh6NsguRoX1c+mBDwAA=; b=OiqzgGQWaZZlDm8WmrLjMGciL aJ+HeLF3eRpyI4ijxQ+ifIQGbkuAPPGf1xQwhlEq01PPVdtVN2+Y6gfW427YsXXnIfdtryKjCTIcL 8lsB8qy0+3jKMcAc0NJ5QNfNQFtyfGZTf9Qmoa6ImmzndXm3jEHzZXUulK54d7sAN1nolcj/l1Z4A fYTda3ueAtoz0G33uKmGESDEWf+YzSEkOFbI+HUt662X7eGOsbt5claNBzf5oK2IbCv0ZmjM2Z0d6 +b/CMjJ2+v0YlFfdxT9RJn90qKzLiL/jdACGhJwu3XhCqmGCcjdyVu1Y/rd8LjnSPz54CCFJ38WGy beSzAzMDA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kccCI-0005oL-Sp; Tue, 10 Nov 2020 22:33:07 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcc0J-0000Ds-QP for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 22:20:53 +0000 Received: by mail-wr1-x44a.google.com with SMTP id b6so6159678wrn.17 for ; Tue, 10 Nov 2020 14:20:37 -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=gNopVjIT8PLD1roCXuMREiwLLvujReoC9+pcOjj05mE=; b=lCftT4m06a6889qXGQTef3H4ubHV8kKj9dGlz5f67eoPKWdz/PHnNnYEjABMQLk8d9 KObCel4cnvyGAfTLT3glV7CaPrDc0oVmARZammV+1pVoZ/2jSlMDKbk5t8ghqy2BrnAQ 6wiA3BXXhqVlgixBVMEYRnob8fIiyC/M+a6xp4u0aNMUCSSJaunS7d4ecvp+s9fgBTTl ILcUALwdqyXB6pkQZeuRw2BZ9ehON8RQWBZCFPbVG5/Tjjcf9C/MjxhSUXZvdV4Wx2sm tXxLD2ziia9ZukMCBDzC8zBSj5kuUeYjuML+1LS3YfaqORZ/tW8RY/g6NyBPCfrCuo0E RgsA== 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=gNopVjIT8PLD1roCXuMREiwLLvujReoC9+pcOjj05mE=; b=LhbqDZ1U9W4I2dYvSdzmaRIwtLZ0CQ2+qUK4hGjLh9yQqfkZmy8yCE6jYMWlYgz23j y2WSOYDhkaTNGXtBHMVD8TfmB8UB3ovbBDuEYPlqB9efIGmZmiT0/bMPK/L6lmDM1rtP 4jHzKC/Hc3q9JmfSYAFNU4fWgIkBeoJz22cxjWIZAcfTuBW7ff80vrdbzsKhBuDcVjL2 A9T63valIhUD1FuMzPpi+smeBGetlT8CzbhlpW/ynLl+tI695divaXj7TNjfYm5FYirt wd2C1Vytk3U1tB4FzyrKbLvTzPYkw7IuLmmDS/YtbsFp3FovhI56RBzVTsC6RBXSAoge 4kTQ== X-Gm-Message-State: AOAM533JoZs19U/5jnYofcEKNWOA7FJBNJJ4u9nWE5thbyJW2+CI1ZNk gloA4uGaztDEkhdoMewUN+DX95yFsLl/EzsT X-Google-Smtp-Source: ABdhPJywHqOrMb83vobFQz6uQH+1U+IiE7bFzlSvWOmiu58rv8s7DM6ShUb7PXTFUABDWl/FwVrflkCpjtBdifZz X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a1c:3803:: with SMTP id f3mr304885wma.14.1605046836014; Tue, 10 Nov 2020 14:20:36 -0800 (PST) Date: Tue, 10 Nov 2020 23:20:07 +0100 In-Reply-To: Message-Id: <5302e6d48429465259bd0868a7dc357290a2e8a5.1605046662.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v2 03/20] kasan: introduce set_alloc_info From: Andrey Konovalov To: Dmitry Vyukov , Alexander Potapenko , Marco Elver X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_172044_187211_6334CA26 X-CRM114-Status: GOOD ( 12.49 ) 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: Branislav Rankov , Catalin Marinas , Kevin Brodsky , Will Deacon , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Andrey Konovalov , Andrey Ryabinin , Andrew Morton , Vincenzo Frascino , Evgenii Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add set_alloc_info() helper and move kasan_set_track() into it. This will simplify the code for one of the upcoming changes. No functional changes. Signed-off-by: Andrey Konovalov Reviewed-by: Dmitry Vyukov Link: https://linux-review.googlesource.com/id/I0316193cbb4ecc9b87b7c2eee0dd79f8ec908c1a Reviewed-by: Marco Elver --- mm/kasan/common.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 8fd04415d8f4..a880e5a547ed 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -318,6 +318,11 @@ bool kasan_slab_free(struct kmem_cache *cache, void *object, unsigned long ip) return __kasan_slab_free(cache, object, ip, true); } +static void set_alloc_info(struct kmem_cache *cache, void *object, gfp_t flags) +{ + kasan_set_track(&kasan_get_alloc_meta(cache, object)->alloc_track, flags); +} + static void *__kasan_kmalloc(struct kmem_cache *cache, const void *object, size_t size, gfp_t flags, bool keep_tag) { @@ -345,7 +350,7 @@ static void *__kasan_kmalloc(struct kmem_cache *cache, const void *object, KASAN_KMALLOC_REDZONE); if (cache->flags & SLAB_KASAN) - kasan_set_track(&kasan_get_alloc_meta(cache, object)->alloc_track, flags); + set_alloc_info(cache, (void *)object, flags); return set_tag(object, tag); }