From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 2C133318139 for ; Fri, 17 Apr 2026 22:18:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776464337; cv=none; b=aNW0Djriw2J4jjfZMUdqJ5XazeyIinVBGF+62PxKuRiGc+E8NzVdKmvEJTNrxe0GHP3p59M0L06DhjqEIvJBPG80bPkv8lKOIHv3lzEPU/Rcrv39XJSxj5ReM6oYl32KmA7be6uHxcBwZLlSxXBcBWg9JoJm3vYMO+Z3tOmOGHU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776464337; c=relaxed/simple; bh=x2ltSZwWwG16qGDDXnqqZkOPdWpby5TntvRFz/1Hh3E=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=I43Kp8OIqUeHmPtFtrMLfx2KMG5N56w4nWPXNRDIDfcM2WM87sZjKIgLDUlQ0aqPPGLMmBBeW8gxaNPZhCTKCmZX2iDw9tiXB25fVCJwgOeCp7+lkpfieocZAWl+v4OoRKxdwmRP4ochYZRrr9rXUBUY09wqCDCrVqt8ZGh5W6g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=H1GvEIgS; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=fx2p+Vhc; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H1GvEIgS"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="fx2p+Vhc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776464335; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2TkwTWh53bAvy7ale2RIwDuDgsVj+kc+55FasuLmjA4=; b=H1GvEIgSYHddB6SKcEZaN8S0iWwiottSMbvXY3+xmEzoP1MC1Djp8NTFsTI9R5sRDMMjEQ +aXIeTvfieCqoFhTAFZN+2Tz2+8ILZKACl95nJNQiUq67sAa3W5ikoiaXyiXECblcszU78 Oc6mOnh8qICHknoBTfyPmdSYC28hNGY= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-590-SBjBverCNaqdtrsiSO3UrQ-1; Fri, 17 Apr 2026 18:18:52 -0400 X-MC-Unique: SBjBverCNaqdtrsiSO3UrQ-1 X-Mimecast-MFC-AGG-ID: SBjBverCNaqdtrsiSO3UrQ_1776464331 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-79a51ba2bf9so38991377b3.3 for ; Fri, 17 Apr 2026 15:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776464331; x=1777069131; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=2TkwTWh53bAvy7ale2RIwDuDgsVj+kc+55FasuLmjA4=; b=fx2p+VhcTXOxX9Qzvvhwzqyg/YI8VHDcuWYQT/FJ0Hk/JNq7QPoW91I2VXYsYJSgQ2 HS0DbDW0MQd2t1WGmz44WljWS+D1LC1CepWV+VVqiS7K9pAw1lkTE2MGvEvS2+pEYbfW x/6fiGx862ePYcaIk8nCAI5Im3r/ng/Oe4n11EWny+j+BNfpJpUCTwy9wnBZ3neEC8Gm FixWxaUqaqdYQwHfEddWmSJi6j10ZTfpu6QVm3jdmb4zzXX7X42vVRU4yWgW1QGlXkUX gc4fnlYLVhHaorNMnPjGSxRmTJXNxG3TVYm4UY4ougXU2SVp5gc7rMj2XhSLONsNQBPi FD5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776464331; x=1777069131; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2TkwTWh53bAvy7ale2RIwDuDgsVj+kc+55FasuLmjA4=; b=Vc69I1RR25G5kDQ21HP3J3wlcYrqUayjTp687ev6Mx+oHLtGi5G4WDLTe079rRhsFG Ebj19XCG3Xtx+VtfxdXOhA1pWja1IaZ6anHHuehr86AcnwCb45BaD0hcax1U09iC/UB6 tNqxMTbqLejKnAQzRxAVrhr0HIPyZGS2NLOoCRT7Bz/fqNFJ7vAAsMmpI/tkfAu5cr28 NG8UQqQslwTld/bdpAW+fuPkqnzWx3kQo0YHGbwx1BwLmwwIpooIfYvI/Pj0jsxx8635 v27Th1AE3yIz8rgtMME4Dm8YADQocmOKMO2JXV/GqIg2OBzJGOXZsRBLGUMspTHf3gLO iHIg== X-Forwarded-Encrypted: i=1; AFNElJ+5pPbP+QVkfjPx2O8De7dOQZDAKwpR5DIFlJ1i2bxadGukiW2xRPaOBYr23Dm06B+CZbM8XK8qITYAR+Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzLk3ugg9dgBjCRjyBlKmfhtJfb6+M2OUm34msk6IRnShsyLLy6 WixHUpGp7TVztr1EbrO0j8rOd92svEYSpHiQH7J2FR++Nz/tdsNtO37lcmHruakajZqp4UL+VN2 GE1lmdHLW4r4j3kkRa4xmG9Gfvnbd/P7Z9qz1dLRX/Wplq5oQxxSZZj1QV7xzQsV/1w== X-Gm-Gg: AeBDietDzs9EOGb7CV/ZcID/qT7KZ3D0uwSIKn4d8aQqnZ3ykVIjC6lTDp9sF2vED/Y X2iD0oP6ji4qoScQbSkEed9EmDQwR75iGMjEIMunALZzTpT0yJVlNDFPLvAdGeDw88EV2p85Zap sa7Li4EyYAgeMuKjm7BD1oLLMF+nEbiYBJVoyVAnEe+FJjt1IdLRp/66uMNTuap2rdsIMY/4ZJo eCcyTIhPj0If0Jhpt9fVn8nP3NPWNKyVdnR47j88FYgZaoiE+youEtsOhQ/w9RAuzdx7Qux3dRo qUJRHyOZlSkD28SJAyaiA4y8Uj2o863lWA92kprLndFEfRsGX8NHAa16dnvwpBReh9GPgCA+vJ4 k7jLhB9bsk5AFX7lK472agCxW9AoDDmkxkeo00WsJvGx+rbxu19CZB9EgnFlrfZk= X-Received: by 2002:a05:690c:60c3:b0:7a2:1f26:3d6a with SMTP id 00721157ae682-7b9ed00a78dmr50596107b3.45.1776464331531; Fri, 17 Apr 2026 15:18:51 -0700 (PDT) X-Received: by 2002:a05:690c:60c3:b0:7a2:1f26:3d6a with SMTP id 00721157ae682-7b9ed00a78dmr50595847b3.45.1776464331001; Fri, 17 Apr 2026 15:18:51 -0700 (PDT) Received: from li-4c4c4544-0032-4210-804c-c3c04f423534.ibm.com ([2600:1700:6476:1430::29]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7b9ee9b0463sm13106777b3.35.2026.04.17.15.18.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2026 15:18:50 -0700 (PDT) Message-ID: Subject: Re: [PATCH] hfs: return error when bnode already hashed in hfs_bnode_create From: Viacheslav Dubeyko To: Tristan Madani , Andrew Morton Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+a19ca73b21fe8bc69101@syzkaller.appspotmail.com, stable@vger.kernel.org, Tristan Madani , Viacheslav Dubeyko Date: Fri, 17 Apr 2026 15:18:49 -0700 In-Reply-To: <20260417185920.182595-1-tristan@talencesecurity.com> References: <20260417185920.182595-1-tristan@talencesecurity.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43app2) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2026-04-17 at 18:59 +0000, Tristan Madani wrote: > hfs_bnode_create() checks if the requested node number is already > present in the B-tree hash table. If it is, the function emits a > WARN_ON(1) and returns the existing node: >=20 > if (node) { > pr_crit("new node %u already hashed?\n", num); > WARN_ON(1); > return node; > } >=20 > On crafted HFS images with inconsistent B-tree bitmap data, the > allocator can repeatedly request creation of node 0 which is > already hashed, triggering this WARNING reliably on every mkdir. >=20 > Replace the WARN_ON with an error return. The node being already > hashed when creation is requested indicates filesystem corruption > -- returning ERR_PTR(-EIO) allows the caller to handle this > gracefully rather than generating a kernel stack trace. >=20 > Reported-by: syzbot+a19ca73b21fe8bc69101@syzkaller.appspotmail.com > Tested-by: syzbot+a19ca73b21fe8bc69101@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=3Da19ca73b21fe8bc69101 > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Cc: stable@vger.kernel.org > Signed-off-by: Tristan Madani > --- > fs/hfs/bnode.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) >=20 > diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c > index e8cd1a31f247..69895ccf81ef 100644 > --- a/fs/hfs/bnode.c > +++ b/fs/hfs/bnode.c > @@ -517,8 +517,7 @@ struct hfs_bnode *hfs_bnode_create(struct hfs_btree *= tree, u32 num) > spin_unlock(&tree->hash_lock); > if (node) { > pr_crit("new node %u already hashed?\n", num); > - WARN_ON(1); > - return node; > + return ERR_PTR(-EIO); We return -EEXISTS in HFS+ because it is the case of node existence [1]. This issue takes place because of node 0 has been set in bitmap as not available. However, every HFS/HFS+ b-tree must have this node. We already implemented this check for HFS+. I would like to ask you to port this check= for the case of HFS [2]. Thanks, Slava. > } > node =3D __hfs_bnode_create(tree, num); > if (!node) [1] https://lore.kernel.org/linux-fsdevel/08e7f7ef7da57448945a8d62160d2d7a67df2= 883.camel@ibm.com/ [2] https://lore.kernel.org/linux-fsdevel/43be87e694ed6fe291990226624559e7f0182= 0d9.camel@dubeyko.com/