From patchwork Tue Dec 19 22:28:47 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: 13499296 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 97B17C41535 for ; Tue, 19 Dec 2023 22:29:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 400946B0096; Tue, 19 Dec 2023 17:29:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AF186B009A; Tue, 19 Dec 2023 17:29:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B5CE6B0096; Tue, 19 Dec 2023 17:29:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E02948D0009 for ; Tue, 19 Dec 2023 17:29:16 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B7B7A1C108C for ; Tue, 19 Dec 2023 22:29:16 +0000 (UTC) X-FDA: 81585009912.05.C42A26A Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) by imf12.hostedemail.com (Postfix) with ESMTP id EC7F140031 for ; Tue, 19 Dec 2023 22:29:14 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=C4rzmgvl; spf=pass (imf12.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.176 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703024955; 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=t1fEJCAjAdlmRrRQli8Oo5QUC+EyE/Q5Y/bl9AnotHpQjmV+PviiVFanK1pT0TjYMnQE7L kKei9kXONHkLmOJsv4NYA4JnBdxRgVtG0F863H730w6HLZcf71r5F2omj0Zl1pslVXX72+ QUoBv7yqTNwC+eh0Nz+0OosmylXLDb0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703024955; a=rsa-sha256; cv=none; b=EMOELbqgjWqXXANGUieD14KlWaOlzcP+n+E7I9rHdtrQcUWzAuWqwiNhnOVPasdTzusLgH kTTzNn8Ht9fxcJgWiRHs+QYCu46srMFdSzUSymSUx9X7VziHw6iL/VLt9lzGnvFhEyit53 EN+ZW+zrq7hnK57hO6NyTN5viPtbL40= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=C4rzmgvl; spf=pass (imf12.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.176 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev 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=1703024953; 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=C4rzmgvlL10DUVbNDtuc0Rxs46Curn42ZGKpKom91VOpoIt4fpkrs/ypbw6AsjfsBn5cAV f4+a7vAj+bLJwhOfAkOj0ot52A4kwU/QGW9g6mUQ3jTBsZTJ9qMcuEm6y1mZK7xk4PDRQ1 qJLgEpIfbiitBegq2Oh+ysHOy3abWJw= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Evgenii Stepanov , Breno Leitao , Alexander Lobakin , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 03/21] kasan: document kasan_mempool_poison_object Date: Tue, 19 Dec 2023 23:28:47 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: EC7F140031 X-Rspam-User: X-Stat-Signature: xdt1xpoahmz6df3t1gib9oeq81xy86ws X-Rspamd-Server: rspam03 X-HE-Tag: 1703024954-466487 X-HE-Meta: U2FsdGVkX1+oHCSOHONRiPAUnoQQxlXW1hR2/u1czLJvThdNdVP8LEBDiOkAQLUh/Z7/+v6IwdGp7cRreZ1hSBWiPKZpv8YQ0LPYh2nPx07t5Ig1+4fKfOMjY02rmFXxeTWLbV9WgbytucMZIvJhCLJTcqA1aL7lIKwAHlaw/YsNS6oY4+JB17GV08aBmTQ7g8SM/928TwLE61V91qxzHviEKXvdlckCo0wk6MMALp3CfgUQTRdHRxUuvDTq1uLYTDJfpDjlhjjzRrsc4HTAroIvUE4l1k2etbtcKeJkrvJwY44UmTabGvyyFC6kuUoD068x4jJI+jIumyZz4BxQxhM3Z3hXTltkurRRmM7fZQE5JYv8GwXyj5Kh/DG6+HIXZOAprZ+8wxfdhF2RD6hSdc6do5qHXy+WIPVqiTc4y9Lx3zW1x1Usi9Wng43ZXd2D4tjrQ6hyNCa0iUz2r9ERlnS5CzWn+s1YOwO6Z79OIO0p4oqKdIyjydlTqOnDVLAOe/8PPMTZkJzOYBF9FWYHcpUHM/THsDZOXROOixmUjlkb/cMHnMOYaBWj5uhSUSuL0zzTX02N8vruyPSIlCmpKJ66eagL8uypXCdkAqWZPTYdwl65rilytQLHusF/TBkvlfH9bEWwJnsHq1qt+8PQMMB9D3ZVc0P2Yq2i4LpefH/PUcx6l5hmm4Tc9bzXD4tPTGTCCd6el8DEVdOUny6S2ShoLCmU1DRl9oEUkuwn5Xxnyf0AA6RX5e2cuDlHZFU1OREWY+SQgqVnj/H4PbTBbZUW6eqbZFkGhH3+wZAMog5YPb5Af5R3oWHt7PHLpgW+Z33VtFnpSIdW5f9e/A+HRSOQHHa2f4kEaWgcSSTrLeB+TP40EPcyQ+CwhL5WK4emo0YpwEl7S+mpb10st2R8eCpWf5nC6RNToNEM1F5Y9vPIrMshgECsA4+aHPlsSYNueVcRLN28H9jfFIyGjG5 +VVZbxpA eY9jYS4VgbC4BxHYeOoiccwyIhjC4ZNxLfBqnyDlY3fuDUYpANBp/pwigUYogC2zRVsvnDV7mYbla6FTXz8oGQnSMtrhzd4I5/8VZ9BS0+e/1IOQ/QNldHy3Rk+qf3KN3dQoAXotsBRFeZC7R22RzghCn/xIAwzdWG0vR93XpVovNEScRqqwHF1+kihF/nBTgieGBML5frzmUVAq1Qq1EzUFodw== 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())