Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp234715rwb; Tue, 4 Oct 2022 03:20:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6n1xePEmqPnH96pBPmiMk3thNxmnSpqEwpK3R3N1xRQd+XcZf1z+Hu4AySu3k1aaymf8dV X-Received: by 2002:a17:903:41c6:b0:178:348e:f760 with SMTP id u6-20020a17090341c600b00178348ef760mr26644485ple.123.1664878853087; Tue, 04 Oct 2022 03:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664878853; cv=none; d=google.com; s=arc-20160816; b=EdBOgW9A+oPgAeEwBUxDPaF90fTouX244Y3wUAYnngShdD+gcfaPCu3ti8s0A7tbuW wAfvmwEPNrvQQVXFnrPikE429WgGrMMkWJNCf9kX3eU4bvyqNJJoQEnscqk2+vgGE6sK HFGs+A1hDly8p/ieq4+K69iQKCFWnSrqfTwXe+ekEPsxrb23Zim+qGvA5jMO1A4MiX3L li9/4XsI+4pPGqR0iLXDUPH1a0hO+r59aPm1uf/18PZn131pmFqI1ktDauWuc4g4Dpu2 Qx1eYjr2dkGJQ6Kbt/SI1iW+tsmqbUvRaGrUzr2X+MjIpn5MwF0Ccx2QQVnsQz08aBsc kbMQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=K8cBt2opq8Vz5IgFqg7H0MSu8Z+lhRpJxKBpnfGhoQk=; b=MjDRUyuyHBV2udilry3gT/MhOx38Mgxa2qgRq6V0ZG5phfDOWifyjHzUe2sjMyVNm7 fqsu//jeDQjLERJrRngH5RzbrwKjIvJ6Dwj4fgsT2oRBITNpM2Mtw/7oVGIUMzKUj+Dz EoOI44YgPEXz5a+4DOqpmh1HIDcQuYSHNAmWAG9oVboo2xJm0SiTJtlRq49NcGZa/51e wzNLhNwQsOAZmhJzsqBpPVBQmW19siTf5F1n7Jvm80VTH+DyOAXvBydz3xrGWAcO63YF 0085UkvryQVq1AEUbke31dteGhVroSgbpT6zb57oV6Or6r+BIM9YtZuW6D2FHYkeys3W HJXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=aksGLhJC; 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=yandex.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a635408000000b004403d4f1f6esi12992397pgb.458.2022.10.04.03.20.40; Tue, 04 Oct 2022 03:20:53 -0700 (PDT) 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=@yandex.ru header.s=mail header.b=aksGLhJC; 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=yandex.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbiJDKH5 (ORCPT + 99 others); Tue, 4 Oct 2022 06:07:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbiJDKHz (ORCPT ); Tue, 4 Oct 2022 06:07:55 -0400 X-Greylist: delayed 591 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 04 Oct 2022 03:07:53 PDT Received: from forward101p.mail.yandex.net (forward101p.mail.yandex.net [77.88.28.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B84527B33; Tue, 4 Oct 2022 03:07:52 -0700 (PDT) Received: from myt5-2f5ba0466eb8.qloud-c.yandex.net (myt5-2f5ba0466eb8.qloud-c.yandex.net [IPv6:2a02:6b8:c12:1c83:0:640:2f5b:a046]) by forward101p.mail.yandex.net (Yandex) with ESMTP id 6D10859CFCF7; Tue, 4 Oct 2022 12:50:42 +0300 (MSK) Received: by myt5-2f5ba0466eb8.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id rEpJMfzEhn-ofhSNNBN; Tue, 04 Oct 2022 12:50:41 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1664877041; bh=K8cBt2opq8Vz5IgFqg7H0MSu8Z+lhRpJxKBpnfGhoQk=; h=Message-Id:Date:Cc:Subject:To:From; b=aksGLhJC7WE4wNfc3JzF+seDDz2hQKmsQioY3ZrS+jepS+I3EXJXG2xyh2Ob4jZtx ZquskaeqVqgbeoicM3Nor8mVHw9TjpfOeu4RrmDzd7wLKzY3bwYxIeGSUEVDOODikY MlcX+iJUN3C0EmcHcVogdHRtGCC3I5e9PODQ44/4= Authentication-Results: myt5-2f5ba0466eb8.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru From: Peter Kosyh To: Ajit Khaparde Cc: Peter Kosyh , Sriharsha Basavapatna , Somnath Kotur , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] net: benet: use snprintf instead sprintf and IFNAMSIZ instead hardcoded constant. Date: Tue, 4 Oct 2022 12:50:34 +0300 Message-Id: <20221004095034.377665-1-pkosyh@yandex.ru> X-Mailer: git-send-email 2.37.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=no 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 printf to array 'eqo->desc' of size 32 may cause buffer overflow when using non-standard IFNAMSIZ. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Peter Kosyh --- drivers/net/ethernet/emulex/benet/be.h | 2 +- drivers/net/ethernet/emulex/benet/be_main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 61fe9625bed1..857a25f45fc8 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -179,7 +179,7 @@ static inline void queue_tail_inc(struct be_queue_info *q) struct be_eq_obj { struct be_queue_info q; - char desc[32]; + char desc[IFNAMSIZ+16]; struct be_adapter *adapter; struct napi_struct napi; diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 414362febbb9..8e75a14da595 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -3485,7 +3485,7 @@ static int be_msix_register(struct be_adapter *adapter) int status, i, vec; for_all_evt_queues(adapter, eqo, i) { - sprintf(eqo->desc, "%s-q%d", netdev->name, i); + snprintf(eqo->desc, sizeof(eqo->desc), "%s-q%d", netdev->name, i); vec = be_msix_vec_get(adapter, eqo); status = request_irq(vec, be_msix, 0, eqo->desc, eqo); if (status) -- 2.37.0