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 9430CC54EBE for ; Mon, 16 Jan 2023 14:26:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: MIME-Version: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:In-Reply-To: References:List-Owner; bh=A3mFx0qhsUDdwkfs8T1ixSbjhp3IebNWzdCdTSlcCuE=; b=prt D/53W09tuLC93WiJrCB7nr54WxkAJBysZ+1Ra9xa2l5KtuBthgmr7IdWZtdKBdNxRKIweMrppMUFZ 7tCHqsSfcG1XfbCJNnqQDEMZZxYVDIiFFOw3B/gezQ5vub4LbfWzrZ64mvsPi0LkayEdp6GdJpSMt Nr07Iq6uPFuJ0hFrjthlQUqJt15LwhWxwb6ySPPOBCKk1acxiMeJqK8qOZszvp7/DWsQ6Ap37IfMC JhOas1FfhiPaRj6Xo09UBzfixLPNl8ObM7jzBfqBdy+nRnSmeZnlefFOrmfUgj+qK0Wbg6GST5cAL FxW6S/aC7gPu2yyn5NAR9nSXj94dZkQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHQPf-00AsC8-Ve; Mon, 16 Jan 2023 14:24:40 +0000 Received: from air.basealt.ru ([194.107.17.39]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHQIP-00AohY-1y for linux-arm-kernel@lists.infradead.org; Mon, 16 Jan 2023 14:17:11 +0000 Received: by air.basealt.ru (Postfix, from userid 490) id 351C02F20230; Mon, 16 Jan 2023 14:17:00 +0000 (UTC) Received: from localhost (broadband-188-32-10-232.ip.moscow.rt.ru [188.32.10.232]) by air.basealt.ru (Postfix) with ESMTPSA id 9612F2F2022E; Mon, 16 Jan 2023 14:16:58 +0000 (UTC) Date: Mon, 16 Jan 2023 17:16:58 +0300 From: "Alexey V. Vissarionov" To: Krzysztof Kozlowski Cc: Alim Akhtar , Greg Kroah-Hartman , Jiri Slaby , Thomas Abraham , Kukjin Kim , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org, lvc-project@linuxtesting.org, gremlin@altlinux.org Subject: [PATCH] serial: samsung: fix buffer size for clk_name Message-ID: <20230116141658.GC8107@altlinux.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230116_061709_505803_A14BEEEB X-CRM114-Status: GOOD ( 10.71 ) 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: , Content-Type: multipart/mixed; boundary="===============7161148109327644145==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============7161148109327644145== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="nmemrqcdn5VTmUEE" Content-Disposition: inline --nmemrqcdn5VTmUEE Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Although very unlikely, the 'clk_num' value may be as big as 2**32 - 1 (uint32_max), so the buffer should have enough space for storing "clk_uart_baud4294967295\0". Also, the numbers in clk_name are expected to be unsigned. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 5f5a7a5578c58852 ("serial: samsung: switch to clkdev based clock loo= kup") Signed-off-by: Alexey V. Vissarionov diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_= tty.c index 0fce856434dafd80..2c701dc7c6a37191 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -1407,7 +1407,7 @@ static void s3c24xx_serial_pm(struct uart_port *port,= unsigned int level, * */ =20 -#define MAX_CLK_NAME_LENGTH 15 +#define MAX_CLK_NAME_LENGTH 24 /* "clk_uart_baud4294967295\0" */ =20 static inline int s3c24xx_serial_getsource(struct uart_port *port) { @@ -1457,7 +1457,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c2= 4xx_uart_port *ourport, !(ourport->cfg->clk_sel & (1 << cnt))) continue; =20 - sprintf(clkname, "clk_uart_baud%d", cnt); + sprintf(clkname, "clk_uart_baud%u", cnt); clk =3D clk_get(ourport->port.dev, clkname); if (IS_ERR(clk)) continue; @@ -1957,7 +1957,7 @@ static int s3c24xx_serial_enable_baudclk(struct s3c24= xx_uart_port *ourport) if (!(clk_sel & (1 << clk_num))) continue; =20 - sprintf(clk_name, "clk_uart_baud%d", clk_num); + sprintf(clk_name, "clk_uart_baud%u", clk_num); clk =3D clk_get(dev, clk_name); if (IS_ERR(clk)) continue; @@ -2522,7 +2522,7 @@ s3c24xx_serial_get_options(struct uart_port *port, in= t *baud, /* now calculate the baud rate */ =20 clk_sel =3D s3c24xx_serial_getsource(port); - sprintf(clk_name, "clk_uart_baud%d", clk_sel); + sprintf(clk_name, "clk_uart_baud%u", clk_sel); =20 clk =3D clk_get(port->dev, clk_name); if (!IS_ERR(clk)) --=20 Alexey V. Vissarionov gremlin =F0=F2=E9 altlinux =F4=FE=EB org; +vii-cmiii-ccxxix-lxxix-xlii GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net --nmemrqcdn5VTmUEE Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJjxVxaAAoJEFv2F9znRj5K0MsP/1QGXpm/Axd8kWH2EW7QmnUo q8LW8ox4wZMJCgzT0dObphT3N7IK9ElbtgauBsn6bYeBy4gB/QHv850tpoysVVb2 QQ/Lr2hxWmuYd9s5/FAyJEHKwLGQWIJw/A2aR3Cz+Cq8FgB5rL0FJQAkMPrJ8bhk /A4zn7fqJ+hzNxiTA5GI4bGWeIrMNCLP4ASAjjZFz8FfJpPv3S9c3xRTnDnTi4cc W7+56nK3Ee1Ag6F+rPWtMYLUBuBZlK6lORR/t1+tgtlUk4n45lnjMllLq2lNMLj5 BV0uLGfioPyvu5tK4GIr3bXqi30Fg18teCYTd/bL34fzwZ0tirOnVQGePlg8YEjg O4Lm/YW0EvEiCK41RDUAJeMtrvhuoyBhfEt6KoA9L2NzORTjOmDGc8x57U755Ghi +4VNGAPUm6RENMuL95ckR6c3ip2XP6TL+49dmzMGme1TxeI/CfteSXmTYiwOF1/E 885S7KKiuMcmc+Ve1XLoQnJICDY9MFx4TJzcrgCNazTzxvBWs36kvgbVQe6MCkiR MjGRXPbqF9fPKOagZuXKsJYLIXVzsYiio3Q7DYahA893V7DvGHqSEnEwN+rDQlR2 LaGQ7YauHx5CkdR3s1XhftBEdxrJHy5E7cbVAk4d9r6PjSOi5yWuBnEbILvoqNni w9bv2xruDpeq4td4y7vt =18iO -----END PGP SIGNATURE----- --nmemrqcdn5VTmUEE-- --===============7161148109327644145== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============7161148109327644145==--