From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Kees Cook <keescook@chromium.org>
Cc: Mirko Lindner <mlindner@marvell.com>,
Stephen Hemminger <stephen@networkplumber.org>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
<netdev@vger.kernel.org>, kernel test robot <lkp@intel.com>,
<linux-kernel@vger.kernel.org>, <linux-hardening@vger.kernel.org>
Subject: Re: [PATCH] sky2: Make sure there is at least one frag_addr available
Date: Thu, 21 Sep 2023 16:14:30 +0200 [thread overview]
Message-ID: <d7462ae5-c971-452f-49d7-855f60c850d3@intel.com> (raw)
In-Reply-To: <20230920202509.never.299-kees@kernel.org>
From: Kees Cook <keescook@chromium.org>
Date: Wed, 20 Sep 2023 13:25:13 -0700
> In the likely pathological case of building sky2 with 16k PAGE_SIZE,
> make sure there is at least 1 frag_addr in struct rx_ring_info:
>
> In file included from include/linux/skbuff.h:28,
> from include/net/net_namespace.h:43,
> from include/linux/netdevice.h:38,
> from drivers/net/ethernet/marvell/sky2.c:18:
> drivers/net/ethernet/marvell/sky2.c: In function 'sky2_rx_unmap_skb':
> include/linux/dma-mapping.h:416:36: warning: array subscript i is outside array bounds of 'dma_addr_t[0]' {aka 'long long unsigned int[]'} [-Warray-bounds=]
> 416 | #define dma_unmap_page(d, a, s, r) dma_unmap_page_attrs(d, a, s, r, 0)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/marvell/sky2.c:1257:17: note: in expansion of macro 'dma_unmap_page'
> 1257 | dma_unmap_page(&pdev->dev, re->frag_addr[i],
> | ^~~~~~~~~~~~~~
> In file included from drivers/net/ethernet/marvell/sky2.c:41:
> drivers/net/ethernet/marvell/sky2.h:2198:25: note: while referencing 'frag_addr'
> 2198 | dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT];
> | ^~~~~~~~~
>
> With CONFIG_PAGE_SIZE_16KB=y, PAGE_SHIFT == 14, so:
>
> #define ETH_JUMBO_MTU 9000
>
> causes "ETH_JUMBO_MTU >> PAGE_SHIFT" to be 0. Use "?: 1" to solve this build warning.
>
> Cc: Mirko Lindner <mlindner@marvell.com>
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: netdev@vger.kernel.org
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202309191958.UBw1cjXk-lkp@intel.com/
> Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
That "nobody uses this HW on non-x86 systems, why bother" is fun each time.
> ---
> drivers/net/ethernet/marvell/sky2.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/marvell/sky2.h b/drivers/net/ethernet/marvell/sky2.h
> index ddec1627f1a7..8d0bacf4e49c 100644
> --- a/drivers/net/ethernet/marvell/sky2.h
> +++ b/drivers/net/ethernet/marvell/sky2.h
> @@ -2195,7 +2195,7 @@ struct rx_ring_info {
> struct sk_buff *skb;
> dma_addr_t data_addr;
> DEFINE_DMA_UNMAP_LEN(data_size);
> - dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT];
> + dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT ?: 1];
> };
>
> enum flow_control {
Thanks,
Olek
prev parent reply other threads:[~2023-09-21 21:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 20:25 [PATCH] sky2: Make sure there is at least one frag_addr available Kees Cook
2023-09-21 3:37 ` Stephen Hemminger
2023-09-21 14:14 ` Alexander Lobakin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d7462ae5-c971-452f-49d7-855f60c850d3@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mlindner@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox