From patchwork Mon Nov 6 20:10:29 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: 162176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2904190vqu; Mon, 6 Nov 2023 12:16:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOfEC9jWYjZaZbc08YgKeNrU3Yct0I4x6TF84OQBDpf8eqz2dRFWwYAyaM3GhaP8PCRtpF X-Received: by 2002:a17:902:f391:b0:1cc:fd1:c85f with SMTP id f17-20020a170902f39100b001cc0fd1c85fmr21122836ple.22.1699301771016; Mon, 06 Nov 2023 12:16:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699301771; cv=none; d=google.com; s=arc-20160816; b=jhL9nZ694uCqmKRH3xgG1mkLwh0/Gxav6telMHjoGqznmFBRxYiqOm0+U2gTzJZyHf utNPKruhFlfVAfBxYypTxwnSgt2jEeBKJnxVUEq/rKfD1DNXowN6Fg7Z3oAeMIMWkS7Y ug4pTv/8jVUAt/3aeSlYz3ra0XNQuwf4AxmY7ezB2FpZdnE2YMba1N5gINhoTwYfV9+0 aDaF5Ki5Gq+jPb0UVH7KUep5XW6iuBdKsoeRO/Vz/2O5ut9tPideHwRjGUhJYrATED4I Qx5Mh231yRdzXiQ4q6iNZRWNiwTumeZYPL4A43GAPmv4QrHNNA7TJMkqaAVTABzE9NSr KSKg== 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=EPGVjwO+qP/d7FcuwPK2D6CcDKWjvT42oG4AsVrb0Go=; fh=n5KN85tQTomq0Sa/nFFC9xbnc77mxkBzF8HoolO/QOw=; b=JDEghi3cpOOFaCE1gIzbWrFdZXNNd056Y4I//GCn3TBhTuZjvU3rOXR0FCNaLBqd3m 4kQcf/pJ47ilSWJLxzzdt+5VZFWoAq2LJ+UvMqKzQhHMmoVFhoIabOxMcBAeI9DcoeKO F3AJqWmSLeBfWT2no0DNKK7C4tzE6qAIdI82cxzVyuh1UgWW4iWppPFn9vcPW+s8NMjs jOuzURgoVyeoghnFWIGBG8sfbLKyvR5Nd1vTTuAuveolO4byrK0eaKPK25dHtNjav1Dp V3cJudmfr1jvAk4AOCihTtK7YQHMYvWCwPxT15C/GR9xs9uTTnyQvhDd5aS/jiWy7W+Y 0yug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=VvwPI2ke; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id w9-20020a170902c78900b001bdf6eb05f2si8242685pla.227.2023.11.06.12.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:16:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=VvwPI2ke; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 6D75D804A9F9; Mon, 6 Nov 2023 12:15:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233142AbjKFUOd (ORCPT + 34 others); Mon, 6 Nov 2023 15:14:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233151AbjKFUON (ORCPT ); Mon, 6 Nov 2023 15:14:13 -0500 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33275198D for ; Mon, 6 Nov 2023 12:13:53 -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=1699301631; 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=VvwPI2keLXzkzqlZ3FnvGVKGg5TiKAVIbhEfe4q4zBpcT7eCPN3B9NQON+ibMnBGElwnGf eWdKn2N728sPwjXJ2GuPBYYG5XnlY5BH2yy4FnLjIp2Sa6KToE0S7E2SFjTIoYB0IY5KEk KahIGvyWN2K+2fQ0a2nUKxfLXrFjdms= 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 20/20] io_uring: use mempool KASAN hook Date: Mon, 6 Nov 2023 21:10:29 +0100 Message-Id: <4f2fc546ce7b494c99c08e282c4d697d6dd58a8f.1699297309.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 12:15:01 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781847053887514149 X-GMAIL-MSGID: 1781847053887514149 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;