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: 13499315 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 2390BC41535 for ; Tue, 19 Dec 2023 22:32:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 318996B009C; Tue, 19 Dec 2023 17:32:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 27CAA6B009D; Tue, 19 Dec 2023 17:32:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F3056B00A0; Tue, 19 Dec 2023 17:32:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D4D6D6B009D for ; Tue, 19 Dec 2023 17:32:33 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AF85FA0413 for ; Tue, 19 Dec 2023 22:32:33 +0000 (UTC) X-FDA: 81585018186.04.D2A2146 Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) by imf23.hostedemail.com (Postfix) with ESMTP id 00873140019 for ; Tue, 19 Dec 2023 22:32:31 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="PVS7/Vp9"; spf=pass (imf23.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.187 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703025152; 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=wH88nobEbW5JyTL4865UxmVo+gte1miKuRupm3F+1WMFXR4mtmnxshSabv2WIw3cZqTt1i AI6Vy3QPo98zwt3qForE/679brMB/x15eT7HnpRjUxmmAa3EffN6j5mWl6w5JxTF0EJAs0 gK8eMsC2w5Nc+vgYMhDBZp7PRSREOHc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703025152; a=rsa-sha256; cv=none; b=NEBT87nlLQK1H6VMXI5DMpjsnA8r0ZEUWfSUzfcKK/mMB0QGLY4yS/DW2OUCVEFvNcnJ2N /DZRifuyhwsGLAP7tBjGiHUhPLrluB4/44hkAAo1AqphYANVKqwMjod82cEvOrSFWuASwT Z3vKSY6jzX7g2FVTmogqkvhwuPNQyaA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="PVS7/Vp9"; spf=pass (imf23.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.187 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=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: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: kmf39h38o9zm1u436opmpbouatpmex4d X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 00873140019 X-Rspam-User: X-HE-Tag: 1703025151-835627 X-HE-Meta: U2FsdGVkX1+rum6i18OJ7DCQh5XaybgQHi5XVxx8vgm2VXZLSbrMeUv+xK0ra1qn0u3NAavbdTMetJIY+zGgDpdoopxSEZnMIEPQF/3fYA/Y0iVHKAfmhgoFsHeEMmf7aqJDx/Zdu4GSqqsE/g7Mjk3nI1isoMjfYnh0bLDvpUJEbk/269OmEr+7XwoaJxoLwbM6zJCVkAxglECusPVp68/CwEjpHQ9e7u3H8Vfr6AnVHJk98+ylSoarhJQupIcVEG/ody1wCRJdfVOOhRZw3nRqm7tf/7Zmi2F1pIoKfQvAyfmC03EKYZUu+nrQBT7BKWlyBHUPftNa6t8fxa4vQp7ovSYp67z6wZAvEM1Vi0hC3JDSEZ6XdRQH+vptigfVGLWsCfhM/D8G16qkSLsit8Odbqfq4f3S4ifHsc6QtzFheUHvy6I51ZKMkKD9hOstksJ1Gd/suEp9o3Ak9D4PTVzSUSxPCAKG5YgPbtvWRB1vivv0kckqF2E4n3M2bpE1r9flajIY0jlEZPIXgcdl/cyrKdU8OByQrStVwoCbk6RT/bTthgXOvQDvkW0aATpXrmGdM1KxqvdcWAs4cTZjok7rSWpIbSywFVYInD8EYph9MBbh+KbtukdvYL2fS2aoYOQ4HEkgRbxJO2IWIiZsJ5d5sL1ZcGRtJfwrKWhXeHXHSgeKe2+ucM4OQxlLoJ2W2gXmwazSTlI4OwZgrfLbZiNtuF1h9Utnnx1eUC76t65Vs5QKKDOge1oHo0da1SZomU/DFxahnVFXKFw3tRhTJP7pX19bOkfs0gRrvfL9620Ki17G6VQWdl0lYYmXoIpPuaKMkgvEl7QsmGNWkskMymL9YiXZmZCED+hl5fYqr2bwclvHBowDThHJEQHsGyHIPsq3M2XDkG1SEgZ7Oy7/I8sXXofBN4tl11FtKoxJqDnvmfVj0qduvZpfwNUULzzm/0JKK8d931JOzAKmz0t seLy+JP5 66HVJtYZJ7s9qtyFm+3JHvXY748hvcrH+8uf9BHWyeQKdwQuqBNv7V5yqFbApauoh345lAzF/Ds8TWq2JdumM+KPM7bhNLbEf4XDcpvlHUEnM8GyBNxl2J5iQvhW58d5EGumdWE50eSW3T/0LhYVohNyqBWWZpBgM8nK1NeG3THmI7CEi2i3EOTMzFs1bWarNBX2YSyA09p2h0kwm8LSueAaAuW+pQ3OqqWIl 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;