From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E2EEC83A14 for ; Wed, 25 Mar 2026 01:17:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774401429; cv=none; b=rnlgyNrfoBFt+s31eJBGkett3fVG/oYtmTJgq8ofPFu3GnxsAaBtWkPqqzbDB9BciEynuc0ZO2syZAPg3Fv4pf6Ss87fVS2De4VCY/bB+QbqFvpiGWwC55IrobHg+mjqoOn9mQUKIi2L4hy16oFTzyiB3EGJoPXWe4Rtl6s7lOE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774401429; c=relaxed/simple; bh=eUmuYh6MnhZTRZc4FbqHkKShm2F9BOVBEFFfcWPRML4=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=KXT/0XUNd/yH/2oP/mduBLNr47V3/y8BVFYrKjmSiKQojD4Vak47+6Dy/58dI0yZRL7iprO7j3WiAjzeIjkRKJZaRMK5+OGfgH1UGnzOKSOoKGh659i4/caCKm83Adp9tec1whf1FSiuEEmOaNcmJQINMp4KWevaUgqbGCg+Nyk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CF2TjVjv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CF2TjVjv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BAF6C2BC87; Wed, 25 Mar 2026 01:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774401428; bh=eUmuYh6MnhZTRZc4FbqHkKShm2F9BOVBEFFfcWPRML4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CF2TjVjvpHqXfwwe8RZG/a67LH0nS7Neo/giEwpuyeBEmrCzwGNm7TkqTSt71pR5D Rr6yKvrGkMt3WcRhiGB1RbOow3kuMAV1oRwlXxg/2f0VSiSxxZhmLzDpPPqK7Yt7BT dZJMiV/jrPGS9VnynXiL4X8IAuJppmjcXfx3e4Ad41/9Uim4Q+6xX3zUOvuY43O8bR PqiX7SA5utzXTm3eSwgpnFMaBjBrS/BUXsPALRIhlvKdZA4eTzMS79+ewcYYLD1Mzn jC2ILFyUSDvPkKl+8PHaWGgUFERUzIJtkON9kzzZzOGnAfE6i0DZ87H65IJthnMm29 MJTlCKKei5nYg== Date: Wed, 25 Mar 2026 10:17:04 +0900 From: Masami Hiramatsu (Google) To: Masami Hiramatsu (Google) Cc: David Laight , Petr Mladek , Rasmus Villemoes , Andy Shevchenko , Steven Rostedt , Sergey Senozhatsky , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] lib/vsprintf: Fix to check field_width and precision Message-Id: <20260325101704.f31e0ba4c13ebb1b63b701aa@kernel.org> In-Reply-To: <20260325093320.5bc786394face92aadbe4e4b@kernel.org> References: <177410406326.38798.16853803119128725972.stgit@devnote2> <177410407207.38798.2345647618225402693.stgit@devnote2> <20260323135905.5272127b@pumpkin> <20260324172433.05292942@pumpkin> <20260325093320.5bc786394face92aadbe4e4b@kernel.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Wed, 25 Mar 2026 09:33:20 +0900 Masami Hiramatsu (Google) wrote: > On Tue, 24 Mar 2026 17:24:33 +0000 > David Laight wrote: > > > On Tue, 24 Mar 2026 17:45:49 +0100 > > Petr Mladek wrote: > > > > > On Mon 2026-03-23 13:59:05, David Laight wrote: > > ... > > > > I've also just fixed nolibc's handling of %*.*s (which is in 'next' since > > > > I only wrote it recently), the above is actually broken. > > > > Negative 'precision' (all values) are fine, they just request the default. > > > > > > Great catch! We should clamp the precision to (0, PRECISION_MAX). But we > > > should warn only when it is outside of (-PRECISION_MAX, PRECISION_MAX). > > > > No, you are going to clamp it needs to be to (-1, PRECISION_MAX); > > but max(precision, PRECISION_MAX) if fine now the value is being saved > > in an int. > > And there is no need to warn about changing negative values - they > > all mean exactly the same thing. > > Ah, indeed. > > "A negative precision is taken as if the precision were omitted." Hmm, and format_decode() does not accept -1 precision. We need another patch to fix it. spec->precision = -1; if (unlikely(*fmt.str == '.')) { fmt.str++; if (isdigit(*fmt.str)) { <---- isdigit() accepts '0'-'9', not '-'. spec->precision = skip_atoi(&fmt.str); <--- this only returns positive value. if (spec->precision < 0) spec->precision = 0; } else if (*fmt.str == '*') { Thanks, -- Masami Hiramatsu (Google)