6ef34c09c6
https://source.android.com/docs/security/bulletin/2023-10-01
* tag 'ASB-2023-10-06_11-5.4' of https://android.googlesource.com/kernel/common:
UPSTREAM: arm64: efi: Make efi_rt_lock a raw_spinlock
UPSTREAM: net: sched: sch_qfq: Fix UAF in qfq_dequeue()
UPSTREAM: net/sched: sch_hfsc: Ensure inner classes have fsc curve
UPSTREAM: net/sched: sch_qfq: account for stab overhead in qfq_enqueue
UPSTREAM: netfilter: nf_tables: prevent OOB access in nft_byteorder_eval
UPSTREAM: af_unix: Fix null-ptr-deref in unix_stream_sendpage().
Linux 5.4.254
sch_netem: fix issues in netem_change() vs get_dist_table()
alpha: remove __init annotation from exported page_is_ram()
scsi: core: Fix possible memory leak if device_add() fails
scsi: snic: Fix possible memory leak if device_add() fails
scsi: 53c700: Check that command slot is not NULL
scsi: storvsc: Fix handling of virtual Fibre Channel timeouts
scsi: core: Fix legacy /proc parsing buffer overflow
netfilter: nf_tables: report use refcount overflow
nvme-rdma: fix potential unbalanced freeze & unfreeze
nvme-tcp: fix potential unbalanced freeze & unfreeze
btrfs: set cache_block_group_error if we find an error
btrfs: don't stop integrity writeback too early
ibmvnic: Handle DMA unmapping of login buffs in release functions
net/mlx5: Allow 0 for total host VFs
dmaengine: mcf-edma: Fix a potential un-allocated memory access
wifi: cfg80211: fix sband iftype data lookup for AP_VLAN
IB/hfi1: Fix possible panic during hotplug remove
drivers: net: prevent tun_build_skb() to exceed the packet size limit
dccp: fix data-race around dp->dccps_mss_cache
bonding: Fix incorrect deletion of ETH_P_8021AD protocol vid from slaves
net/packet: annotate data-races around tp->status
mISDN: Update parameter type of dsp_cmx_send()
selftests/rseq: Fix build with undefined __weak
drm/nouveau/disp: Revert a NULL check inside nouveau_connector_get_modes
x86: Move gds_ucode_mitigated() declaration to header
x86/mm: Fix VDSO and VVAR placement on 5-level paging machines
x86/cpu/amd: Enable Zenbleed fix for AMD Custom APU 0405
usb: common: usb-conn-gpio: Prevent bailing out if initial role is none
usb: dwc3: Properly handle processing of pending events
usb-storage: alauda: Fix uninit-value in alauda_check_media()
binder: fix memory leak in binder_init()
iio: cros_ec: Fix the allocation size for cros_ec_command
nilfs2: fix use-after-free of nilfs_root in dirtying inodes via iput
x86/pkeys: Revert a5eff72597
("x86/pkeys: Add PKRU value to init_fpstate")
radix tree test suite: fix incorrect allocation size for pthreads
drm/nouveau/gr: enable memory loads on helper invocation on all channels
dmaengine: pl330: Return DMA_PAUSED when transaction is paused
ipv6: adjust ndisc_is_useropt() to also return true for PIO
mmc: moxart: read scr register without changing byte order
Linux 5.4.253
Revert "driver core: Annotate dev_err_probe() with __must_check"
drivers: core: fix kernel-doc markup for dev_err_probe()
driver code: print symbolic error code
driver core: Annotate dev_err_probe() with __must_check
ARM: dts: nxp/imx6sll: fix wrong property name in usbphy node
ARM: dts: imx6sll: fixup of operating points
ARM: dts: imx: add usb alias
ARM: dts: imx: Align L2 cache-controller nodename with dtschema
ARM: dts: imx6sll: Make ssi node name same as other platforms
arm64: dts: stratix10: fix incorrect I2C property for SCL signal
ceph: defer stopping mdsc delayed_work
ceph: use kill_anon_super helper
ceph: show tasks waiting on caps in debugfs caps file
PM: sleep: wakeirq: fix wake irq arming
PM / wakeirq: support enabling wake-up irq after runtime_suspend called
selftests/rseq: Play nice with binaries statically linked against glibc 2.35+
selftests/rseq: check if libc rseq support is registered
powerpc/mm/altmap: Fix altmap boundary check
mtd: rawnand: omap_elm: Fix incorrect type in assignment
test_firmware: return ENOMEM instead of ENOSPC on failed memory allocation
test_firmware: prevent race conditions by a correct implementation of locking
ext2: Drop fragment support
fs: Protect reconfiguration of sb read-write from racing writes
net: usbnet: Fix WARNING in usbnet_start_xmit/usb_submit_urb
Bluetooth: L2CAP: Fix use-after-free in l2cap_sock_ready_cb
fs/sysv: Null check to prevent null-ptr-deref bug
net: tap_open(): set sk_uid from current_fsuid()
net: tun_chr_open(): set sk_uid from current_fsuid()
mtd: rawnand: meson: fix OOB available bytes for ECC
mtd: spinand: toshiba: Fix ecc_get_status
USB: zaurus: Add ID for A-300/B-500/C-700
libceph: fix potential hang in ceph_osdc_notify()
scsi: zfcp: Defer fc_rport blocking until after ADISC response
tcp_metrics: fix data-race in tcpm_suck_dst() vs fastopen
tcp_metrics: annotate data-races around tm->tcpm_net
tcp_metrics: annotate data-races around tm->tcpm_vals[]
tcp_metrics: annotate data-races around tm->tcpm_lock
tcp_metrics: annotate data-races around tm->tcpm_stamp
tcp_metrics: fix addr_same() helper
ip6mr: Fix skb_under_panic in ip6mr_cache_report()
net: dcb: choose correct policy to parse DCB_ATTR_BCN
net: ll_temac: fix error checking of irq_of_parse_and_map()
net: ll_temac: Switch to use dev_err_probe() helper
driver core: add device probe log helper
bpf: sockmap: Remove preempt_disable in sock_map_sk_acquire
net/sched: cls_route: No longer copy tcf_result on update to avoid use-after-free
net/sched: cls_fw: No longer copy tcf_result on update to avoid use-after-free
net/sched: cls_u32: No longer copy tcf_result on update to avoid use-after-free
net: add missing data-race annotation for sk_ll_usec
net: add missing data-race annotations around sk->sk_peek_off
net: add missing READ_ONCE(sk->sk_rcvbuf) annotation
net: add missing READ_ONCE(sk->sk_sndbuf) annotation
net: add missing READ_ONCE(sk->sk_rcvlowat) annotation
net: annotate data-races around sk->sk_max_pacing_rate
mISDN: hfcpci: Fix potential deadlock on &hc->lock
net: sched: cls_u32: Fix match key mis-addressing
perf test uprobe_from_different_cu: Skip if there is no gcc
rtnetlink: let rtnl_bridge_setlink checks IFLA_BRIDGE_MODE length
net/mlx5e: fix return value check in mlx5e_ipsec_remove_trailer()
net/mlx5: DR, fix memory leak in mlx5dr_cmd_create_reformat_ctx
KVM: s390: fix sthyi error handling
word-at-a-time: use the same return type for has_zero regardless of endianness
loop: Select I/O scheduler 'none' from inside add_disk()
perf: Fix function pointer case
arm64: Fix bit-shifting UB in the MIDR_CPU_MODEL() macro
arm64: Add AMPERE1 to the Spectre-BHB affected list
ASoC: cs42l51: fix driver to properly autoload with automatic module loading
net/sched: sch_qfq: account for stab overhead in qfq_enqueue
btrfs: fix race between quota disable and quota assign ioctls
btrfs: qgroup: return ENOTCONN instead of EINVAL when quotas are not enabled
btrfs: qgroup: remove one-time use variables for quota_root checks
cpufreq: intel_pstate: Drop ACPI _PSS states table patching
ACPI: processor: perflib: Avoid updating frequency QoS unnecessarily
ACPI: processor: perflib: Use the "no limit" frequency QoS
dm cache policy smq: ensure IO doesn't prevent cleaner policy progress
ASoC: wm8904: Fill the cache for WM8904_ADC_TEST_0 register
s390/dasd: fix hanging device after quiesce/resume
virtio-net: fix race between set queues and probe
btrfs: check if the transaction was aborted at btrfs_wait_for_commit()
irq-bcm6345-l1: Do not assume a fixed block to cpu mapping
tpm_tis: Explicitly check for error code
btrfs: check for commit error at btrfs_attach_transaction_barrier()
hwmon: (nct7802) Fix for temp6 (PECI1) processed even if PECI1 disabled
staging: ks7010: potential buffer overflow in ks_wlan_set_encode_ext()
Documentation: security-bugs.rst: clarify CVE handling
Documentation: security-bugs.rst: update preferences when dealing with the linux-distros group
Revert "usb: xhci: tegra: Fix error check"
usb: xhci-mtk: set the dma max_seg_size
USB: quirks: add quirk for Focusrite Scarlett
usb: ohci-at91: Fix the unhandle interrupt when resume
usb: dwc3: don't reset device side if dwc3 was configured as host-only
usb: dwc3: pci: skip BYT GPIO lookup table for hardwired phy
Revert "usb: dwc3: core: Enable AutoRetry feature in the controller"
can: gs_usb: gs_can_close(): add missing set of CAN state to CAN_STATE_STOPPED
USB: serial: simple: sort driver entries
USB: serial: simple: add Kaufmann RKS+CAN VCP
USB: serial: option: add Quectel EC200A module support
USB: serial: option: support Quectel EM060K_128
serial: sifive: Fix sifive_serial_console_setup() section
serial: 8250_dw: Preserve original value of DLF register
tracing: Fix warning in trace_buffered_event_disable()
ring-buffer: Fix wrong stat of cpu_buffer->read
ata: pata_ns87415: mark ns87560_tf_read static
dm raid: fix missing reconfig_mutex unlock in raid_ctr() error paths
block: Fix a source code comment in include/uapi/linux/blkzoned.h
ASoC: fsl_spdif: Silence output on stop
drm/msm: Fix IS_ERR_OR_NULL() vs NULL check in a5xx_submit_in_rb()
drm/msm/adreno: Fix snapshot BINDLESS_DATA size
drm/msm/dpu: drop enum dpu_core_perf_data_bus_id
RDMA/mlx4: Make check for invalid flags stricter
benet: fix return value check in be_lancer_xmit_workarounds()
net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
net/sched: mqprio: add extack to mqprio_parse_nlattr()
net/sched: mqprio: refactor nlattr parsing to a separate function
platform/x86: msi-laptop: Fix rfkill out-of-sync on MSI Wind U100
team: reset team's flags when down link is P2P device
bonding: reset bond's flags when down link is P2P device
tcp: Reduce chance of collisions in inet6_hashfn().
ipv6 addrconf: fix bug where deleting a mngtmpaddr can create a new temporary address
ethernet: atheros: fix return value check in atl1e_tso_csum()
phy: hisilicon: Fix an out of bounds check in hisi_inno_phy_probe()
vxlan: calculate correct header length for GPE
i40e: Fix an NULL vs IS_ERR() bug for debugfs_create_dir()
ext4: fix to check return value of freeze_bdev() in ext4_shutdown()
keys: Fix linking a duplicate key to a keyring's assoc_array
uapi: General notification queue definitions
scsi: qla2xxx: Array index may go out of bound
scsi: qla2xxx: Fix inconsistent format argument type in qla_os.c
pwm: meson: fix handling of period/duty if greater than UINT_MAX
pwm: meson: Simplify duplicated per-channel tracking
pwm: meson: Remove redundant assignment to variable fin_freq
ftrace: Fix possible warning on checking all pages used in ftrace_process_locs()
ftrace: Store the order of pages allocated in ftrace_page
ftrace: Check if pages were allocated before calling free_pages()
ftrace: Add information on number of page groups allocated
fs: dlm: interrupt posix locks only when process is killed
dlm: rearrange async condition return
dlm: cleanup plock_op vs plock_xop
PCI/ASPM: Avoid link retraining race
PCI/ASPM: Factor out pcie_wait_for_retrain()
PCI/ASPM: Return 0 or -ETIMEDOUT from pcie_retrain_link()
ext4: Fix reusing stale buffer heads from last failed mounting
ext4: rename journal_dev to s_journal_dev inside ext4_sb_info
btrfs: fix extent buffer leak after tree mod log failure at split_node()
btrfs: fix race between quota disable and relocation
btrfs: qgroup: catch reserved space leaks at unmount time
bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent
bcache: remove 'int n' from parameter list of bch_bucket_alloc_set()
gpio: tps68470: Make tps68470_gpio_output() always set the initial value
jbd2: Fix wrongly judgement for buffer head removing while doing checkpoint
jbd2: recheck chechpointing non-dirty buffer
jbd2: remove redundant buffer io error checks
jbd2: fix kernel-doc markups
jbd2: fix incorrect code style
Linux 5.4.252
x86: fix backwards merge of GDS/SRSO bit
xen/netback: Fix buffer overrun triggered by unusual packet
x86/cpu, kvm: Add support for CPUID_80000021_EAX
x86/bugs: Increase the x86 bugs vector size to two u32s
tools headers cpufeatures: Sync with the kernel sources
x86/cpufeatures: Assign dedicated feature word for CPUID_0x8000001F[EAX]
x86/cpu: Add VM page flush MSR availablility as a CPUID feature
x86/cpufeatures: Add SEV-ES CPU feature
Documentation/x86: Fix backwards on/off logic about YMM support
x86/mm: Initialize text poking earlier
mm: Move mm_cachep initialization to mm_init()
x86/mm: Use mm_alloc() in poking_init()
x86/mm: fix poking_init() for Xen PV guests
x86/xen: Fix secondary processors' FPU initialization
KVM: Add GDS_NO support to KVM
x86/speculation: Add Kconfig option for GDS
x86/speculation: Add force option to GDS mitigation
x86/speculation: Add Gather Data Sampling mitigation
x86/fpu: Move FPU initialization into arch_cpu_finalize_init()
x86/fpu: Mark init functions __init
x86/fpu: Remove cpuinfo argument from init functions
init, x86: Move mem_encrypt_init() into arch_cpu_finalize_init()
init: Invoke arch_cpu_finalize_init() earlier
init: Remove check_bugs() leftovers
um/cpu: Switch to arch_cpu_finalize_init()
sparc/cpu: Switch to arch_cpu_finalize_init()
sh/cpu: Switch to arch_cpu_finalize_init()
mips/cpu: Switch to arch_cpu_finalize_init()
m68k/cpu: Switch to arch_cpu_finalize_init()
ia64/cpu: Switch to arch_cpu_finalize_init()
ARM: cpu: Switch to arch_cpu_finalize_init()
x86/cpu: Switch to arch_cpu_finalize_init()
init: Provide arch_cpu_finalize_init()
Revert "posix-timers: Ensure timer ID search-loop limit is valid"
Revert "drm/panel: Initialise panel dev and funcs through drm_panel_init()"
Revert "drm/panel: Add and fill drm_panel type field"
Revert "drm/panel: simple: Add connector_type for innolux_at043tn24"
Revert "Revert "8250: add support for ASIX devices with a FIFO bug""
Linux 5.4.251
tracing/histograms: Return an error if we fail to add histogram to hist_vars list
tcp: annotate data-races around fastopenq.max_qlen
tcp: annotate data-races around tp->notsent_lowat
tcp: annotate data-races around rskq_defer_accept
tcp: annotate data-races around tp->linger2
net: Replace the limit of TCP_LINGER2 with TCP_FIN_TIMEOUT_MAX
tcp: annotate data-races around tp->tcp_tx_delay
netfilter: nf_tables: can't schedule in nft_chain_validate
netfilter: nf_tables: fix spurious set element insertion failure
llc: Don't drop packet from non-root netns.
fbdev: au1200fb: Fix missing IRQ check in au1200fb_drv_probe
Revert "tcp: avoid the lookup process failing to get sk in ehash table"
net:ipv6: check return value of pskb_trim()
iavf: Fix use-after-free in free_netdev
net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()/cpsw_ale_set_field()
pinctrl: amd: Use amd_pinconf_set() for all config options
fbdev: imxfb: warn about invalid left/right margin
spi: bcm63xx: fix max prepend length
igb: Fix igb_down hung on surprise removal
wifi: iwlwifi: mvm: avoid baid size integer overflow
wifi: wext-core: Fix -Wstringop-overflow warning in ioctl_standard_iw_point()
devlink: report devlink_port_type_warn source device
bpf: Address KCSAN report on bpf_lru_list
sched/fair: Don't balance task to its current running CPU
arm64: mm: fix VA-range sanity check
posix-timers: Ensure timer ID search-loop limit is valid
md/raid10: prevent soft lockup while flush writes
md: fix data corruption for raid456 when reshape restart while grow up
nbd: Add the maximum limit of allocated index in nbd_dev_add
debugobjects: Recheck debug_objects_enabled before reporting
ext4: correct inline offset when handling xattrs in inode body
drm/client: Fix memory leak in drm_client_modeset_probe
drm/client: Fix memory leak in drm_client_target_cloned
can: bcm: Fix UAF in bcm_proc_show()
selftests: tc: set timeout to 15 minutes
fuse: revalidate: don't invalidate if interrupted
btrfs: fix warning when putting transaction with qgroups enabled after abort
perf probe: Add test for regression introduced by switch to die_get_decl_file()
drm/atomic: Fix potential use-after-free in nonblocking commits
scsi: qla2xxx: Remove unused nvme_ls_waitq wait queue
scsi: qla2xxx: Pointer may be dereferenced
scsi: qla2xxx: Correct the index of array
scsi: qla2xxx: Check valid rport returned by fc_bsg_to_rport()
scsi: qla2xxx: Fix potential NULL pointer dereference
scsi: qla2xxx: Wait for io return on terminate rport
tracing/probes: Fix not to count error code to total length
tracing: Fix null pointer dereference in tracing_err_log_open()
xtensa: ISS: fix call to split_if_spec
ring-buffer: Fix deadloop issue on reading trace_pipe
tracing/histograms: Add histograms to hist_vars if they have referenced variables
tty: serial: samsung_tty: Fix a memory leak in s3c24xx_serial_getclk() when iterating clk
tty: serial: samsung_tty: Fix a memory leak in s3c24xx_serial_getclk() in case of error
Revert "8250: add support for ASIX devices with a FIFO bug"
meson saradc: fix clock divider mask length
ceph: don't let check_caps skip sending responses for revoke msgs
hwrng: imx-rngc - fix the timeout for init and self check
firmware: stratix10-svc: Fix a potential resource leak in svc_create_memory_pool()
serial: atmel: don't enable IRQs prematurely
drm/rockchip: vop: Leave vblank enabled in self-refresh
drm/atomic: Allow vblank-enabled + self-refresh "disable"
fs: dlm: return positive pid value for F_GETLK
md/raid0: add discard support for the 'original' layout
misc: pci_endpoint_test: Re-init completion for every test
misc: pci_endpoint_test: Free IRQs before removing the device
PCI: rockchip: Set address alignment for endpoint mode
PCI: rockchip: Use u32 variable to access 32-bit registers
PCI: rockchip: Fix legacy IRQ generation for RK3399 PCIe endpoint core
PCI: rockchip: Add poll and timeout to wait for PHY PLLs to be locked
PCI: rockchip: Write PCI Device ID to correct register
PCI: rockchip: Assert PCI Configuration Enable bit after probe
PCI: qcom: Disable write access to read only registers for IP v2.3.3
PCI: Add function 1 DMA alias quirk for Marvell 88SE9235
PCI/PM: Avoid putting EloPOS E2/S2/H2 PCIe Ports in D3cold
jfs: jfs_dmap: Validate db_l2nbperpage while mounting
ext4: only update i_reserved_data_blocks on successful block allocation
ext4: fix wrong unit use in ext4_mb_clear_bb
erofs: fix compact 4B support for 16k block size
SUNRPC: Fix UAF in svc_tcp_listen_data_ready()
misc: fastrpc: Create fastrpc scalar with correct buffer count
powerpc: Fail build if using recordmcount with binutils v2.37
net: bcmgenet: Ensure MDIO unregistration has clocks enabled
mtd: rawnand: meson: fix unaligned DMA buffers handling
tpm: tpm_vtpm_proxy: fix a race condition in /dev/vtpmx creation
pinctrl: amd: Only use special debounce behavior for GPIO 0
pinctrl: amd: Detect internal GPIO0 debounce handling
pinctrl: amd: Fix mistake in handling clearing pins at startup
net/sched: make psched_mtu() RTNL-less safe
net/sched: flower: Ensure both minimum and maximum ports are specified
cls_flower: Add extack support for src and dst port range options
wifi: airo: avoid uninitialized warning in airo_get_rate()
erofs: avoid infinite loop in z_erofs_do_read_page() when reading beyond EOF
platform/x86: wmi: Break possible infinite loop when parsing GUID
platform/x86: wmi: move variables
platform/x86: wmi: use guid_t and guid_equal()
platform/x86: wmi: remove unnecessary argument
platform/x86: wmi: Fix indentation in some cases
platform/x86: wmi: Replace UUID redefinitions by their originals
ipv6/addrconf: fix a potential refcount underflow for idev
NTB: ntb_tool: Add check for devm_kcalloc
NTB: ntb_transport: fix possible memory leak while device_register() fails
ntb: intel: Fix error handling in intel_ntb_pci_driver_init()
NTB: amd: Fix error handling in amd_ntb_pci_driver_init()
ntb: idt: Fix error handling in idt_pci_driver_init()
udp6: fix udp6_ehashfn() typo
icmp6: Fix null-ptr-deref of ip6_null_entry->rt6i_idev in icmp6_dev().
ionic: remove WARN_ON to prevent panic_on_warn
ionic: ionic_intr_free parameter change
ionic: move irq request to qcq alloc
ionic: clean irq affinity on queue deinit
ionic: improve irq numa locality
net/sched: cls_fw: Fix improper refcount update leads to use-after-free
net: mvneta: fix txq_map in case of txq_number==1
scsi: qla2xxx: Fix error code in qla2x00_start_sp()
igc: set TP bit in 'supported' and 'advertising' fields of ethtool_link_ksettings
igc: Remove delay during TX ring configuration
drm/panel: simple: Add connector_type for innolux_at043tn24
drm/panel: Add and fill drm_panel type field
drm/panel: Initialise panel dev and funcs through drm_panel_init()
workqueue: clean up WORK_* constant types, clarify masking
net: lan743x: Don't sleep in atomic context
block/partition: fix signedness issue for Amiga partitions
tty: serial: fsl_lpuart: add earlycon for imx8ulp platform
netfilter: nf_tables: prevent OOB access in nft_byteorder_eval
netfilter: conntrack: Avoid nf_ct_helper_hash uses after free
netfilter: nf_tables: fix scheduling-while-atomic splat
netfilter: nf_tables: unbind non-anonymous set if rule construction fails
netfilter: nf_tables: reject unbound anonymous set before commit phase
netfilter: nf_tables: add NFT_TRANS_PREPARE_ERROR to deal with bound set/chain
netfilter: nf_tables: incorrect error path handling with NFT_MSG_NEWRULE
netfilter: nf_tables: add rescheduling points during loop detection walks
netfilter: nf_tables: use net_generic infra for transaction data
netfilter: add helper function to set up the nfnetlink header and use it
netfilter: nftables: add helper function to set the base sequence number
netfilter: nf_tables: fix nat hook table deletion
block: add overflow checks for Amiga partition support
fanotify: disallow mount/sb marks on kernel internal pseudo fs
fs: no need to check source
ARM: orion5x: fix d2net gpio initialization
btrfs: fix race when deleting quota root from the dirty cow roots list
fs: Lock moved directories
fs: Establish locking order for unrelated directories
Revert "f2fs: fix potential corruption when moving a directory"
ext4: Remove ext4 locking of moved directory
fs: avoid empty option when generating legacy mount string
jffs2: reduce stack usage in jffs2_build_xattr_subsystem()
integrity: Fix possible multiple allocation in integrity_inode_get()
bcache: Remove unnecessary NULL point check in node allocations
mmc: sdhci: fix DMA configure compatibility issue when 64bit DMA mode is used.
mmc: core: disable TRIM on Micron MTFC4GACAJCN-1M
mmc: core: disable TRIM on Kingston EMMC04G-M627
NFSD: add encoding of op_recall flag for write delegation
ALSA: jack: Fix mutex call in snd_jack_report()
i2c: xiic: Don't try to handle more interrupt events after error
i2c: xiic: Defer xiic_wakeup() and __xiic_start_xfer() in xiic_process()
sh: dma: Fix DMA channel offset calculation
net: dsa: tag_sja1105: fix MAC DA patching from meta frames
net/sched: act_pedit: Add size check for TCA_PEDIT_PARMS_EX
xsk: Honor SO_BINDTODEVICE on bind
xsk: Improve documentation for AF_XDP
tcp: annotate data races in __tcp_oow_rate_limited()
net: bridge: keep ports without IFF_UNICAST_FLT in BR_PROMISC mode
powerpc: allow PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y
f2fs: fix error path handling in truncate_dnode()
mailbox: ti-msgmgr: Fill non-message tx data fields with 0x0
spi: bcm-qspi: return error if neither hif_mspi nor mspi is available
Add MODULE_FIRMWARE() for FIRMWARE_TG357766.
sctp: fix potential deadlock on &net->sctp.addr_wq_lock
rtc: st-lpc: Release some resources in st_rtc_probe() in case of error
pwm: sysfs: Do not apply state to already disabled PWMs
pwm: imx-tpm: force 'real_period' to be zero in suspend
mfd: stmpe: Only disable the regulators if they are enabled
KVM: s390: vsie: fix the length of APCB bitmap
mfd: stmfx: Fix error path in stmfx_chip_init
serial: 8250_omap: Use force_suspend and resume for system suspend
mfd: intel-lpss: Add missing check for platform_get_resource
usb: dwc3: qcom: Release the correct resources in dwc3_qcom_remove()
KVM: s390: fix KVM_S390_GET_CMMA_BITS for GFNs in memslot holes
mfd: rt5033: Drop rt5033-battery sub-device
usb: hide unused usbfs_notify_suspend/resume functions
usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
extcon: Fix kernel doc of property capability fields to avoid warnings
extcon: Fix kernel doc of property fields to avoid warnings
usb: dwc3: qcom: Fix potential memory leak
media: usb: siano: Fix warning due to null work_func_t function pointer
media: videodev2.h: Fix struct v4l2_input tuner index comment
media: usb: Check az6007_read() return value
sh: j2: Use ioremap() to translate device tree address into kernel memory
w1: fix loop in w1_fini()
block: change all __u32 annotations to __be32 in affs_hardblocks.h
block: fix signed int overflow in Amiga partition support
usb: dwc3: gadget: Propagate core init errors to UDC during pullup
USB: serial: option: add LARA-R6 01B PIDs
hwrng: st - keep clock enabled while hwrng is registered
hwrng: st - Fix W=1 unused variable warning
NFSv4.1: freeze the session table upon receiving NFS4ERR_BADSESSION
ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard
modpost: fix off by one in is_executable_section()
crypto: marvell/cesa - Fix type mismatch warning
modpost: fix section mismatch message for R_ARM_{PC24,CALL,JUMP24}
modpost: fix section mismatch message for R_ARM_ABS32
crypto: nx - fix build warnings when DEBUG_FS is not enabled
hwrng: virtio - Fix race on data_avail and actual data
hwrng: virtio - always add a pending request
hwrng: virtio - don't waste entropy
hwrng: virtio - don't wait on cleanup
hwrng: virtio - add an internal buffer
powerpc/mm/dax: Fix the condition when checking if altmap vmemap can cross-boundary
pinctrl: at91-pio4: check return value of devm_kasprintf()
perf dwarf-aux: Fix off-by-one in die_get_varname()
pinctrl: cherryview: Return correct value if pin in push-pull mode
PCI: Add pci_clear_master() stub for non-CONFIG_PCI
PCI: ftpci100: Release the clock resources
PCI: pciehp: Cancel bringup sequence if card is not present
scsi: 3w-xxxx: Add error handling for initialization failure in tw_probe()
PCI/ASPM: Disable ASPM on MFD function removal to avoid use-after-free
scsi: qedf: Fix NULL dereference in error handling
ASoC: imx-audmix: check return value of devm_kasprintf()
clk: keystone: sci-clk: check return value of kasprintf()
clk: cdce925: check return value of kasprintf()
ALSA: ac97: Fix possible NULL dereference in snd_ac97_mixer
clk: tegra: tegra124-emc: Fix potential memory leak
drm/radeon: fix possible division-by-zero errors
drm/amdkfd: Fix potential deallocation of previously deallocated memory.
fbdev: omapfb: lcd_mipid: Fix an error handling path in mipid_spi_probe()
arm64: dts: renesas: ulcb-kf: Remove flow control for SCIF1
IB/hfi1: Fix sdma.h tx->num_descs off-by-one errors
soc/fsl/qe: fix usb.c build errors
ASoC: es8316: Do not set rate constraints for unsupported MCLKs
ASoC: es8316: Increment max value for ALC Capture Target Volume control
memory: brcmstb_dpfe: fix testing array offset after use
ARM: ep93xx: fix missing-prototype warnings
drm/panel: simple: fix active size for Ampire AM-480272H3TMQW-T01H
arm64: dts: qcom: msm8916: correct camss unit address
ARM: dts: gta04: Move model property out of pinctrl node
RDMA/bnxt_re: Fix to remove an unnecessary log
drm: sun4i_tcon: use devm_clk_get_enabled in `sun4i_tcon_init_clocks`
Input: adxl34x - do not hardcode interrupt trigger type
ARM: dts: BCM5301X: Drop "clock-names" from the SPI node
Input: drv260x - sleep between polling GO bit
radeon: avoid double free in ci_dpm_init()
netlink: Add __sock_i_ino() for __netlink_diag_dump().
ipvlan: Fix return value of ipvlan_queue_xmit()
netfilter: nf_conntrack_sip: fix the ct_sip_parse_numerical_param() return value.
netfilter: conntrack: dccp: copy entire header to stack buffer, not just basic one
lib/ts_bm: reset initial match offset for every block of text
net: nfc: Fix use-after-free caused by nfc_llcp_find_local
nfc: llcp: simplify llcp_sock_connect() error paths
gtp: Fix use-after-free in __gtp_encap_destroy().
selftests: rtnetlink: remove netdevsim device after ipsec offload test
netlink: do not hard code device address lenth in fdb dumps
netlink: fix potential deadlock in netlink_set_err()
wifi: ath9k: convert msecs to jiffies where needed
wifi: cfg80211: rewrite merging of inherited elements
wifi: iwlwifi: pull from TXQs with softirqs disabled
rtnetlink: extend RTEXT_FILTER_SKIP_STATS to IFLA_VF_INFO
wifi: ath9k: Fix possible stall on ath9k_txq_list_has_key()
memstick r592: make memstick_debug_get_tpc_name() static
kexec: fix a memory leak in crash_shrink_memory()
watchdog/perf: more properly prevent false positives with turbo modes
watchdog/perf: define dummy watchdog_update_hrtimer_threshold() on correct config
wifi: rsi: Do not set MMC_PM_KEEP_POWER in shutdown
wifi: ath9k: don't allow to overwrite ENDPOINT0 attributes
wifi: ray_cs: Fix an error handling path in ray_probe()
wifi: ray_cs: Drop useless status variable in parse_addr()
wifi: ray_cs: Utilize strnlen() in parse_addr()
wifi: wl3501_cs: Fix an error handling path in wl3501_probe()
wl3501_cs: use eth_hw_addr_set()
net: create netdev->dev_addr assignment helpers
wl3501_cs: Fix misspelling and provide missing documentation
wl3501_cs: Remove unnecessary NULL check
wl3501_cs: Fix a bunch of formatting issues related to function docs
wifi: atmel: Fix an error handling path in atmel_probe()
wifi: orinoco: Fix an error handling path in orinoco_cs_probe()
wifi: orinoco: Fix an error handling path in spectrum_cs_probe()
regulator: core: Streamline debugfs operations
regulator: core: Fix more error checking for debugfs_create_dir()
nfc: llcp: fix possible use of uninitialized variable in nfc_llcp_send_connect()
nfc: constify several pointers to u8, char and sk_buff
wifi: mwifiex: Fix the size of a memory allocation in mwifiex_ret_802_11_scan()
spi: spi-geni-qcom: Correct CS_TOGGLE bit in SPI_TRANS_CFG
samples/bpf: Fix buffer overflow in tcp_basertt
wifi: ath9k: avoid referencing uninit memory in ath9k_wmi_ctrl_rx
wifi: ath9k: fix AR9003 mac hardware hang check register offset calculation
ima: Fix build warnings
pstore/ram: Add check for kstrdup
evm: Complete description of evm_inode_setattr()
ARM: 9303/1: kprobes: avoid missing-declaration warnings
powercap: RAPL: Fix CONFIG_IOSF_MBI dependency
PM: domains: fix integer overflow issues in genpd_parse_state()
clocksource/drivers/cadence-ttc: Fix memory leak in ttc_timer_probe
clocksource/drivers/cadence-ttc: Use ttc driver as platform driver
tracing/timer: Add missing hrtimer modes to decode_hrtimer_mode().
irqchip/jcore-aic: Fix missing allocation of IRQ descriptors
irqchip/jcore-aic: Kill use of irq_create_strict_mappings()
md/raid10: fix io loss while replacement replace rdev
md/raid10: fix null-ptr-deref of mreplace in raid10_sync_request
md/raid10: fix wrong setting of max_corr_read_errors
md/raid10: fix overflow of md/safe_mode_delay
md/raid10: check slab-out-of-bounds in md_bitmap_get_counter
x86/resctrl: Only show tasks' pid in current pid namespace
x86/resctrl: Use is_closid_match() in more places
bgmac: fix *initial* chip reset to support BCM5358
drm/amdgpu: Validate VM ioctl flags.
scripts/tags.sh: Resolve gtags empty index generation
drm/i915: Initialise outparam for error return from wait_for_register
HID: wacom: Use ktime_t rather than int when dealing with timestamps
fbdev: imsttfb: Fix use after free bug in imsttfb_probe
video: imsttfb: check for ioremap() failures
x86/smp: Use dedicated cache-line for mwait_play_dead()
gfs2: Don't deref jdesc in evict
Linux 5.4.250
x86/cpu/amd: Add a Zenbleed fix
x86/cpu/amd: Move the errata checking functionality up
x86/microcode/AMD: Load late on both threads too
Conflicts:
drivers/usb/dwc3/gadget.c
Change-Id: Ibd4bab8255496e4640f2eaf4eb7836209dd7cbfb
811 lines
18 KiB
C
811 lines
18 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Userspace interface
|
|
* Linux ethernet bridge
|
|
*
|
|
* Authors:
|
|
* Lennert Buytenhek <buytenh@gnu.org>
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/etherdevice.h>
|
|
#include <linux/netpoll.h>
|
|
#include <linux/ethtool.h>
|
|
#include <linux/if_arp.h>
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/rtnetlink.h>
|
|
#include <linux/if_ether.h>
|
|
#include <linux/slab.h>
|
|
#include <net/dsa.h>
|
|
#include <net/sock.h>
|
|
#include <linux/if_vlan.h>
|
|
#include <net/switchdev.h>
|
|
#include <net/net_namespace.h>
|
|
|
|
#include "br_private.h"
|
|
|
|
/*
|
|
* Determine initial path cost based on speed.
|
|
* using recommendations from 802.1d standard
|
|
*
|
|
* Since driver might sleep need to not be holding any locks.
|
|
*/
|
|
static int port_cost(struct net_device *dev)
|
|
{
|
|
struct ethtool_link_ksettings ecmd;
|
|
|
|
if (!__ethtool_get_link_ksettings(dev, &ecmd)) {
|
|
switch (ecmd.base.speed) {
|
|
case SPEED_10000:
|
|
return 2;
|
|
case SPEED_1000:
|
|
return 4;
|
|
case SPEED_100:
|
|
return 19;
|
|
case SPEED_10:
|
|
return 100;
|
|
}
|
|
}
|
|
|
|
/* Old silly heuristics based on name */
|
|
if (!strncmp(dev->name, "lec", 3))
|
|
return 7;
|
|
|
|
if (!strncmp(dev->name, "plip", 4))
|
|
return 2500;
|
|
|
|
return 100; /* assume old 10Mbps */
|
|
}
|
|
|
|
|
|
/* Check for port carrier transitions. */
|
|
void br_port_carrier_check(struct net_bridge_port *p, bool *notified)
|
|
{
|
|
struct net_device *dev = p->dev;
|
|
struct net_bridge *br = p->br;
|
|
|
|
if (!(p->flags & BR_ADMIN_COST) &&
|
|
netif_running(dev) && netif_oper_up(dev))
|
|
p->path_cost = port_cost(dev);
|
|
|
|
*notified = false;
|
|
if (!netif_running(br->dev))
|
|
return;
|
|
|
|
spin_lock_bh(&br->lock);
|
|
if (netif_running(dev) && netif_oper_up(dev)) {
|
|
if (p->state == BR_STATE_DISABLED) {
|
|
br_stp_enable_port(p);
|
|
*notified = true;
|
|
}
|
|
} else {
|
|
if (p->state != BR_STATE_DISABLED) {
|
|
br_stp_disable_port(p);
|
|
*notified = true;
|
|
}
|
|
}
|
|
spin_unlock_bh(&br->lock);
|
|
}
|
|
|
|
static void br_port_set_promisc(struct net_bridge_port *p)
|
|
{
|
|
int err = 0;
|
|
|
|
if (br_promisc_port(p))
|
|
return;
|
|
|
|
err = dev_set_promiscuity(p->dev, 1);
|
|
if (err)
|
|
return;
|
|
|
|
br_fdb_unsync_static(p->br, p);
|
|
p->flags |= BR_PROMISC;
|
|
}
|
|
|
|
static void br_port_clear_promisc(struct net_bridge_port *p)
|
|
{
|
|
int err;
|
|
|
|
/* Check if the port is already non-promisc or if it doesn't
|
|
* support UNICAST filtering. Without unicast filtering support
|
|
* we'll end up re-enabling promisc mode anyway, so just check for
|
|
* it here.
|
|
*/
|
|
if (!br_promisc_port(p) || !(p->dev->priv_flags & IFF_UNICAST_FLT))
|
|
return;
|
|
|
|
/* Since we'll be clearing the promisc mode, program the port
|
|
* first so that we don't have interruption in traffic.
|
|
*/
|
|
err = br_fdb_sync_static(p->br, p);
|
|
if (err)
|
|
return;
|
|
|
|
dev_set_promiscuity(p->dev, -1);
|
|
p->flags &= ~BR_PROMISC;
|
|
}
|
|
|
|
/* When a port is added or removed or when certain port flags
|
|
* change, this function is called to automatically manage
|
|
* promiscuity setting of all the bridge ports. We are always called
|
|
* under RTNL so can skip using rcu primitives.
|
|
*/
|
|
void br_manage_promisc(struct net_bridge *br)
|
|
{
|
|
struct net_bridge_port *p;
|
|
bool set_all = false;
|
|
|
|
/* If vlan filtering is disabled or bridge interface is placed
|
|
* into promiscuous mode, place all ports in promiscuous mode.
|
|
*/
|
|
if ((br->dev->flags & IFF_PROMISC) || !br_vlan_enabled(br->dev))
|
|
set_all = true;
|
|
|
|
list_for_each_entry(p, &br->port_list, list) {
|
|
if (set_all) {
|
|
br_port_set_promisc(p);
|
|
} else {
|
|
/* If the number of auto-ports is <= 1, then all other
|
|
* ports will have their output configuration
|
|
* statically specified through fdbs. Since ingress
|
|
* on the auto-port becomes forwarding/egress to other
|
|
* ports and egress configuration is statically known,
|
|
* we can say that ingress configuration of the
|
|
* auto-port is also statically known.
|
|
* This lets us disable promiscuous mode and write
|
|
* this config to hw.
|
|
*/
|
|
if ((p->dev->priv_flags & IFF_UNICAST_FLT) &&
|
|
(br->auto_cnt == 0 ||
|
|
(br->auto_cnt == 1 && br_auto_port(p))))
|
|
br_port_clear_promisc(p);
|
|
else
|
|
br_port_set_promisc(p);
|
|
}
|
|
}
|
|
}
|
|
|
|
int nbp_backup_change(struct net_bridge_port *p,
|
|
struct net_device *backup_dev)
|
|
{
|
|
struct net_bridge_port *old_backup = rtnl_dereference(p->backup_port);
|
|
struct net_bridge_port *backup_p = NULL;
|
|
|
|
ASSERT_RTNL();
|
|
|
|
if (backup_dev) {
|
|
if (!netif_is_bridge_port(backup_dev))
|
|
return -ENOENT;
|
|
|
|
backup_p = br_port_get_rtnl(backup_dev);
|
|
if (backup_p->br != p->br)
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (p == backup_p)
|
|
return -EINVAL;
|
|
|
|
if (old_backup == backup_p)
|
|
return 0;
|
|
|
|
/* if the backup link is already set, clear it */
|
|
if (old_backup)
|
|
old_backup->backup_redirected_cnt--;
|
|
|
|
if (backup_p)
|
|
backup_p->backup_redirected_cnt++;
|
|
rcu_assign_pointer(p->backup_port, backup_p);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void nbp_backup_clear(struct net_bridge_port *p)
|
|
{
|
|
nbp_backup_change(p, NULL);
|
|
if (p->backup_redirected_cnt) {
|
|
struct net_bridge_port *cur_p;
|
|
|
|
list_for_each_entry(cur_p, &p->br->port_list, list) {
|
|
struct net_bridge_port *backup_p;
|
|
|
|
backup_p = rtnl_dereference(cur_p->backup_port);
|
|
if (backup_p == p)
|
|
nbp_backup_change(cur_p, NULL);
|
|
}
|
|
}
|
|
|
|
WARN_ON(rcu_access_pointer(p->backup_port) || p->backup_redirected_cnt);
|
|
}
|
|
|
|
static void nbp_update_port_count(struct net_bridge *br)
|
|
{
|
|
struct net_bridge_port *p;
|
|
u32 cnt = 0;
|
|
|
|
list_for_each_entry(p, &br->port_list, list) {
|
|
if (br_auto_port(p))
|
|
cnt++;
|
|
}
|
|
if (br->auto_cnt != cnt) {
|
|
br->auto_cnt = cnt;
|
|
br_manage_promisc(br);
|
|
}
|
|
}
|
|
|
|
static void nbp_delete_promisc(struct net_bridge_port *p)
|
|
{
|
|
/* If port is currently promiscuous, unset promiscuity.
|
|
* Otherwise, it is a static port so remove all addresses
|
|
* from it.
|
|
*/
|
|
dev_set_allmulti(p->dev, -1);
|
|
if (br_promisc_port(p))
|
|
dev_set_promiscuity(p->dev, -1);
|
|
else
|
|
br_fdb_unsync_static(p->br, p);
|
|
}
|
|
|
|
static void release_nbp(struct kobject *kobj)
|
|
{
|
|
struct net_bridge_port *p
|
|
= container_of(kobj, struct net_bridge_port, kobj);
|
|
kfree(p);
|
|
}
|
|
|
|
static void brport_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid)
|
|
{
|
|
struct net_bridge_port *p = kobj_to_brport(kobj);
|
|
|
|
net_ns_get_ownership(dev_net(p->dev), uid, gid);
|
|
}
|
|
|
|
static struct kobj_type brport_ktype = {
|
|
#ifdef CONFIG_SYSFS
|
|
.sysfs_ops = &brport_sysfs_ops,
|
|
#endif
|
|
.release = release_nbp,
|
|
.get_ownership = brport_get_ownership,
|
|
};
|
|
|
|
static void destroy_nbp(struct net_bridge_port *p)
|
|
{
|
|
struct net_device *dev = p->dev;
|
|
|
|
p->br = NULL;
|
|
p->dev = NULL;
|
|
dev_put(dev);
|
|
|
|
kobject_put(&p->kobj);
|
|
}
|
|
|
|
static void destroy_nbp_rcu(struct rcu_head *head)
|
|
{
|
|
struct net_bridge_port *p =
|
|
container_of(head, struct net_bridge_port, rcu);
|
|
destroy_nbp(p);
|
|
}
|
|
|
|
static unsigned get_max_headroom(struct net_bridge *br)
|
|
{
|
|
unsigned max_headroom = 0;
|
|
struct net_bridge_port *p;
|
|
|
|
list_for_each_entry(p, &br->port_list, list) {
|
|
unsigned dev_headroom = netdev_get_fwd_headroom(p->dev);
|
|
|
|
if (dev_headroom > max_headroom)
|
|
max_headroom = dev_headroom;
|
|
}
|
|
|
|
return max_headroom;
|
|
}
|
|
|
|
static void update_headroom(struct net_bridge *br, int new_hr)
|
|
{
|
|
struct net_bridge_port *p;
|
|
|
|
list_for_each_entry(p, &br->port_list, list)
|
|
netdev_set_rx_headroom(p->dev, new_hr);
|
|
|
|
br->dev->needed_headroom = new_hr;
|
|
}
|
|
|
|
/* Delete port(interface) from bridge is done in two steps.
|
|
* via RCU. First step, marks device as down. That deletes
|
|
* all the timers and stops new packets from flowing through.
|
|
*
|
|
* Final cleanup doesn't occur until after all CPU's finished
|
|
* processing packets.
|
|
*
|
|
* Protected from multiple admin operations by RTNL mutex
|
|
*/
|
|
static void del_nbp(struct net_bridge_port *p)
|
|
{
|
|
struct net_bridge *br = p->br;
|
|
struct net_device *dev = p->dev;
|
|
|
|
sysfs_remove_link(br->ifobj, p->dev->name);
|
|
|
|
nbp_delete_promisc(p);
|
|
|
|
spin_lock_bh(&br->lock);
|
|
br_stp_disable_port(p);
|
|
spin_unlock_bh(&br->lock);
|
|
|
|
br_ifinfo_notify(RTM_DELLINK, NULL, p);
|
|
|
|
list_del_rcu(&p->list);
|
|
if (netdev_get_fwd_headroom(dev) == br->dev->needed_headroom)
|
|
update_headroom(br, get_max_headroom(br));
|
|
netdev_reset_rx_headroom(dev);
|
|
|
|
nbp_vlan_flush(p);
|
|
br_fdb_delete_by_port(br, p, 0, 1);
|
|
switchdev_deferred_process();
|
|
nbp_backup_clear(p);
|
|
|
|
nbp_update_port_count(br);
|
|
|
|
netdev_upper_dev_unlink(dev, br->dev);
|
|
|
|
dev->priv_flags &= ~IFF_BRIDGE_PORT;
|
|
|
|
netdev_rx_handler_unregister(dev);
|
|
|
|
br_multicast_del_port(p);
|
|
|
|
kobject_uevent(&p->kobj, KOBJ_REMOVE);
|
|
kobject_del(&p->kobj);
|
|
|
|
br_netpoll_disable(p);
|
|
|
|
call_rcu(&p->rcu, destroy_nbp_rcu);
|
|
}
|
|
|
|
/* Delete bridge device */
|
|
void br_dev_delete(struct net_device *dev, struct list_head *head)
|
|
{
|
|
struct net_bridge *br = netdev_priv(dev);
|
|
struct net_bridge_port *p, *n;
|
|
|
|
list_for_each_entry_safe(p, n, &br->port_list, list) {
|
|
del_nbp(p);
|
|
}
|
|
|
|
br_recalculate_neigh_suppress_enabled(br);
|
|
|
|
br_fdb_delete_by_port(br, NULL, 0, 1);
|
|
|
|
cancel_delayed_work_sync(&br->gc_work);
|
|
|
|
br_sysfs_delbr(br->dev);
|
|
unregister_netdevice_queue(br->dev, head);
|
|
}
|
|
|
|
/* find an available port number */
|
|
static int find_portno(struct net_bridge *br)
|
|
{
|
|
int index;
|
|
struct net_bridge_port *p;
|
|
unsigned long *inuse;
|
|
|
|
inuse = bitmap_zalloc(BR_MAX_PORTS, GFP_KERNEL);
|
|
if (!inuse)
|
|
return -ENOMEM;
|
|
|
|
set_bit(0, inuse); /* zero is reserved */
|
|
list_for_each_entry(p, &br->port_list, list) {
|
|
set_bit(p->port_no, inuse);
|
|
}
|
|
index = find_first_zero_bit(inuse, BR_MAX_PORTS);
|
|
bitmap_free(inuse);
|
|
|
|
return (index >= BR_MAX_PORTS) ? -EXFULL : index;
|
|
}
|
|
|
|
/* called with RTNL but without bridge lock */
|
|
static struct net_bridge_port *new_nbp(struct net_bridge *br,
|
|
struct net_device *dev)
|
|
{
|
|
struct net_bridge_port *p;
|
|
int index, err;
|
|
|
|
index = find_portno(br);
|
|
if (index < 0)
|
|
return ERR_PTR(index);
|
|
|
|
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
|
if (p == NULL)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
p->br = br;
|
|
dev_hold(dev);
|
|
p->dev = dev;
|
|
p->path_cost = port_cost(dev);
|
|
p->priority = 0x8000 >> BR_PORT_BITS;
|
|
p->port_no = index;
|
|
p->flags = BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD;
|
|
br_init_port(p);
|
|
br_set_state(p, BR_STATE_DISABLED);
|
|
br_stp_port_timer_init(p);
|
|
err = br_multicast_add_port(p);
|
|
if (err) {
|
|
dev_put(dev);
|
|
kfree(p);
|
|
p = ERR_PTR(err);
|
|
}
|
|
|
|
return p;
|
|
}
|
|
|
|
int br_add_bridge(struct net *net, const char *name)
|
|
{
|
|
struct net_device *dev;
|
|
int res;
|
|
|
|
dev = alloc_netdev(sizeof(struct net_bridge), name, NET_NAME_UNKNOWN,
|
|
br_dev_setup);
|
|
|
|
if (!dev)
|
|
return -ENOMEM;
|
|
|
|
dev_net_set(dev, net);
|
|
dev->rtnl_link_ops = &br_link_ops;
|
|
|
|
res = register_netdev(dev);
|
|
if (res)
|
|
free_netdev(dev);
|
|
return res;
|
|
}
|
|
|
|
int br_del_bridge(struct net *net, const char *name)
|
|
{
|
|
struct net_device *dev;
|
|
int ret = 0;
|
|
|
|
rtnl_lock();
|
|
dev = __dev_get_by_name(net, name);
|
|
if (dev == NULL)
|
|
ret = -ENXIO; /* Could not find device */
|
|
|
|
else if (!(dev->priv_flags & IFF_EBRIDGE)) {
|
|
/* Attempt to delete non bridge device! */
|
|
ret = -EPERM;
|
|
}
|
|
|
|
else if (dev->flags & IFF_UP) {
|
|
/* Not shutdown yet. */
|
|
ret = -EBUSY;
|
|
}
|
|
|
|
else
|
|
br_dev_delete(dev, NULL);
|
|
|
|
rtnl_unlock();
|
|
return ret;
|
|
}
|
|
|
|
/* MTU of the bridge pseudo-device: ETH_DATA_LEN or the minimum of the ports */
|
|
static int br_mtu_min(const struct net_bridge *br)
|
|
{
|
|
const struct net_bridge_port *p;
|
|
int ret_mtu = 0;
|
|
|
|
list_for_each_entry(p, &br->port_list, list)
|
|
if (!ret_mtu || ret_mtu > p->dev->mtu)
|
|
ret_mtu = p->dev->mtu;
|
|
|
|
return ret_mtu ? ret_mtu : ETH_DATA_LEN;
|
|
}
|
|
|
|
void br_mtu_auto_adjust(struct net_bridge *br)
|
|
{
|
|
ASSERT_RTNL();
|
|
|
|
/* if the bridge MTU was manually configured don't mess with it */
|
|
if (br_opt_get(br, BROPT_MTU_SET_BY_USER))
|
|
return;
|
|
|
|
/* change to the minimum MTU and clear the flag which was set by
|
|
* the bridge ndo_change_mtu callback
|
|
*/
|
|
dev_set_mtu(br->dev, br_mtu_min(br));
|
|
br_opt_toggle(br, BROPT_MTU_SET_BY_USER, false);
|
|
}
|
|
|
|
static void br_set_gso_limits(struct net_bridge *br)
|
|
{
|
|
unsigned int gso_max_size = GSO_MAX_SIZE;
|
|
u16 gso_max_segs = GSO_MAX_SEGS;
|
|
const struct net_bridge_port *p;
|
|
|
|
list_for_each_entry(p, &br->port_list, list) {
|
|
gso_max_size = min(gso_max_size, p->dev->gso_max_size);
|
|
gso_max_segs = min(gso_max_segs, p->dev->gso_max_segs);
|
|
}
|
|
br->dev->gso_max_size = gso_max_size;
|
|
br->dev->gso_max_segs = gso_max_segs;
|
|
}
|
|
|
|
/*
|
|
* Recomputes features using slave's features
|
|
*/
|
|
netdev_features_t br_features_recompute(struct net_bridge *br,
|
|
netdev_features_t features)
|
|
{
|
|
struct net_bridge_port *p;
|
|
netdev_features_t mask;
|
|
|
|
if (list_empty(&br->port_list))
|
|
return features;
|
|
|
|
mask = features;
|
|
features &= ~NETIF_F_ONE_FOR_ALL;
|
|
|
|
list_for_each_entry(p, &br->port_list, list) {
|
|
features = netdev_increment_features(features,
|
|
p->dev->features, mask);
|
|
}
|
|
features = netdev_add_tso_features(features, mask);
|
|
|
|
return features;
|
|
}
|
|
|
|
/* called with RTNL */
|
|
int br_add_if(struct net_bridge *br, struct net_device *dev,
|
|
struct netlink_ext_ack *extack)
|
|
{
|
|
struct net_bridge_port *p;
|
|
int err = 0;
|
|
unsigned br_hr, dev_hr;
|
|
bool changed_addr, fdb_synced = false;
|
|
|
|
/* Don't allow bridging non-ethernet like devices, or DSA-enabled
|
|
* master network devices since the bridge layer rx_handler prevents
|
|
* the DSA fake ethertype handler to be invoked, so we do not strip off
|
|
* the DSA switch tag protocol header and the bridge layer just return
|
|
* RX_HANDLER_CONSUMED, stopping RX processing for these frames.
|
|
*/
|
|
if ((dev->flags & IFF_LOOPBACK) ||
|
|
dev->type != ARPHRD_ETHER || dev->addr_len != ETH_ALEN ||
|
|
!is_valid_ether_addr(dev->dev_addr) ||
|
|
netdev_uses_dsa(dev))
|
|
return -EINVAL;
|
|
|
|
/* No bridging of bridges */
|
|
if (dev->netdev_ops->ndo_start_xmit == br_dev_xmit) {
|
|
NL_SET_ERR_MSG(extack,
|
|
"Can not enslave a bridge to a bridge");
|
|
return -ELOOP;
|
|
}
|
|
|
|
/* Device has master upper dev */
|
|
if (netdev_master_upper_dev_get(dev))
|
|
return -EBUSY;
|
|
|
|
/* No bridging devices that dislike that (e.g. wireless) */
|
|
if (dev->priv_flags & IFF_DONT_BRIDGE) {
|
|
NL_SET_ERR_MSG(extack,
|
|
"Device does not allow enslaving to a bridge");
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
p = new_nbp(br, dev);
|
|
if (IS_ERR(p))
|
|
return PTR_ERR(p);
|
|
|
|
call_netdevice_notifiers(NETDEV_JOIN, dev);
|
|
|
|
err = dev_set_allmulti(dev, 1);
|
|
if (err) {
|
|
br_multicast_del_port(p);
|
|
kfree(p); /* kobject not yet init'd, manually free */
|
|
goto err1;
|
|
}
|
|
|
|
err = kobject_init_and_add(&p->kobj, &brport_ktype, &(dev->dev.kobj),
|
|
SYSFS_BRIDGE_PORT_ATTR);
|
|
if (err)
|
|
goto err2;
|
|
|
|
err = br_sysfs_addif(p);
|
|
if (err)
|
|
goto err2;
|
|
|
|
err = br_netpoll_enable(p);
|
|
if (err)
|
|
goto err3;
|
|
|
|
err = netdev_rx_handler_register(dev, br_handle_frame, p);
|
|
if (err)
|
|
goto err4;
|
|
|
|
dev->priv_flags |= IFF_BRIDGE_PORT;
|
|
|
|
err = netdev_master_upper_dev_link(dev, br->dev, NULL, NULL, extack);
|
|
if (err)
|
|
goto err5;
|
|
|
|
err = nbp_switchdev_mark_set(p);
|
|
if (err)
|
|
goto err6;
|
|
|
|
dev_disable_lro(dev);
|
|
|
|
list_add_rcu(&p->list, &br->port_list);
|
|
|
|
nbp_update_port_count(br);
|
|
if (!br_promisc_port(p) && (p->dev->priv_flags & IFF_UNICAST_FLT)) {
|
|
/* When updating the port count we also update all ports'
|
|
* promiscuous mode.
|
|
* A port leaving promiscuous mode normally gets the bridge's
|
|
* fdb synced to the unicast filter (if supported), however,
|
|
* `br_port_clear_promisc` does not distinguish between
|
|
* non-promiscuous ports and *new* ports, so we need to
|
|
* sync explicitly here.
|
|
*/
|
|
fdb_synced = br_fdb_sync_static(br, p) == 0;
|
|
if (!fdb_synced)
|
|
netdev_err(dev, "failed to sync bridge static fdb addresses to this port\n");
|
|
}
|
|
|
|
netdev_update_features(br->dev);
|
|
|
|
br_hr = br->dev->needed_headroom;
|
|
dev_hr = netdev_get_fwd_headroom(dev);
|
|
if (br_hr < dev_hr)
|
|
update_headroom(br, dev_hr);
|
|
else
|
|
netdev_set_rx_headroom(dev, br_hr);
|
|
|
|
if (br_fdb_insert(br, p, dev->dev_addr, 0))
|
|
netdev_err(dev, "failed insert local address bridge forwarding table\n");
|
|
|
|
if (br->dev->addr_assign_type != NET_ADDR_SET) {
|
|
/* Ask for permission to use this MAC address now, even if we
|
|
* don't end up choosing it below.
|
|
*/
|
|
err = dev_pre_changeaddr_notify(br->dev, dev->dev_addr, extack);
|
|
if (err)
|
|
goto err7;
|
|
}
|
|
|
|
err = nbp_vlan_init(p, extack);
|
|
if (err) {
|
|
netdev_err(dev, "failed to initialize vlan filtering on this port\n");
|
|
goto err7;
|
|
}
|
|
|
|
spin_lock_bh(&br->lock);
|
|
changed_addr = br_stp_recalculate_bridge_id(br);
|
|
|
|
if (netif_running(dev) && netif_oper_up(dev) &&
|
|
(br->dev->flags & IFF_UP))
|
|
br_stp_enable_port(p);
|
|
spin_unlock_bh(&br->lock);
|
|
|
|
br_ifinfo_notify(RTM_NEWLINK, NULL, p);
|
|
|
|
if (changed_addr)
|
|
call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev);
|
|
|
|
br_mtu_auto_adjust(br);
|
|
br_set_gso_limits(br);
|
|
|
|
kobject_uevent(&p->kobj, KOBJ_ADD);
|
|
|
|
return 0;
|
|
|
|
err7:
|
|
if (fdb_synced)
|
|
br_fdb_unsync_static(br, p);
|
|
list_del_rcu(&p->list);
|
|
br_fdb_delete_by_port(br, p, 0, 1);
|
|
nbp_update_port_count(br);
|
|
err6:
|
|
netdev_upper_dev_unlink(dev, br->dev);
|
|
err5:
|
|
dev->priv_flags &= ~IFF_BRIDGE_PORT;
|
|
netdev_rx_handler_unregister(dev);
|
|
err4:
|
|
br_netpoll_disable(p);
|
|
err3:
|
|
sysfs_remove_link(br->ifobj, p->dev->name);
|
|
err2:
|
|
br_multicast_del_port(p);
|
|
kobject_put(&p->kobj);
|
|
dev_set_allmulti(dev, -1);
|
|
err1:
|
|
dev_put(dev);
|
|
return err;
|
|
}
|
|
|
|
/* called with RTNL */
|
|
int br_del_if(struct net_bridge *br, struct net_device *dev)
|
|
{
|
|
struct net_bridge_port *p;
|
|
bool changed_addr;
|
|
|
|
p = br_port_get_rtnl(dev);
|
|
if (!p || p->br != br)
|
|
return -EINVAL;
|
|
|
|
/* Since more than one interface can be attached to a bridge,
|
|
* there still maybe an alternate path for netconsole to use;
|
|
* therefore there is no reason for a NETDEV_RELEASE event.
|
|
*/
|
|
del_nbp(p);
|
|
|
|
br_mtu_auto_adjust(br);
|
|
br_set_gso_limits(br);
|
|
|
|
spin_lock_bh(&br->lock);
|
|
changed_addr = br_stp_recalculate_bridge_id(br);
|
|
spin_unlock_bh(&br->lock);
|
|
|
|
if (changed_addr)
|
|
call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev);
|
|
|
|
netdev_update_features(br->dev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void br_port_flags_change(struct net_bridge_port *p, unsigned long mask)
|
|
{
|
|
struct net_bridge *br = p->br;
|
|
|
|
if (mask & BR_AUTO_MASK)
|
|
nbp_update_port_count(br);
|
|
|
|
if (mask & BR_NEIGH_SUPPRESS)
|
|
br_recalculate_neigh_suppress_enabled(br);
|
|
}
|
|
|
|
bool br_port_flag_is_set(const struct net_device *dev, unsigned long flag)
|
|
{
|
|
struct net_bridge_port *p;
|
|
|
|
p = br_port_get_rtnl_rcu(dev);
|
|
if (!p)
|
|
return false;
|
|
|
|
return p->flags & flag;
|
|
}
|
|
EXPORT_SYMBOL_GPL(br_port_flag_is_set);
|
|
|
|
#ifdef CONFIG_ENABLE_SFE
|
|
/* br_port_dev_get()
|
|
* Using the given addr, identify the port to which it is reachable,
|
|
* returing a reference to the net device associated with that port.
|
|
*
|
|
* NOTE: Return NULL if given dev is not a bridge or
|
|
* the mac has no associated port
|
|
*/
|
|
struct net_device *br_port_dev_get(struct net_device *dev, unsigned char *addr)
|
|
{
|
|
struct net_bridge_fdb_entry *fdbe;
|
|
struct net_bridge *br;
|
|
struct net_device *netdev = NULL;
|
|
|
|
/* Is this a bridge? */
|
|
if (!(dev->priv_flags & IFF_EBRIDGE))
|
|
return NULL;
|
|
|
|
br = netdev_priv(dev);
|
|
|
|
/* Lookup the fdb entry and get reference to the port dev */
|
|
rcu_read_lock();
|
|
fdbe = br_fdb_find_rcu(br, addr, 0);
|
|
if (fdbe && fdbe->dst) {
|
|
netdev = fdbe->dst->dev; /* port device */
|
|
dev_hold(netdev);
|
|
}
|
|
rcu_read_unlock();
|
|
return netdev;
|
|
}
|
|
EXPORT_SYMBOL(br_port_dev_get);
|
|
#endif
|