Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1388287lqd; Thu, 25 Apr 2024 14:10:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWg9fk92p+1CaSez/O5DaFSFPWJ0c8D0hlYP/Uhp3NQzKy/rFtV/CzzmIbwMkOODigX1jDdLs0OBaXXGX7+ec4yEkup/5Zbpiexpd0TQ== X-Google-Smtp-Source: AGHT+IHoZ1Rssr0chIksnIRkJU/3cQsRb0j2017bkgUuTguGkjcPccyfAbkMZ3H6CqLgkP3p8d+f X-Received: by 2002:a05:6512:2f0:b0:516:a6ff:2467 with SMTP id m16-20020a05651202f000b00516a6ff2467mr416867lfq.0.1714079400405; Thu, 25 Apr 2024 14:10:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714079400; cv=pass; d=google.com; s=arc-20160816; b=xi8GqeGos6NC6jPDLPcBrL8/pJpC+kZ5GZbjy7R+R+XyqVOwnnJNEOXcG2TKuhgLgl Vw9+qWPoniQ5e1P5xlSooECr78miomlc38at7KtdbJ/uW8tcao/T4CEOKG4HKmZbne1j xjblaYhQbcMdjND9PKqb9cYtti0RYh28ukKxC0gC5zF7YY6vehrbryUouiKwfsaHBk5u HipUHDOMe1atqF+Yfw1PI1XYrtTlwW+iUqbtJ0+wmAah8IHzAb1pfoyu4ZgHTvN+XRMv EFnpSCi07GMBs8WXApuYKtG/7J+gq+cN2YbYIgJx2um9Bq+hdc8C3E8ZurPX5PzwBp/R W5RQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=5BQT9j7sLQeMY/YB9pvp7PU2WrrBXiYonNuoxwRbYFE=; fh=70yZg1uiyb2EDuSZmY0t1kxXqEwpPURHAZ9EAl3KFkc=; b=nxvImMPB2SS/1BtyiQhyg+zdFbHU4YilbReUd8ssHiDwg7YStRShWhlbLv98dI5yNX m0+45bNPlmH+/BPWtiGpnvaguQ/J+WqnAdrDtZJd8//DLgIcijIpNyavuxXaFBbrJueZ 7ab7DHL+JdgPIO0IPhSR8bR8186enfPZVu6qK3P61P7VbXrEw2RoeHEDQf4B8Z+WlFM9 uJqCx05yzXY69ddAC7Zi7FpZSmO5J1AHHPocnkmpytxFmBiS1ntU7VQmq728BkQN/SIt tQtLx73S4sdP0yuAtgpHvfs35NitXY6d96j4l1+VRsYpniKrx6qQCAmtLDg/jk6QusS9 CP6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fwaSUXof; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-159188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n17-20020aa7c691000000b005700fc82b7asi10119443edq.389.2024.04.25.14.10.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 14:10:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fwaSUXof; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-159188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 23F8E1F22E0F for ; Thu, 25 Apr 2024 21:10:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 547B71553BF; Thu, 25 Apr 2024 21:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="fwaSUXof" Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D9F915534E for ; Thu, 25 Apr 2024 21:09:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714079391; cv=none; b=JSwX7Kc/v1/cII0H0Wxtqg3lwEuDFOnUwp1+UbtMu5qmt7CxbVglxM0VCQrTNHNN+KggMZpk7CiCOvUIjpvxDIqnWYk4AqeUb1FPoBfUxpSxB7X/aQCX7owxdvb8DxUNPm8cDRoI9r52Pragc6veACulE81uBRHGbSP5YobGSBU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714079391; c=relaxed/simple; bh=hwNZS76oWiIdn5n+tWivvlFReYO7EbPFLIBPF+1gTq0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=X5I2dQhoqnn3JMplqaJ3FU+u4vQnTZ2YDwEUl9K8yLKBgb+8hFeEf5Qx/Clnj7PFWrQgfYtcRPD2ci2sniG+PydnsHkX3Cg4n72tJbjcQUSkUQlTck/8v/be2K4/jXo50nZ+HegE0Q7nTKosUnZjNXqpbTAh/mGi1y+N1dhvElE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=fwaSUXof; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Thu, 25 Apr 2024 17:09:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714079387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5BQT9j7sLQeMY/YB9pvp7PU2WrrBXiYonNuoxwRbYFE=; b=fwaSUXof6osVkLcezsvOOJo5sLF5ZSkRYS1kXifZw1N2Vj/4pQtg/ZlD5zdSf1ljvSMJep OdgD2AYS62LPpd7OvgZ0L0m4jlDBwGfoPtkapcid80whwL/WAsVsILYrNJzMMk943mhMza Y3FdBiDc37FhEeTKP2s+gBH5ZetXbNg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Kees Cook Cc: Suren Baghdasaryan , Catalin Marinas , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] mm/slub: Avoid recursive loop with kmemleak Message-ID: References: <20240425205516.work.220-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240425205516.work.220-kees@kernel.org> X-Migadu-Flow: FLOW_OUT On Thu, Apr 25, 2024 at 01:55:23PM -0700, Kees Cook wrote: > The system will immediate fill up stack and crash when both > CONFIG_DEBUG_KMEMLEAK and CONFIG_MEM_ALLOC_PROFILING are enabled. > Avoid allocation tagging of kmemleak caches, otherwise recursive > allocation tracking occurs. > > Fixes: 279bb991b4d9 ("mm/slab: add allocation accounting into slab allocation and free paths") > Signed-off-by: Kees Cook > --- > Cc: Suren Baghdasaryan > Cc: Kent Overstreet > Cc: Catalin Marinas > Cc: Andrew Morton > Cc: Christoph Lameter > Cc: Pekka Enberg > Cc: David Rientjes > Cc: Joonsoo Kim > Cc: Vlastimil Babka > Cc: Roman Gushchin > Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> > Cc: linux-mm@kvack.org > --- > mm/kmemleak.c | 4 ++-- > mm/slub.c | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/mm/kmemleak.c b/mm/kmemleak.c > index c55c2cbb6837..fdcf01f62202 100644 > --- a/mm/kmemleak.c > +++ b/mm/kmemleak.c > @@ -463,7 +463,7 @@ static struct kmemleak_object *mem_pool_alloc(gfp_t gfp) > > /* try the slab allocator first */ > if (object_cache) { > - object = kmem_cache_alloc(object_cache, gfp_kmemleak_mask(gfp)); > + object = kmem_cache_alloc_noprof(object_cache, gfp_kmemleak_mask(gfp)); What do these get accounted to, or does this now pop a warning with CONFIG_MEM_ALLOC_PROFILING_DEBUG? > if (object) > return object; > } > @@ -947,7 +947,7 @@ static void add_scan_area(unsigned long ptr, size_t size, gfp_t gfp) > untagged_objp = (unsigned long)kasan_reset_tag((void *)object->pointer); > > if (scan_area_cache) > - area = kmem_cache_alloc(scan_area_cache, gfp_kmemleak_mask(gfp)); > + area = kmem_cache_alloc_noprof(scan_area_cache, gfp_kmemleak_mask(gfp)); > > raw_spin_lock_irqsave(&object->lock, flags); > if (!area) { > diff --git a/mm/slub.c b/mm/slub.c > index a94a0507e19c..9ae032ed17ed 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -2016,7 +2016,7 @@ prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p) > if (!p) > return NULL; > > - if (s->flags & SLAB_NO_OBJ_EXT) > + if (s->flags & (SLAB_NO_OBJ_EXT | SLAB_NOLEAKTRACE)) > return NULL; > > if (flags & __GFP_NO_OBJ_EXT) > -- > 2.34.1 >