From nobody Wed Apr 1 08:15:26 2026 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9190B43E480 for ; Tue, 31 Mar 2026 17:52:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774979582; cv=none; b=tfPvxxNnTMAsvIbkwjuthsKgm6oQGalvSPtvTX45toMkvsL3u9I/00E6fErTjr2s904pjcNPNrXs8QWDGa54njrSiGvx+jKZ/SFwrIrxZ6m+1WOmzt5KdTiuFSQ3vZi3e0lyxNwfD9H3LDbGqSMCYnENSlodjAe3fgrTxchNldg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774979582; c=relaxed/simple; bh=QAZXf4JkOAmC+Mx/SpSz0uAK8WAYsJWx1iucQR2ubXk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hF9APnCtjB26AlagIsvU/r63CSWKkgeQJ43TYZudun1T7WDMjlQ2C0Q5O1cSC3mbi+6AcCbioJGb9GrqYx40ORFfs4Odm0OQa7Ps9IVqByI5ATC9YveE0ykchySYeqJDMzhaEMpy8uiJ554Tuut51azgv1EuNmr8ePvxXQC2aRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jv800zfu; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jv800zfu" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-35c1d101355so2547433a91.1 for ; Tue, 31 Mar 2026 10:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774979577; x=1775584377; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fed1i3OKdyyPfPcS5zEZlT7I7sjgHB4UBU0/7zGF7T0=; b=jv800zfurZ+1e6mv2QGDc6ovb5dTzJqa++edh9NKNy1/7TO2aaBhDTKxAR1SgyiW3F ZHMhTIVm1ZiMNFec8NtKK6FarSMaBP5xLnlXhh1sq30oF76+/usycYe5f//+wZI8Zd34 NZxTX1ruKFQiWH2i92tI2fJo47+qeJfMAvQ0Int8LtMyCrA3GSeXipdjbBlAQK2rGCOf /uz/DM0O8JRSidPzByoEn6/D6S3b3u7Ijbit61xaImkB02+TTBCpwbR9K6paTwfo/fDm EwZPxoEJgYyiVbxLXfvKLzK1c0Z0lBTVGFrBFSY0TvLltTDw4MShepSx4NtjCwLHxVp5 o1eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774979577; x=1775584377; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fed1i3OKdyyPfPcS5zEZlT7I7sjgHB4UBU0/7zGF7T0=; b=mtmf6qsytPa4i1Ms9UHDIMAFcOK3sLxsKRkiWreYQPSTG6npykSAfz8z7ds2JqMZAs iuDA3RyrgsYGgenOuVuGdt43nB3NnLf8Yy/cGTTy+qI+5m+b0f5FF9m5WhZeTEjDJ3D9 24eOh1s0kIAK64rLTxAJwovbd++XLlDBF1+MpDxuZ7/MLcg5JXZqo8oUJIEgCeK8WZmD lOKsQX2BP3S4rXkiO9BVe0LcJhhss4KhJemoxz8s1pZnMeoUazOd413L5IivkH+VVCmy sg3Gctt+9PQ/VXYqQXFUSK1K4cg4qlZEITPZXzbqhZ/YzghpsR7iI47kbHE5OjHNiIw3 vVXA== X-Forwarded-Encrypted: i=1; AJvYcCU3+UTTKR7uU8+xvKzNOc/nPSYeP/48o8a5L7dEoIlpTy1fYUu1XMijVajIDYaqgepy38k3pvSeNwxpGN8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4OR0uOj/NffvSplBn00gCKmbBmUFtjXDTpQjzH+SYY5+1RwmJ wFsfrzxj6WpwG/eWtyk+bffbaZWUSoYyDNCToTz37qb9X2VWnzgMiQQu X-Gm-Gg: ATEYQzyXEI6azqmpLP4mVWqOv09A4re/LHLVsXHsABgQ5dpfhA90EwhIyoNOQ78p85u tSZpB1k5l+I5EME1Sp93Sv4LNFU+PXV2N3OkvKzHqdoyLdqLY2dy+vl+Ia6FmgtWNQxsHsQXwQD PkkKtzUIT2+EDpzTgMiWuTqEX5ccq4wXXN9J/XOUZViizvw0Za34A+593AVPsW4669ZzO+OdjXY QrczLC2X0y7aktfmWzfbMKA4ssCUbKIBJH/svO+S5g/xWDricj45gEWysiLVb9V+rKe77NMSttX 418nnowCR04TjkSsujMK5rF9Qn56z1ldlePE6BACXsdMozlCZCLFoTUdTihHGg6SISmnLA4Hcbd AgA8E78F4DtBI+u/Z208R23mQ6Vwg6+ZGRU2Jqqw8TXdebDjjxUBtcduWYzlEPtFZb4swoOxYn/ XgLeFOWJUL8aXLMHiWvKy/4ctwWrb2YsYalKz9DLLI3SAnq/W6ZPdLS7jISSZDrRmppqftcVoSG YU4rFg= X-Received: by 2002:a17:903:1ca:b0:2b0:624f:8edc with SMTP id d9443c01a7336-2b269aba73dmr1339905ad.12.1774979577486; Tue, 31 Mar 2026 10:52:57 -0700 (PDT) Received: from carrot.home.local (i114-181-46-93.s41.a014.ap.plala.or.jp. [114.181.46.93]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b24265e7basm163211155ad.21.2026.03.31.10.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 10:52:56 -0700 (PDT) From: Ryusuke Konishi To: Viacheslav Dubeyko Cc: linux-nilfs , LKML , Deepanshu Kartikey , Junjie Cao Subject: [PATCH] nilfs2: reject zero bd_oblocknr in nilfs_ioctl_mark_blocks_dirty() Date: Wed, 1 Apr 2026 02:52:09 +0900 Message-ID: <20260331175253.32329-1-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Deepanshu Kartikey nilfs_ioctl_mark_blocks_dirty() uses bd_oblocknr to detect dead blocks by comparing it with the current block number bd_blocknr. If they differ, the block is considered dead and skipped. However, bd_oblocknr should never be 0 since block 0 typically stores the primary superblock and is never a valid GC target block. A corrupted ioctl request with bd_oblocknr set to 0 causes the comparison to incorrectly match when the lookup returns -ENOENT and sets bd_blocknr to 0, bypassing the dead block check and calling nilfs_bmap_mark() on a non-existent block. This causes nilfs_btree_do_lookup() to return -ENOENT, triggering the WARN_ON(ret =3D=3D -ENOENT). Fix this by rejecting ioctl requests with bd_oblocknr set to 0 at the beginning of each iteration. [ryusuke: slightly modified the commit message and comments for accuracy] Fixes: 7942b919f732 ("nilfs2: ioctl operations") Reported-by: syzbot+98a040252119df0506f8@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D98a040252119df0506f8 Suggested-by: Ryusuke Konishi Signed-off-by: Deepanshu Kartikey Reported-by: syzbot+466a45fcfb0562f5b9a0@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D466a45fcfb0562f5b9a0 Cc: Junjie Cao Signed-off-by: Ryusuke Konishi --- Hi Viacheslav, Please add this to the queue for the next cycle. This fixes assertion failures that can occur with broken GC ioctl calls recently discovered by syzbot. Thanks, Ryusuke Konishi fs/nilfs2/ioctl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index e17b8da66491..e0a606643e87 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c @@ -736,6 +736,12 @@ static int nilfs_ioctl_mark_blocks_dirty(struct the_ni= lfs *nilfs, int ret, i; =20 for (i =3D 0; i < nmembs; i++) { + /* + * bd_oblocknr must never be 0 as block 0 + * is never a valid GC target block + */ + if (unlikely(!bdescs[i].bd_oblocknr)) + return -EINVAL; /* XXX: use macro or inline func to check liveness */ ret =3D nilfs_bmap_lookup_at_level(bmap, bdescs[i].bd_offset, --=20 2.43.0