Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp57134imu; Tue, 27 Nov 2018 08:59:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/UowSNIuE64ot18BjHQdvkXcj4K6LBdkudtNcfROIz1sSa24iTOulgjLEqBnn9Rts6zgWFd X-Received: by 2002:a17:902:7b91:: with SMTP id w17mr33312929pll.111.1543337997277; Tue, 27 Nov 2018 08:59:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543337997; cv=none; d=google.com; s=arc-20160816; b=JWu5ThyUCKGYRMjGFYqeEcZmgQ/l4Z3+ekBKE1IJiXH1syhnaqth2xk3wSvz955xGR ItqyTtA4BtYjmp3ydTDU1+puGf/tUk73nDuduhjqaJmicE03HD5KAKpk0B7qqAZSD+md btadCZEVhD11LutcHLfpOuTpQujxiLrEgrUVXhFcqlry11NivXW+/RNHm2Thcq+fA7KN hZjkvKg9JhvWOAa2Lfb0m/FSxJ6CRWGrMen3lx6tfayJ+dhTKWsKSa9UuUOGL8hNPnqc WzvFLvRrlt23CPClI5IQkE5TejPdPcj12W3RS+1okZQgBu/ImA67LOspdkni//219cfh Jrwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N8jYgDbVKt3tw47AlDQNwZCbiy1BMntGMdo2UlIpEQI=; b=q3wwNpU4aXG8SzO3De8Y+u42iAKywexRGj9qVKCfPD79DnlezTfYRgsw6avUW0rG+f dDe0RegMfU9Xs9Y95XwaV97fFXXxatP5qpJC1xWuwQb5r5wBYOo9qbwJNl4T50oeKWwk 3D66f6g7k9J2dwSuV9JJsUjFCDDSByxIZkHW/4sxuHVaE3L0QqoR5XqS0TNorwhBYguC GLHUbh49qTjqiu6uJusGmW6jbvcSvF/gK0oI+yIpPWPEaeQ9DYpR/7THYhu1kwTdi04k E2GH3jhAeP0Jn2i5jV1lJGRX1Nu9IjKER1b8zwf4g+kHFJ2xmQScCJkWUMo3Cvrd+Rcc hbUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FKQNuSOT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si4290821pld.197.2018.11.27.08.59.41; Tue, 27 Nov 2018 08:59:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FKQNuSOT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731851AbeK1DzE (ORCPT + 99 others); Tue, 27 Nov 2018 22:55:04 -0500 Received: from mail-wm1-f44.google.com ([209.85.128.44]:51288 "EHLO mail-wm1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731816AbeK1DzD (ORCPT ); Tue, 27 Nov 2018 22:55:03 -0500 Received: by mail-wm1-f44.google.com with SMTP id j207so15506079wmj.1 for ; Tue, 27 Nov 2018 08:56:30 -0800 (PST) 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=N8jYgDbVKt3tw47AlDQNwZCbiy1BMntGMdo2UlIpEQI=; b=FKQNuSOTJW4cI4UcMN2RMDAj67rDzAAuvIhRvYzrA5MRBzvI7iBS9pNRw+tGfyAPy5 J4kITg0pv/5kwt/0WqqCW5vwwjIxYhMXJQnr0Zuo7IfhOi/DhNph6xMuFi/J0eB/vWls ZoYGMPImV6SSIHtBxVj2ohaIPo1AwQqp6QzZUsCVsEir5T2Qwp0at7yHW2Ez9ekmn4Cf Jkdh5pCyYqW7lPMgC7l5jv1YgEyaPp1txFdlImHREgqqUnNbKKTp6d9F/SoqhrG6K5R0 o/mtuEHYAsIeNgDX86Sqr81v4KgPr7XHTjxZnrGJJXGtnkq1k43BVPH0a7rPx0Ah/qEL BO9w== 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=N8jYgDbVKt3tw47AlDQNwZCbiy1BMntGMdo2UlIpEQI=; b=TRtP0Pbf13FwtzMvEXaLdzKbtiKshdIoqWKka4CaBpj2itP+AWBqrFKp2w1eNESv+M cTdRWdGRd5FBb8vSZJpBuluX3cjnmHFd+iTUNuLYsJc+7yCof6WdLuRxbO4vOwCrhyK1 A9yKDJxDj0ju8DdwC6t72BbikrIgDKryNNuQoZr5JrztN/BT//+ltOdpJPGSEu4rJUZw qdJASm37sNSRlRILXavc9LQSuziOvbFv29LGip5tW+QB5oSOjrxTMxgzj6E6WH8wUqxO YkvHxczQb4rpmfKX/2GJdb/Vyo9PYOMPj+hmbUxbo6zQqRWP9Yo6h7H+7Qz2zYxzcRXG PhcQ== X-Gm-Message-State: AA+aEWY14xVYD2StPbpPqFx05DruxgLKKOA1vIbiSA60srmfubTEyzX1 lybyXuNYUMnj3Y+yAFJ8mORBcw== X-Received: by 2002:a1c:174f:: with SMTP id 76mr1184907wmx.116.1543337789747; Tue, 27 Nov 2018 08:56:29 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id k73sm6383099wmd.36.2018.11.27.08.56.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 08:56:28 -0800 (PST) From: Andrey Konovalov To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Christoph Lameter , Andrew Morton , Mark Rutland , Nick Desaulniers , Marc Zyngier , Dave Martin , Ard Biesheuvel , "Eric W . Biederman" , Ingo Molnar , Paul Lawrence , Geert Uytterhoeven , Arnd Bergmann , "Kirill A . Shutemov" , Greg Kroah-Hartman , Kate Stewart , Mike Rapoport , 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 , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Jann Horn , Mark Brand , Chintan Pandya , Vishwath Mohan , Andrey Konovalov Subject: [PATCH v12 22/25] kasan: add __must_check annotations to kasan hooks Date: Tue, 27 Nov 2018 17:55:40 +0100 Message-Id: <6d8c6f59c5b5a3dde569f893ecf3b56e58030ba1.1543337629.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds __must_check annotations to kasan hooks that return a pointer to make sure that a tagged pointer always gets propagated. Suggested-by: Andrey Ryabinin Signed-off-by: Andrey Konovalov --- include/linux/kasan.h | 16 ++++++++++------ mm/kasan/common.c | 15 +++++++++------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/include/linux/kasan.h b/include/linux/kasan.h index 8da7b7a4397a..b40ea104dd36 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -49,16 +49,20 @@ void kasan_cache_create(struct kmem_cache *cache, unsigned int *size, void kasan_poison_slab(struct page *page); void kasan_unpoison_object_data(struct kmem_cache *cache, void *object); void kasan_poison_object_data(struct kmem_cache *cache, void *object); -void *kasan_init_slab_obj(struct kmem_cache *cache, const void *object); +void * __must_check kasan_init_slab_obj(struct kmem_cache *cache, + const void *object); -void *kasan_kmalloc_large(const void *ptr, size_t size, gfp_t flags); +void * __must_check kasan_kmalloc_large(const void *ptr, size_t size, + gfp_t flags); void kasan_kfree_large(void *ptr, unsigned long ip); void kasan_poison_kfree(void *ptr, unsigned long ip); -void *kasan_kmalloc(struct kmem_cache *s, const void *object, size_t size, - gfp_t flags); -void *kasan_krealloc(const void *object, size_t new_size, gfp_t flags); +void * __must_check kasan_kmalloc(struct kmem_cache *s, const void *object, + size_t size, gfp_t flags); +void * __must_check kasan_krealloc(const void *object, size_t new_size, + gfp_t flags); -void *kasan_slab_alloc(struct kmem_cache *s, void *object, gfp_t flags); +void * __must_check kasan_slab_alloc(struct kmem_cache *s, void *object, + gfp_t flags); bool kasan_slab_free(struct kmem_cache *s, void *object, unsigned long ip); struct kasan_cache { diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 195ca385cf7a..1144e741feb6 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -373,7 +373,8 @@ static u8 assign_tag(struct kmem_cache *cache, const void *object, bool new) #endif } -void *kasan_init_slab_obj(struct kmem_cache *cache, const void *object) +void * __must_check kasan_init_slab_obj(struct kmem_cache *cache, + const void *object) { struct kasan_alloc_meta *alloc_info; @@ -389,7 +390,8 @@ void *kasan_init_slab_obj(struct kmem_cache *cache, const void *object) return (void *)object; } -void *kasan_slab_alloc(struct kmem_cache *cache, void *object, gfp_t flags) +void * __must_check kasan_slab_alloc(struct kmem_cache *cache, void *object, + gfp_t flags) { return kasan_kmalloc(cache, object, cache->object_size, flags); } @@ -449,8 +451,8 @@ bool kasan_slab_free(struct kmem_cache *cache, void *object, unsigned long ip) return __kasan_slab_free(cache, object, ip, true); } -void *kasan_kmalloc(struct kmem_cache *cache, const void *object, size_t size, - gfp_t flags) +void * __must_check kasan_kmalloc(struct kmem_cache *cache, const void *object, + size_t size, gfp_t flags) { unsigned long redzone_start; unsigned long redzone_end; @@ -482,7 +484,8 @@ void *kasan_kmalloc(struct kmem_cache *cache, const void *object, size_t size, } EXPORT_SYMBOL(kasan_kmalloc); -void *kasan_kmalloc_large(const void *ptr, size_t size, gfp_t flags) +void * __must_check kasan_kmalloc_large(const void *ptr, size_t size, + gfp_t flags) { struct page *page; unsigned long redzone_start; @@ -506,7 +509,7 @@ void *kasan_kmalloc_large(const void *ptr, size_t size, gfp_t flags) return (void *)ptr; } -void *kasan_krealloc(const void *object, size_t size, gfp_t flags) +void * __must_check kasan_krealloc(const void *object, size_t size, gfp_t flags) { struct page *page; -- 2.20.0.rc0.387.gc7a69e6b6c-goog