From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (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 323363E0C79 for ; Fri, 8 May 2026 14:19:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778249971; cv=none; b=UgXp0lhE4KlqtMbjPyrzcLIvcmaPB3zyqMHzAph9Gc6FMTeTICzRuAsetyaCP0rUOOJ2mPzCfDgXe0JYXOrjo4QlRIk+4AJs4AS0+/IkgfH9GYZlhsbadGIq2f8unmRCy+UYAfptg5EwxUKXIO/0qZSkkjL8ItJMVZLNOQhMVfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778249971; c=relaxed/simple; bh=qX6ZIf5sIB20nZttfhTQPcEWRGJ/WkHu9OFjzJJnDGs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bWZiwTc7JGn7djHypFuPtbSOzGFn1oQ1KY6ZJjYaoL2Dpo2IkNdL1rdHk8EHPRDnruhFNXXiZxYXBr9owDW/2gVo/ANDBZb36RbA2HaNbD8pUADt7vzrxEm1+rFWsOz5GeGiHZm/oaUrXCGLCa+ELG5e3RAzhX5OpepGUFkog4M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=vm1OzPru; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="vm1OzPru" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=71MRgc94yCBicm2ycw6S5Zh5MIeRKVhFah006V5GOnU=; b=vm1OzPru4CpigpKSxBNglzxLyY GPNothc14LxiEnurDtQKUDRZ8H8nlq7+f/oPtWTo0OIsllToxqU6GPHjKAEOFQ42bRAKYmsEDaIh7 bcf3cQEnrx3sO/XO/1rnONtqLOM+nX0k13bH1aXktv+ZANM+b8A6KVN9Z7cD4TU+ZYupw5hVlQz6Y oNo+jYYm50GDATnWLiQjCgSXsxRknQCp4HHOopINBHCYZvKNfjsCEks1d9YjPmD70LZK1KpM5k8e5 6apqOjKrW1RRXHS1Md3jjhizM+KN3FPEnjsY9FEnGdeaTKiCqVnPPRjPxtfuZHcORXCUHgAYBw6Wv fIJNDFYg==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wLM2p-005Ckn-0q; Fri, 08 May 2026 14:19:11 +0000 Date: Fri, 8 May 2026 07:19:06 -0700 From: Breno Leitao To: Waiman Long Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Frederic Weisbecker , Mike Rapoport , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/isolation: Don't free memblock allocated cpumasks Message-ID: References: <20260505051821.1107133-1-longman@redhat.com> 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: <20260505051821.1107133-1-longman@redhat.com> X-Debian-User: leitao On Tue, May 05, 2026 at 01:18:21AM -0400, Waiman Long wrote: > One workaround for now to avoid these warning/bug > messages is to keep the memblock allocated cpumasks even if they are > no longer needed until the memblock subsystem is properly updated to > handle memblock_free(). We just hit the same KASAN UAF from a different caller on a v7.1-rc3 boot, which I think reinforces that the fix really needs to be in memblock rather than in each subsystem. In our case the offender is the IMA kexec buffer release path: [ 113.498542] BUG: KASAN: use-after-free in memblock_isolate_range+0x208/0x8f0 [ 113.514206] Read of size 8 at addr ff11001824ba4000 by task swapper/0/1 ... [ 113.532258] memblock_isolate_range+0x208/0x8f0 [ 113.532267] memblock_phys_free+0x5f/0x300 [ 113.532274] ima_free_kexec_buffer+0x1d/0x40 [ 113.532280] ima_load_kexec_buffer+0xbf/0xf0 [ 113.532285] ima_init+0x42/0xa0 [ 113.532287] init_ima+0x5e/0x190 [ 113.532290] security_initcall_late+0xad/0x210 [ 113.532301] do_one_initcall+0x138/0x540 Same shape as your second trace: memblock_phys_free() reads memblock.reserved.regions, which memblock_discard() has already returned to the buddy allocator (the KASAN shadow shows the page as fully poisoned, and pfn 0x1824ba4 has been reallocated). It then page-faults a moment later on the same address. ima_init runs as a security_initcall_late, so by the time ima_free_kexec_buffer() calls memblock_phys_free() on the previous kernel's measurement buffer, memblock has long been torn down on configurations without CONFIG_ARCH_KEEP_MEMBLOCK This regression seems to come from commit 87ce9e83ab8b ("memblock, treewide: make memblock_free() handle late freeing"), which dropped memblock_free_late() and made memblock_phys_free() unconditionally call memblock_remove_range(&memblock.reserved, ...) followed by an optional __free_reserved_area().