From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2EDE0C27C79 for ; Thu, 20 Jun 2024 05:21:25 +0000 (UTC) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B6E4B3D0DFA for ; Thu, 20 Jun 2024 07:21:23 +0200 (CEST) Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 63B413CF2D7 for ; Thu, 20 Jun 2024 07:21:08 +0200 (CEST) Authentication-Results: in-4.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.cz (client-ip=195.135.223.131; helo=smtp-out2.suse.de; envelope-from=pvorel@suse.cz; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id AC7E2100F4DE for ; Thu, 20 Jun 2024 07:21:07 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id 6552F1F840; Thu, 20 Jun 2024 05:21:06 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none 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 4261913ABC; Thu, 20 Jun 2024 05:21:06 +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 XYVkDkK8c2blKQAAD6G6ig (envelope-from ); Thu, 20 Jun 2024 05:21:06 +0000 Date: Thu, 20 Jun 2024 07:21:00 +0200 From: Petr Vorel To: Li Wang Message-ID: <20240620052100.GC537887@pevik> References: <20240620021635.489505-1-liwang@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 6552F1F840 X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Virus-Scanned: clamav-milter 1.0.3 at in-4.smtp.seeweb.it X-Virus-Status: Clean Subject: Re: [LTP] [PATCH v2] tst_kconfig: Avoid reporting buffer overflow when parsing /proc/cmdline X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Petr Vorel Cc: ltp@lists.linux.it Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-bounces+ltp=archiver.kernel.org@lists.linux.it Sender: "ltp" > Li Wang wrote: > When the test is run with a kernel booting with many parameters, the > > buffer size is often not large enough to store the complete command > > line. This results in a buffer overflow and the test complains with > > the following message: > > tst_kconfig.c:609: TWARN: Buffer overflowed while parsing /proc/cmdline > > Note: > > Petr point out that these configs, which are generated by toolchain will > > be longer than 128 chars someday, but I don't think that is the reason > > we need raise our parsed buffer, since tst_kcmdline_parse() was just add > > for popular parameter (which always pass by user and short). So far I > > don't see any LTP test parse a longer parameters. > > Fixes: 180834982 ("kconfig: add funtion to parse /proc/cmdline") > > Signed-off-by: Li Wang > > Cc: Petr Vorel > > --- > > include/tst_kconfig.h | 2 +- > > lib/tst_kconfig.c | 4 ++-- > > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/include/tst_kconfig.h b/include/tst_kconfig.h > > index dcb370574..23f807409 100644 > > --- a/include/tst_kconfig.h > > +++ b/include/tst_kconfig.h > > @@ -87,7 +87,7 @@ int tst_kconfig_check(const char *const kconfigs[]); > > */ > > struct tst_kcmdline_var { > > const char *key; > > - char value[128]; > > + char value[256]; > > bool found; > > }; > > diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c > > index e16ca1400..8eb1b803f 100644 > > --- a/lib/tst_kconfig.c > > +++ b/lib/tst_kconfig.c > > @@ -569,7 +569,7 @@ char tst_kconfig_get(const char *confname) > > void tst_kcmdline_parse(struct tst_kcmdline_var params[], size_t > > params_len) > > { > > - char buf[128], line[512]; > > + char buf[256], line[512]; > Petr, if you are still worried, feel free to enlarge them to char > 'buf[512], line[2048];' during merge :). Li, I'm ok with 256 :). Reviewed-by: Petr Vorel - tst_res(TWARN, "Buffer overflowed while parsing /proc/cmdline"); + tst_res(TINFO, "Buffer overflowed while parsing /proc/cmdline"); But I wonder if we should keep TWARN. Or at least add + tst_res(TINFO, "WARNING: Buffer overflowed while parsing /proc/cmdline"); BTW I also see Cyril's comment about adding TINFO | TWARN (or TINFO_WARN), where he does not like neither of these two and even suggest to actually remove TWARN. https://lore.kernel.org/ltp/ZldFa-3CXXbVKmVW@yuki/ > BTW, I don't want to allocate the size dynamically to make the code more > complicated. Fully agree. Kind regards, Petr -- Mailing list info: https://lists.linux.it/listinfo/ltp