From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 B1497367B84 for ; Tue, 30 Jun 2026 10:06:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782813977; cv=none; b=QTydLhsd8gm5VoZvvMBNB1ks915LtHhu4hH3vaQMtZKhul9ZZUuX516ALl0PX0nWXi4+Mh52yQOoGnd4Re1+TGZzCYhNLWuFP+nnE4nfl4sWVP+swihhHEEcS1yIicmLbCU/CZ4T4NGkDMg9eeg4MDHJjFpj6wdz12wq3N5QpwE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782813977; c=relaxed/simple; bh=gGQAAIyoD+h7Z9llH2gkofmyWJfpV6p3d7RJw6eTTPc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EGOh7/abDGf9tPUWqbN4sAob/z9wbAZasYILQhQswcgqAq+EKg4R7OG5+uhziSqDyV70yHZrqKQlU9jdcueazHu1ZSFN4x/7qF1yH/iym6FW1y44WTaJSYGhpirA0b8TOhfCfdhmk3+HrUFY/Y9oabqY94PNTzwRL1LKG0uP+hE= 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=La8v0TyG; arc=none smtp.client-ip=209.85.128.50 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="La8v0TyG" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-493a287b8c1so16505485e9.0 for ; Tue, 30 Jun 2026 03:06:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782813974; x=1783418774; 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=mtwliPDiq/xVOyMkLB16zfgx4HPYeHz9vWwy4071LTQ=; b=La8v0TyGyU1+S5DtP1r3uZKe5jaL9yAsZNs2/O5nDUZaNlJxF3oXnStG3vWZOD9JRY DaRIA40HLcLkW/SR3dFSLfHKImNoMDmWcaugm93KAG2LBUe2Y16PxMtFFXqtNLwvqU+W +WBP23ZcCE8rLiEeTvuUEHKIM8YoCL5FlD33262Pt0a/SwGH6ScdrfOT9HJS2wJsVkBc HNeJjLsHtVeXMiAD7XsPRKgVzZI83jlPj8HmAGxc9YDL3vlR0jIejTGcmrDOnJAUsRJI ARHAm56CfTwrAA5V7yYmWma6Fpgtpwc5jRui3En+V+ujsQdwSwctwWYyuU+o+mzvOTFP qQdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782813974; x=1783418774; 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=mtwliPDiq/xVOyMkLB16zfgx4HPYeHz9vWwy4071LTQ=; b=SPn78SJRYGiu+Z4OSof6z5EE/M9vXiIO2JklklwykE+Xyc06lFVNN4da4qEfmB/Cad 2GMInB31PF0Kqawsz3t/TMy5aoPaoyvS6CKCuqlZjxrX0hNKNNh4dZtODJg/wvOln1KL rkarjPBHlV7D5oRHlI0HpjOJAQuRyndYJ2SmPcZNj+VXcBT1lLgifbDcyL983PM2v9On 0HnC6C68M0XnaVNfeUg2oI1spyUEqjLqvZgi6tqn7XNyH1aAPNRCZajB2od7xUzScl2S 8/m+gdATgSXmLMwfs++SKP1h2o+lo30E2Kb/kqxjMz61R9RHrrl+1WUK08u86LseWEMe QNKw== X-Forwarded-Encrypted: i=1; AFNElJ9wm5QEyViQCYzT8Qf+/wB4JyOCfjkAVmdOnJrdWEK8L8NlmOb132gycy4bTTN1LZy/itHd+I+crt3MwKE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxghqc2rGScpWnK+ABJKmegn5i/AmcvEgml24KjrHH6LjVIr87e 8P8MuNfLXSpFQ74W6jhoQlBK+02e0i0pPE5Iv/btZyWV8mod58+R1Sfr X-Gm-Gg: AfdE7ckbN/DUtCThZPyNMUtPuWN42Z2ptzo9TDNEDg6CICE/zna7VOrpyM7AjjTei12 XvN0mz8E48F46lqmhZLvdiXU4s0mYuuj8UId46PcH6S4fJ5etZfy8o2j34HwfRz3x3IvPzBtAeF h39k/EFuQ1lHicqNzkTYfgmCoVLZR2DzHSo9eD6JiOPOswqax0M4x3rMaYZfD1bATSTJm5Bo610 n0xsy5BlF0qIpiNbRj90L8Q5ZmAVxTdVRc/27ziSxWw33SLhvPt+gF5Y9ZMG/youpj1gtZfyr5D OpRd4WVLtWhSlo25sVoMV7es5wQ0VEA/6AYghZ9Wir5pEyWiZYHytIz5m3vGMjscWDWS5N8DrJJ ioeRuNpjv6vO3xVnLTf80t4JXxnZDlgfxJ3VjpxdEKOxOd8To4enE5wffkIVD0zvLVJfpkeTIJ/ X0mYjrbFOEGD3DcLY/JiPomtmOMg== X-Received: by 2002:a05:600c:6290:b0:492:5030:5e7b with SMTP id 5b1f17b1804b1-493b8288851mr43492795e9.10.1782813973931; Tue, 30 Jun 2026 03:06:13 -0700 (PDT) Received: from Dev-Null-MSI ([2a0d:3344:52ac:a808:98a4:4381:be45:536f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493b8d0afacsm63712565e9.12.2026.06.30.03.06.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2026 03:06:13 -0700 (PDT) From: Yousef Alhouseen To: Carlos Maiolino Cc: "Darrick J . Wong" , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, syzbot+b7dfbed0c6c2b5e9fd34@syzkaller.appspotmail.com, Yousef Alhouseen Subject: [PATCH v2] xfs: use null daddr for unset first bad log block Date: Tue, 30 Jun 2026 12:06:07 +0200 Message-ID: <20260630100607.7150-1-alhouseenyousef@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit xlog_do_recovery_pass() may return before setting first_bad. The caller must distinguish that case from an error at a valid log block, including block zero after the log wraps. Initialize first_bad to XFS_BUF_DADDR_NULL and test it explicitly before treating the error as a torn write. Fixes: 7088c4136fa1 ("xfs: detect and trim torn writes during log recovery") Suggested-by: Darrick J. Wong Reported-by: syzbot+b7dfbed0c6c2b5e9fd34@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=b7dfbed0c6c2b5e9fd34 Cc: stable@vger.kernel.org Signed-off-by: Yousef Alhouseen --- Changes in v2: - Use XFS_BUF_DADDR_NULL instead of zero as the unset sentinel. - Test the sentinel explicitly before handling a torn write. fs/xfs/xfs_log_recover.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 09e6678ca487..5f984bf5698a 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -1028,7 +1028,7 @@ xlog_verify_head( { struct xlog_rec_header *tmp_rhead; char *tmp_buffer; - xfs_daddr_t first_bad; + xfs_daddr_t first_bad = XFS_BUF_DADDR_NULL; xfs_daddr_t tmp_rhead_blk; int found; int error; @@ -1057,7 +1057,8 @@ xlog_verify_head( */ error = xlog_do_recovery_pass(log, *head_blk, tmp_rhead_blk, XLOG_RECOVER_CRCPASS, &first_bad); - if ((error == -EFSBADCRC || error == -EFSCORRUPTED) && first_bad) { + if ((error == -EFSBADCRC || error == -EFSCORRUPTED) && + first_bad != XFS_BUF_DADDR_NULL) { /* * We've hit a potential torn write. Reset the error and warn * about it. @@ -3575,4 +3576,3 @@ xlog_recover_cancel( if (xlog_recovery_needed(log)) xlog_recover_cancel_intents(log); } - -- 2.54.0