From patchwork Tue Dec 19 22:29:05 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: 181331 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2275177dyi; Tue, 19 Dec 2023 14:35:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFd1GOFSOt0QFDrpE+p+lW65flyBUKu6WcK0iynhBiv4+zl8QpbowWhZrl8a2zryCd0yCir X-Received: by 2002:a17:902:db09:b0:1d3:ead1:dc07 with SMTP id m9-20020a170902db0900b001d3ead1dc07mr582124plx.75.1703025354423; Tue, 19 Dec 2023 14:35:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703025354; cv=none; d=google.com; s=arc-20160816; b=zrcI+9z5qOv6VvMGJR4Lq1Q6pNNbKbn1+pzgP0swVIMLcTbwKIw1Hmwcksr8ikDnYI 85pBEHZ4VWYtZXive91GucU3RGktPNUCfQGpoqPUf9aSfUU92auc0IrjqDQxbQQhZ1z2 SgQmF/bxyWRq8yiJZ53Mb2gcbUkgdRfyqiLY3mxeta6Kxdgdi0d5RdJU84OGsqS/8PTg iBvWW1LzrHPzGfUGToytJ2Y6FCuNFrQOC8M/xmqV6/IoP6/IrkoEdtclGvuflZepFMO+ cEOX+GU8qiT8xsGs5ihMmCfvFPqZBieqsLXcp6Qa1qubJlFbnZQgcAyEYyr4h+4p6fLc EV4w== 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=EPGVjwO+qP/d7FcuwPK2D6CcDKWjvT42oG4AsVrb0Go=; fh=AIzsiqkKUtrB7QnM+XRgAblgvDINIC5pDvD0mg8EzrU=; b=cGyvJkBABettmtOCNm8Qxw3ILXYl5RaV8fXDfDhu32Msr1fusg2waRAuKpzJlYgsHE N/2LntvrdqqBRv5fNukruoWq1E/ob7yadPOsYkbOgp9qy5To6JfncG96H1JbZjuOYCLg N4eDYhkPKArfTrt5/O4FYpfVKnleI3RnoJ5HoGvqN/XELR2IUbS/jzhiadWzYYQBaicu m3QmRu/GK/MTGEL6CI7Vmy6BIME50Lyise6yWMKEu2fuv+TuuoceyjQSaSXRcTXeAuhp gvP8itURMSiCqRxnEsibZmsTxJOiBT7XctDADC4qszNpEwA53GoVbKFXDmplZXQVjMyO Hj2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="PVS7/Vp9"; spf=pass (google.com: domain of linux-kernel+bounces-6063-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6063-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g10-20020a1709026b4a00b001d3c3d4869csi3380846plt.481.2023.12.19.14.35.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 14:35:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6063-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="PVS7/Vp9"; spf=pass (google.com: domain of linux-kernel+bounces-6063-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6063-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 268C6286086 for ; Tue, 19 Dec 2023 22:35:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 384794F1EB; Tue, 19 Dec 2023 22:32:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="PVS7/Vp9" X-Original-To: linux-kernel@vger.kernel.org Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (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 1C8C54CB34 for ; Tue, 19 Dec 2023 22:32:32 +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=1703025150; 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=EPGVjwO+qP/d7FcuwPK2D6CcDKWjvT42oG4AsVrb0Go=; b=PVS7/Vp9rKcCStvahkmREEOMnuEX6kau1z/8KUeJ+M+L9oh0S/muURork3hPcDgoR/5lvV ReB2LpYutwX5p3c63FdFGnocPloJeeIBz+IrzYNEY41q/t2SiRz0dp5ZLm4EF8f/mEHnF3 IzsuSBbMxsPovIvvYoBbisxMLMXLZwo= 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 21/21] io_uring: use mempool KASAN hook Date: Tue, 19 Dec 2023 23:29:05 +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: 1785751514352964152 X-GMAIL-MSGID: 1785751514352964152 From: Andrey Konovalov Use the proper kasan_mempool_unpoison_object hook for unpoisoning cached objects. A future change might also update io_uring to check the return value of kasan_mempool_poison_object to prevent double-free and invalid-free bugs. This proves to be non-trivial with the current way io_uring caches objects, so this is left out-of-scope of this series. Signed-off-by: Andrey Konovalov --- io_uring/alloc_cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_uring/alloc_cache.h b/io_uring/alloc_cache.h index 8de0414e8efe..bf2fb26a6539 100644 --- a/io_uring/alloc_cache.h +++ b/io_uring/alloc_cache.h @@ -33,7 +33,7 @@ static inline struct io_cache_entry *io_alloc_cache_get(struct io_alloc_cache *c struct io_cache_entry *entry; entry = container_of(cache->list.next, struct io_cache_entry, node); - kasan_unpoison_range(entry, cache->elem_size); + kasan_mempool_unpoison_object(entry, cache->elem_size); cache->list.next = cache->list.next->next; cache->nr_cached--; return entry;