Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6847155rwb; Tue, 22 Nov 2022 21:03:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf4UpGURcPdmnykrPo0pQQxyPiQzo4bwVBJ+WzWo17G7N6c5ri3fpNLXHXQsbFbIWg/vZihS X-Received: by 2002:a17:902:f641:b0:181:b25e:e7bc with SMTP id m1-20020a170902f64100b00181b25ee7bcmr8108243plg.46.1669179779780; Tue, 22 Nov 2022 21:02:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669179779; cv=none; d=google.com; s=arc-20160816; b=hQR1+dJqLJP+MC+n/XvYhOJD/phH3By2lWv1tOMnwZuUIPMU7tb5wHnsO5SQVrQeRI Qv8KuOjwfXOpWSZPUKqC5DPnLoqt9cV9C0yvmZaCQxZozEj5lOgrbBoUW6zqx4FcTZep 4TnZoRrcsSDNjx+DrRYC98jfbIUOBmKdSC7KHaO/WKMDoMYrGCZQEwggdv+iY8wAYI8S p9GEfRj84gzt/CL2Ubbs//K3XueT7EfEYsXsSWozkceX768eIBuxnYNaddIkeJGNdX7v FeYGHR+NgSWfvK6DAgGEKzKACJQD3RCSJ2cTr7VeVyUppssCqNNsz0NmmF/q7cRifRcD uWXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WYedM0Aj0w9D1hJCQ236NiWetN3rOXUP9MqYswX3xUE=; b=YeEDJK6v129tr1a0Vp8Arh7E1QxZpyft/3wZQ9PxJ5c0Ccehkc6KqvxSBR0/MlvSNt 70N5v48NydB5S63Lbi7n0LEm4ULokAxm5TEf81XN/vjz71xtSffDlBnO/yDOclpa793q MLfYL2mkzxLJqCamUO5d9frMvBUojcbmwNKme6FOgEQN/yXbUpEECkVj4SW7mq+puXhu 1KzfcfjG5m2Z7tpIF/+TwQIvUuJSEheKVUOkAM3jdsvn9feqJYLOo66XKRZkqnkDOWtD SnTJODqqN4LCcDXHqSxeL3G0Bne6wbYXLcJDYSaNYVzxzoGc3NVqr+Bhoyaw/n3Vqbuj 1yRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a2yJvPLI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd11-20020a656e0b000000b00476bfca3894si6593779pgb.369.2022.11.22.21.02.47; Tue, 22 Nov 2022 21:02:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a2yJvPLI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235409AbiKWEns (ORCPT + 90 others); Tue, 22 Nov 2022 23:43:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234151AbiKWEno (ORCPT ); Tue, 22 Nov 2022 23:43:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AA8BCC16D; Tue, 22 Nov 2022 20:43:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C249461A51; Wed, 23 Nov 2022 04:43:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 046A5C433D6; Wed, 23 Nov 2022 04:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669178623; bh=b58VdBqgq0NaqB9sgIa30VbocJ1L94i6622vlfiDO5Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=a2yJvPLIRDQOqdwGNBw8OwQ/AmelXp4/WXwW68oM54bNUAEfZx9lIL1giTaBEw/bx /zvTMezK9lTAFG4RueHCFWNGRmQcsYGvcEcoco6wLzE3Diq1UX8BZqdFQyEV3wFDXk I6fBk42lGbJyomFe4UIXG/m3I8LwI6tXaBy1pnCOELX4j8++JV01mrLGsjX9bLcw9E oPA/B8sWRHpAfOymTVYtdUeHbBEiGLNhF6WWkHij7gLnlVyrk9EXkwXuBCzGna7X/6 UEVMSVpWNc5aicqA86LwyS0Qnw9b/rR8RFJhZEVZaKvIwULbDBw9KwlZuINL8P9Lgo iW3t5MLZL3zcw== Date: Tue, 22 Nov 2022 20:43:41 -0800 From: Saeed Mahameed To: Jakub Kicinski Cc: Leon Romanovsky , Peter Kosyh , Tariq Toukan , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: Re: [PATCH] mlx4: use snprintf() instead of sprintf() for safety Message-ID: References: <20221122130453.730657-1-pkosyh@yandex.ru> <20221122121223.265d6d97@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20221122121223.265d6d97@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22 Nov 12:12, Jakub Kicinski wrote: >On Tue, 22 Nov 2022 16:48:15 +0200 Leon Romanovsky wrote: >> On Tue, Nov 22, 2022 at 04:04:53PM +0300, Peter Kosyh wrote: >> > Use snprintf() to avoid the potential buffer overflow. Although in the >> > current code this is hardly possible, the safety is unclean. >> >> Let's fix the tools instead. The kernel code is correct. > >I'm guessing the code is correct because port can't be a high value? >Otherwise, if I'm counting right, large enough port representation >(e.g. 99999999) could overflow the string. If that's the case - how >would they "fix the tool" to know the port is always a single digit? +1 FWIW, Reviewed-by: Saeed Mahameed