Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10634017imu; Thu, 6 Dec 2018 04:27:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/UTEd58RIn93YpJ35+HtrC/9bxKNVyuqKlnd5fSgbCn5Gx2uGAMIOt8tc4jwNTschnFLynP X-Received: by 2002:a62:9657:: with SMTP id c84mr29081960pfe.77.1544099243541; Thu, 06 Dec 2018 04:27:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544099243; cv=none; d=google.com; s=arc-20160816; b=J+9BnYEWOJSfKQeWQrK+PuSXbHwGYDBfZqtETCMJV2eMwfYC0gSC2Pfs+oQFMjlYe4 OD+tmWpfA5kJPFJj2kkLMMnVJDTznEPN7yaGuWKMoIpktcsJD19yznxq/KRYoZFq3dEq yM01OLnvSBFxFEqU4LAnbWdd8e9wvLkP9iHNnHZtqUzum2PsYkqR8AER8ODhWR537yn8 gQT5gOb1lwFc3jFQ9vZUEM3hEw8Zj7s7sAmrQusjp/zNfNMrqXICvh7E6x/jxs4CyXFy ytC/EwUHtzQkyHYvY5YFn2Up5pA/pIAR2gBZOVI48K3YW/E+Lt5ModHWy1IU1/oo+h2+ uA/w== 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=AZfZTLqWsknIvYMLnZdolPQtd9B+6yIRrKwPZ48RLc4=; b=hCuWpYtLpuFPVYAcjvh2ze3ZWbEsKnRxtXvT8tp10RSIvhmPUsbpfUyaHComIFMHwq 8WQTDGUyBj5HCjbcylEOBbOtG5ovO5IhdWipWGwD8X3RQOWRaDUNhg+ELBoeRtKByg9P Vt7J+lKGRITHNsoBXLd/McniisArJZ2Ei6Ov2F6dV/7RwjJr/cKNHv8Q8WMqhjGpbEMb lEqe0KT1oksyjrxBoNU8CN/y68AN+AKGjT0LR/+v5l6thE3XidX+aBfnT/oAboln3spO riH0mThQZn0nIznRYos51Z6N2mOGOx0Z/Qo58jNBNMC2zYNYfeyfoxf0zLQdBC21h9dr WHYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="EW/3SMqp"; 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 q24si175951pgi.334.2018.12.06.04.27.06; Thu, 06 Dec 2018 04:27:23 -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="EW/3SMqp"; 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 S1729893AbeLFMZy (ORCPT + 99 others); Thu, 6 Dec 2018 07:25:54 -0500 Received: from mail-wr1-f52.google.com ([209.85.221.52]:43555 "EHLO mail-wr1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729817AbeLFMZ0 (ORCPT ); Thu, 6 Dec 2018 07:25:26 -0500 Received: by mail-wr1-f52.google.com with SMTP id r10so267467wrs.10 for ; Thu, 06 Dec 2018 04:25:25 -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=AZfZTLqWsknIvYMLnZdolPQtd9B+6yIRrKwPZ48RLc4=; b=EW/3SMqpcTiMhWNm2orG3EvbNyLZ48vaZIbUCv4K7/oj7HRZ9uPY1RH0eYr1rAgVW0 jyMP2dxynkJIJWAOyFDrXOO+bxX/RQl8Uyo6CKjDuuK1f5Yt+om29IOR4qfuWKYTdBa6 HSbK7N4y6Wq1gjNxQBTGM2y0gddfv8BnrSJP27jRBzimexVneU2mKh133NTPYQ2fqCvG CPhOs/+CryNsf6lHjyX+rz5v7pe0z3I5TS14++RGHvLCAQL4JcZIvyC/7qVGdYVi9+AZ yENfqxMnbM8uAyVl4QWMFZDJgy1UENGmTQUl26yxkghXpslYWoLlLUoaBcjn9yfCweYI TAWw== 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=AZfZTLqWsknIvYMLnZdolPQtd9B+6yIRrKwPZ48RLc4=; b=jsX+91yB1VPwbUC/N0rsoNvM2NYipd/oGI7qgwPZAuuvRfZI4y63UxB7hQ5lHVGdAi EHKCWWc3GBJmnGaZljoOpNBhq3aiX/bg4+TF0Z6q2PPCEEg3BuKzKTa2VGmGCTX6fQ/R LPHNoUR1SMyFSB3todqLPphIGLU7A+cPSbrvrZbukRT+4UhbpioVRf3j1dBoNziSyiI/ vl1T0+2v/rDO5KaB123C4wr1CKnePEWcZUqrmEZGa6g1RxUREfp+OW4U2QII9IHG4E3p JqexWZppdo22ke8HgrWhk7zUHmwFk52yqpB6+j2uDgqOx+lKoq4dHdA+2UT/iG9Htij8 QlOQ== X-Gm-Message-State: AA+aEWYOuMllAKJFb4V4rMn3xvnYHpTIn33FJOtShw0rJdqbZC1P4jXu vs62Aa16ljRhIRpxtF010O9+IQ== X-Received: by 2002:adf:f8d2:: with SMTP id f18mr20884354wrq.265.1544099124211; Thu, 06 Dec 2018 04:25:24 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id j8sm339988wrt.40.2018.12.06.04.25.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 04:25:23 -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 v13 22/25] kasan: add __must_check annotations to kasan hooks Date: Thu, 6 Dec 2018 13:24:40 +0100 Message-Id: <03b269c5e453945f724bfca3159d4e1333a8fb1c.1544099024.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-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.rc1.387.gf8505762e3-goog