From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F11E8200C2 for ; Tue, 2 Dec 2025 23:23:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764717802; cv=none; b=qABmi1vpWtCHcUM/yQYVDlPjnD8vC4+krmNQGQC2zll2t6cTcfbkmPLw0lgNXPa7c/lPwyLdB3KfFCyPQN9bA2DbfYx2IlsZZ2FXgvSilEuOxcNfoqdzIQYQWaBKP26JZoeoe8kdxt5M3J2/pd6CG/nw4AUZQwEeXoRMotA7APE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764717802; c=relaxed/simple; bh=S93eJ0Eu1zfU6fil9PyTt+lgYx0wNxFtPFFERmhsitQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L/oxzmwvicNdwWGjapmOZSq+cNnN08YPQrTyo8mPo/v07v9XUB5sN+pn5uYQhkjOzFSCoYRxJVhpbn2F9XnV+PDQn1CQvtDnZ6rCUm3uBEs6Sm8gAa8g0WolxZl72jSGhEUytaV9C6C9Q4Go4R6qS3XHhr831FaK0t6dmsKVep8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j1+RzGCp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j1+RzGCp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C042DC4CEF1; Tue, 2 Dec 2025 23:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764717801; bh=S93eJ0Eu1zfU6fil9PyTt+lgYx0wNxFtPFFERmhsitQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=j1+RzGCp8Ds2mGnAkkCXz5a2tsDMzcHoUprQIYTJtUPQWzUHYUJEtvmK0aqckp3kU 11MbIu6e5UEGJQAiH32gkmYShdxPBnFFd/2Zb1+Zp/7MNUN8WkGwKIn7XzN+IkVdyX a8FNxZey1CymvoGiNkkwMlMSQgRcPQVERuiORDBIHtyj9GlaPb0e498DbRDoGGhdR2 QjXwvHNO/vEQsNqHgf/DQ+a1OiJHQc38m2F7Nh20z7/sLYXghwanbYrBth7521FZc2 bgJz/eCiQzPhtMLGwTCGwwcO8W7PHJ4GitaUYHBgVtm+m2MwJ9VDxYLDyb1S5DR/N6 0U+tuwbRrDO9Q== Date: Tue, 2 Dec 2025 15:23:21 -0800 From: Kees Cook To: Jiayuan Chen Cc: linux-mm@kvack.org, syzbot+997752115a851cb0cf36@syzkaller.appspotmail.com, Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Andrew Morton , Uladzislau Rezki , Danilo Krummrich , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] mm/kasan: Fix incorrect unpoisoning in vrealloc for KASAN Message-ID: <202512021522.7888E2B6@keescook> References: <20251128111516.244497-1-jiayuan.chen@linux.dev> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20251128111516.244497-1-jiayuan.chen@linux.dev> On Fri, Nov 28, 2025 at 07:15:14PM +0800, Jiayuan Chen wrote: > Syzkaller reported a memory out-of-bounds bug [1]. This patch fixes two > issues: > > 1. In vrealloc, we were missing the KASAN_VMALLOC_VM_ALLOC flag when > unpoisoning the extended region. This flag is required to correctly > associate the allocation with KASAN's vmalloc tracking. > > Note: In contrast, vzalloc (via __vmalloc_node_range_noprof) explicitly > sets KASAN_VMALLOC_VM_ALLOC and calls kasan_unpoison_vmalloc() with it. > vrealloc must behave consistently — especially when reusing existing > vmalloc regions — to ensure KASAN can track allocations correctly. > > 2. When vrealloc reuses an existing vmalloc region (without allocating new > pages), KASAN previously generated a new tag, which broke tag-based > memory access tracking. We now add a 'reuse_tag' parameter to > __kasan_unpoison_vmalloc() to preserve the original tag in such cases. > > A new helper kasan_unpoison_vralloc() is introduced to handle this reuse > scenario, ensuring consistent tag behavior during reallocation. > > [1]: https://syzkaller.appspot.com/bug?extid=997752115a851cb0cf36 > > Fixes: a0309faf1cb0 ("mm: vmalloc: support more granular vrealloc() sizing") Is this the right Fixes tag? I didn't change the kasan logic meaningfully in the above patch, perhaps it should be commit d699440f58ce ("mm: fix vrealloc()'s KASAN poisoning logic") -- Kees Cook