Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2376660rdf; Mon, 6 Nov 2023 12:14:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVjqGWQ/U60el5exqBrSNhUt33nGwIC65Nb4OzhJXc8H2QteJX/hn33pMKZSwWsbBKwn2C X-Received: by 2002:a05:6808:13d6:b0:3b2:ef9a:4339 with SMTP id d22-20020a05680813d600b003b2ef9a4339mr38089646oiw.49.1699301680346; Mon, 06 Nov 2023 12:14:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699301680; cv=none; d=google.com; s=arc-20160816; b=gvy5fxr1sY4v/+ujaUPTjFWhcfdjOG5QeJi9HwnbJid+W73y/KHRObPtMVUg/GIhyY /lVzDzcjPKrUeunlp50WQa6LFWFweVjov4QxFZUImgYz+76eQ7K+CczJvNkDGqAFsYDR cNHwBZJueqDVP1NaR5US8H91yUzLLoFPOyiWlnroq3vZTM7V52W4F8Cjmy+Kpz2dAJ7Q qnSZjVg8zy7uImZz3KFSRDgMsJY3S7C8HjtZv1P8oRoKedD1Lxkr7zWY8kB1CtzQVNta CRCVOfLGwjImcNxqlHVJB81z0QwadeyEK4hp/g74BQQShpKXJ+ZlruPT4863to7a3mpW SYAw== 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 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 199-20020a6300d0000000b00578d3f8d4d4si395455pga.448.2023.11.06.12.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:14:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; 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 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 5CF10801B9DD; Mon, 6 Nov 2023 12:14:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233139AbjKFUOd (ORCPT + 99 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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 12:14:39 -0800 (PST) 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; -- 2.25.1