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: 13447417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79F46C0018A for ; Mon, 6 Nov 2023 20:10:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37AC36B0289; Mon, 6 Nov 2023 15:10:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 327466B028C; Mon, 6 Nov 2023 15:10:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C7B96B028A; Mon, 6 Nov 2023 15:10:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0D8476B0288 for ; Mon, 6 Nov 2023 15:10:39 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DE8E31606C6 for ; Mon, 6 Nov 2023 20:10:38 +0000 (UTC) X-FDA: 81428622156.23.D2D55EA Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) by imf24.hostedemail.com (Postfix) with ESMTP id 1CF7518001B for ; Mon, 6 Nov 2023 20:10:36 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Z07E7O2S; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf24.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.178 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699301437; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nDVhwjjwJnVTlqgIL3b0i6xOOMbmQ8bjgeF5HzBvdls=; b=FtoSnYNq9sXSX/Z2G1UgfyMGIwDmxnpYAMKP7uEOSPVWhFdUdwZrinYWu4TFWUOQwnS0o9 H4mXQSxgVKbMnhT0ZnsM1H34cHjoBqyZcPnPmn5TuhG8g4CG/4NTSKpFTD17hSUQ/yW42z sWIMAr5qSzSMrxIgOPs52rTVMQgUO6o= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Z07E7O2S; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf24.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.178 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699301437; a=rsa-sha256; cv=none; b=aEo7lxfO2dF6xVUsPB6AY4Yvi9Cw2sTKGGtk1Djrc8DDk2JTTwzqfgoK3jPFKww+OGjxHd 2V/UtKFJLSgrbydz6vv5YSNyd1dZsndK2b1+qOzQ7M/n/cxTrKvjAXYnTWTR4inxJXkOPN iaYW7PpQU2zyKfL1WqVmDYiQKHrdMO8= 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-Rspamd-Queue-Id: 1CF7518001B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: dwre6ms1eswnp3pe39chqgbzut3hyytk X-HE-Tag: 1699301436-202346 X-HE-Meta: U2FsdGVkX1+FOX9nMhp7WvTPjryhefzjbJ5uOfboneV9c0SAM9ssVW+SZVX+03BTbnEH1J7cSSWxy8FQjzLDlyhD3bkFFo9yw7jTOBYbLAibRayNwmZuOcCSUkd8qH52YD2O93FRjCqcclSs/HQ7wQRdM8C2eZ3guukgQJr49s58jWpfAwtdR0LHuGZo9UZ1VMJmL8qEAOOvgctclQ8b95d5EEGN5o9mX5vyJJAaz0MyUZtQdV5BWGR9sTNdmg80rhJ9crllFm2Qel2klPKNQK0yw/xVGi2m8sPkZruRLCB0gVt+xrxMZjgKk+0vLevp2ju/hK4UNj76DiyhgZuVhkHFPizYheOn0kAZ0mk7fXsa3eWcsbCWJGIqk8w5M0cwC25Y7IGLbDwQgLZiHld3eImIeFM7LBhbiiTT/IEwM9W0tTyi8UnJDuSAqMCcV24NYy4XZNhq8xw5NZqNPi/T+CJGMt5lIqNTNA5ehVx4diLjlU0R3Y7JVWhlfVyRe75C2ixPFirkEuWYGqp2STPuNLkO4oslO6hA0+Y0acxYn5gUPQa3hKfnPbfzk+JQkRwAxeOsxHovvFb3Vtot+PiksJ8fUtch8cc/wU+B1jBotScGYzJWBzbxZxxrS+ZOP5QOPGiUCO3wJogDP9G3Kw1JwrMN54dT8GfUbW4wOYKDlXD4VBY7u2jZyi2ZeC5REg6MI7msNhrQLQU1fiY/DyVQzSVEdIL8a5Or3Em+L0L1kq0ufwXwdtoopNYuFWx1NfcIOxwPoeRqdaClgw/4E5npC2EJJ+REDYIUZ7wKwPU3ozuDihgaImCWvgJTsY2rJovj2MR6jF7ca6/QqtIfBvj84Uc4/ybBm6KmfZ0f6wBAkSM0YWAlo3YlX1OvY3kEtwUnlrPosLcrw0s9Qnm4vUuJGkw6tNZaTS5JlKPDUyZv9uKLez18HgW/I1pirD+8AH5RzOI6ElBEIUHvcIInjvQ hOFmK1fU m35ktUF8sMoatvCJoiIhJESWbHgm/Bxr5WwBdjaloRdhqR+JJLhjkVNjqQs/Byhgt/caLZ6+wOq9qdszdCADI1hyhWqwyra2FnViEKE4Oojh7urUTTi+WWV3CoCNRhtCLUg5kY1heoYv3F5sJY0GydtgH1rpLiq4WAyWAGzP9o7Mmps+KnRAahwsj79/5DcE4CVId6+BIXaIfoD//YEZx5cXmPQ== 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: List-Subscribe: List-Unsubscribe: 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())