Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2375390rdf; Mon, 6 Nov 2023 12:12:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IELU28lVrOnuO+ySSkgjZHClhTnGM0nThTiv15is0DHVdFBpr6fbqjXhv7wABq+sdpWG+Dd X-Received: by 2002:a05:6358:94a6:b0:169:81cc:d7f9 with SMTP id i38-20020a05635894a600b0016981ccd7f9mr26784551rwb.0.1699301533054; Mon, 06 Nov 2023 12:12:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699301533; cv=none; d=google.com; s=arc-20160816; b=enMkZJKNp3B+wak/44S7YqbkUkR9d0ApuPlGVzrOU0YBK4jeBw6+4e+Ok+kVid+N8b RXMOPBIW5dQI/BxFCmmNleyQWC+CwlJIr0zuqwNxgiozCk7V4qTey2f86iNBP8tqVe1B mbeDIcYBShp9/U3lMTxxyzcEd5NMsYHYiRR6GX2BlxcEL0B2PCJLcAgtWvvPQU7DCQiU 1GszqyMjeMvZlkMx5IHKvIqVhn5UfepZ7vdGsoxdI0qFzckfn5ysWwTLsPu+GxWWQCNW vohl+u89APhLFlqOp0MN1+G4B0Z6kzW+YnXo7q0fUsOfFmSm5msZTLkbCKY+30QZy8NN 0bLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nDVhwjjwJnVTlqgIL3b0i6xOOMbmQ8bjgeF5HzBvdls=; fh=n5KN85tQTomq0Sa/nFFC9xbnc77mxkBzF8HoolO/QOw=; b=vnaZR3QKPH7lvevjccb302RTbUb3zg2Wl2vLLEUkpGF/cU6SiXfEB5BAdioB64KNX/ J6h7bBzen7hAJXvPXJm3rLLsiXMwuduN4wuEaWHIT1YMaaeexXsDdXiQ0ZHLexptBl2K V3ELipkibTxsQA6gUa5F1sK3/BQFHRrAVOerJdvpExKwjMd5Se1bXNqchrAzrkDdYofW 4OsxWNWBysPoLPiKVl+9fr/hFZUD3J8NSZB7IodgWGOslk5GPItNFNvkG/wuBU+erGmM tUP0N96hkhcbP6C1t+7UPW7lxtSVmLjFSvkfo5TUwHAJ9vint7dh37HTh3rgssnoHPih rOZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Z07E7O2S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id l72-20020a63914b000000b00565e0624182si397273pge.404.2023.11.06.12.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:12:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Z07E7O2S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 804C680C6DDB; Mon, 6 Nov 2023 12:11:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232977AbjKFUKr (ORCPT + 99 others); Mon, 6 Nov 2023 15:10:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232380AbjKFUKk (ORCPT ); Mon, 6 Nov 2023 15:10:40 -0500 Received: from out-175.mta1.migadu.com (out-175.mta1.migadu.com [95.215.58.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32D5A10C0 for ; Mon, 6 Nov 2023 12:10:37 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1699301435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nDVhwjjwJnVTlqgIL3b0i6xOOMbmQ8bjgeF5HzBvdls=; b=Z07E7O2SjDMyBRw/gSN9ci3NIZpunAPyyaCA7cmKpuMNMpB9/xhAR5qE7hyZk1t7jX+DKx 14Ptj42a2mWVBNIixSLaxs56Zs4E+ThuwbFOTv55BULKHRjR18asj8U8MJh/Z0FNeXZws6 6EI38tuAtGntOeBhrd01a+m6ax6bdrc= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Evgenii Stepanov , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH RFC 03/20] kasan: document kasan_mempool_poison_object Date: Mon, 6 Nov 2023 21:10:12 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 06 Nov 2023 12:11:23 -0800 (PST) From: Andrey Konovalov Add documentation comment for kasan_mempool_poison_object. Signed-off-by: Andrey Konovalov --- include/linux/kasan.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/kasan.h b/include/linux/kasan.h index 0d1f925c136d..bbf6e2fa4ffd 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -213,6 +213,24 @@ static __always_inline void * __must_check kasan_krealloc(const void *object, } void __kasan_mempool_poison_object(void *ptr, unsigned long ip); +/** + * kasan_mempool_poison_object - Check and poison a mempool slab allocation. + * @ptr: Pointer to the slab allocation. + * + * This function is intended for kernel subsystems that cache slab allocations + * to reuse them instead of freeing them back to the slab allocator (e.g. + * mempool). + * + * This function poisons a slab allocation without initializing its memory and + * without putting it into the quarantine (for the Generic mode). + * + * This function also performs checks to detect double-free and invalid-free + * bugs and reports them. + * + * This function operates on all slab allocations including large kmalloc + * allocations (the ones returned by kmalloc_large() or by kmalloc() with the + * size > KMALLOC_MAX_SIZE). + */ static __always_inline void kasan_mempool_poison_object(void *ptr) { if (kasan_enabled()) -- 2.25.1