* [PATCH 1/1] ice: fix array overflow on receiving too many fragments for a packet
@ 2020-12-07 1:14 Xiaohui Zhang
2020-12-07 1:55 ` Jesse Brandeburg
2020-12-07 9:00 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: Xiaohui Zhang @ 2020-12-07 1:14 UTC (permalink / raw)
To: Xiaohui Zhang, Jesse Brandeburg, Tony Nguyen, David S . Miller,
Jakub Kicinski, intel-wired-lan, netdev, linux-kernel
From: Zhang Xiaohui <ruc_zhangxiaohui@163.com>
If the hardware receives an oversized packet with too many rx fragments,
skb_shinfo(skb)->frags can overflow and corrupt memory of adjacent pages.
This becomes especially visible if it corrupts the freelist pointer of
a slab page.
Signed-off-by: Zhang Xiaohui <ruc_zhangxiaohui@163.com>
---
drivers/net/ethernet/intel/ice/ice_txrx.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
index eae75260f..f0f034fa5 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
@@ -823,8 +823,12 @@ ice_add_rx_frag(struct ice_ring *rx_ring, struct ice_rx_buf *rx_buf,
if (!size)
return;
- skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buf->page,
+ struct skb_shared_info *shinfo = skb_shinfo(skb);
+
+ if (shinfo->nr_frags < ARRAY_SIZE(shinfo->frags)) {
+ skb_add_rx_frag(skb, shinfo, rx_buf->page,
rx_buf->page_offset, size, truesize);
+ }
/* page is being used so we must update the page offset */
ice_rx_buf_adjust_pg_offset(rx_buf, truesize);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] ice: fix array overflow on receiving too many fragments for a packet
2020-12-07 1:14 [PATCH 1/1] ice: fix array overflow on receiving too many fragments for a packet Xiaohui Zhang
@ 2020-12-07 1:55 ` Jesse Brandeburg
2020-12-07 9:00 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: Jesse Brandeburg @ 2020-12-07 1:55 UTC (permalink / raw)
To: Xiaohui Zhang
Cc: Tony Nguyen, David S . Miller, Jakub Kicinski, intel-wired-lan,
netdev, linux-kernel
Xiaohui Zhang wrote:
> From: Zhang Xiaohui <ruc_zhangxiaohui@163.com>
>
> If the hardware receives an oversized packet with too many rx fragments,
> skb_shinfo(skb)->frags can overflow and corrupt memory of adjacent pages.
> This becomes especially visible if it corrupts the freelist pointer of
> a slab page.
As I replied to the ionic patch, please justify this with how you found
it and how you reproduced a problem. Resend the patches as a series so
we can discuss them as one change.
>
> Signed-off-by: Zhang Xiaohui <ruc_zhangxiaohui@163.com>
> ---
> drivers/net/ethernet/intel/ice/ice_txrx.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
> index eae75260f..f0f034fa5 100644
> --- a/drivers/net/ethernet/intel/ice/ice_txrx.c
> +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
> @@ -823,8 +823,12 @@ ice_add_rx_frag(struct ice_ring *rx_ring, struct ice_rx_buf *rx_buf,
>
> if (!size)
> return;
> - skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buf->page,
> + struct skb_shared_info *shinfo = skb_shinfo(skb);
> +
> + if (shinfo->nr_frags < ARRAY_SIZE(shinfo->frags)) {
> + skb_add_rx_frag(skb, shinfo, rx_buf->page,
> rx_buf->page_offset, size, truesize);
> + }
The driver is using 2kB receive buffers, and can chain them together up
to a max receive size of 9126 bytes (or so), so how can we receive more
than 18 fragments? Please explain your logic
>
> /* page is being used so we must update the page offset */
> ice_rx_buf_adjust_pg_offset(rx_buf, truesize);
Your patch doesn't compile. You must compile test and explain your
patches better.
CC [M] drivers/net/ethernet/intel/ice//ice_main.o
CC [M] drivers/net/ethernet/intel/ice//ice_controlq.o
CC [M] drivers/net/ethernet/intel/ice//ice_common.o
CC [M] drivers/net/ethernet/intel/ice//ice_nvm.o
CC [M] drivers/net/ethernet/intel/ice//ice_switch.o
CC [M] drivers/net/ethernet/intel/ice//ice_sched.o
CC [M] drivers/net/ethernet/intel/ice//ice_base.o
CC [M] drivers/net/ethernet/intel/ice//ice_lib.o
CC [M] drivers/net/ethernet/intel/ice//ice_txrx_lib.o
CC [M] drivers/net/ethernet/intel/ice//ice_txrx.o
drivers/net/ethernet/intel/ice//ice_txrx.c: In function ‘ice_add_rx_frag’:
drivers/net/ethernet/intel/ice//ice_txrx.c:829:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
829 | struct skb_shared_info *shinfo = skb_shinfo(skb);
| ^~~~~~
drivers/net/ethernet/intel/ice//ice_txrx.c:832:24: warning: passing argument 2 of ‘skb_add_rx_frag’ makes integer from pointer without a cast [-Wint-conversion]
832 | skb_add_rx_frag(skb, shinfo, rx_buf->page,
| ^~~~~~
| |
| struct skb_shared_info *
In file included from ./include/linux/if_ether.h:19,
from ./include/uapi/linux/ethtool.h:19,
from ./include/linux/ethtool.h:18,
from ./include/linux/netdevice.h:37,
from ./include/trace/events/xdp.h:8,
from ./include/linux/bpf_trace.h:5,
from drivers/net/ethernet/intel/ice//ice_txrx.c:8:
./include/linux/skbuff.h:2182:47: note: expected ‘int’ but argument is of type ‘struct skb_shared_info *’
2182 | void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
| ~~~~^
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] ice: fix array overflow on receiving too many fragments for a packet
2020-12-07 1:14 [PATCH 1/1] ice: fix array overflow on receiving too many fragments for a packet Xiaohui Zhang
2020-12-07 1:55 ` Jesse Brandeburg
@ 2020-12-07 9:00 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-12-07 9:00 UTC (permalink / raw)
To: Xiaohui Zhang, Jesse Brandeburg, Tony Nguyen, David S . Miller,
Jakub Kicinski, intel-wired-lan, netdev, linux-kernel
Cc: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3841 bytes --]
Hi Xiaohui,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tnguy-next-queue/dev-queue]
[also build test WARNING on v5.10-rc7 next-20201204]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Xiaohui-Zhang/ice-fix-array-overflow-on-receiving-too-many-fragments-for-a-packet/20201207-141033
base: https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git dev-queue
config: riscv-allyesconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/b3906f69dcad641195cbf1ce9af3e9105a6f72e1
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Xiaohui-Zhang/ice-fix-array-overflow-on-receiving-too-many-fragments-for-a-packet/20201207-141033
git checkout b3906f69dcad641195cbf1ce9af3e9105a6f72e1
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=riscv
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
In file included from include/vdso/processor.h:10,
from arch/riscv/include/asm/processor.h:11,
from include/linux/prefetch.h:15,
from drivers/net/ethernet/intel/ice/ice_txrx.c:6:
arch/riscv/include/asm/vdso/processor.h: In function 'cpu_relax':
arch/riscv/include/asm/vdso/processor.h:14:2: error: implicit declaration of function 'barrier' [-Werror=implicit-function-declaration]
14 | barrier();
| ^~~~~~~
drivers/net/ethernet/intel/ice/ice_txrx.c: In function 'ice_add_rx_frag':
>> drivers/net/ethernet/intel/ice/ice_txrx.c:828:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
828 | struct skb_shared_info *shinfo = skb_shinfo(skb);
| ^~~~~~
>> drivers/net/ethernet/intel/ice/ice_txrx.c:831:24: warning: passing argument 2 of 'skb_add_rx_frag' makes integer from pointer without a cast [-Wint-conversion]
831 | skb_add_rx_frag(skb, shinfo, rx_buf->page,
| ^~~~~~
| |
| struct skb_shared_info *
In file included from include/net/net_namespace.h:39,
from include/linux/netdevice.h:37,
from include/trace/events/xdp.h:8,
from include/linux/bpf_trace.h:5,
from drivers/net/ethernet/intel/ice/ice_txrx.c:8:
include/linux/skbuff.h:2187:47: note: expected 'int' but argument is of type 'struct skb_shared_info *'
2187 | void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
| ~~~~^
cc1: some warnings being treated as errors
vim +828 drivers/net/ethernet/intel/ice/ice_txrx.c
825
826 if (!size)
827 return;
> 828 struct skb_shared_info *shinfo = skb_shinfo(skb);
829
830 if (shinfo->nr_frags < ARRAY_SIZE(shinfo->frags)) {
> 831 skb_add_rx_frag(skb, shinfo, rx_buf->page,
832 rx_buf->page_offset, size, truesize);
833 }
834
835 /* page is being used so we must update the page offset */
836 ice_rx_buf_adjust_pg_offset(rx_buf, truesize);
837 }
838
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 67660 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-07 9:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 1:14 [PATCH 1/1] ice: fix array overflow on receiving too many fragments for a packet Xiaohui Zhang
2020-12-07 1:55 ` Jesse Brandeburg
2020-12-07 9:00 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).