1
linux/Documentation/networking
Joe Damato 08062af0a5 net: napi: Prevent overflow of napi_defer_hard_irqs
In commit 6f8b12d661 ("net: napi: add hard irqs deferral feature")
napi_defer_irqs was added to net_device and napi_defer_irqs_count was
added to napi_struct, both as type int.

This value never goes below zero, so there is not reason for it to be a
signed int. Change the type for both from int to u32, and add an
overflow check to sysfs to limit the value to S32_MAX.

The limit of S32_MAX was chosen because the practical limit before this
patch was S32_MAX (anything larger was an overflow) and thus there are
no behavioral changes introduced. If the extra bit is needed in the
future, the limit can be raised.

Before this patch:

$ sudo bash -c 'echo 2147483649 > /sys/class/net/eth4/napi_defer_hard_irqs'
$ cat /sys/class/net/eth4/napi_defer_hard_irqs
-2147483647

After this patch:

$ sudo bash -c 'echo 2147483649 > /sys/class/net/eth4/napi_defer_hard_irqs'
bash: line 0: echo: write error: Numerical result out of range

Similarly, /sys/class/net/XXXXX/tx_queue_len is defined as unsigned:

include/linux/netdevice.h:      unsigned int            tx_queue_len;

And has an overflow check:

dev_change_tx_queue_len(..., unsigned long new_len):

  if (new_len != (unsigned int)new_len)
          return -ERANGE;

Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Joe Damato <jdamato@fastly.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20240904153431.307932-1-jdamato@fastly.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-09-05 18:42:56 -07:00
..
caif
device_drivers Devicetree updates for v6.11: 2024-07-17 18:07:31 -07:00
devlink Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue 2024-07-13 16:04:52 -07:00
dsa
mac80211_hwsim
net_cachelines net: napi: Prevent overflow of napi_defer_hard_irqs 2024-09-05 18:42:56 -07:00
netlink_spec Documentation: Document each netlink family 2023-11-24 01:16:56 +00:00
pse-pd net: pse-pd: Add support for PSE PIs 2024-04-18 18:27:33 -07:00
6lowpan.rst
6pack.rst
af_xdp.rst Revert "xsk: Document ability to redirect to any socket bound to the same umem" 2024-06-05 09:43:05 +02:00
alias.rst
arcnet-hardware.rst
arcnet.rst
atm.rst
ax25.rst
bareudp.rst Documentation: bareudp: Corrected description of bareudp module. 2020-07-28 17:53:03 -07:00
batman-adv.rst
bonding.rst bonding: Add independent control state machine 2024-02-06 13:17:54 +01:00
bridge.rst Documentation: update mailing list addresses 2024-02-21 13:44:21 -07:00
can_ucan_protocol.rst
can.rst can: bcm: add recvmsg flags for own, local and remote traffic 2024-02-12 16:55:17 +01:00
cdc_mbim.rst Documentation: networking: correct spelling 2023-01-31 13:00:47 +01:00
checksum-offloads.rst
dccp.rst
dctcp.rst
dns_resolver.rst dns_resolver: correct module name in dns resolver documentation 2024-03-26 10:15:36 +01:00
driver.rst
eql.rst
ethtool-netlink.rst ethtool: Extend cable testing interface with result source information 2024-08-26 09:33:58 -07:00
failover.rst
fib_trie.rst
filter.rst ARC: Add eBPF JIT support 2024-05-12 16:51:36 -07:00
gen_stats.rst
generic_netlink.rst
generic-hdlc.rst
gtp.rst
ieee802154.rst
ila.rst docs: networking: convert ila.txt to ReST 2020-04-28 14:39:47 -07:00
index.rst Documentation: networking: document phy_link_topology 2024-08-23 13:04:35 +01:00
ioam6-sysctl.rst
ip_dynaddr.rst docs: networking: convert ip_dynaddr.txt to ReST 2020-04-28 14:39:47 -07:00
ip-sysctl.rst Add support for PIO p flag 2024-07-31 13:49:48 +01:00
ipsec.rst docs: networking: convert ipsec.txt to ReST 2020-04-28 14:39:47 -07:00
ipv6.rst
ipvlan.rst
ipvs-sysctl.rst ipvs: run_estimation should control the kthread tasks 2022-12-10 22:44:43 +01:00
iso15765-2.rst Documentation: networking: document ISO 15765-2 2024-06-20 11:56:22 +02:00
j1939.rst
kapi.rst
kcm.rst
l2tp.rst documentation/networking: update l2tp docs 2024-08-11 04:38:49 +01:00
lapb-module.rst
mac80211-auth-assoc-deauth.txt
mac80211-injection.rst
mctp.rst
mpls-sysctl.rst
mptcp-sysctl.rst doc: mptcp: alphabetical order 2024-06-01 15:18:01 -07:00
mptcp.rst doc: new 'mptcp' page in 'networking' 2024-06-01 15:18:01 -07:00
msg_zerocopy.rst docs: net: description of MSG_ZEROCOPY for AF_VSOCK 2023-10-15 13:19:42 +01:00
multi-pf-netdev.rst docs: networking: Align documentation with behavior change 2024-08-16 14:29:44 -07:00
multiqueue.rst
napi.rst
net_dim.rst ethtool: provide customized dim profile management 2024-06-25 17:15:06 -07:00
net_failover.rst
netconsole.rst net: netconsole: Add continuation line prefix to userdata messages 2024-03-11 14:07:57 -07:00
netdev-features.rst netdev_features: convert NETIF_F_NETNS_LOCAL to dev->netns_local 2024-09-03 11:36:43 +02:00
netdevices.rst netdev_features: convert NETIF_F_LLTX to dev->lltx 2024-09-03 11:36:43 +02:00
netfilter-sysctl.rst
netif-msg.rst
nexthop-group-resilient.rst
nf_conntrack-sysctl.rst netfilter: conntrack: documentation: remove reference to non-existent sysctl 2024-05-06 16:29:21 +02:00
nf_flowtable.rst
nfc.rst
openvswitch.rst
operstates.rst
packet_mmap.rst mm, treewide: rename MAX_ORDER to MAX_PAGE_ORDER 2024-01-08 15:27:15 -08:00
page_pool.rst net: page_pool: expose page pool stats via netlink 2023-11-28 15:48:39 +01:00
phonet.rst
phy-link-topology.rst Documentation: networking: document phy_link_topology 2024-08-23 13:04:35 +01:00
phy.rst net: phy: introduce core support for phy-mode = "10g-qxgmii" 2024-06-18 13:28:26 +02:00
pktgen.rst
plip.rst
ppp_generic.rst
proc_net_tcp.rst
radiotap-headers.rst
rds.rst
regulatory.rst
representors.rst Documentation: Add documentation for eswitch attribute 2024-03-28 18:20:08 -07:00
rxrpc.rst
scaling.rst net: ethtool: add support for symmetric-xor RSS hash 2023-12-13 22:07:16 -08:00
sctp.rst
secid.rst
seg6-sysctl.rst
segmentation-offloads.rst
sfp-phylink.rst doc: sfp-phylink: update the porting guide with PCS handling 2024-03-07 15:27:05 +01:00
skbuff.rst
smc-sysctl.rst net/smc: add sysctl for max conns per lgr for SMC-R v2.1 2023-11-24 12:13:14 +00:00
snmp_counter.rst docs: automarkup: linkify git revs 2023-11-17 13:13:24 -07:00
sriov.rst docs: net: document guidance of implementing the SR-IOV NDOs 2024-06-21 10:18:45 +01:00
statistics.rst netdev: add per-queue statistics 2024-03-07 21:13:25 -08:00
strparser.rst
switchdev.rst netdev_features: convert NETIF_F_NETNS_LOCAL to dev->netns_local 2024-09-03 11:36:43 +02:00
sysfs-tagging.rst
tc-actions-env-rules.rst
tc-queue-filters.rst
tcp_ao.rst Documentation/tcp-ao: Add a few lines on tracepoints 2024-06-12 06:39:04 +01:00
tcp-thin.rst
team.rst docs: networking: convert team.txt to ReST 2020-04-30 12:56:38 -07:00
timestamping.rst docs: networking: timestamping: mention MSG_EOR flag 2023-12-13 18:19:39 -08:00
tipc.rst
tls-handshake.rst
tls-offload-layers.svg
tls-offload-reorder-bad.svg
tls-offload-reorder-good.svg
tls-offload.rst
tls.rst
tproxy.rst
tuntap.rst
udplite.rst
vrf.rst
vxlan.rst
x25-iface.rst
x25.rst
xdp-rx-metadata.rst xdp: Add VLAN tag hint 2023-12-13 16:16:40 -08:00
xfrm_device.rst xfrm: generalize xdo_dev_state_update_curlft to allow statistics update 2024-02-05 16:45:49 -08:00
xfrm_proc.rst xfrm: Add dir validation to "in" data path lookup 2024-05-01 10:06:27 +02:00
xfrm_sync.rst
xfrm_sysctl.rst docs: networking: convert xfrm_sysctl.txt to ReST 2020-05-01 12:24:41 -07:00
xsk-tx-metadata.rst xsk: Require XDP_UMEM_TX_METADATA_LEN to actuate tx_metadata_len 2024-07-25 11:57:27 +02:00