Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

eth: fbnic: Add validation for MTU changes

Increasing the MTU beyond the HDS threshold causes the hardware to
fragment packets across multiple buffers. If a single-buffer XDP program
is attached, the driver will drop all multi-frag frames. While we can't
prevent a remote sender from sending non-TCP packets larger than the MTU,
this will prevent users from inadvertently breaking new TCP streams.

Traditionally, drivers supported XDP with MTU less than 4Kb
(packet per page). Fbnic currently prevents attaching XDP when MTU is too high.
But it does not prevent increasing MTU after XDP is attached.

Fixes: 1b0a3950dbd4 ("eth: fbnic: Add XDP pass, drop, abort support")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Dimitri Daskalakis <dimitri.daskalakis1@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Dimitri Daskalakis and committed by
David S. Miller
ccd8e877 be054cc6

+18
+18
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
··· 262 262 return 0; 263 263 } 264 264 265 + static int fbnic_change_mtu(struct net_device *dev, int new_mtu) 266 + { 267 + struct fbnic_net *fbn = netdev_priv(dev); 268 + 269 + if (fbnic_check_split_frames(fbn->xdp_prog, new_mtu, fbn->hds_thresh)) { 270 + dev_err(&dev->dev, 271 + "MTU %d is larger than HDS threshold %d in XDP mode\n", 272 + new_mtu, fbn->hds_thresh); 273 + 274 + return -EINVAL; 275 + } 276 + 277 + WRITE_ONCE(dev->mtu, new_mtu); 278 + 279 + return 0; 280 + } 281 + 265 282 void fbnic_clear_rx_mode(struct fbnic_dev *fbd) 266 283 { 267 284 struct net_device *netdev = fbd->netdev; ··· 550 533 .ndo_start_xmit = fbnic_xmit_frame, 551 534 .ndo_features_check = fbnic_features_check, 552 535 .ndo_set_mac_address = fbnic_set_mac, 536 + .ndo_change_mtu = fbnic_change_mtu, 553 537 .ndo_set_rx_mode = fbnic_set_rx_mode, 554 538 .ndo_get_stats64 = fbnic_get_stats64, 555 539 .ndo_bpf = fbnic_bpf,