From patchwork Mon Nov 6 20:10:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 162160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2901746vqu; Mon, 6 Nov 2023 12:11:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAW573Y+haoVYnmL7uyh4KNO82GbSWHr0QORXsEdUvbqwDx7mT7ujcXj65NvFYYH9YT6mE X-Received: by 2002:a05:6358:6f8d:b0:16b:7049:e8f8 with SMTP id s13-20020a0563586f8d00b0016b7049e8f8mr2300599rwn.12.1699301480683; Mon, 06 Nov 2023 12:11:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699301480; cv=none; d=google.com; s=arc-20160816; b=kr8+3doVgk0GgQtMSV95+gqdyNN5zqD5GKwn3qpU3C/l+eFwGe6gvm04X3wK9fGfQe w0RfG9KnbZ5LI6JfqSc8bJDg1NXbLePS7f0SGfnbbO1cUQmPtimzpSAsMFDFoxnSQ0jP 9glJVlN+eE4mYVpumXbp7itiaNsh0rcYhn+CLbShMRLeHL2S5MhB8n3b44MFiHYyGGUI nFxSDDuSF1yzCp46/ktbCGZIe3phBVwjfspXiSJPbg0ni0o0hGOM9o6oZqgh2UMlPYrZ azwO+mXOLSKVHTNvQ+QlNAcwaUIM71em5BYMSdJWp1bUE4Y8eSRMCtqfvFean7/vOTks jzoQ== 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 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id v191-20020a6389c8000000b005b96c4292bbsi362472pgd.420.2023.11.06.12.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:11:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; 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 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 9C04180886AA; Mon, 6 Nov 2023 12:10:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232992AbjKFUKs (ORCPT + 34 others); Mon, 6 Nov 2023 15:10:48 -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 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 12:10:59 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781846749231127678 X-GMAIL-MSGID: 1781846749231127678 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())