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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 6E7EECFA752 for ; Fri, 4 Oct 2024 09:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zppxy3hAjcFadbhorn8LmHeB5MeFnmyS+d2upsi3xw4=; b=U3lCeutmPz+MeUaeP9G6WNEcGv vPtPBiqW5B2qXBdrzKGKjxAlNbvMnJ29fKjhYBNXZdMtZovDqimrvlOh2v8Qyk52fVqUBurUL9Fpe q4STsIGnReF1FiETA3Bv6pssNYisP7kZ+LZVUIDGa2dm1PlvdmVWYogOz6nR8B7+JvGdaQblBb3qA 3EwBhg9WhZxVY04X+ivD3+0JfIXYaOHBfnkud8KadhBk0NNLzjCn9HyRLW2cq8Y045BCWhVLl8FDv UbBVwZPBibKd/lHc7vzcnufy50lYg4tNhz8HJxOuDMN0FAUugnoAaH2GGFDpUCs3l9D0elrlN4N5U Qdh7KbBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sweLc-0000000BYxa-47Zg; Fri, 04 Oct 2024 09:11:40 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sweJy-0000000BYXd-40GJ for linux-arm-kernel@lists.infradead.org; Fri, 04 Oct 2024 09:10:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=zppxy3hAjcFadbhorn8LmHeB5MeFnmyS+d2upsi3xw4=; b=BRE1pX979nhXBK8ettm5asQ1nG sbG57b2E0uijsJqlg0/cXtw7kHYIuu9JSpJY/hJDfuTFo2PTUkyLZ/P7dqEz2fEHAs2QBMUNOCOyb 80F8KJkYu9Fkrw+NuVurz/V8w0nSI9DjB5ZN/jAju7oZOm9bxtg1uKcV03NoHShSzQRsa503lIswi WWRidyU+e2KagtafsT99kUXGTRZSl4nr2Xr2PpMYvoSq6OQmAearnLmfSHiiOXdq7wU3yIVatUbno ySihYnAZstazM4hQbRkR28KUz+GX/PgXAnwVM8sQ+kC6qb1TFO2mvMnRChZy7uiudyLSVVZxbX9rL eoM8tgkw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:54774) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sweJs-0001ar-2T; Fri, 04 Oct 2024 10:09:52 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.96) (envelope-from ) id 1sweJr-00013s-07; Fri, 04 Oct 2024 10:09:51 +0100 Date: Fri, 4 Oct 2024 10:09:50 +0100 From: "Russell King (Oracle)" To: Paulo Miguel Almeida Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [next] ARM: Replace snprintf() with the safer scnprintf() variant Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241004_020959_316161_3D36A481 X-CRM114-Status: GOOD ( 12.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Oct 04, 2024 at 03:59:30PM +1300, Paulo Miguel Almeida wrote: > There is a general misunderstanding amongst engineers that {v}snprintf() > returns the length of the data *actually* encoded into the destination > array. However, as per the C99 standard {v}snprintf() really returns > the length of the data that *would have been* written if there were > enough space for it. This misunderstanding has led to buffer-overruns > in the past. It's generally considered safer to use the {v}scnprintf() > variants in their place (or even sprintf() in simple cases). So, basically, it's unsafe to use the result of (v)snprintf(). So why do we need to change locations that do not use the result? This patch is mere noise. Sorry, I won't be applying it. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!