Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6374692rwb; Tue, 22 Nov 2022 12:26:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf6JG2eyJcMOlnxTLkTEgfeCo623xztgNJgl2+7ndQMsRweXMmpsgb+SSofC+3KKAFbnxgOQ X-Received: by 2002:a05:6402:4516:b0:467:b88c:f3af with SMTP id ez22-20020a056402451600b00467b88cf3afmr5646549edb.24.1669148767644; Tue, 22 Nov 2022 12:26:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669148767; cv=none; d=google.com; s=arc-20160816; b=VfOesIQFC4NuJBT9bDLxYdRMa8qubIvNeHVAyAyMvQR5fEol57sz82jvOr/uN0cw13 DTelovCplOJesj1+SAzIv+kuyBPDqi4ig28ecAm3L960bE5TSbBjGrumHYOYyi3mksIP fP4vmzvPZ08FuNkCxFaE328ThyirFh7iKJjAVnBrIdmuaH4PMJEQmvSwPXbRM207KOJt H7AKWBTrlbsoUlEw0k2CI71/lYyl/J5yZNlPWdZXCOa6+Y8g3ppSLtWQKFoi5+qOQLh7 d909fPt52ArQ6uX5e1Ob4QFusO9OBdwL+ikxoXxPmiHP9XiDQr24Q146DP0Qzwj/P/sJ LlOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=V0BYskXUFAYwuHRsaafPli57Xa6kudnsRltzK64EW8o=; b=kapYMPoyyj10wKL7568WFM6hbo/G6aXi9b2J248Xwhg0EdiBbNp9TDLN8nHIDYEYOK NJ9kd+GRhl0Dd+D0qtuEeV49kiKGOOuBzH6d1wLadAgUN+Aap3UbAsbJ1PEpuYEJkqd9 N6I20LOeaPj91ZP3AAbv3kwmozjpXJO0WpiRCtVkoNNzHRatKgILd42T+8BdIIz78+j+ /yXUNOMXBouHIB3vOyd1xT02tJmoIBwv3FvaFRENnDifDuoDA//JvMGX5JYBxo0XlUPo GdIP8u/LQBKtGgRCgxGxObKBupOwYFNbOl42BuOTnK4BR0j9lEHo6jTchrjApkT2k0cQ wKFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dh3PsVIv; 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 s8-20020a056402520800b0045d25cf222csi2810621edd.362.2022.11.22.12.25.45; Tue, 22 Nov 2022 12:26:07 -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=Dh3PsVIv; 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 S234704AbiKVUMh (ORCPT + 89 others); Tue, 22 Nov 2022 15:12:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234696AbiKVUMd (ORCPT ); Tue, 22 Nov 2022 15:12:33 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2705FBD7; Tue, 22 Nov 2022 12:12:27 -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 ams.source.kernel.org (Postfix) with ESMTPS id C46FCB81D85; Tue, 22 Nov 2022 20:12:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2456AC433C1; Tue, 22 Nov 2022 20:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669147944; bh=ErWQ6/edZDHfnmUj1x+2RpXl4f9HPSeF5jQRSQKBKOo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Dh3PsVIvtCZ+ztGKmg8rwGcRRizt+CZnrruVT6xkYS/H+N3oig4wWQ+sPu2sGhmjn qoM3ahO/U8f6t9q+EiuZ9Ka25iUR5L0PtRUkxGNgYz/e/2DCJ10W62hYmUTk3MIu5K YuYbbXCAKNRc4KTZAew2/NwG7p0aGGWOOcC30VLl1KBKhK7+6kLjb3bCznVadPT5PQ apqLyBvq26P4OoK2E8SDcu1SAi3bZVnOa56y8xLGomOPEGejGQ6iWGH8pl7e+DbRJ9 o1upCLxtGFnj1GhAQHnrDXMxCjQNRnt1Es1ls9yHGaYlyazofQmAjSaSoGeaZPvHPV t7tw6LN00wxOQ== Date: Tue, 22 Nov 2022 12:12:23 -0800 From: Jakub Kicinski To: Leon Romanovsky Cc: 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: <20221122121223.265d6d97@kernel.org> In-Reply-To: References: <20221122130453.730657-1-pkosyh@yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 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?