DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] net/bnxt: fix buffer overflow in TF set message helpers
@ 2026-10-28  3:53 Stephen Hemminger
  2026-10-28 15:40 ` Kishore Padmanabha
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2026-10-28  3:53 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, stable, Kishore Padmanabha, Ajit Khaparde,
	Somnath Kotur, Michael Wildt, Randy Schacher

LTO build with -Werror reports stack overflows in tf_msg.c:

  In function 'tf_global_cfg_set':
  rte_memcpy.h:91:9: error: writing 16 bytes into a region of size 8
  tf_msg.c:1574:45: note: at offset 48 into destination object 'req'
  of size 56

  In function 'tf_msg_set_if_tbl_entry':
  rte_memcpy.h:105:9: error: writing 32 bytes into a region of size 0
  tf_msg.c:1813:41: note: at offset 136 into destination object 'req'
  of size 128

tf_msg_set_global_cfg() limits config_sz_in_bytes to 16, but
req.data and req.mask are each 8 bytes. A config larger than 8 bytes
overruns data into mask, and the mask copy runs off the end of req.

tf_msg_set_if_tbl_entry() has no check at all. data_sz_in_bytes is a
uint16_t copied into the 88 byte req.data. The ULP mapper fills it
from a blob of up to 128 bytes.

Check both against sizeof() of the destination, as the matching get
functions already do.

Fixes: 98487d729b4a ("net/bnxt: cleanup and refactor session management")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnxt/tf_core/tf_msg.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index aab8d05d81..ab03afaabd 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -23,7 +23,6 @@
  * means we have to manually sync hwrm with these defines if the
  * tf.yaml changes.
  */
-#define TF_MSG_SET_GLOBAL_CFG_DATA_SIZE  16
 #define TF_MSG_EM_INSERT_KEY_SIZE        64
 #define TF_MSG_EM_INSERT_RECORD_SIZE     96
 #define TF_MSG_TBL_TYPE_SET_DATA_SIZE    88
@@ -1618,7 +1617,7 @@ tf_msg_set_global_cfg(struct tf *tfp,
 	req.offset = tfp_cpu_to_le_32(params->offset);
 
 	/* Check for data size conformity */
-	if (params->config_sz_in_bytes > TF_MSG_SET_GLOBAL_CFG_DATA_SIZE) {
+	if (params->config_sz_in_bytes > sizeof(req.data)) {
 		rc = -EINVAL;
 		TFP_DRV_LOG(ERR,
 			    "%s: Invalid parameters for msg type, rc:%s\n",
@@ -1816,6 +1815,9 @@ tf_msg_set_if_tbl_entry(struct tf *tfp,
 	struct tf_dev_info *dev;
 	struct tf_session *tfs;
 
+	if (params->data_sz_in_bytes > sizeof(req.data))
+		return -EINVAL;
+
 	/* Retrieve the session information */
 	rc = tf_session_get_session(tfp, &tfs);
 	if (rc) {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC] net/bnxt: fix buffer overflow in TF set message helpers
  2026-10-28  3:53 [RFC] net/bnxt: fix buffer overflow in TF set message helpers Stephen Hemminger
@ 2026-10-28 15:40 ` Kishore Padmanabha
  0 siblings, 0 replies; 2+ messages in thread
From: Kishore Padmanabha @ 2026-10-28 15:40 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: dev, stable, Ajit Khaparde, Somnath Kotur, Michael Wildt,
	Randy Schacher


[-- Attachment #1.1: Type: text/plain, Size: 2782 bytes --]

On Tue, Oct 27, 2026 at 11:53 PM Stephen Hemminger <
stephen@networkplumber.org> wrote:

> LTO build with -Werror reports stack overflows in tf_msg.c:
>
>   In function 'tf_global_cfg_set':
>   rte_memcpy.h:91:9: error: writing 16 bytes into a region of size 8
>   tf_msg.c:1574:45: note: at offset 48 into destination object 'req'
>   of size 56
>
>   In function 'tf_msg_set_if_tbl_entry':
>   rte_memcpy.h:105:9: error: writing 32 bytes into a region of size 0
>   tf_msg.c:1813:41: note: at offset 136 into destination object 'req'
>   of size 128
>
> tf_msg_set_global_cfg() limits config_sz_in_bytes to 16, but
> req.data and req.mask are each 8 bytes. A config larger than 8 bytes
> overruns data into mask, and the mask copy runs off the end of req.
>
> tf_msg_set_if_tbl_entry() has no check at all. data_sz_in_bytes is a
> uint16_t copied into the 88 byte req.data. The ULP mapper fills it
> from a blob of up to 128 bytes.
>
> Check both against sizeof() of the destination, as the matching get
> functions already do.
>
> Fixes: 98487d729b4a ("net/bnxt: cleanup and refactor session management")
> Cc: stable@dpdk.org
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>
Acked-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>

> ---
>  drivers/net/bnxt/tf_core/tf_msg.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/bnxt/tf_core/tf_msg.c
> b/drivers/net/bnxt/tf_core/tf_msg.c
> index aab8d05d81..ab03afaabd 100644
> --- a/drivers/net/bnxt/tf_core/tf_msg.c
> +++ b/drivers/net/bnxt/tf_core/tf_msg.c
> @@ -23,7 +23,6 @@
>   * means we have to manually sync hwrm with these defines if the
>   * tf.yaml changes.
>   */
> -#define TF_MSG_SET_GLOBAL_CFG_DATA_SIZE  16
>  #define TF_MSG_EM_INSERT_KEY_SIZE        64
>  #define TF_MSG_EM_INSERT_RECORD_SIZE     96
>  #define TF_MSG_TBL_TYPE_SET_DATA_SIZE    88
> @@ -1618,7 +1617,7 @@ tf_msg_set_global_cfg(struct tf *tfp,
>         req.offset = tfp_cpu_to_le_32(params->offset);
>
>         /* Check for data size conformity */
> -       if (params->config_sz_in_bytes > TF_MSG_SET_GLOBAL_CFG_DATA_SIZE) {
> +       if (params->config_sz_in_bytes > sizeof(req.data)) {
>                 rc = -EINVAL;
>                 TFP_DRV_LOG(ERR,
>                             "%s: Invalid parameters for msg type, rc:%s\n",
> @@ -1816,6 +1815,9 @@ tf_msg_set_if_tbl_entry(struct tf *tfp,
>         struct tf_dev_info *dev;
>         struct tf_session *tfs;
>
> +       if (params->data_sz_in_bytes > sizeof(req.data))
> +               return -EINVAL;
> +
>         /* Retrieve the session information */
>         rc = tf_session_get_session(tfp, &tfs);
>         if (rc) {
> --
> 2.53.0
>
>

[-- Attachment #1.2: Type: text/html, Size: 3839 bytes --]

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5493 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-28 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-28  3:53 [RFC] net/bnxt: fix buffer overflow in TF set message helpers Stephen Hemminger
2026-10-28 15:40 ` Kishore Padmanabha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox