lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACKFLi=N6deF89AncWbuadMZrL9Z8_w5bLkL6WOJBgUWzDPpmg@mail.gmail.com>
Date: Fri, 5 Jul 2024 11:27:47 -0700
From: Michael Chan <michael.chan@...adcom.com>
To: Simon Horman <horms@...nel.org>
Cc: "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, 
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org
Subject: Re: [PATCH net-next 2/3] bnxt_en: check for irq name truncation

On Fri, Jul 5, 2024 at 4:27 AM Simon Horman <horms@...nel.org> wrote:
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 220d05e2f6fa..15e68c8e599d 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -10538,7 +10538,7 @@ static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,
>         return __bnxt_trim_rings(bp, rx, tx, max, sh);
>  }
>
> -static void bnxt_setup_msix(struct bnxt *bp)
> +static int bnxt_setup_msix(struct bnxt *bp)
>  {
>         const int len = sizeof(bp->irq_tbl[0].name);
>         struct net_device *dev = bp->dev;
> @@ -10558,6 +10558,7 @@ static void bnxt_setup_msix(struct bnxt *bp)
>         for (i = 0; i < bp->cp_nr_rings; i++) {
>                 int map_idx = bnxt_cp_num_to_irq_num(bp, i);
>                 char *attr;
> +               int rc;
>
>                 if (bp->flags & BNXT_FLAG_SHARED_RINGS)
>                         attr = "TxRx";
> @@ -10566,24 +10567,35 @@ static void bnxt_setup_msix(struct bnxt *bp)
>                 else
>                         attr = "tx";
>
> -               snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name,
> -                        attr, i);
> +               rc = snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d",
> +                             dev->name, attr, i);
> +               if (rc >= len)
> +                       return -E2BIG;

I may be missing something obvious here.  snprintf() will truncate and
not overwrite the buffer, right?  Why is it necessary to abort if
there is truncation?  Thanks.

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4209 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ