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: 13447468 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 424EDC4167B for ; Mon, 6 Nov 2023 20:13:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFECB6B02B0; Mon, 6 Nov 2023 15:13:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DAEFC6B02B1; Mon, 6 Nov 2023 15:13:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C00696B02B2; Mon, 6 Nov 2023 15:13:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B1B216B02B0 for ; Mon, 6 Nov 2023 15:13:54 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 92A9E4089D for ; Mon, 6 Nov 2023 20:13:54 +0000 (UTC) X-FDA: 81428630388.16.EC16296 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) by imf08.hostedemail.com (Postfix) with ESMTP id 99F30160005 for ; Mon, 6 Nov 2023 20:13:52 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=VvwPI2ke; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf08.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.173 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699301632; 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=EPGVjwO+qP/d7FcuwPK2D6CcDKWjvT42oG4AsVrb0Go=; b=SRPW4ANKlAwghIs+KtbbXxHGW3dzd8C1UqesWi5h771XeoC5dh+H9KdzEwQVfcP0+9lIEH LihWrHpRDF1POSJVax1lvzwmZ5O3uIqiW8ILj3vNBAlNgPiEYUXyqw/7lq3xc8ja+Qdr+R 85HXNCMK4ceG9fZbeCiMMxhS4OcQ2Zs= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=VvwPI2ke; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf08.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.173 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699301632; a=rsa-sha256; cv=none; b=6zsedj6RAMQv716tuWT+GKuZOdVy/XtQ0K+b4e2kgWNvfr/7T9tw0oQA0E3bWQ8wuPh9si 30BS7jPqjyP1uC0Y9tFEcR5OxEX4GQVP3VSeiSEb9bmC/vzr0d8wIuJNUkKM6gz+LUlfrk 2j2AC/ZXeeRi7MHyxCwmtW3a/rW9XQI= 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-Rspamd-Queue-Id: 99F30160005 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: ttqu6yw8nqstcnte4ff35frje1amkmr7 X-HE-Tag: 1699301632-197147 X-HE-Meta: U2FsdGVkX1/KKlMdkN1rKACWk/o/rI4TaqOkCE7hF+uf3/y9pWX2+IqVG0GVr8PSAcHYxhEAN8aBGoVuQj+iCwoL5py5R3GwTRVSCMFGM7x2pLBMFtVzaZjmzzW0xEJ7Yd1Qm/yzHU+dTezmCbrjflwe+6pJKARPYeVU00VltzoshX8KLFbohGbsFLM5O15vPpf/Ro5qidMLRrmrr+uKJtjdiHD8on2bsch49ibIZDB4u9MRySVyeGlPTP8qHNKi21lQQfxFNJY2HB3W7PYRyS+7aUueqt9E50jRkdZVT/oGSZkV08+upopPsXqE7Q/XX6sKX3aa8NfV+PYbZRji7MEYHY/t/hGzZpjaEbtyq6Yjo54AnDO+gRVVu4G35F6Zrq36aFi++audV67z8CeLbtIE3ypmbDCKOtqi0pbtgDrjbPVIcmbqbiu/awmK4FnDnL/yzloYkWy7WjcppxygItiXH/B7VUYyHA/+dbndtM6wDx3bwC3xs1/V/waNGvF26+FFnuZCazwHXOzY1Xue+gEOvuz1Gy61F+35T/tLvBL39Zx5CVFtoNiEVhZuRYrC3rXdCWmoRLpE9RegEEKQJjczlXIOkhpTfM+qaxedBfAOG1Us1trqB15u6ID01cDTP332UkBxkZrIMaSkFAVnEmOnLMWlB6z7lgJuX1d6bWzNhFWgcFBYGY1peM7+vqX57HFOh+/sGR+7DHSm21IIRgZB1ZQX8/kdOVIjVA87xaqUYTsTIpvEg54yGm65ZYP0WcDoEqDmKxdlwG8zWWajIFXZsFvP4vnKD1qKuZmIho7iwTQLNDMyvfo9968p6aAmF9RLOg2u/GYbY1S8nXJdRWfISmXIsN5O9YYF4ox/LnuIq9ePCFK3jYU3YlbRhKMK4Hhj3oz51Vdr+8Mg0tQiU/72ZPY7+SGC6hAyC8Cw9ZSFS8dQqYIyoW0nuRpHsbG94vjWw2rpGaTWN2KXRDK ZMOzBFEC xEGsarN0+6+WAPF38/hd+RI0NJuCroeMQGHH1ECjccCQNBTRd5qpIxklWs2spn2WYD6kuCtETeqZ4hvPbR78dO/18hMwwDrPXBGOy1kBECZz71YhoaoG0pCobr33auUvocdgW4fL9bg5if/QdqYz0n+/Q++9LAK7q4yTsHn8/MKs7Xln79Dv4qieSLTQ08XrfYIZmj2R/FgSQL/L0tioa2GxtZ6NnuY7aaMhD 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 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;