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 4803518E025 for ; Sat, 21 Mar 2026 14:41:06 +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=1774104067; cv=none; b=A75d6iVaE4PdniCZD3XmR04S04vNYVf53caZPuRy0cDd5vpOrEnqyj2/3E3NcNgHjHLm+DxMVjJi2JCmVN2OX2NmWVhDZj0IolPxbkF9lR5cT38NoGqWeEQV+2eSZkHXSZp/+ZeTjX5apA28DB9nnXGDPASTBbdWN8lxS50aGJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774104067; c=relaxed/simple; bh=QInNzlEXwuRxKx+roi7A4hjYBpCVDx1KRbH+ZIrusKA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=bT64UtNcwVkON5/t8sCKoJhNCdFlTFckIU2lBcKOXjuudc4qOz7R01fQ0rUJUsfzab5WZ7RUas501oq0a/QwGmUmn85ihclS9ymY/0JiAeMrieEYtM+DGJTUPjuGxbDUS0bVAEuB9cGr6mqMY4LbE+a6qiSZ0AY6bubORLCiFg0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oqUY2uB+; 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="oqUY2uB+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 876E7C19421; Sat, 21 Mar 2026 14:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774104066; bh=QInNzlEXwuRxKx+roi7A4hjYBpCVDx1KRbH+ZIrusKA=; h=From:To:Cc:Subject:Date:From; b=oqUY2uB+Mw2TWOh9J3fIM85EWs5PbnQSMXKV5hFJBUz2Yrfu9hcxYdY+mG/ZuMvVO E1xdk2HGIFd4s9ZAyKLhhPRH9fzXs/x7h3pdyaAwWZgI/mB/4ZMXCs815W4m4lbM3J 6ga7kWB9rJzrKz50Yl/LGW4xeiOzPEITYVGuT8SzEC2EXC7AQLIvIOiR/xgc8eK0gL UeNd3eOsgF+1sX6Ljna1Cw4Jw+GuwWplf19YeaAh5CYF/kprvYdTWFR5aD8WOnADru zYKveB1SgTMUiqRritH+ktlf+r0ubNwWHbaeIt9oTQkA2h1GIX9w2/1l5g1KaA/NPW aTRKyw0xBsT8A== From: "Masami Hiramatsu (Google)" To: Petr Mladek , Steven Rostedt , Andy Shevchenko Cc: Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton , David Laight , linux-kernel@vger.kernel.org Subject: [PATCH v3 0/2] lib/vsprintf: Fixes size check Date: Sat, 21 Mar 2026 23:41:03 +0900 Message-ID: <177410406326.38798.16853803119128725972.stgit@devnote2> X-Mailer: git-send-email 2.43.0 User-Agent: StGit/0.19 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="utf-8" Content-Transfer-Encoding: 8bit Hi, Here is the 3rd version of patches to fix vsnprintf(). - Fix to limit the size of width and precision. - Warn if the return size is over INT_MAX. Previous version is here; https://lore.kernel.org/all/177397887883.33018.9867883986177366222.stgit@devnote2/ In this version, check and update witdth and precision before assigning to spec data structure [1/2] and use a local variable to be better readability [2/2]. Recently we discussed snprintf() usage in bootconfig and found snprintf() design has a problem[1]. It returns the required or printed size in 'int' but the maxlen is passed by 'size_t'. The maxlen is already limited by INT_MAX, but if the expected print size becomes bigger than INT_MAX, it can return negative value. We also found width and precision size check does not work. [1] https://lore.kernel.org/all/20260317121507.30735331@gandalf.local.home/ Thank you, --- Masami Hiramatsu (Google) (2): lib/vsprintf: Fix to check field_width and precision lib/vsprintf: Limit the returning size to INT_MAX lib/vsprintf.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) -- Masami Hiramatsu (Google)