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: 181315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2272694dyi; Tue, 19 Dec 2023 14:30:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6Dfh/KbQnALU3i9+Kz5DAbor2BZcVVlM7fJQdcLRrnjP472Pj/3qhvKw7lRwNHDJkSjpP X-Received: by 2002:a17:906:118d:b0:a23:5672:735 with SMTP id n13-20020a170906118d00b00a2356720735mr1119395eja.290.1703025040472; Tue, 19 Dec 2023 14:30:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703025040; cv=none; d=google.com; s=arc-20160816; b=OsI/2gRUWxCoNp1ln5oCqwn/Pv4UbHyFw58kt/0u/b6lPGCQYs2A7cXvVBYy8dB41K WI4qpRcY/DBD5mlVRfoo0w9PsGRmvDE3SAuFB3SwELJ3vqTIUcWE1bvVEjVyldWhn/hU 5RPd9X6BLrVUVd2nHEj4oZj6fqMgKW6buK5oGCERnehdQMe6dkMScYLmVIL6kFBiOmRH bE6kuYUIEq4jduUBUbHY2dKyOS+Dxa4x5ZrcYxleNl/vjRBZ8CN6hnOv5uish9VbIE2d hLvHJvXrLbBr44H0ARSjmfr62U9614+iUCRr7aMQU4oV3PO9HyIK9sjbSFz5JWYzzHEb a/cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nDVhwjjwJnVTlqgIL3b0i6xOOMbmQ8bjgeF5HzBvdls=; fh=AIzsiqkKUtrB7QnM+XRgAblgvDINIC5pDvD0mg8EzrU=; b=0hHLCmGjS29zOHNNU1IJ9jIf1+i4mfdis0sBhFEXgXdSBuja2u/ucYHe3gufhjtDTn qRoA/ArLnO3cee6IJ5vjrfMlTUQI8InQthPsnR3perc+ZvDisHxza148VswudZDzBIJP twlFMeyJFiA95i4IAcA6fCnOaOkxYg1yA9o/VJv+lOrPSL8ACOndmrEPr0U57Fydid8Y LzphOr0MwU5OaX5Uul50dZcXcCm06b/h9ghp24dYEaG2Q/ZkFmgQqpE2fFjk8Eot2Cec EdifqTtfHdB5o8D8RSJM0o+2UPdtIUXQeY46wJyxF/bKUndyaZtffn8aD7T+q408UxAs YmaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=C4rzmgvl; spf=pass (google.com: domain of linux-kernel+bounces-6045-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6045-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w5-20020a170906d20500b00a265d4f7650si627901ejz.736.2023.12.19.14.30.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 14:30:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6045-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=C4rzmgvl; spf=pass (google.com: domain of linux-kernel+bounces-6045-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6045-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 14D8F1F2482F for ; Tue, 19 Dec 2023 22:30:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DDB441228; Tue, 19 Dec 2023 22:29:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="C4rzmgvl" X-Original-To: linux-kernel@vger.kernel.org Received: from out-184.mta1.migadu.com (out-184.mta1.migadu.com [95.215.58.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABD083D0B3 for ; Tue, 19 Dec 2023 22:29:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785751184838122981 X-GMAIL-MSGID: 1785751184838122981 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())