Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7333242rwl; Thu, 23 Mar 2023 02:56:09 -0700 (PDT) X-Google-Smtp-Source: AK7set+xE3S7s+Vt+vpjtMGO8xu6qfEIsCjotf7yQKOnERWACQjjr9JWgde7vgtv8sE4ckfQDOgq X-Received: by 2002:a17:903:7c7:b0:19c:dbce:dce4 with SMTP id ko7-20020a17090307c700b0019cdbcedce4mr4246095plb.15.1679565368860; Thu, 23 Mar 2023 02:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679565368; cv=none; d=google.com; s=arc-20160816; b=gj6/tlqAs29VXWz+i43sT2UJ0D6aAdye2dk0Utg5rsT93DyDj4YekO/JQaFK5Sh0o3 BZKwdrEHXfO97L4yHG6k5Az5W0HgkXkXk71jmrVn72Pc1freV5FCEnBVBgIkzgNLLhPj Qequ4qvjYBDqJ7eyulhPd5ME6DBOXnk3KL/ZY0iwkHlGCv0Nt7P0unmWD7DtFIBhx/ho ZZBYVUG3Mw77uQvKw+iSjx/iaaRkhXyv/GXyTc0Iv+B26mwkzc8/kP2SAhzbwSyZNmy2 jXiwD2ZwutnNskIksT5P9twS7GoG54GkKOjWJWNQG1EE6ZrXnZ0uvkt1piYeo1x/ss2P JDzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=vDlGr14ZVvQg1Nj6sP7mL6XAaiIugwM/EnaIl8Ce8Bs=; b=p4+ZqmRJ+RFmhtjdiCgoIoaDdyk01264K7RbzV/8eK2PSAFa7t76anxslvQnm57bZM AhkSXGicnCUqq2S4LnRWA/KfR8kQnedpRA0W8Z7MMY501ihDpE4wyq/+JDSHgGLZs7cC H4X3pZkRYKlvkdvId5dAAbq09O3dKC8ZemKwxZaZc7tdPNG0X+xGyrteKtgSe7QYHH4U LjZz9BApm07/2GRZoI6IBwNX2gvLYXCj9oNIAdExIGyyQoYLxX349ggEIW97pzvYj/RD 37MyWUP8vBkA3wkLRusraJc+1Q849/SOgdg40Etm3HasXaDhs8tyHQE+TiFwVgbgFEIt V0Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=vqHmF5Yt; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=74iHc4MZ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 7-20020a631447000000b00503a2ab160esi18085977pgu.553.2023.03.23.02.55.54; Thu, 23 Mar 2023 02:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=vqHmF5Yt; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=74iHc4MZ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230157AbjCWJzg (ORCPT + 99 others); Thu, 23 Mar 2023 05:55:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbjCWJzJ (ORCPT ); Thu, 23 Mar 2023 05:55:09 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88D6A35EE3; Thu, 23 Mar 2023 02:53:49 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 31E065C253; Thu, 23 Mar 2023 09:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1679565228; 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=vDlGr14ZVvQg1Nj6sP7mL6XAaiIugwM/EnaIl8Ce8Bs=; b=vqHmF5Ytl9nJ/0BSI1GNg58lvmUqekplnYMCmLIS7GpetvrsOvjvpvsJkA6+cCzwkOFTTZ /wL0I0+d9cXOJ/LzoMY6zI6xWZPcmq1dFddhPXljMDX2SuFvtlkrEzhcnlbVDg/0YqvmtG N1DouTqk9qc51uNg+ovSsQJ99HHEdDA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1679565228; 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=vDlGr14ZVvQg1Nj6sP7mL6XAaiIugwM/EnaIl8Ce8Bs=; b=74iHc4MZnIzKnYRZuvqQaO3S94VEbcG2MHgzha/Y8y5WKksbl4j6Y+aPe+37ZZtaK3Obty tXQyGI17fRMzXaDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 18414132C2; Thu, 23 Mar 2023 09:53:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id lDTlBawhHGQ+VgAAMHmgww (envelope-from ); Thu, 23 Mar 2023 09:53:48 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 085E7A071C; Thu, 23 Mar 2023 10:53:47 +0100 (CET) Date: Thu, 23 Mar 2023 10:53:46 +0100 From: Jan Kara To: Andy Shevchenko Cc: Kees Cook , Greg Kroah-Hartman , Cezary Rojewski , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Theodore Ts'o , Jan Kara , Andy Shevchenko , "Rafael J. Wysocki" Subject: Re: [PATCH v1 1/3] jbd2: Avoid printing out the boundary Message-ID: <20230323095346.ibpv25xjjf6rozpv@quack3> References: <20230322141206.56347-1-andriy.shevchenko@linux.intel.com> <20230322141206.56347-2-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230322141206.56347-2-andriy.shevchenko@linux.intel.com> X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed 22-03-23 16:12:04, Andy Shevchenko wrote: > Theoretically possible that "%pg" will take all room for the j_devname > and hence the "-%lu" will go out the boundary due to unconditional > sprintf() in use. To make this code more robust, replace two sequential > s*printf():s by a single call and then replace forbidden character. > It's possible to do this way, because '/' won't ever be in the result > of "-%lu". > > Signed-off-by: Andy Shevchenko Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/jbd2/journal.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c > index 8ae419152ff6..00c0aa4a3a91 100644 > --- a/fs/jbd2/journal.c > +++ b/fs/jbd2/journal.c > @@ -1515,9 +1515,8 @@ journal_t *jbd2_journal_init_inode(struct inode *inode) > > journal->j_inode = inode; > snprintf(journal->j_devname, sizeof(journal->j_devname), > - "%pg", journal->j_dev); > - p = strreplace(journal->j_devname, '/', '!'); > - sprintf(p, "-%lu", journal->j_inode->i_ino); > + "%pg-%lu", journal->j_dev, journal->j_inode->i_ino); > + strreplace(journal->j_devname, '/', '!'); > jbd2_stats_proc_init(journal); > > return journal; > -- > 2.40.0.1.gaa8946217a0b > -- Jan Kara SUSE Labs, CR