Commit 90a9693
net/mlx5e: Fix generating skb from nonlinear xdp_buff
xdp programs can change the layout of an xdp_buff through
bpf_xdp_adjust_tail(), bpf_xdp_adjust_head(). Therefore, the driver
cannot assume the size of the linear data area nor fragments. Fix the
bug in mlx5e driver by generating skb according to xdp_buff layout.
Currently, when handling multi-buf xdp, the mlx5e driver assumes the
layout of an xdp_buff to be unchanged. That is, the linear data area
continues to be empty and the fragments remains the same. This may
cause the driver to generate erroneous skb or triggering a kernel
warning. When an xdp program added linear data through
bpf_xdp_adjust_head() the linear data will be ignored as
mlx5e_build_linear_skb() builds an skb with empty linear data and then
pull data from fragments to fill the linear data area. When an xdp
program has shrunk the nonlinear data through bpf_xdp_adjust_tail(),
the delta passed to __pskb_pull_tail() may exceed the actual nonlinear
data size and trigger the BUG_ON in it.
To fix the issue, first build the skb with linear data area matching
the xdp_buff. Then, call __pskb_pull_tail() to fill the linear data for
up to MLX5E_RX_MAX_HEAD bytes. In addition, recalculate nr_frags and
truesize after xdp program runs.
Fixes: f52ac70 ("net/mlx5e: RX, Add XDP multi-buffer support in Striding RQ")
Signed-off-by: Amery Hung <[email protected]>1 parent 07f2c0d commit 90a9693
1 file changed
+43
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1725 | 1725 | | |
1726 | 1726 | | |
1727 | 1727 | | |
| 1728 | + | |
1728 | 1729 | | |
1729 | | - | |
1730 | 1730 | | |
1731 | 1731 | | |
1732 | 1732 | | |
1733 | | - | |
| 1733 | + | |
1734 | 1734 | | |
1735 | 1735 | | |
1736 | 1736 | | |
1737 | 1737 | | |
| 1738 | + | |
1738 | 1739 | | |
1739 | 1740 | | |
1740 | 1741 | | |
| |||
1775 | 1776 | | |
1776 | 1777 | | |
1777 | 1778 | | |
1778 | | - | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
1779 | 1782 | | |
1780 | | - | |
| 1783 | + | |
1781 | 1784 | | |
1782 | 1785 | | |
1783 | 1786 | | |
1784 | 1787 | | |
1785 | 1788 | | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
1786 | 1799 | | |
1787 | 1800 | | |
1788 | 1801 | | |
| |||
1796 | 1809 | | |
1797 | 1810 | | |
1798 | 1811 | | |
1799 | | - | |
| 1812 | + | |
1800 | 1813 | | |
1801 | 1814 | | |
1802 | 1815 | | |
1803 | 1816 | | |
1804 | | - | |
| 1817 | + | |
1805 | 1818 | | |
1806 | 1819 | | |
1807 | 1820 | | |
| |||
2073 | 2086 | | |
2074 | 2087 | | |
2075 | 2088 | | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
2076 | 2092 | | |
2077 | 2093 | | |
2078 | | - | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
2079 | 2098 | | |
2080 | | - | |
2081 | | - | |
| 2099 | + | |
| 2100 | + | |
2082 | 2101 | | |
2083 | 2102 | | |
2084 | 2103 | | |
| |||
2087 | 2106 | | |
2088 | 2107 | | |
2089 | 2108 | | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
2090 | 2112 | | |
2091 | 2113 | | |
2092 | | - | |
| 2114 | + | |
2093 | 2115 | | |
2094 | 2116 | | |
2095 | 2117 | | |
| |||
2102 | 2124 | | |
2103 | 2125 | | |
2104 | 2126 | | |
2105 | | - | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
2106 | 2130 | | |
2107 | 2131 | | |
2108 | | - | |
| 2132 | + | |
2109 | 2133 | | |
2110 | 2134 | | |
2111 | 2135 | | |
2112 | 2136 | | |
2113 | | - | |
2114 | | - | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
2115 | 2141 | | |
2116 | | - | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
2117 | 2145 | | |
2118 | | - | |
2119 | 2146 | | |
2120 | 2147 | | |
2121 | 2148 | | |
| |||
0 commit comments