Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2063626lqo; Sun, 19 May 2024 11:25:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV14notJsNjlSnDQ1ZpDooNCejFnS6jUyxFYps09YKOroS95zbwQcAM4ekgzLm1GBhKz/RdBSKWIshBDUhmrjo6C9ORYbJudMfbNZMbrA== X-Google-Smtp-Source: AGHT+IGNH7cTaQ0CCWvjhjAe/ux5l1d1YJ7lK6TtokamEa5Mp/pbJj6t7DpE80F3GSRXgp3HwYyN X-Received: by 2002:a50:bb61:0:b0:572:a7c8:f12b with SMTP id 4fb4d7f45d1cf-5752b4a20d7mr3898252a12.13.1716143129458; Sun, 19 May 2024 11:25:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716143129; cv=pass; d=google.com; s=arc-20160816; b=kOgC2HSi8BnDwtk3kPQnTXJeHEL/EcURhwd9iB49AjfaLLZlImzj4pLfE6gyRjuRWd 5QCzdMjbcrxz141Bj/MK+FQJa63r89U16/bxV8gkeIvJIy41BCb/XJJH2Sur2gnIvIgv YNyuAQ2jPw1VH++OR9d77AESoJwLE/agwEDKDa8AqBWtctxw0Ai55CqUuaKvmViJarUw I8Tiz6lOmoxFunirysY2//oY0PDI/d2I0lk6eg9v9uBbkJhj9HRKmg9a9LVt1weKffwW hUZPPL/m6/WI5XHelJ2kcjRqv4+4ZRyAYUZzBcVK1HUX5LgfiMjn2s/apkLTLzT9AovF hKDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=CZcRqAT2Hi9yDWO8AgOOTA1HMWZQbltFlns+P+hoiOI=; fh=GOqmGKoLDxGnaxz4G5NCDYCBSaENlCNgkc0j1YUW0gQ=; b=0ZekQMgkwyM7Yuze1SOTIM+3AjkFvSyQtd+uTbgMKpj9rZpa292XXk5tdM+92m5i7o kQu/78P8BOVVkR9r0u48IZQke+kc3AXeoaJnn3LUU/EzkK72nYo4/l1+vwDDlHdl7sW0 YUbNxiIj3Sjiwbxyx3OotLaQY/79KWD7n5QHnHPLmR16GFQELUzN5JKSPIE58gIEUDEb UzGWNeIZRVowqN3WlkbGEqup2TCpZ+eCaUabaecy1X5x8W4dx7QAVEhuD46nNwrOFe8Q iZw8x/nd3cS7YC6JIdNBNDcq2V306YGBnD1MSxQEd3qLfFfSe+bHrfDHFbmibZBds0yW mwWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=eb7nYwoJ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-183197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183197-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-578118fb72asi142872a12.28.2024.05.19.11.25.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 11:25:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=eb7nYwoJ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-183197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183197-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 19C921F221CE for ; Sun, 19 May 2024 18:25:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 683B06A8A6; Sun, 19 May 2024 18:25:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="eb7nYwoJ" Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (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 D19F869D3C for ; Sun, 19 May 2024 18:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716143121; cv=none; b=vBK6HmBYAZenkIfNip9l51PhD5coitfOTInIVjmPBZzKQ6FM2Ghm6efO79B9ZJLlZOlviixDPmGfUHI4beQn9Iuhv5fVoFly8RVz1DfbQeceCAogxwcDLy7vJzmgp1rB/tVWCwNacgcOZaFqDbJD9fUEN40CMWuVEedFhkGy3wE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716143121; c=relaxed/simple; bh=BPkMiBJmFbqc3tij2Xd3XOMpsHnYCTRsmbhkmPPLLfE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LbjuWi8slXERaugxZiHmwxuXZ8VW+wZChUUtRFxEVRiOiVlYvYGSZtGjvZ3eDs+bgtB3NMrUqr1YtHhIoptN0cyymokwwUhSqRTZ2aSv79iteRNuEtpV86VUURyfLtOWd4aXKPqdITl3px6tAgCdDk9QqN7gt0fgJnHU+VUMC84= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=eb7nYwoJ; arc=none smtp.client-ip=95.215.58.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: cam.alvarez.i@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1716143113; 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: in-reply-to:in-reply-to:references:references; bh=CZcRqAT2Hi9yDWO8AgOOTA1HMWZQbltFlns+P+hoiOI=; b=eb7nYwoJyvWNoWkYNPH+CFyEFJ0HVytomFWb0PeZC2uSgdpleQWs4IDXu2+bLMzWv2jguS DP4iRbeMl6da1jVTYnhei4eHdYUjzWoYlos8Yf+f8IaymOQVhGVbF+pTTwPGFeZUbYDoCv QlejPHzVPF2le/OP2jsHfXKI9WHo3AY= X-Envelope-To: bfoster@redhat.com X-Envelope-To: linux-bcachefs@vger.kernel.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: syzbot+10b936c5eaee2819b49b@syzkaller.appspotmail.com Date: Sun, 19 May 2024 14:25:09 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Camila Alvarez Cc: Brian Foster , linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+10b936c5eaee2819b49b@syzkaller.appspotmail.com Subject: Re: [PATCH] bcachefs: fix last_seq and last_empty_seq in bch2_fs_journal_start() Message-ID: References: <20240516031919.592696-1-cam.alvarez.i@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240516031919.592696-1-cam.alvarez.i@gmail.com> X-Migadu-Flow: FLOW_OUT On Wed, May 15, 2024 at 11:19:20PM -0400, Camila Alvarez wrote: > 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. I think this is correct, but we should try to come up with some better assertions or something to make the code clearer; we don't want off by ones to lurk so easily. Could you give it some thought? > > 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 >