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 84BFE3F65E7 for ; Thu, 26 Mar 2026 11:58:03 +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=1774526283; cv=none; b=M0vGPMEbjNumTBEUPaD+BADsIFNgkJxXzsMArpqBtRSeolDnlYXh+IUnyKjRjPSlc0NjQGLri5GPRF5zX1Se2D17IyvFT0Ditq96HwhWBVUwD7fPqARTDcCBuuhovqNkhKUYcWijzWjWUlC6D2n5y4mangTKBFlnP1QmaXKKETE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774526283; c=relaxed/simple; bh=TfI8P9IDzTVohqOp/U1IaiLJddAVLLDDlV4gEJI5Z9I=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=DvEzUXBcYSZATPdukmrZj5pchaGy98GohKHIfedeMvdXhsi41qz8/n81sfDDkQDVgV9izEpEPJoPr+5/7/vwwI2ThVUopAMaGvdWKxg027QEkGyDZ7cOG6xYJC78SXLNGkD0TFQTdZgH8DDLYPyNX0T6riiR5Km80uj5Q+GfkzA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oZxzv7IR; 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="oZxzv7IR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41808C116C6; Thu, 26 Mar 2026 11:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774526283; bh=TfI8P9IDzTVohqOp/U1IaiLJddAVLLDDlV4gEJI5Z9I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=oZxzv7IRkrIm8Zs25T/3lgGacA7Ub8uSex31Ed7zqy15mGHLwYvBGkusBNZCivwJj W4g6Kl9fQgLF/CxhPz+asoGSMbgO9g/WyQ2WmFXhKkjfawy3MSJbpJZlug+LNiAkA5 TIQDBkVijeVhVcqeqqpvj6zbDAwGML6qsIN0EkJSLdXGw3RWFWfgaSoWm9yimCz5l5 0YUYLsSD8AjdR6R7C/jynaMfzSXCFuXfhL9GnGXFHbLwu3pB5LcbB0xAw5hjGj0OTA KWOREQYXfSAjR0s1Wcwba4CiueO0xc0iEN6v7pNdOMiC1A5D+//rkEdwOscHowN/28 z74jY4i8VXolA== Date: Thu, 26 Mar 2026 20:57:58 +0900 From: Masami Hiramatsu (Google) To: Andy Shevchenko Cc: Petr Mladek , Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton , David Laight , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 1/2] lib/vsprintf: Fix to check field_width and precision Message-Id: <20260326205758.d2dd498a0cada73953cf68d7@kernel.org> In-Reply-To: References: <177444525139.185641.12184379647176430297.stgit@devnote2> <177444526111.185641.13236217811424905684.stgit@devnote2> 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 Thu, 26 Mar 2026 11:57:46 +0200 Andy Shevchenko wrote: > On Wed, Mar 25, 2026 at 10:27:41PM +0900, Masami Hiramatsu (Google) wrote: > > > Check the field_width and presition correctly. Previously it depends > > on the bitfield conversion from int to check out-of-range error. > > However, commit 938df695e98d ("vsprintf: associate the format state > > with the format pointer") changed those fields to int. > > We need to check the out-of-range correctly without bitfield > > conversion. > > ... > > > +static void > > +set_field_width(struct printf_spec *spec, int width) > > One line. > Ah, OK. > static void set_field_width(struct printf_spec *spec, int width) > > > +{ > > + spec->field_width = clamp(width, -FIELD_WIDTH_MAX, FIELD_WIDTH_MAX); > > + WARN_ONCE(spec->field_width != width, "field width %d out of range", > > + width); > > I would also make it one line for readability. > > WARN_ONCE(spec->field_width != width, "field width %d out of range", width); OK. > > > +} > > + > > +static void > > +set_precision(struct printf_spec *spec, int prec) > > One line > > static void set_precision(struct printf_spec *spec, int prec) OK, let me update it. Thanks for review! > > > +{ > > + spec->precision = clamp(prec, 0, PRECISION_MAX); > > + WARN_ONCE(spec->precision < prec, "precision %d too large", prec); > > +} > > -- > With Best Regards, > Andy Shevchenko > > -- Masami Hiramatsu (Google)