From patchwork Tue Nov 6 17:30:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10670993 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1879815E9 for ; Tue, 6 Nov 2018 17:32:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 030AB2AC02 for ; Tue, 6 Nov 2018 17:32:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00ABE2ABF3; Tue, 6 Nov 2018 17:32:02 +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=unavailable 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 7632D2AB30 for ; Tue, 6 Nov 2018 17:32:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 754CB6B037A; Tue, 6 Nov 2018 12:31:17 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 701AA6B037C; Tue, 6 Nov 2018 12:31:17 -0500 (EST) 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 5A5EB6B037D; Tue, 6 Nov 2018 12:31:17 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id DEBB56B037A for ; Tue, 6 Nov 2018 12:31:16 -0500 (EST) Received: by mail-wr1-f71.google.com with SMTP id 37-v6so12407863wrb.15 for ; Tue, 06 Nov 2018 09:31:16 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=8r2DFMCmgv2dbc3cAFakXBt3nELpcd/DvTnHXWqU0so=; b=QSTQ0zNgaggJb2M+WpfKDxw6zwkj/uqpoTi+QthkkcuXI/mTfxkL12XfmEAPg5qtgq cTiPagnpQ7Qciq8gKVQbxD40FaHvI1UDRpqS/G+ewX2sZuaaXSwnwtag6e5wQrOIYg4V UcceZsAUbM817U8i3Hc1jTyeTkDeN3mD5MFanVh181O6TJYQf9FJy9ZorNRRfjc9E98l 2Pi+2VwFCKIA4u3aLFKlGuyl0/4B+AZYq2mV8YyJqCrqJMW0bzqKPKUhUCe1RcLw0BzZ odEgx21Pnw0FkFCDktg7eYTa2Xmpw/YqJrdwpxYlRzGLBTcbZLpchPSLWsAnkXuOjzkX lMZQ== X-Gm-Message-State: AGRZ1gIYvj4sJFmCSNVbScoTxkqIq34XpEnIIQxnWQxAL7znL78eixmS xh/RuNizvioUPzk7pl5vP8s7UGJZJ+KqA3atd6a9XdLa2WFnXV22JwEJ7Zzv/xAxU79yFTOIqZF gPaFE+Q35IkFopKvP7X41gN9GIZ6nvi+pI0jiGvvstPQkrlB03zrU9JyUlWtKr2RHgNbFurU6RN 1b3RfKwf0BG0pJ0+KufB9LTudCOsRatRAQVUQ31N3C4sTxd2bSrIO/GAvO4bJiM8yj3XsQ0EM5h YpoQEtNQZlYw0YtVHJEuNSfRs+odLPck8LUr2rpzVUepSb+kR7dNgFM1Tgp88PGByynNPbACg9k n+tlbubDGEAkjCbGUcsmGDB8mkpiPeQbBYlxW/Y5CIhHHxDxiE2LxpsH4p5AjNIqVlBcs96asOG 5 X-Received: by 2002:adf:e6c4:: with SMTP id y4-v6mr16092730wrm.101.1541525476448; Tue, 06 Nov 2018 09:31:16 -0800 (PST) X-Received: by 2002:adf:e6c4:: with SMTP id y4-v6mr16092657wrm.101.1541525475401; Tue, 06 Nov 2018 09:31:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541525475; cv=none; d=google.com; s=arc-20160816; b=jEnWGE6Z+pdFJtviJEBOFBQjqyI2MEURP+AFBpMexGQ/O1hMvEUuk6NVETbZIDlrOq ofihlHQuFCAsWMrzheTfXgaEfHuHsCe1lv00J8MJjGUBn/ARrwVGTjE6aL0OiTKemkgu +f+K4s6mbgG2gN3PvaCKuangyIhAKzCn4RJNIJzGmMk7FhtQG3HpH7teNTELDvwMdkQ9 LJeeG0lPQPWq3vE/cE3//nlfPDKQbLPsuAJJS5rA8qaL4FlqIsBkQFrYaA62EUURDNE3 zNR2Z/APdvJk+u2UDWZIpY8L67DYKmcr//MIjtVFIMQoq9eqn3/21ci0/vkERrRB1XUo nOXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=8r2DFMCmgv2dbc3cAFakXBt3nELpcd/DvTnHXWqU0so=; b=Z4XhwHzyZwpcJ4LFyKzKKgUW+OSbvPbOn09s/6OdS38dKbn8Yd5o6rARWwriAy8Xr2 h0oRWVMFhJaCQcqDcmh95JapYWSy4R1id4Us9BTB5m06AlmYHa0mPr+ngYM+qWbeqVBF nXyxDCjU5WwXkx+Qx4risgo7Pda/EYuCz+TzO0p3qjF8iLB1NQE/z/+TH8e67l9e40hg nzlh6+tS6y5UAMQG1nfnwRqQR8iTkkyP/Lgxn2pC+GuDnfJwL9uSZT8oDEWpdvZL7krz oVE4PlAdGKtgG3b1VNhQQtlJn0MmRzXxDJROIy4LCSUpVcsD91vXuLy3EJrTNivWJOoE 3Sdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lvmCGUI+; 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 6-v6sor1685824wma.24.2018.11.06.09.31.15 for (Google Transport Security); Tue, 06 Nov 2018 09:31:15 -0800 (PST) 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=lvmCGUI+; 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 :mime-version:content-transfer-encoding; bh=8r2DFMCmgv2dbc3cAFakXBt3nELpcd/DvTnHXWqU0so=; b=lvmCGUI+87O0ce35KSXHBahMKJ94XjvOa/lc1RzDbLGdAMVgMJf/dEKG+kDc4wjr/N SH5DgfCv1uex78tmHBn1CeQ5oQRZiRfXq/oKbb7MwNqgo7XFo3Ij8Xt2OkMIZcBGxroH Z/00EW3ffnxNitl5dpxL53MIFDWucsW4MYcyodfy1MDGc5Z22Ei6D6VBvF1sAl+/TYWN ijYS5Ns+oGXcEid8nTSC8bHf98JDq+0qw+Nb2NvtyLZwfcOpsuogr4u5sZiBj622KHoW uxrlLbnWhzVexMHZMYlJhh+n7eisaAq6BmCE62Q7AbeW/FS0QBTGrwU+FaWIrry5HC16 rLEg== X-Google-Smtp-Source: AJdET5esDe6ZtATwtaDTsbSQ9FhotCf4hRaEsVPOy3OZwBrbEtOas7y6YubwybzaHKnZJ0hspUDlEg== X-Received: by 2002:a1c:a141:: with SMTP id k62-v6mr2678368wme.68.1541525474870; Tue, 06 Nov 2018 09:31:14 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z17-v6sm16328416wrm.65.2018.11.06.09.31.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 09:31:14 -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 v10 20/22] kasan: add __must_check annotations to kasan hooks Date: Tue, 6 Nov 2018 18:30:35 +0100 Message-Id: X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog In-Reply-To: References: MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP This patch adds __must_check annotations to kasan hooks that return a pointer to make sure that a tagged pointer always gets propagated. Signed-off-by: Andrey Konovalov --- include/linux/kasan.h | 16 ++++++++++------ mm/kasan/common.c | 14 ++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/linux/kasan.h b/include/linux/kasan.h index d5a2a7f1f72c..a8ee04b3d1c1 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..ba8e78eb0c67 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -373,7 +373,7 @@ 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 +389,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 +450,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 +483,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 +508,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;