Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6517426rdb; Tue, 2 Jan 2024 04:54:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFr/eFoE6XTeD41sDW+Z1KCByR9tg/FS6S5j/DWsofMnhfkmPK60Z4yepznQFf5irKBfsYq X-Received: by 2002:a05:622a:60f:b0:425:9aab:fba4 with SMTP id z15-20020a05622a060f00b004259aabfba4mr27319516qta.39.1704200095523; Tue, 02 Jan 2024 04:54:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704200095; cv=none; d=google.com; s=arc-20160816; b=Dyyih9Z9/pEE1u2X2U0n9T4cVzM4HJrdxX9JVWcH5tjkeUuK0J2RfnduU1/gGNx6R8 MIbvUrs8oxey2Y7cJViY2Bn8xiwtnXRjXqKYYv5+fMy822JFk/b2SH5CGqTcNuDyZDDe lG5NQbf77L2hIe9Zw3ovQfAJARFdsMJ/WnJAau6+i5nNhjb+AwknjG/ZTM/Xo8NFwX3Z IUi8M/OogkemC6EcKUumtlI+8fvzV6kuPbMO0za3xplxuy9BEp/ZhbgoD3QOy0uA1f1k YcNGUbX1nl6qibx/JU0CGSdy10WzSBap3kd+IOq5PtJXZtRSL4OHGHpPfFP552KDS7eF sz+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=rzpHQecmeH/R/ZNceK/OpsKzmGzn/z2pMokFTKQkVW8=; fh=FyCHTDws/5IrfNgPWVFTAAhk8MeJh+BMbJgBeQ8Nmrg=; b=UcnhN6vKQcVt38Ha/mu/km4DFWlNZch+Ol5NNDwEWLPSEka8/+EmYPqZoCGrXbyki5 yRImQoeV0lWFJ+Zny53/Hqg0qIk2LRfg3sn10lfVPni4Y4GRCaLR3tRv4NyqAxzRsj82 jZsedw5U27/MQGRNQSmpiIb5pdGat3XRjV1S36Cvu22g/95fKstuZ9tyoOdOsbfJavr8 dmsT11TArD4V9eFzsIFupqEHkGU62qb7jou+Fl36Mp2D+iZiE2p5BumjkQzMZu8VgL+G WsJd96T1AlJjgLz/Eb6RfAHyNoFxU8v+Bj+vqmJIhco58h7l/bPaTNruUfMUNUnshnBc Mgbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=avc7+IFJ; spf=pass (google.com: domain of linux-kernel+bounces-14360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n11-20020a05622a040b00b0042771d55d36si26897424qtx.669.2024.01.02.04.54.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 04:54:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=avc7+IFJ; spf=pass (google.com: domain of linux-kernel+bounces-14360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8BB401C21F70 for ; Tue, 2 Jan 2024 12:54:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF577FBEC; Tue, 2 Jan 2024 12:54:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="avc7+IFJ" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-vk1-f177.google.com (mail-vk1-f177.google.com [209.85.221.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B36B3FBE4 for ; Tue, 2 Jan 2024 12:54:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-vk1-f177.google.com with SMTP id 71dfb90a1353d-4b77c844087so1579244e0c.1 for ; Tue, 02 Jan 2024 04:54:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704200086; x=1704804886; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=rzpHQecmeH/R/ZNceK/OpsKzmGzn/z2pMokFTKQkVW8=; b=avc7+IFJV7oIkKsbUde0fFR2LEEXvElyS8oJh0lfAJnrrYWwIck9r14ZqDCuFtBYmV uDb7eFwizBm+WwjlyZgk+QK+6M8bVjWFJUoQGdI8TaYy++oxCWXEUOqaHOtlrEDSNVmY zaeKbVFsg2X4mR9WeEvT92u0kk0ykIaSRdZnYbv2+pDls5rOxQGXN5xJSCfdZg08fc92 IqzWeqWZHpm5eSwqfZeYdAsK2lWOcYYzJhUMC4YNL4f44WBA/x9oS09cXBxvkC9pe3DD v4P/ui8tWhCSMkdQoevLbRQOvXdQ8KHzH5IeGALYqOd5001yXcTaYVPGmcIn9mxOspMt n72A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704200086; x=1704804886; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rzpHQecmeH/R/ZNceK/OpsKzmGzn/z2pMokFTKQkVW8=; b=lAmYt9o/bfWl1DXAQ8TWODqTm0C0VkNfcjvdasRzh0t4PPwLWa5Aian/n3xrGQES9T SJoF/r+7IbtK5Zs6SQ3Xw9Ag9LcLjlfade+WiPkFV5kUfWvpHX1+V/O5CG4REXMUFMfW 9cOP8TMERmP82zP56CdHMoOaEGmU4v8bi5eRW9mCTwUohptZXmJ6sorTQlrrGQ0z+MgE kRBHqCPGuulvqr0TVEu/Tb9fshmIb3LnskhC6f8EOeeVxWluRCAJzAFsltCwVABxKsBv T+a8pSk7nDKlUfaJAqY0dcdRPPx/EROL5IFCZTEGpdJsgdA1fnhEvy1/nHpM+FL/O9pL JeRw== X-Gm-Message-State: AOJu0YyVRWEl2lmFDNIwltu0OVsTcoqSrHc11w9/7PbY5Ka1KyDuI6n+ fsPyRbl6SL7Uo6VkPSkOL/fhZvelct0H2tyYrpsIUu2IPDTo X-Received: by 2002:a05:6122:9a0:b0:4b6:c780:ac90 with SMTP id g32-20020a05612209a000b004b6c780ac90mr10538276vkd.0.1704200086271; Tue, 02 Jan 2024 04:54:46 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Marco Elver Date: Tue, 2 Jan 2024 13:54:08 +0100 Message-ID: Subject: Re: [PATCH mm 00/21] kasan: save mempool stack traces To: andrey.konovalov@linux.dev Cc: Alexander Potapenko , 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 Content-Type: text/plain; charset="UTF-8" On Tue, 19 Dec 2023 at 23:29, wrote: > > From: Andrey Konovalov > > This series updates KASAN to save alloc and free stack traces for > secondary-level allocators that cache and reuse allocations internally > instead of giving them back to the underlying allocator (e.g. mempool). > > As a part of this change, introduce and document a set of KASAN hooks: > > bool kasan_mempool_poison_pages(struct page *page, unsigned int order); > void kasan_mempool_unpoison_pages(struct page *page, unsigned int order); > bool kasan_mempool_poison_object(void *ptr); > void kasan_mempool_unpoison_object(void *ptr, size_t size); > > and use them in the mempool code. > > Besides mempool, skbuff and io_uring also cache allocations and already > use KASAN hooks to poison those. Their code is updated to use the new > mempool hooks. > > The new hooks save alloc and free stack traces (for normal kmalloc and > slab objects; stack traces for large kmalloc objects and page_alloc are > not supported by KASAN yet), improve the readability of the users' code, > and also allow the users to prevent double-free and invalid-free bugs; > see the patches for the details. > > There doesn't appear to be any conflicts with the KASAN patches that are > currently in mm, but I rebased the patchset on top just in case. > > Changes RFC->v1: > - New patch "mempool: skip slub_debug poisoning when KASAN is enabled". > - Replace mempool_use_prealloc_only API with mempool_alloc_preallocated. > - Avoid triggering slub_debug-detected corruptions in mempool tests. > > Andrey Konovalov (21): > kasan: rename kasan_slab_free_mempool to kasan_mempool_poison_object > kasan: move kasan_mempool_poison_object > kasan: document kasan_mempool_poison_object > kasan: add return value for kasan_mempool_poison_object > kasan: introduce kasan_mempool_unpoison_object > kasan: introduce kasan_mempool_poison_pages > kasan: introduce kasan_mempool_unpoison_pages > kasan: clean up __kasan_mempool_poison_object > kasan: save free stack traces for slab mempools > kasan: clean up and rename ____kasan_kmalloc > kasan: introduce poison_kmalloc_large_redzone > kasan: save alloc stack traces for mempool > mempool: skip slub_debug poisoning when KASAN is enabled > mempool: use new mempool KASAN hooks > mempool: introduce mempool_use_prealloc_only > kasan: add mempool tests > kasan: rename pagealloc tests > kasan: reorder tests > kasan: rename and document kasan_(un)poison_object_data > skbuff: use mempool KASAN hooks > io_uring: use mempool KASAN hook > > include/linux/kasan.h | 161 +++++++- > include/linux/mempool.h | 1 + > io_uring/alloc_cache.h | 5 +- > mm/kasan/common.c | 221 ++++++---- > mm/kasan/kasan_test.c | 870 +++++++++++++++++++++++++++------------- > mm/mempool.c | 67 +++- > mm/slab.c | 10 +- > mm/slub.c | 4 +- > net/core/skbuff.c | 10 +- > 9 files changed, 954 insertions(+), 395 deletions(-) Acked-by: Marco Elver