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 10124225775 for ; Sun, 3 May 2026 09:00:13 +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=1777798814; cv=none; b=o6aZs4AVQSOkM57JqmwAbLKn4kKwyejDsbIytRy+JNYvfDwePe4vTEB5IoDKRdtH1mBExGi75XNJ19CRGdT3z+OxJUcggV0hqDSURaPnYs0eqFLuRaaVRrTPkADrqtZCqRVDPVPVvGgEOW0wFANTXwB5RiSS7r3XgNwe1i0D2+U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777798814; c=relaxed/simple; bh=s3S0iiMVvJEoUB1cUh8UR8xxo23zU97CWT6LJTFqzkw=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=fumYat6wYUku9H5j1WBZPIW9dIkC2V1W3CBvgDUsH4weUzBRg4d+4Q9Nhd91EMiBDH4ILru2Q1rHScSblcDGRtgQCdvlw49AGqsP1QaREvToMDLBeKbU9yT+8jhwd0/fder9d7d+zimybp2v6GvGYQjZQRIuDg9LeSy1AXOXEN4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Is0wAzKY; 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="Is0wAzKY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14F50C2BCB4; Sun, 3 May 2026 09:00:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777798813; bh=s3S0iiMVvJEoUB1cUh8UR8xxo23zU97CWT6LJTFqzkw=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=Is0wAzKY9lti7ORBWLtFbQCBy4RaeXmJd/y5/t+Eklt3YkpOyatHSX1pycbQztf9R SO0lgXxe4xpaExNk2Fj/+jn+FcRglvCXoSVxVsihi/SEA+Rub9jMs0aKby2b7jrKZJ FKvk/0Q5dlFVqHtTHPMv3YGtk90c0AMNG2MGDTYSugEtPi+KrI4dSwfebV8jgU6Sml 19HERYRuYl5J7oJwtLOnvNALTdAsV0ATWKbK/c1hdxJoMUgn32V5+jSZyvdQfOez++ ygWQ6OwWEvcgWJnz1gUNq0c9nBwQ1xM/ajs9YRaQPDTPUJvUxGmGVo0jFPq6ruf8dx Wrb8nEIf6bmQQ== Message-ID: <137eb793-7f09-4c70-bd20-2294a8763d53@kernel.org> Date: Sun, 3 May 2026 17:00:09 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [bug report] potential order violation bug in 'fs/f2fs/segment.c', in '__create_discard_cmd' To: Ginger , jaegeuk@kernel.org References: Content-Language: en-US From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/23/26 13:48, Ginger wrote: > Dear Linux kernel maintainers, > > My research-based static analyzer found a potential atomicity bug > within the 'fs/f2fs' subsystem, more specifically, in > 'fs/f2fs/segment.c'. > > Kernel version: long-term kernel v6.18.9 > > Potential concurrent triggering executions: > T0: > __create_discard_cmd > --> dc = f2fs_kmem_cache_alloc(discard_cmd_slab, GFP_NOFS, true, NULL); > --> list_add_tail(&dc->list, pend_list); > --> spin_lock_init(&dc->lock); > --> dc->bio_ref = 0; Hi, Actually, fields of dc entries are protected by dcc->cmd_lock, so it should be fine? it needs to fix static analyzer? IIUC. Thanks, > > In T0, the freshly allocated 'struct discard_cmd *dc' is first added > to the globally visible list 'pend_list' (i.e., from > dcc->pend_list[plist_idx(len)]'. > However, its fields like 'dc->lock' and 'dc->bio_ref' are set up after > being globally visible. > This violated the expected order of setting up private local heap > variables before exposing them to the global state, causing potential > concurrency bugs with '__issue_discard_cmd()' or > '__submit_discard_cmd()' within 'fs/f2fs/segment.c'. > > Please kindly check at your convenience. Thank you for your time and > consideration. > > Best regards, > Ginger