Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp39197lqo; Wed, 15 May 2024 20:21:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwrQEFOhqRLmzvPQfjOYoQWiSRV4r7SdHa+AH75kIuMkGRHoer/bhBtn+6tB956BKRiVob8TdcDHwZRzaOiGDogtcS4O2SEpRRgPCMuw== X-Google-Smtp-Source: AGHT+IFiyfdQ92O4K2Q1Z9pP3vGmtInenSF1e4OHYiKZlnreXML/RR0HdwLp7yVCO9seqB/XoFcP X-Received: by 2002:a05:6a20:f3b0:b0:1ad:7e4d:5b81 with SMTP id adf61e73a8af0-1afde0af4a0mr15142934637.5.1715829674835; Wed, 15 May 2024 20:21:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715829674; cv=pass; d=google.com; s=arc-20160816; b=mz8ifTf0XmZqAuajDbalLALCvCpsxI404fiIxobCDeQVv9DO2R5RZAzCH1mr3VLv1p f52LWKtPag54V4ubEzUcY/OhTzhf1MztIQ4SgnbWF7XxKjGn+RNue5+gHIzN0lyX8xJn FQWBaVVIJhgFCD5KV9dI235CPEZKF6Z44Xyn6G4wR+2yn2falxkCjt/bhJ2VWwSQS5Pu 2YRQ7kGDyNays1oHJvxt7u/m6EcfnhdepPRn63siRdHql6tEJj9VFNNDK0XOB36Rmvmi Y0ChKB+b+AxzwuCKfOccBERqpEmjlwJ65oMFBz4rEH3QrrmYuNrjWs8aVPMO5aN0Yxzt zlzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=T4hGieocM0GD4D8ugKQkb0PeE3WjJFXzsgOiBI9qhZ4=; fh=D1nBKevyduhOAQ/FXKUuH9nCNba5nTrQLTc7J8b0mfI=; b=Vzt3PMiPfHBvaUEcW4zjduslkANOffD3gFaRAWi8jZphcdxzhPglaEDonykTtm47NE Rn+zQ6kXqtZd4B0VqYMoHv/b5nTY4fMB3Ec4CZ1OWY8A4TFuTiXO6ScDpUi0WlLoIBu4 5dn/aiRwM5FrYtZAggSSLPoAdO4VFkxC+8YgkG+jdfI4AieWhjm+tg0D1moL0b4NiY2j AZgRJ0a3puUHNdr1O85w5Ct+BInDYLOUyvMdrNYp1B3yVvn9P+XxUS/eNFxUSi3roJBT uMr5NfNwWnS7uAEDWXgaDA4YhJ3Ntg+3dBYAFRseAz0tl1zBV8WMYOO2W794YUyPEOd9 U7yQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jKisL3Iv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-180594-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180594-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0bf32701si142307475ad.310.2024.05.15.20.21.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 20:21:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180594-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jKisL3Iv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-180594-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180594-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7AFE5283485 for ; Thu, 16 May 2024 03:21:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FE7A4691; Thu, 16 May 2024 03:21:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jKisL3Iv" Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (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 3F3D323A6; Thu, 16 May 2024 03:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715829667; cv=none; b=MV09h1TSe++RzGgcElyiatH+5Tr96mmqctIiFDUuSZHZ/po/WBym5QHSe0gNgUiVkAiuDpivF/cjeWtvMGQQbFDbd+TDxsF/U8fosMOEMbM1yVYeZfCzp0jRrVDHVn9zuAN9JbbMNCgTsO4EDP4qZAuzW0oJ1y2bYLiAfWV5sqw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715829667; c=relaxed/simple; bh=qaMpaSvbiULWJTnySDPvvx26VQcPpbEg1arIk24D7fc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=TM2M0lchXheHHj36DHz7Nnvqj6iH9Upqz1GReWNoiw5wQYND5jYcoXo2QbQIWCcpzcecz2bR+N0aJ3ASosTT+l8S2u8aFqXXwBB6g29EAFNbLekEwRtpSoHFWNiAadCEDSJ1gBx83srkvLEJSg6+QUsiDIPt+Wm2vLsY5nVGcJ4= 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=jKisL3Iv; arc=none smtp.client-ip=209.85.160.42 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 Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-23f9d07829bso95954fac.3; Wed, 15 May 2024 20:21:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715829665; x=1716434465; 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=T4hGieocM0GD4D8ugKQkb0PeE3WjJFXzsgOiBI9qhZ4=; b=jKisL3Iv02iIYGPap5RRU1XWuyfqmJTHs6JujJrcDObXbL6SUbXhZWtjOz+bE+xNZ5 PCArlEvMuGmgW7KGFodFWfB/aP0fnHRCK/Qg9aqc362s7SJJqsBcgXMKQeXHMMNPn494 +RAMkAYPcSCho03HfntNyl8lKKi7NI3BqmbYNP8nf4Dz1cBPysTMq+KB64HBOw2bwjT1 syIrh9KyCJxOl4e+PsWFa+7EYflsTJiqE/70ygZU4QXe5Gd8fXhyHz8bMgXxQ+oM34Gf KQRfgHQD+ZqkFmuORbabOA3T9P+2ZT3sRjiQngd1pM3vVq5u5YMRJ38F3KrXzfJzGibT YOUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715829665; x=1716434465; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=T4hGieocM0GD4D8ugKQkb0PeE3WjJFXzsgOiBI9qhZ4=; b=HEAztetUF7iFpttOhkp/P5AoFEBQGfSE+4kXBAWHzn95OHPx0n475qZcWK7YfFS6jE bS58bzK9eTHlYhu/GKe7PLcNbkh2qOBirLRIqsHyX91l4jeZs2djvx4lL3sxNwo4Yt/F H6iHa2nxAqD+BrbZSQR3s1EFlE6ImXmotpmQhdQvj0YztCl+zTJWSPRd5yYp7kPbgXAy +sIPx0Or6GHW9aQNeKccZbkrKv6Tb5hJwh5BTBbxJ/DBlin2e6g9LENGN6LJZCLvNnew pJo6gg44ciPVC3q/KL8/eR90BH2WI24tuEt5w7LqxbiQkjBTudGJPbjCqm4uEjALCC6t EdIg== X-Forwarded-Encrypted: i=1; AJvYcCVpnKi+YMYIDCcbFBoEq07wxiQvCaGGLgA/V8xxJEzmQaI3KbenzCT8vpc+rf0vFB6dhEvD/Rpb4TOKdJm173pgCI86MpbfJtRORifZEXHKy8EHIOB9IDExCop9R/pOgMtNkFDwiz1T4qDri2o= X-Gm-Message-State: AOJu0Yz+lhc3oTiBUU3sco1n47GDaIGLsYTe9yAFpxVhxKaJWyuJ+21R wRvEsHe2SJ1Tgt9nKXNJNlMOAUb29kM1t8JlT4zfKjt+X7rDe152 X-Received: by 2002:a05:6870:3047:b0:240:3a4e:504e with SMTP id 586e51a60fabf-24172fca27emr19952487fac.58.1715829665180; Wed, 15 May 2024 20:21:05 -0700 (PDT) Received: from localhost.localdomain ([190.196.103.34]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2aa01dasm12222785b3a.92.2024.05.15.20.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 20:21:04 -0700 (PDT) From: Camila Alvarez To: Kent Overstreet Cc: Brian Foster , linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, Camila Alvarez , syzbot+10b936c5eaee2819b49b@syzkaller.appspotmail.com Subject: [PATCH] bcachefs: fix last_seq and last_empty_seq in bch2_fs_journal_start() Date: Wed, 15 May 2024 23:19:20 -0400 Message-Id: <20240516031919.592696-1-cam.alvarez.i@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Values were left as the next possible sequence number when there were no entries. The fix involves updating the last_seq initial value and setting last_empty_seq to cur_seq - 1. Reported-by: syzbot+10b936c5eaee2819b49b@syzkaller.appspotmail.com Signed-off-by: Camila Alvarez --- fs/bcachefs/journal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index adec8e1ea73e..3835c458eec9 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -1196,7 +1196,7 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq) struct journal_replay *i, **_i; struct genradix_iter iter; bool had_entries = false; - u64 last_seq = cur_seq, nr, seq; + u64 last_seq = cur_seq - 1, nr, seq; genradix_for_each_reverse(&c->journal_entries, iter, _i) { i = *_i; @@ -1256,7 +1256,7 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq) } if (!had_entries) - j->last_empty_seq = cur_seq; + j->last_empty_seq = cur_seq - 1; spin_lock(&j->lock); -- 2.34.1