Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp519556lqb; Wed, 29 May 2024 02:53:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXTyr+A21hA5519wrtSU09ml8jZMveSKYgDx31U8hqqixshcCoFsrDQb6lZhB8rNM88r/GTLS8Tukf/bUQQjQqdPiOClJVPghyXZBpZCA== X-Google-Smtp-Source: AGHT+IGgbScdyT9zZpVyGh//zd6ySA0WPoyxJ6x9A36TMcf3rhBxl2hPnh1NNBPVKP9JD13tnhuD X-Received: by 2002:a17:903:32cd:b0:1f4:5c4b:dc48 with SMTP id d9443c01a7336-1f45c4beaffmr144628865ad.11.1716976399603; Wed, 29 May 2024 02:53:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716976399; cv=pass; d=google.com; s=arc-20160816; b=r8NFRXs0r7QlUDpTkXPmon5d1R86wqUAhEHxjskP2azHdl6HN0eRIimUzVndjn/GHZ /1PPoUEmE68MOaKTv2jj24vP/7wsCBP5s8c1odwqreqoBfWH2WCmt62Kn7QK2BURZWSy ApUdGmfPhc319zTJIhoYL0f3Fu5etptFbqLHzUJYnsrfGHyzluE51l0KMyIxEXjMQBic VajmqU7pVJCPHA/I91HisffbzCdDmzjgH9K0cApejsq2NFpdguvjuiK3nh7SjiufbhdV iK6qvcxZ56q++IG3CilCX82BVSMFZG55/p8oDwEtZmcs03+IcV70YE2RVz5M3JFLda7/ BPUg== 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:dkim-signature:dkim-signature :dkim-signature; bh=FqAdLPrYpeP2hRlhvLGvf4ixrOgf8Ok3KPjSNl4wreY=; fh=bjQBmcU5o9IXgjrt25p2O8kaVKBpGDFc2mqf/oFbyis=; b=Wdk35V1wcs/bywpI3O7bG3lG64YE081RMr/KG6a5IKH7/enuFLTtKSp41uiGCieuun Ux9M9d2s+kg7Up0j9x8FiszxbY3jGToN/pREWov564a8YQbWBAtPTVqToAAhijK8QJV4 qZXHpDNTiQbS72NYLg7w9/jASrOlUviOkZXD7W7truqN7PGun6bwNDuh4d4+CFlFqgJO Zu/Ja39k64K1j1v9D143OTLL4pAEatpWbUBIvSD8zghOunSNehNApkl9VwE5s1WaiPlx SH6WGPjc3oRw9rB9dSKYECaZ17TJu2Gq6N6orlnjL9yWKaKgnPUEXP+MgvvyIixzvhOV 00Nw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=O81h11Mu; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=d3o3uKIf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-193891-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193891-linux.lists.archive=gmail.com@vger.kernel.org" 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-1f44c971941si97033935ad.322.2024.05.29.02.53.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 02:53:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193891-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=@suse.cz header.s=susede2_rsa header.b=O81h11Mu; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=d3o3uKIf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-193891-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193891-linux.lists.archive=gmail.com@vger.kernel.org" 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 D8110281DD5 for ; Wed, 29 May 2024 09:52:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5413D16EC02; Wed, 29 May 2024 09:51:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="O81h11Mu"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="zhMTQOxB"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="d3o3uKIf"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="pEEaYwYz" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 2719316ABEB; Wed, 29 May 2024 09:51:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716976289; cv=none; b=TJ07mutl2Yz97nxLDIrFS+eBHZQJGotykYmusGbsLBtaIWTkAKN34m9xywkQG5LRlmyBwTUOC4JEZ8Li1WYMYPrAvPINYond98k4yRoq6nXPDH3DzYnS7ZJ0c/UhZBvaUTGDniazlMREoV4fFXJmoxPt3+lje1tL5eU2QUo+zNM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716976289; c=relaxed/simple; bh=YcXMSAiXYTWYD+B9xHrJXe+f9U1uQ4Iaw4UQkhIvGAQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EWmIR5SYicgDCumw77hXAJKJTGhDWEKGaiI/CooUn4crDXqo4Ayi80PPGfBxA24pvYi/1ub3aidrFUha48IziNpEIx6OO8ybUlz7HlMMbV/mkgC6EOMYUA3J4wgyr+RaJkBHSWTqWlgoN37+xkadBatYttRsOaceo1B3zsDUhOs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=O81h11Mu; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=zhMTQOxB; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=d3o3uKIf; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=pEEaYwYz; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F072C22D44; Wed, 29 May 2024 09:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1716976285; h=from:from:reply-to: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=FqAdLPrYpeP2hRlhvLGvf4ixrOgf8Ok3KPjSNl4wreY=; b=O81h11MusrSEK65a42zVplfa90Fvf9IRoBm6s4dmPb2tgC23vPxTpU6LB8GHS3zKGFFw2e hZEM+6Se7Nt497NHkrwOKwoFDmiBgrUNEV7f7qE84EHDKC/eQi0gfQKb7EuP2XSYW96Ko+ Q26BYt2lOXh8O7A9Py5F+SOk3KcE+hI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1716976285; h=from:from:reply-to: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=FqAdLPrYpeP2hRlhvLGvf4ixrOgf8Ok3KPjSNl4wreY=; b=zhMTQOxBGd+dbxAuUzrETt32OTvwdvlKfFQcF6NtVQU/GdgUpo9Hrtea2YuNJznMH/Kujv uOyeJTOnqsfmZPAA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1716976284; h=from:from:reply-to: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=FqAdLPrYpeP2hRlhvLGvf4ixrOgf8Ok3KPjSNl4wreY=; b=d3o3uKIfQtG8+DnLcIjs3jP2se3epXVniyBt3ymIuotoDAhhEfs2agUo0yQnVO6bW3iPOl zITwnFqDUnGNPmcVjbFoYgGz7qdVk69CQcnV86PZRVjHjvivc5RvZfANKIUA/IHEuZPq0g DiHiJFFErU8cOIg+z+abIddvZ4RAXo4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1716976284; h=from:from:reply-to: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=FqAdLPrYpeP2hRlhvLGvf4ixrOgf8Ok3KPjSNl4wreY=; b=pEEaYwYzpuQzWvylxML73HbK4LhXKg5grWGRANfddeEVRbP86ZRSWFKsgO5Rzz5l5HyC5o 9OAORjAD+LqmKlDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E40BB1372E; Wed, 29 May 2024 09:51:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WT6sN5z6VmYfAwAAD6G6ig (envelope-from ); Wed, 29 May 2024 09:51:24 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id A91D1A0825; Wed, 29 May 2024 11:51:16 +0200 (CEST) Date: Wed, 29 May 2024 11:51:16 +0200 From: Jan Kara To: "Luis Henriques (SUSE)" Cc: Theodore Ts'o , Andreas Dilger , Jan Kara , Harshad Shirwadkar , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] ext4: fix possible tid_t sequence overflows Message-ID: <20240529095116.b3arzr5rjz6cs2rb@quack3> References: <20240529092030.9557-1-luis.henriques@linux.dev> <20240529092030.9557-3-luis.henriques@linux.dev> 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: <20240529092030.9557-3-luis.henriques@linux.dev> X-Spam-Flag: NO X-Spam-Score: -3.80 X-Spam-Level: X-Spamd-Result: default: False [-3.80 / 50.00]; BAYES_HAM(-3.00)[99.98%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_THREE(0.00)[3]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[mit.edu,dilger.ca,suse.cz,gmail.com,vger.kernel.org]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.cz:email,linux.dev:email] On Wed 29-05-24 10:20:30, Luis Henriques (SUSE) wrote: > In the fast commit code there are a few places where tid_t variables are > being compared without taking into account the fact that these sequence > numbers may wrap. Fix this issue by using the helper functions tid_gt() > and tid_geq(). > > Signed-off-by: Luis Henriques (SUSE) Thanks! Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/ext4/fast_commit.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c > index 088bd509b116..30d312e16916 100644 > --- a/fs/ext4/fast_commit.c > +++ b/fs/ext4/fast_commit.c > @@ -353,7 +353,7 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason, handle_t *handl > read_unlock(&sbi->s_journal->j_state_lock); > } > spin_lock(&sbi->s_fc_lock); > - if (sbi->s_fc_ineligible_tid < tid) > + if (tid_gt(tid, sbi->s_fc_ineligible_tid)) > sbi->s_fc_ineligible_tid = tid; > spin_unlock(&sbi->s_fc_lock); > WARN_ON(reason >= EXT4_FC_REASON_MAX); > @@ -1207,7 +1207,7 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid) > if (ret == -EALREADY) { > /* There was an ongoing commit, check if we need to restart */ > if (atomic_read(&sbi->s_fc_subtid) <= subtid && > - commit_tid > journal->j_commit_sequence) > + tid_gt(commit_tid, journal->j_commit_sequence)) > goto restart_fc; > ext4_fc_update_stats(sb, EXT4_FC_STATUS_SKIPPED, 0, 0, > commit_tid); > @@ -1282,7 +1282,7 @@ static void ext4_fc_cleanup(journal_t *journal, int full, tid_t tid) > list_del_init(&iter->i_fc_list); > ext4_clear_inode_state(&iter->vfs_inode, > EXT4_STATE_FC_COMMITTING); > - if (iter->i_sync_tid <= tid) { > + if (tid_geq(tid, iter->i_sync_tid)) { > ext4_fc_reset_inode(&iter->vfs_inode); > } else { > /* > @@ -1322,7 +1322,7 @@ static void ext4_fc_cleanup(journal_t *journal, int full, tid_t tid) > list_splice_init(&sbi->s_fc_q[FC_Q_STAGING], > &sbi->s_fc_q[FC_Q_MAIN]); > > - if (tid >= sbi->s_fc_ineligible_tid) { > + if (tid_geq(tid, sbi->s_fc_ineligible_tid)) { > sbi->s_fc_ineligible_tid = 0; > ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); > } > -- Jan Kara SUSE Labs, CR