Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1872702rdb; Tue, 3 Oct 2023 03:57:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPDAkt5rKENWALSwfJlI0y04lmntAx2ZbkkAeIRNlRIkbkmRtjtrZHa/A/0Xj0J5ZrcHLV X-Received: by 2002:a05:6870:a3d0:b0:1c0:5f7a:896f with SMTP id h16-20020a056870a3d000b001c05f7a896fmr16011342oak.8.1696330633748; Tue, 03 Oct 2023 03:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696330633; cv=none; d=google.com; s=arc-20160816; b=jQ237rypVoQqj6G+JPmeDpgfhC50XvcfelD5gFnI+aQavYHxtBT9GM8M3QUN6JAhB8 2QlgQLIQ+D87mbclIMVeL1YmuyOU7pO2RVbSIN02inu2Mln+pJEcDVWhtVP9b8VSUEV3 G1ZVTKY5v5dxmYUhC/DE3ZfwkVIFBIR7k1k6/kVqlsGmVx6LOZP1Fk/QEtMn+Etu2fRt btc/UP9t8mveqlkGs8EsmTwnronkIba3LPvVGsLkzZZWypUy4wXftqEBw8LfGMgUn6Sl wvvr6ioSgWtdlBeV7Mx3/Czi9cTX35MaPX0kKA3wPZrY73OblvsD82PqXZ3dq9++1hH2 abDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=U4kqWlKSrKUGHjjrIp64JpYLKcrrQXp4C9HCFKljZwE=; fh=0w/vSzGveF63WplM20DY5d5wouJaaAgj7n4Z4l663/A=; b=rAR1aAy1Oaz1LUruAhI8Ot9xgGUfWDEO+EWJSqurIhBw5ZDy8KcCTvJ5sqD/tRGBwc 9BInnjHovc2UaMqelcH9T1mR8cdR0v/x2NI0Ttfb8MPpUJsBIvwzl5iitX+PfF+LR3te BXhyGrhDzEDSTzFNWrdkJtkCRc9Uxae3EbdQkc35UUpgptnq8l2b4bAINvfwN1MeZZp/ KguPNkd3g7DaY/RK+sUhctD3+B+fPLR7tP+Y2r0dbZOwKHJ+TOqaPeMohNZ/rsora1AG JKtCIPlRP/o94p1lxvNhHnb6KBzar5uBgMXX3XHsXpc2Tcf7VwszzK+U7Ij2S0GJFLg7 H7zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XI3o7enO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id n125-20020a632783000000b00578bd92e502si1219674pgn.558.2023.10.03.03.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 03:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XI3o7enO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D7216802F6B2; Tue, 3 Oct 2023 03:57:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239766AbjJCK5F (ORCPT + 99 others); Tue, 3 Oct 2023 06:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239735AbjJCK5E (ORCPT ); Tue, 3 Oct 2023 06:57:04 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05D3A9B for ; Tue, 3 Oct 2023 03:57:01 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68061C433CA; Tue, 3 Oct 2023 10:56:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696330620; bh=L2ltrDergf8j+6fN/XHH5Y2TY5o3ImTEqYPcQIDDz74=; h=Date:From:To:Cc:Subject:From; b=XI3o7enOreh7fRsdaT70e9scAOoD65yQRBnHI6PYbVcep0ISwndyOulaRdbTy/VTF 0U9drLcniIQyOtYmnZjHHNM0cX3J1t8xX/uazdVob2up4RGkLBhod76s+s1+iDsUQL dN01yQ2zvr8ECqcQnAVSH8KQUr6SsXxDNNXQsqYQc/jksSmHJx3H5yk3pf2c9Y2a1K 17BlOVCZDoDyXgKR5wmI0VclvNtJLyP1+ntRipJp4kFsqTQ25kh3yl4FCZrhpVs9r3 1XOq2udkA3et5rTP2CVa8jqSzPzCLPjh2xg2J+ExgVfpFV75GBtuH+dKAgZWo1qYOW GmIlJrrfFpuTg== Date: Tue, 3 Oct 2023 12:56:54 +0200 From: "Gustavo A. R. Silva" To: Ayush Sawal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rohit Maheshwari Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH v2][next] cxgb4/ch_ktls: Fix undefined behavior bug in struct chcr_ktls_ofld_ctx_tx Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 03 Oct 2023 03:57:11 -0700 (PDT) `struct tls_offload_context_tx` is a flexible structure, which means that it contains a flexible-array member at the bottom. This could potentially lead to an overwrite of the objects following `base` in `struct chcr_ktls_ofld_ctx_tx` at run-time. Notice that flexible-array member `driver_state` in `struct tls_offload_context_tx` can grow up to 16 bytes: | include/net/tls.h-170: | #define TLS_DRIVER_STATE_SIZE_TX 16 | include/net/tls.h-173: | #define TLS_OFFLOAD_CONTEXT_SIZE_TX \ | (sizeof(struct tls_offload_context_tx) + TLS_DRIVER_STATE_SIZE_TX) | net/tls/tls_device.c-1119: | offload_ctx = kzalloc(TLS_OFFLOAD_CONTEXT_SIZE_TX, GFP_KERNEL); Fix this by placing the declaration of object `base` at the end of `struct chcr_ktls_ofld_ctx_tx`. -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting ready to enable it globally. Fixes: 34aba2c45024 ("cxgb4/chcr : Register to tls add and del callback") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva --- Changes in v2: - Update changelog text: mention -Wflex-array-member-not-at-end. v1: - Link: https://lore.kernel.org/linux-hardening/ZRvyysCUTqA7aXN4@work/ drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.h b/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.h index 10572dc55365..35e34e3db663 100644 --- a/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.h +++ b/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.h @@ -68,8 +68,8 @@ struct chcr_ktls_info { }; struct chcr_ktls_ofld_ctx_tx { - struct tls_offload_context_tx base; struct chcr_ktls_info *chcr_info; + struct tls_offload_context_tx base; }; struct chcr_ktls_uld_ctx { -- 2.34.1