Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp81487rwb; Wed, 18 Jan 2023 14:28:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXtERzvuh2xQVCP3lvpwq4GOBzktUnk7ulBUWsZnpLRBEVdZ+Z3vcbjeU2X/ug1cgdTBcY2y X-Received: by 2002:a17:902:efd4:b0:194:5ee5:3c44 with SMTP id ja20-20020a170902efd400b001945ee53c44mr27761552plb.17.1674080936552; Wed, 18 Jan 2023 14:28:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674080936; cv=none; d=google.com; s=arc-20160816; b=MG+KtTCfmyTbsMgY638kZtOt2kRSiFkhnWoMasf2yHNzn8jF6jnu0/Lh8NB+X36LwM OwiTuBZgcT31gYoeseCzYpbgWvuDlACKvn41zLxFdIZuEsKt6KCkgKqEreUeOuOu5n0I YV8t0tDS8I1MOGOEOiCF9oJ9s6iayLscC+RzyEwZb1xxhcPPS3DduuXhvVdbcXf85r7z 2Miz6OMR8MKRVdCsxGDaMBFO62QuXCUBZrUKYU/lRux6Hu1zx0bn5en6AE6G63UPaBJL 0XxOkbWzt2e31svRNJBRoP3Nt4E7jPXUDN2zCX64wkD0llULdPS4ZuGakhthjwubT2Wt 5cvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=vhCjbWtkLmo4KnsVEQWWwW2foKxi10gJ8nRMMaIaGsI=; b=CZN/hrwO/73h5x5jQeSZETzaN+/skniPjvGU41vXSeje4xDFR2mG37sV0FWJ4dCHNQ nIOXVHJJ3s9MjF9btL5jhhBQLmf5+LPAfQ66FY8jOjXCh7kJu07Kvd7ikJD0SMPM6ltP TeCqSTNulBOKBAnrXb2DPtxJ0NgNm5PO1ekF/KugLTAC/9HbJmgHffLRmwFnv8Qk4nNl XYMvJYQNQi/TgxZtq3duqT+hJak+jGQ6xvl194CdXGP65bI9a5ZYetg6wlX0ho0Rtqox Qd4vnNb+N0ru6inFFt8QftPG88ytO6SJI6o878TIbSpmGyWn7ff/9YD5xkvsfsDl9k/y kQgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=MML9x2fQ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q20-20020a170902b11400b00187073496b4si35174679plr.136.2023.01.18.14.28.50; Wed, 18 Jan 2023 14:28:56 -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=@broadcom.com header.s=google header.b=MML9x2fQ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbjARVAt (ORCPT + 45 others); Wed, 18 Jan 2023 16:00:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230342AbjARVAF (ORCPT ); Wed, 18 Jan 2023 16:00:05 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4349589AF for ; Wed, 18 Jan 2023 13:00:00 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id v6so396668ejg.6 for ; Wed, 18 Jan 2023 13:00:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vhCjbWtkLmo4KnsVEQWWwW2foKxi10gJ8nRMMaIaGsI=; b=MML9x2fQ5AIVSlzjl2iGJ0bx+t4j3W56aJwgkfmdOpZG8FITSTlYOosipeiubA/Sbp d/xy++8MwS7OijhvxUb4ctmVo+/m7FmIJixaKkiwuw2Ag/G2Ly2X2QNWAyDGoMr+epoB RCX+4sx7XdMSqkL6usW8f7GMlz020eu6MALTw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vhCjbWtkLmo4KnsVEQWWwW2foKxi10gJ8nRMMaIaGsI=; b=w67YImmoJq3a+vXejP6PF4BvhA5ZH1A7klUzpC4A9f5uTsaXfjoWM7D+dDfW1Wbrri HM2+UgrsIwJd7GlGSPCUUYvn5JT+2cgZI2lf8N+SlWLWFzOhDRHN9Z0aZtveyUVUFzsY t6RdgCPnrNWZiBu1VOshVThe5xMSTq8NrIn0107cJAfI2z01Plnnw5bDvgm7zn97R3h2 BUFsJrDZQENnByJaIbxcRNrChBRrc7tyX5lZ8pPoccbhFq8rkRfrvnmFXJO6A/Un0LeN 2w7+DKfaEuLFVOP1FLBT+yWjDqBayHcx8d1QSNniJ1WrHarj83fOBrlD7Z9CdjnRbjmN XGSg== X-Gm-Message-State: AFqh2koqyrgTpvkpV8ckEsJ8XG1b6Sd3/FJKjj6Q5bfSG2CTI/aGFOhI z+U+E6D0S4C82MXoXYWIzsABOKk6DdvdY+uVgwsDvA== X-Received: by 2002:a17:906:9394:b0:7c4:efcf:3bc8 with SMTP id l20-20020a170906939400b007c4efcf3bc8mr1084302ejx.702.1674075598966; Wed, 18 Jan 2023 12:59:58 -0800 (PST) MIME-Version: 1.0 References: <20230118203457.never.612-kees@kernel.org> In-Reply-To: <20230118203457.never.612-kees@kernel.org> From: Michael Chan Date: Wed, 18 Jan 2023 12:59:47 -0800 Message-ID: Subject: Re: [PATCH] bnxt: Do not read past the end of test names To: Kees Cook Cc: Niklas Cassel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="0000000000006e46d005f2901905" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE 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 --0000000000006e46d005f2901905 Content-Type: text/plain; charset="UTF-8" On Wed, Jan 18, 2023 at 12:35 PM Kees Cook wrote: > > Test names were being concatenated based on a offset beyond the end of > the first name, which tripped the buffer overflow detection logic: > > detected buffer overflow in strnlen > [...] > Call Trace: > bnxt_ethtool_init.cold+0x18/0x18 > > Refactor struct hwrm_selftest_qlist_output to use an actual array, > and adjust the concatenation to use snprintf() rather than a series of > strncat() calls. > > Reported-by: Niklas Cassel > Link: https://lore.kernel.org/lkml/Y8F%2F1w1AZTvLglFX@x1-carbon/ > Tested-by: Niklas Cassel > Fixes: eb51365846bc ("bnxt_en: Add basic ethtool -t selftest support.") > Cc: Michael Chan > Cc: "David S. Miller" > Cc: Eric Dumazet > Cc: Jakub Kicinski > Cc: Paolo Abeni > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook Reviewed-by: Michael Chan > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h > index 2686a714a59f..a5408879e077 100644 > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h > @@ -10249,14 +10249,7 @@ struct hwrm_selftest_qlist_output { > u8 unused_0; > __le16 test_timeout; > u8 unused_1[2]; > - char test0_name[32]; > - char test1_name[32]; > - char test2_name[32]; > - char test3_name[32]; > - char test4_name[32]; > - char test5_name[32]; > - char test6_name[32]; > - char test7_name[32]; > + char test_name[8][32]; bnxt_hsi.h is a generated file. I will need to make a request so that future versions will be generated like this. Thanks. > u8 eyescope_target_BER_support; > #define SELFTEST_QLIST_RESP_EYESCOPE_TARGET_BER_SUPPORT_BER_1E8_SUPPORTED 0x0UL > #define SELFTEST_QLIST_RESP_EYESCOPE_TARGET_BER_SUPPORT_BER_1E9_SUPPORTED 0x1UL > -- > 2.34.1 > --0000000000006e46d005f2901905 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIQbQYJKoZIhvcNAQcCoIIQXjCCEFoCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg gg3EMIIFDTCCA/WgAwIBAgIQeEqpED+lv77edQixNJMdADANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA5MTYwMDAwMDBaFw0yODA5MTYwMDAwMDBaMFsxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTEwLwYDVQQDEyhHbG9iYWxTaWduIEdDQyBS MyBQZXJzb25hbFNpZ24gMiBDQSAyMDIwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB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