Commit Graph

6020 Commits

Author SHA1 Message Date
30beff131b UPSTREAM: dma-buf: heaps: Use _IOCTL_ for userspace IOCTL identifier
This is more consistent with the DMA and DRM frameworks convention. This
patch is only a name change, no logic is changed.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191216133405.1001-2-afd@ti.com

Bug: 162857866
(cherry picked from commit b3b4346544b571c96d46be615b9db69a601ce4c8)
Signed-off-by: Hridya Valsaraju <hridya@google.com>
Change-Id: I745294e2c01eaaa731c366ac0a8ef473fb8d7a28
2026-05-31 11:15:35 +01:00
faed0d4603 UPSTREAM: dma-buf: Add dma-buf heaps framework
This framework allows a unified userspace interface for dma-buf
exporters, allowing userland to allocate specific types of memory
for use in dma-buf sharing.

Each heap is given its own device node, which a user can allocate
a dma-buf fd from using the DMA_HEAP_IOC_ALLOC.

This code is an evoluiton of the Android ION implementation,
and a big thanks is due to its authors/maintainers over time
for their effort:
  Rebecca Schultz Zavin, Colin Cross, Benjamin Gaignard,
  Laura Abbott, and many other contributors!

Cc: Laura Abbott <labbott@redhat.com>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Pratik Patel <pratikp@codeaurora.org>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: Vincent Donnefort <Vincent.Donnefort@arm.com>
Cc: Sudipto Paul <Sudipto.Paul@arm.com>
Cc: Andrew F. Davis <afd@ti.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chenbo Feng <fengc@google.com>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Dave Airlie <airlied@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Acked-by: Sandeep Patil <sspatil@android.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191203172641.66642-2-john.stultz@linaro.org

Bug: 162857866
(cherry picked from commit c02a81fba74fe3488ad6b08bfb5a1329005418f8)
Signed-off-by: Hridya Valsaraju <hridya@google.com>
Change-Id: I4efff280bee0003e164d4ea4a3e327c1f1b5d433
2026-05-31 11:15:35 +01:00
2fadb0a6a4 UPSTREAM: Add udmabuf misc device
A driver to let userspace turn memfd regions into dma-bufs.

Use case:  Allows qemu create dmabufs for the vga framebuffer or
virtio-gpu ressources.  Then they can be passed around to display
those guest things on the host.  To spice client for classic full
framebuffer display, and hopefully some day to wayland server for
seamless guest window display.

qemu test branch:
  https://git.kraxel.org/cgit/qemu/log/?h=sirius/udmabuf

Cc: David Airlie <airlied@linux.ie>
Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Change-Id: I5cce2b2f4a968f27564ea8008ff1194338b6a775
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20180827093444.23623-1-kraxel@redhat.com
2026-05-31 11:15:33 +01:00
6982efdd89 UPSTREAM: nexthop: support for fdb ecmp nexthops
This patch introduces ecmp nexthops and nexthop groups
for mac fdb entries. In subsequent patches this is used
by the vxlan driver fdb entries. The use case is
E-VPN multihoming [1,2,3] which requires bridged vxlan traffic
to be load balanced to remote switches (vteps) belonging to
the same multi-homed ethernet segment (This is analogous to
a multi-homed LAG but over vxlan).

Changes include new nexthop flag NHA_FDB for nexthops
referenced by fdb entries. These nexthops only have ip.
This patch includes appropriate checks to avoid routes
referencing such nexthops.

example:
$ip nexthop add id 12 via 172.16.1.2 fdb
$ip nexthop add id 13 via 172.16.1.3 fdb
$ip nexthop add id 102 group 12/13 fdb

$bridge fdb add 02:02:00:00:00:13 dev vxlan1000 nhid 101 self

[1] E-VPN https://tools.ietf.org/html/rfc7432
[2] E-VPN VxLAN: https://tools.ietf.org/html/rfc8365
[3] LPC talk with mention of nexthop groups for L2 ecmp
http://vger.kernel.org/lpc_net2018_talks/scaling_bridge_fdb_database_slidesV3.pdf

v4 - fixed uninitialized variable reported by kernel test robot
Reported-by: kernel test robot <rong.a.chen@intel.com>

Change-Id: Ifcb70362fedda68775c879192a62b8cae8e574e0
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2026-05-31 11:15:32 +01:00
23ea704e18 Merge tag 'v4.19.325-cip132' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip into android13-4.19-kona
version 4.19.325-cip132

* tag 'v4.19.325-cip132' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip:
  CIP: Bump version suffix to -cip132 after merge from cip/linux-4.19.y-st tree
  Update localversion-st, tree is up-to-date with 5.10.254.
  x86/CPU: Fix FPDSS on Zen1
  seg6: separate dst_cache for input and output paths in seg6 lwtunnel
  netfilter: nft_ct: fix use-after-free in timeout object destroy
  apparmor: fix differential encoding verification
  apparmor: fix missing bounds check on DEFAULT table in verify_dfa()
  ext4: convert inline data to extents when truncate exceeds inline size
  virtio_net: Fix UAF on dst_ops when IFF_XMIT_DST_RELEASE is cleared and napi_tx is false
  ipv6: fix NULL pointer deref in ip6_rt_get_dev_rcu()
  crypto: af_alg - Fix page reassignment overflow in af_alg_pull_tsgl
  crypto: authencesn - Fix src offset when decrypting in-place
  crypto: authencesn - Do not place hiseq at end of dst for out-of-place decryption
  crypto: authenc - use memcpy_sglist() instead of null skcipher
  crypto: algif_aead - snapshot IV for async AEAD requests
  crypto: algif_aead - Revert to operating out-of-place
  crypto: algif_aead - use memcpy_sglist() instead of null skcipher
  crypto: doc - fix kernel-doc notation in chacha.c and af_alg.c
  Buffer overflow in drivers/xen/sys-hypervisor.c
  xen/privcmd: fix double free via VMA splitting
  crypto: algif_aead - Fix minimum RX size check for decryption
  crypto: scatterwalk - Backport memcpy_sglist()
  batman-adv: avoid OGM aggregation when skb tailroom is insufficient
  device property: Check fwnode->secondary when finding properties
  device property: Check fwnode->secondary in fwnode_graph_get_next_endpoint()
  device property: Retrieve fwnode from of_node via accessor
  media: device property: Return true in fwnode_device_is_available for NULL ops
  ext4: fix the might_sleep() warnings in kvfree()
  mm/huge_memory: fix folio isn't locked in softleaf_to_folio()
  usb: gadget: u_ether: Fix race between gether_disconnect and eth_stop
  usb: gadget: f_hid: move list and spinlock inits from bind to alloc
  net: rfkill: prevent unlimited numbers of rfkill events from being created
  cpufreq: governor: fix double free in cpufreq_dbs_governor_init() error path
  cpufreq: governor: Free dbs_data directly when gov->init() fails
  xen/privcmd: unregister xenstore notifier on module exit
  rxrpc: Fix key/keyring checks in setsockopt(RXRPC_SECURITY_KEY/KEYRING)
  net: stmmac: fix integer underflow in chain mode
  net: qualcomm: qca_uart: report the consumed byte on RX skb allocation failure
  mmc: vub300: fix NULL-deref on disconnect
  net: altera-tse: fix skb leak on DMA mapping error in tse_start_xmit()
  batman-adv: reject oversized global TT response buffers
  arm64: dts: hisilicon: hi3798cv200: Add missing dma-ranges
  arm64: dts: hisilicon: poplar: Correct PCIe reset GPIO polarity
  wifi: brcmsmac: Fix dma_free_coherent() size
  tipc: fix bc_ackers underflow on duplicate GRP_ACK_MSG
  apparmor: fix unprivileged local user can do privileged policy management
  apparmor: Fix double free of ns_name in aa_replace_profiles()
  apparmor: fix side-effect bug in match_char() macro usage
  apparmor: fix: limit the number of levels of policy namespaces
  apparmor: replace recursive profile removal with iterative approach
  apparmor: fix memory leak in verify_header
  apparmor: validate DFA start states are in bounds in unpack_pdb
  mm/rmap: fix two comments related to huge_pmd_unshare()
  mm/hugetlb: fix two comments related to huge_pmd_unshare()
  mm/hugetlb: make detecting shared pte more reliable
  Input: uinput - take event lock when submitting FF request "event"
  Input: uinput - fix circular locking dependency with ff-core
  xfrm_user: fix info leak in build_report()
  wifi: rt2x00usb: fix devres lifetime
  usb: gadget: f_uac1_legacy: validate control request size
  usb: gadget: dummy_hcd: fix premature URB completion when ZLP follows partial transfer
  USB: dummy-hcd: Fix locking/synchronization error
  vxlan: validate ND option lengths in vxlan_na_create
  comedi: me4000: Fix potential overrun of firmware buffer
  comedi: me_daq: Fix potential overrun of firmware buffer
  comedi: ni_atmio16d: Fix invalid clean-up after failed attach
  comedi: Reinit dev->spinlock between attachments to low-level drivers
  comedi: dt2815: add hardware detection to prevent crash
  bridge: br_nd_send: validate ND option lengths
  usb: ulpi: fix double free in ulpi_register_interface() error path
  usb: quirks: add DELAY_INIT quirk for another Silicon Motion flash drive
  iio: gyro: mpu3050: Fix out-of-sequence free_irq()
  iio: gyro: mpu3050: Move iio_device_register() to correct location
  iio: gyro: mpu3050: Fix irq resource leak
  iio: gyro: mpu3050: Fix incorrect free_irq() variable
  Input: xpad - add support for Razer Wolverine V3 Pro
  USB: core: add NO_LPM quirk for Razer Kiyo Pro webcam
  USB: serial: option: add support for Rolling Wireless RW135R-GL
  USB: serial: io_edgeport: add support for Blackbox IC135A
  drm/ast: dp501: Fix initialization of SCU2C
  MIPS: Fix the GCC version check for `__multi3' workaround
  Bluetooth: SMP: force responder MITM requirements before building the pairing response
  Bluetooth: SMP: derive legacy responder STK authentication from MITM state
  ALSA: ctxfi: Fix missing SPDIFI1 index handling
  ALSA: caiaq: fix stack out-of-bounds read in init_card
  USB: serial: option: add MeiG Smart SRM825WN
  drm/ioc32: stop speculation on the drm_compat_ioctl path
  media: dvb-frontends: w7090p: fix null-ptr-deref in w7090p_tuner_write_serpar and w7090p_tuner_read_serpar
  Revert "media: dvb-frontends: w7090p: fix null-ptr-deref in w7090p_tuner_write_serpar and w7090p_tuner_read_serpar"
  drm/vmwgfx: Add seqno waiter for sync_files
  Revert "drm/vmwgfx: Add seqno waiter for sync_files"
  ipv6: avoid overflows in ip6_datagram_send_ctl()
  net/sched: cls_flow: fix NULL pointer dereference on shared blocks
  net/sched: cls_fw: fix NULL pointer dereference on shared blocks
  net/x25: Fix overflow when accumulating packets
  net/x25: Fix potential double free of skb
  net: macb: properly unregister fixed rate clocks
  net: macb: fix clk handling on PCI glue driver removal
  Bluetooth: MGMT: validate LTK enc_size on load
  netfilter: x_tables: restrict xt_check_match/xt_check_target extensions for NFPROTO_ARP
  netfilter: ctnetlink: zero expect NAT fields when CTA_EXPECT_NAT absent
  netfilter: nf_conntrack_helper: pass helper to expect cleanup
  netfilter: ipset: use nla_strcmp for IPSET_ATTR_NAME attr
  netfilter: x_tables: ensure names are nul-terminated
  netfilter: nfnetlink_log: account for netlink header size
  net: ipv6: flowlabel: defer exclusive option free until RCU teardown
  bpf: Fix regsafe() for pointers to packet
  net: xilinx: axienet: Correct BD length masks to match AXIDMA IP spec
  ipv6: prevent possible UaF in addrconf_permanent_addr()
  net/sched: sch_hfsc: fix divide-by-zero in rtsc_min()
  bridge: br_nd_send: linearize skb before parsing ND options
  ip6_tunnel: clear skb2->cb[] in ip4ip6_err()
  ipv6: icmp: clear skb2->cb[] in ip6_err_gen_icmpv6_unreach()
  tg3: Fix race for querying speed/duplex
  net: ipv6: ndisc: fix ndisc_ra_useropt to initialize nduseropt_padX fields to zero to prevent an info-leak
  crypto: af-alg - fix NULL pointer dereference in scatterwalk
  HID: multitouch: Check to ensure report responses match the request
  atm: lec: fix use-after-free in sock_def_readable()
  HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq
  dmaengine: xilinx_dma: Fix reset related timeout with two-channel AXIDMA
  dmaengine: xilinx_dma: Program interrupt delay timeout
  btrfs: fix lost error when running device stats on multiple devices fs
  btrfs: fix super block offset in error message in btrfs_validate_super()
  dmaengine: xilinx: xilinx_dma: Fix residue calculation for cyclic DMA
  dmaengine: xilinx: xilinx_dma: Fix dma_device directions
  ext4: reject mount if bigalloc with s_first_data_block != 0
  ext4: avoid allocate block from corrupted group in ext4_mb_find_by_goal()
  ext4: make recently_deleted() properly work with lazy itable initialization
  scsi: ses: Handle positive SCSI error from ses_recv_diag()
  scsi: ibmvfc: Fix OOB access in ibmvfc_discover_targets_done()
  alarmtimer: Fix argument order in alarm_timer_forward()
  cpufreq: conservative: Reset requested_freq on limits change
  s390/barrier: Make array_index_mask_nospec() __always_inline
  sysctl: fix uninitialized variable in proc_do_large_bitmap
  ACPICA: Allow address_space_handler Install and _REG execution as 2 separate steps
  ACPICA: include/acpi/acpixf.h: Fix indentation
  drm/i915/gmbus: fix spurious timeout on 512-byte burst reads
  scsi: scsi_transport_sas: Fix the maximum channel scanning issue
  RDMA/rw: Fall back to direct SGE on MR pool exhaustion
  net: macb: use the current queue number for stats
  netfilter: nf_conntrack_sip: fix use of uninitialized rtp_addr in process_sdp
  netfilter: ip6t_rt: reject oversized addrnr in rt_mt6_check()
  netfilter: nfnetlink_log: fix uninitialized padding leak in NFULA_PAYLOAD
  Bluetooth: L2CAP: Fix ERTM re-init and zero pdu_len infinite loop
  net: fix fanout UAF in packet_release() via NETDEV_UP race
  rtnetlink: count IFLA_INFO_SLAVE_KIND in if_nlmsg_size
  openvswitch: validate MPLS set/set_masked payload length
  net: openvswitch: Avoid releasing netdev before teardown completes
  pinctrl: mediatek: common: Fix probe failure for devices without EINT
  Bluetooth: L2CAP: Fix null-ptr-deref on l2cap_sock_ready_cb
  Bluetooth: hci_ll: Fix firmware leak on error path
  Bluetooth: L2CAP: Validate PDU length before reading SDU length in l2cap_ecred_data_rcv()
  af_key: validate families in pfkey_send_migrate()
  xfrm: call xdo_dev_state_delete during state update
  dma-buf: Include ioctl.h in UAPI header
  xen/privcmd: restrict usage in unprivileged domU
  i2c: fsi: Fix a potential leak in fsi_i2c_probe()
  icmp: fix NULL pointer dereference in icmp_tag_validation()
  nfnetlink_osf: validate individual option lengths in fingerprints
  net: bonding: fix NULL deref in bond_debug_rlb_hash_show
  udp_tunnel: fix NULL deref caused by udp_sock_create6 when CONFIG_IPV6=n
  net: macb: fix uninitialized rx_fs_lock
  wifi: wlcore: Return -ENOMEM instead of -EAGAIN if there is not enough headroom
  wifi: mac80211: fix NULL deref in mesh_matches_local()
  PM: runtime: Fix a race condition related to device removal
  net: bcmgenet: increase WoL poll timeout
  netfilter: nf_conntrack_h323: check for zero length in DecodeQ931()
  netfilter: xt_time: use unsigned int for monthday bit shift
  netfilter: xt_CT: drop pending enqueued packets on template removal
  netfilter: nf_conntrack_h323: fix OOB read in decode_int() CONS case
  netfilter: nf_conntrack_sip: fix Content-Length u32 truncation in sip_help_tcp()
  netfilter: ctnetlink: fix use-after-free in ctnetlink_dump_exp_ct()
  netfilter: ctnetlink: remove refcounting in expectation dumpers
  net/rose: fix NULL pointer dereference in rose_transmit_link on reconnect
  Bluetooth: HIDP: Fix possible UAF
  Bluetooth: SMP: make SM/PER/KDU/BI-04-C happy
  Bluetooth: LE L2CAP: Disconnect if sum of payload sizes exceed SDU
  Bluetooth: LE L2CAP: Disconnect if received packet's SDU exceeds IMTU
  staging: rtl8723bs: fix null dereference in find_network
  net/tcp-md5: Fix MAC comparison to be constant-time
  ALSA: pcm: fix wait_time calculations
  can: gs_usb: gs_can_open(): always configure bitrates before starting device
  usb: gadget: f_tcm: Fix NULL pointer dereferences in nexus handling
  nfsd: fix heap overflow in NFSv4.0 LOCK replay cache
  arm64: mm: Add PTE_DIRTY back to PAGE_KERNEL* to fix kexec/hibernation
  smb: client: fix iface port assignment in parse_server_interfaces
  iio: light: bh1780: fix PM runtime leak on error path
  tracing: Fix syscall events activation by ensuring refcount hits zero
  s390/xor: Fix xor_xc_2() inline assembly constraints
  drm/amd/display: Use GFP_ATOMIC in dc_create_stream_for_sink
  smb: client: Don't log plaintext credentials in cifs_set_cifscreds
  wifi: mac80211: fix NULL pointer dereference in mesh_rx_csa_frame()
  wifi: libertas: fix use-after-free in lbs_free_adapter()
  ext4: fix dirtyclusters double decrement on fs shutdown
  ext4: drop extent cache when splitting extent fails
  drm/exynos: vidi: use priv->vidi_dev for ctx lookup in vidi_connection_ioctl()
  net: Handle napi_schedule() calls from non-interrupt
  drm/radeon: apply state adjust rules to some additional HAINAN vairants
  serial: 8250: Add late synchronize_irq() to shutdown to handle DW UART BUSY
  Bluetooth: L2CAP: Validate L2CAP_INFO_RSP payload length before access
  net: macb: fix use-after-free access to PTP clock
  nvdimm/bus: Fix potential use after free in asynchronous initialization
  iio: chemical: bme680: Fix measurement wait duration calculation
  iio: potentiometer: mcp4131: fix double application of wiper shift
  iio: dac: ds4424: reject -128 RAW value
  btrfs: abort transaction on failure to update root in the received subvol ioctl
  x86/apic: Disable x2apic on resume if the kernel expects so
  drm/amdgpu: Fix use-after-free race in VM acquire
  net: ethernet: arc: emac: quiesce interrupts before requesting IRQ
  net: ncsi: fix skb leak in error paths
  parisc: Fix initial page table creation for boot
  nouveau/dpcd: return EBUSY for aux xfer if the device is asleep
  parisc: Increase initial mapping to 64 MB with KALLSYMS
  batman-adv: Avoid double-rtnl_lock ELP metric worker
  media: dvb-net: fix OOB access in ULE extension header tables
  staging: rtl8723bs: fix potential out-of-bounds read in rtw_restruct_wmm_ie
  libceph: Fix potential out-of-bounds access in ceph_handle_auth_reply()
  mmc: mmci: Fix device_node reference leak in of_get_dml_pipe_index()
  usb: image: mdc800: kill download URB on timeout
  usb: mdc800: handle signal and read racing
  usb: class: cdc-wdm: fix reordering issue in read code path
  USB: usbcore: Introduce usb_bulk_msg_killable()
  usb: misc: uss720: properly clean up reference in uss720_probe()
  usb: yurex: fix race in probe
  usb: xhci: Fix memory leak in xhci_disable_slot()
  usb/core/quirks: Add Huawei ME906S-device to wakeup quirk
  net: usb: lan78xx: skip LTM configuration for LAN7850
  net: usb: lan78xx: fix silent drop of packets with checksum errors
  cgroup: fix race between task migration and iteration
  e1000/e1000e: Fix leak in DMA error cleanup
  i40e: fix src IP mask checks and memcpy argument names in cloud filter
  nvme-pci: Fix slab-out-of-bounds in nvme_dbbuf_set
  sched: idle: Make skipping governor callbacks more consistent
  netfilter: nfnetlink_cthelper: fix OOB read in nfnl_cthelper_dump_table()
  netfilter: nfnetlink_queue: fix entry leak in bridge verdict error path
  netfilter: x_tables: guard option walkers against 1-byte tail reads
  can: hi311x: hi3110_open(): add check for hi3110_power_enable() return value
  serial: caif: hold tty->link reference in ldisc_open and ser_release
  net/sched: teql: fix NULL pointer dereference in iptunnel_xmit on TEQL slave xmit
  powerpc: 83xx: km83xx: Fix keymile vendor prefix
  remoteproc: sysmon: Correct subsys_name_len type in QMI request
  powerpc/uaccess: Fix inline assembly for clang build on PPC32
  scsi: ses: Fix devices attaching to different hosts
  ACPI: OSI: Add DMI quirk for Acer Aspire One D255
  unshare: fix unshare_fs() handling
  ACPI: PM: Save NVS memory on Lenovo G70-35
  scsi: storvsc: Fix scheduling while atomic on PREEMPT_RT
  net: vxlan: fix nd_tbl NULL dereference when IPv6 is disabled
  net: bridge: fix nd_tbl NULL dereference when IPv6 is disabled
  nfc: rawsock: cancel tx_work before socket teardown
  nfc: nci: clear NCI_DATA_EXCHANGE before calling completion callback
  nfc: nci: free skb on nci_transceive early error paths
  net: nfc: nci: Fix zero-length proprietary notifications
  amd-xgbe: fix sleep while atomic on suspend/resume
  xen/acpi-processor: fix _CST detection using undersized evaluation buffer
  wifi: wlcore: Fix a locking bug
  can: bcm: fix locking for bcm_op runtime updates
  atm: lec: fix null-ptr-deref in lec_arp_clear_vccs
  platform/x86: thinkpad_acpi: Fix errors reading battery thresholds
  drbd: fix "LOGIC BUG" in drbd_al_begin_io_nonblock()
  Squashfs: check metadata block offset is within range
  wifi: radiotap: reject radiotap with unknown bits
  ALSA: usb-audio: Use correct version for UAC3 header validation
  can: ucan: Fix infinite loop from zero-length messages
  can: ems_usb: ems_usb_read_bulk_callback(): check the proper length of a message
  net: usb: pegasus: validate USB endpoints
  net: usb: kalmia: validate USB endpoints
  net: usb: kaweth: validate USB endpoints
  nfc: pn533: properly drop the usb interface reference on disconnect
  media: dvb-core: fix wrong reinitialization of ringbuffer on reopen
  net: arcnet: com20020-pci: fix support for 2.5Mbit cards
  ALSA: hda/conexant: Add quirk for HP ZBook Studio G4
  clk: tegra: tegra124-emc: fix device leak on set_rate()
  drm/tegra: dsi: fix device leak on probe
  ARM: omap2: Fix reference count leaks in omap_control_init()
  ARM: OMAP2+: add missing of_node_put before break and return
  ARM: clean up the memset64() C wrapper

Change-Id: If58eb7898e90d049cd97232a5f2c1fc971671b1f
2026-05-12 18:00:02 +01:00
77c55edd80 dma-buf: Include ioctl.h in UAPI header
[ Upstream commit a116bac87118903925108e57781bbfc7a7eea27b ]

include/uapi/linux/dma-buf.h uses several macros from ioctl.h to define
its ioctl commands. However, it does not include ioctl.h itself. So,
if userspace source code tries to include the dma-buf.h file without
including ioctl.h, it can result in build failures.

Therefore, include ioctl.h in the dma-buf UAPI header.

Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
Reviewed-by: T.J. Mercier <tjmercier@google.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20260303002309.1401849-1-isaacmanjarres@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
2026-05-07 10:55:20 +02:00
b0da80ea68 Merge tag 'v4.19.325-cip131' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip into android13-4.19-kona
version 4.19.325-cip131

* tag 'v4.19.325-cip131' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip:
  CIP: Bump version suffix to -cip131 after merge from cip/linux-4.19.y-st tree
  Update localversion-st, tree is up-to-date with 5.10.252.
  nfsd: fix return error code for nfsd_map_name_to_[ug]id
  net: usb: pegasus: enable basic endpoint checking
  Bluetooth: L2CAP: Fix not checking l2cap_chan security level
  Bluetooth: Enforce key size of 16 bytes on FIPS level
  xfrm6: fix uninitialized saddr in xfrm6_get_saddr()
  netfilter: nf_conntrack: Add allow_clash to generic protocol handler
  ext4: don't cache extent during splitting extent
  NTB: ntb_transport: Fix too small buffer for debugfs_name
  net: ethernet: ec_bhf: Fix dma_free_coherent() dma handle
  fbdev: ffb: fix corrupted video output on Sun FFB1
  fbdev: of: display_timing: fix refcount leak in of_get_display_timings()
  atm: fore200e: fix use-after-free in tasklets during device removal
  net: wan/fsl_ucc_hdlc: Fix dma_free_coherent() in uhdlc_memclean()
  net: ethernet: marvell: skge: remove incorrect conflicting PCI ID
  ceph: supply snapshot context in ceph_zero_partial_object()
  MIPS: rb532: Fix MMIO UART resource registration
  parisc: kernel: replace kfree() with put_device() in create_tree_node()
  drm/amdkfd: Fix out-of-bounds write in kfd_event_page_set()
  usb: dwc2: fix resume failure if dr_mode is host
  btrfs: continue trimming remaining devices on failure
  kexec: derive purgatory entry from symbol
  ocfs2: fix reflink preserve cleanup issue
  ocfs2: fix xattr array entry __counted_by error
  rapidio: replace rio_free_net() with kfree() in rio_scan_alloc_net()
  iio: gyro: itg3200: Fix unchecked return value in read_raw
  dm mpath: make pg_init_delay_msecs settable
  bus: fsl-mc: fix an error handling in fsl_mc_device_add()
  md/bitmap: fix GPF in write_page caused by resize race
  xfs: fix remote xattr valuelblk check
  xfs: fix freemap adjustments when adding xattrs to leaf blocks
  xfs: delete attr leaf freemap entries when empty
  xfs: mark data structures corrupt on EIO and ENODATA
  mm, page_alloc, thp: prevent reclaim for __GFP_THISNODE THP allocations
  drm: of: drm_of_panel_bridge_remove(): fix device_node leak
  dm-unstripe: fix mapping bug when there are multiple targets in a table
  clk: tegra: tegra124-emc: Fix potential memory leak in tegra124_clk_register_emc()
  dm: clear cloned request bio pointer when last clone bio completes
  media: i2c/tw9906: Fix potential memory leak in tw9906_probe()
  media: i2c/tw9903: Fix potential memory leak in tw9903_probe()
  media: cx25821: Add missing unmap in snd_cx25821_hw_params()
  media: cx23885: Add missing unmap in snd_cx23885_hw_params()
  media: cx88: Add missing unmap in snd_cx88_hw_params()
  media: radio-keene: fix memory leak in error path
  HID: prodikeys: Check presence of pm->input_ep82
  HID: magicmouse: Do not crash on missing msc->input
  HID: hid-pl: handle probe errors
  media: mtk-mdp: Fix a reference leak bug in mtk_mdp_remove()
  dm-verity: correctly handle dm_bufio_client_create() failure
  fpga: dfl: use subsys_initcall to allow built-in drivers to be added
  rpmsg: core: fix race in driver_override_show() and use core helper
  netfilter: nf_conntrack_h323: fix OOB read in decode_choice()
  net: consume xmit errors of GSO frames
  Bluetooth: L2CAP: Fix missing key size check for L2CAP_LE_CONN_REQ
  Bluetooth: l2cap: Check encryption key size on incoming connection
  wifi: cfg80211: wext: fix IGTK key ID off-by-one
  net: usb: lan78xx: scan all MDIO addresses on LAN7801
  lan78xx: Fix memory allocation bug
  lan78xx: Fix race condition in disconnect handling
  lan78xx: Remove unused pause frame queue
  net: usb: kaweth: remove TX queue manipulation in kaweth_set_rx_mode
  ntb: ntb_hw_switchtec: Fix shift-out-of-bounds for 0 mw lut
  ntb: ntb_hw_switchtec: Fix array-index-out-of-bounds access
  drm/radeon: Add HAINAN clock adjustment
  drm/amdgpu: Add HAINAN clock adjustment
  ARM: 9467/1: mm: Don't use %pK through printk
  include: uapi: netfilter_bridge.h: Cover for musl libc
  iio: magnetometer: Remove IRQF_ONESHOT
  Revert "mfd: da9052-spi: Change read-mask to write-mask"
  binder: don't use %pK through printk
  serial: 8250_dw: handle clock enable errors in runtime_resume
  m68k: nommu: fix memmove() with differently aligned src and dest for 68000
  clk: microchip: core: correct return value on *_get_parent()
  nfc: nxp-nci: remove interrupt trigger type
  myri10ge: avoid uninitialized variable use
  PCI: Mark Nvidia GB10 to avoid bus reset
  PCI: Fix pci_slot_lock () device locking
  PCI: Mark ASM1164 SATA controller to avoid bus reset
  net/rds: Clear reconnect pending bit
  vmw_vsock: bypass false-positive Wnonnull warning with gcc-16
  net: usb: sr9700: remove code to drive nonexistent multicast filter
  Bluetooth: btusb: Add device ID for Realtek RTL8761BU
  Bluetooth: hci_conn: use mod_delayed_work for active mode timeout
  ipv4: fib: Annotate access to struct fib_alias.fa_state.
  wifi: iwlegacy: add missing mutex protection in il3945_store_measurement()
  wifi: iwlegacy: add missing mutex protection in il4965_store_tx_power()
  net/rds: No shortcut out of RDS_CONN_ERROR
  net: usb: r8152: fix transmit queue timeout
  openrisc: define arch-specific version of nop()
  netfilter: xt_tcpmss: check remaining length before reading optlen
  wifi: libertas: fix WARNING in usb_tx_block
  jfs: nlink overflow in jfs_rename
  jfs: Add missing set_freezable() for freezable kthread
  modpost: Amend ppc64 save/restfpr symnames for -Os build
  ASoC: es8328: Add error unwind in resume
  HID: multitouch: add eGalaxTouch EXC3188 support
  drm/atmel-hlcdc: fix use-after-free of drm_crtc_commit after release
  drm/atmel-hlcdc: fix memory leak from the atomic_destroy_state callback
  virt: vbox: uapi: Mark inner unions in packed structs as packed
  hyper-v: Mark inner union in hv_kvp_exchg_msg_value as packed
  drm: Account property blob allocations to memcg
  media: cx25821: Fix a resource leak in cx25821_dev_setup()
  media: solo6x10: Check for out of bounds chip_id
  media: pvrusb2: fix URB leak in pvr2_send_request_ex
  media: adv7180: fix frame interval in progressive mode
  ASoC: wm8962: Add WM8962_ADC_MONOMIX to "3D Coefficients" mask
  media: omap3isp: set initial format
  media: omap3isp: isppreview: always clamp in preview_try_format()
  media: omap3isp: isp_video_mbus_to_pix/pix_to_mbus fixes
  media: dvb-core: dmxdevfilter must always flush bufs
  parisc: Prevent interrupts during reboot
  arm64: tegra: smaug: Add usb-role-switch support
  pstore: ram_core: fix incorrect success return when vmap() fails
  mailbox: bcm-ferxrm-mailbox: Use default primary handler
  clocksource/drivers/sh_tmu: Always leave device running after probe
  sparc: don't reference obsolete termio struct for TC* constants
  xenbus: Use .freeze/.thaw to handle xenbus devices
  ACPICA: Abort AML bytecode execution when executing AML_FATAL_OP
  EFI/CPER: don't go past the ARM processor CPER record buffer
  x86/xen/pvh: Enable PAE mode for 32-bit guest only when CONFIG_X86_PAE is set
  s390/purgatory: Add -Wno-default-const-init-unsafe to KBUILD_CFLAGS
  tools/power cpupower: Reset errno before strtoull()
  minix: Add required sanity checking to minix_check_superblock()
  hfsplus: pretend special inodes as regular files
  audit: add missing syscalls to read class
  hfsplus: fix volume corruption issue for generic/498
  audit: add fchmodat2() to change attributes class
  rtc: interface: Alarm race handling should not discard preceding error
  SUNRPC: fix gss_auth kref leak in gss_alloc_msg error path
  SUNRPC: auth_gss: fix memory leaks in XDR decoding error paths
  ata: pata_ftide010: Fix some DMA timings
  ext4: fix memory leak in ext4_ext_shift_extents()
  MIPS: Work around LLVM bug when gp is used as global register variable
  apparmor: fix invalid deref of rawdata when export_binary is unset
  apparmor: fix rlimit for posix cpu timers
  apparmor: fix NULL sock in aa_sock_file_perm
  bonding: alb: fix UAF in rlb_arp_recv during bond up/down
  macvlan: observe an RCU grace period in macvlan_common_newlink() error path
  netfilter: nf_conntrack_h323: don't pass uninitialised l3num value
  net/rds: rds_sendmsg should not discard payload_len
  xen-netback: reject zero-queue configuration from guest
  net: usb: catc: enable basic endpoint checking
  usbb: catc: use correct API for MAC addresses
  cpuidle: Skip governor when only one idle state is available
  pinctrl: single: fix refcount leak in pcs_add_gpio_func()
  iio: sca3000: Fix a resource leak in sca3000_probe()
  ovl: Fix uninit-value in ovl_fill_real
  drivers: iio: mpu3050: use dev_err_probe for regulator request
  mfd: arizona: Fix regulator resource leak on wm5102_clear_write_sequencer() failure
  Revert "mmc: rtsx_pci_sdmmc: increase power-on settling delay to 5ms"
  mmc: rtsx_pci_sdmmc: increase power-on settling delay to 5ms
  mmc: core: Initial support for SD express card/host
  serial: SH_SCI: improve "DMA support" prompt
  staging: greybus: lights: avoid NULL deref
  fbdev: au1200fb: Fix a memory leak in au1200fb_drv_probe()
  tracing: Remove duplicate ENABLE_EVENT_STR and DISABLE_EVENT_STR macros
  scsi: csiostor: Fix dereference of null pointer rn
  pNFS: fix a missing wake up while waiting on NFS_LAYOUT_DRAIN
  svcrdma: Remove queue-shortening warnings
  RDMA/core: Fix a couple of obvious typos in comments
  power: supply: wm97xx_battery: Convert to GPIO descriptor
  power: supply: bq27xxx: fix wrong errno when bus ops are unsupported
  power: supply: sbs-battery: Fix use-after-free in power_supply_changed()
  power: supply: rt9455: Fix use-after-free in power_supply_changed()
  power: supply: act8945a: Fix use-after-free in power_supply_changed()
  serial: caif: fix use-after-free in caif_serial ldisc_close()
  net: atm: fix crash due to unvalidated vcc pointer in sigd_send()
  procfs: fix missing RCU protection when reading real_parent in do_task_stat()
  netfilter: nft_set_rbtree: check for partial overlaps in anonymous sets
  netfilter: nft_set_hash: fix get operation on big endian
  bonding: only set speed/duplex to unknown, if getting speed failed
  ucount: check for CAP_SYS_RESOURCE using ns_capable_noaudit()
  tcp: tcp_tx_timestamp() must look at the rtx queue
  fat: avoid parent link count underflow in rmdir
  PCI: Mark 3ware-9650SA Root Port Extended Tags as broken
  netfilter: nf_conncount: fix tracking of connections from localhost
  netfilter: nf_conncount: increase the connection clean up limit to 64
  netfilter: nf_conncount: make nf_conncount_gc_list() to disable BH
  wifi: cfg80211: stop NAN and P2P in cfg80211_leave
  PCI/portdrv: Fix potential resource leak
  PCI: Do not attempt to set ExtTag for VFs
  PCI: mediatek: Fix IRQ domain leak when MSI allocation fails
  Revert "hwmon: (ibmpex) fix use-after-free in high/low store"
  spi: tools: Add include folder to .gitignore
  regulator: Flag uncontrollable regulators as always_on
  regulator: core: Respect off_on_delay at startup
  smack: /smack/doi: accept previously used values
  smack: /smack/doi must be > 0
  arm64: dts: amlogic: gx: assign the MMC signal clocks
  ARM: dts: allwinner: sun5i-a13-utoo-p66: delete "power-gpios" property
  EDAC/i5400: Fix snprintf() limit calculation in calculate_dimm_size()
  EDAC/i5000: Fix snprintf() size calculation in calculate_dimm_size()
  pstore/ram: fix buffer overflow in persistent_ram_save_old()
  sched/rt: Skip currently executing CPU in rto_next_cpu()
  mfd: wm8350-core: Use IRQF_ONESHOT
  EDAC/altera: Remove IRQF_ONESHOT
  hrtimer: Fix trace oddity
  crypto: cavium - fix dma_free_coherent() size
  s390/cio: Fix device lifecycle handling in css_alloc_subchannel()
  PM: sleep: wakeirq: harden dev_pm_clear_wake_irq() against races
  md/raid10: fix any_working flag handling in raid10_sync_request
  tpm: st33zp24: Fix missing cleanup on get_burstcount() error
  tpm: tpm_i2c_infineon: Fix locality leak on get_burstcount() failure
  gfs2: Add metapath_dibh helper
  gfs2: Add wrapper for iomap_file_buffered_write
  fs: add <linux/init_task.h> for 'init_fs'
  hfsplus: return error when node already exists in hfs_bnode_create
  auxdisplay: arm-charlcd: fix release_mem_region() size
  RDMA/umad: Reject negative data_len in ib_umad_write

Change-Id: Ice1efa8b2faaaab14d1d1563e5aa6ae36549682b
2026-04-22 07:08:43 +01:00
a686f26bf5 include: uapi: netfilter_bridge.h: Cover for musl libc
[ Upstream commit 4edd4ba71ce0df015303dba75ea9d20d1a217546 ]

Musl defines its own struct ethhdr and thus defines __UAPI_DEF_ETHHDR to
zero. To avoid struct redefinition errors, user space is therefore
supposed to include netinet/if_ether.h before (or instead of)
linux/if_ether.h. To relieve them from this burden, include the libc
header here if not building for kernel space.

Reported-by: Alyssa Ross <hi@alyssa.is>
Suggested-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
2026-04-12 13:56:48 +08:00
276459f34f virt: vbox: uapi: Mark inner unions in packed structs as packed
[ Upstream commit c25d01e1c4f2d43f47af87c00e223f5ca7c71792 ]

The unpacked unions within a packed struct generates alignment warnings
on clang for 32-bit ARM:

./usr/include/linux/vbox_vmmdev_types.h:239:4: error: field u within 'struct vmmdev_hgcm_function_parameter32'
  is less aligned than 'union (unnamed union at ./usr/include/linux/vbox_vmmdev_types.h:223:2)'
  and is usually due to 'struct vmmdev_hgcm_function_parameter32' being packed,
  which can lead to unaligned accesses [-Werror,-Wunaligned-access]
     239 |         } u;
         |           ^

./usr/include/linux/vbox_vmmdev_types.h:254:6: error: field u within
  'struct vmmdev_hgcm_function_parameter64::(anonymous union)::(unnamed at ./usr/include/linux/vbox_vmmdev_types.h:249:3)'
  is less aligned than 'union (unnamed union at ./usr/include/linux/vbox_vmmdev_types.h:251:4)' and is usually due to
  'struct vmmdev_hgcm_function_parameter64::(anonymous union)::(unnamed at ./usr/include/linux/vbox_vmmdev_types.h:249:3)'
  being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]

With the recent changes to compile-test the UAPI headers in more cases,
these warning in combination with CONFIG_WERROR breaks the build.

Fix the warnings.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202512140314.DzDxpIVn-lkp@intel.com/
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/linux-kbuild/20260110-uapi-test-disable-headers-arm-clang-unaligned-access-v1-1-b7b0fa541daa@kernel.org/
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/linux-kbuild/29b2e736-d462-45b7-a0a9-85f8d8a3de56@app.fastmail.com/
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Tested-by: Nicolas Schier <nsc@kernel.org>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/20260115-kbuild-alignment-vbox-v1-2-076aed1623ff@linutronix.de
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
2026-04-12 13:56:47 +08:00
e1c5814fcf hyper-v: Mark inner union in hv_kvp_exchg_msg_value as packed
[ Upstream commit 1e5271393d777f6159d896943b4c44c4f3ecff52 ]

The unpacked union within a packed struct generates alignment warnings
on clang for 32-bit ARM:

./usr/include/linux/hyperv.h:361:2: error: field  within 'struct hv_kvp_exchg_msg_value'
  is less aligned than 'union hv_kvp_exchg_msg_value::(anonymous at ./usr/include/linux/hyperv.h:361:2)'
  and is usually due to 'struct hv_kvp_exchg_msg_value' being packed,
  which can lead to unaligned accesses [-Werror,-Wunaligned-access]
     361 |         union {
         |         ^

With the recent changes to compile-test the UAPI headers in more cases,
this warning in combination with CONFIG_WERROR breaks the build.

Fix the warning.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202512140314.DzDxpIVn-lkp@intel.com/
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/linux-kbuild/20260110-uapi-test-disable-headers-arm-clang-unaligned-access-v1-1-b7b0fa541daa@kernel.org/
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/linux-kbuild/29b2e736-d462-45b7-a0a9-85f8d8a3de56@app.fastmail.com/
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Wei Liu (Microsoft) <wei.liu@kernel.org>
Tested-by: Nicolas Schier <nsc@kernel.org>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/20260115-kbuild-alignment-vbox-v1-1-076aed1623ff@linutronix.de
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
2026-04-12 13:56:46 +08:00
56ce939ed0 UPSTREAM: geneve: Allow configuration of DF behaviour
draft-ietf-nvo3-geneve-08 says:

   It is strongly RECOMMENDED that Path MTU Discovery ([RFC1191],
   [RFC1981]) be used by setting the DF bit in the IP header when Geneve
   packets are transmitted over IPv4 (this is the default with IPv6).

Now that ICMP error handling is working for GENEVE, we can comply with
this recommendation.

Make this configurable, though, to avoid breaking existing setups. By
default, DF won't be set. It can be set or inherited from inner IPv4
packets. If it's configured to be inherited and we are encapsulating IPv6,
it will be set.

This only applies to non-lwt tunnels: if an external control plane is
used, tunnel key will still control the DF flag.

v2:
- DF behaviour configuration only applies for non-lwt tunnels, apply DF
  setting only if (!geneve->collect_md) in geneve_xmit_skb()
  (Stephen Hemminger)

Change-Id: I8c4148083e8ab7ecc7dd134d7f490f0738a04fb6
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2026-03-20 13:38:05 -04:00
33c2eed3f2 UPSTREAM: geneve: add ttl inherit support
Similar with commit 72f6d71e49 ("vxlan: add ttl inherit support"),
currently ttl == 0 means "use whatever default value" on geneve instead
of inherit inner ttl. To respect compatibility with old behavior, let's
add a new IFLA_GENEVE_TTL_INHERIT for geneve ttl inherit support.

Reported-by: Jianlin Shi <jishi@redhat.com>
Suggested-by: Jiri Benc <jbenc@redhat.com>
Change-Id: I6bdec79ff810c7609fca9be6eab5bcfed23547e4
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2026-03-20 13:38:05 -04:00
f2dc54176e UPSTREAM: ipv4: Add "offload" and "trap" indications to routes
When performing L3 offload, routes and nexthops are usually programmed
into two different tables in the underlying device. Therefore, the fact
that a nexthop resides in hardware does not necessarily mean that all
the associated routes also reside in hardware and vice-versa.

While the kernel can signal to user space the presence of a nexthop in
hardware (via 'RTNH_F_OFFLOAD'), it does not have a corresponding flag
for routes. In addition, the fact that a route resides in hardware does
not necessarily mean that the traffic is offloaded. For example,
unreachable routes (i.e., 'RTN_UNREACHABLE') are programmed to trap
packets to the CPU so that the kernel will be able to generate the
appropriate ICMP error packet.

This patch adds an "offload" and "trap" indications to IPv4 routes, so
that users will have better visibility into the offload process.

'struct fib_alias' is extended with two new fields that indicate if the
route resides in hardware or not and if it is offloading traffic from
the kernel or trapping packets to it. Note that the new fields are added
in the 6 bytes hole and therefore the struct still fits in a single
cache line [1].

Capable drivers are expected to invoke fib_alias_hw_flags_set() with the
route's key in order to set the flags.

The indications are dumped to user space via a new flags (i.e.,
'RTM_F_OFFLOAD' and 'RTM_F_TRAP') in the 'rtm_flags' field in the
ancillary header.

v2:
* Make use of 'struct fib_rt_info' in fib_alias_hw_flags_set()

[1]
struct fib_alias {
        struct hlist_node  fa_list;                      /*     0    16 */
        struct fib_info *          fa_info;              /*    16     8 */
        u8                         fa_tos;               /*    24     1 */
        u8                         fa_type;              /*    25     1 */
        u8                         fa_state;             /*    26     1 */
        u8                         fa_slen;              /*    27     1 */
        u32                        tb_id;                /*    28     4 */
        s16                        fa_default;           /*    32     2 */
        u8                         offload:1;            /*    34: 0  1 */
        u8                         trap:1;               /*    34: 1  1 */
        u8                         unused:6;             /*    34: 2  1 */

        /* XXX 5 bytes hole, try to pack */

        struct callback_head rcu __attribute__((__aligned__(8))); /*    40    16 */

        /* size: 56, cachelines: 1, members: 12 */
        /* sum members: 50, holes: 1, sum holes: 5 */
        /* sum bitfield members: 8 bits (1 bytes) */
        /* forced alignments: 1, forced holes: 1, sum forced holes: 5 */
        /* last cacheline: 56 bytes */
} __attribute__((__aligned__(8)));

Change-Id: I922ddc53c253a28de2132b32a091c3363605859b
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2026-03-20 13:38:05 -04:00
135eff3beb UPSTREAM: net: nexthop uapi
New UAPI for nexthops as standalone objects:
- defines netlink ancillary header, struct nhmsg
- RTM commands for nexthop objects, RTM_*NEXTHOP,
- RTNLGRP for nexthop notifications, RTNLGRP_NEXTHOP,
- Attributes for creating nexthops, NHA_*
- Attribute for route specs to specify a nexthop by id, RTA_NH_ID.

The nexthop attributes and semantics follow the route and RTA ones for
device, gateway and lwt encap. Unique to nexthop objects are a blackhole
and a group which contains references to other nexthop objects. With the
exception of blackhole and group, nexthop objects MUST contain a device.
Gateway and encap are optional. Nexthop groups can only reference other
pre-existing nexthops by id. If the NHA_ID attribute is present that id
is used for the nexthop. If not specified, one is auto assigned.

Dump requests can include attributes:
- NHA_GROUPS to return only nexthop groups,
- NHA_MASTER to limit dumps to nexthops with devices enslaved to the
  given master (e.g., VRF)
- NHA_OIF to limit dumps to nexthops using given device

nlmsg_route_perms in selinux code is updated for the new RTM comands.

Change-Id: If128ffc0daf4640aa9a7bdb07d9149675772125e
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2026-03-20 13:38:03 -04:00
a984488d32 Merge tag 'v4.19.325-cip130' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip into android13-4.19-kona
version 4.19.325-cip130

* tag 'v4.19.325-cip130' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip:
  CIP: Bump version suffix to -cip130 after merge from cip/linux-4.19.y-st tree
  Update localversion-st, tree is up-to-date with 5.10.251.
  f2fs: fix out-of-bounds access in sysfs attribute read/write
  USB: serial: option: add Telit FN920C04 RNDIS compositions
  f2fs: fix to avoid UAF in f2fs_write_end_io()
  fbdev: rivafb: fix divide error in nv3_arb()
  scsi: qla2xxx: Fix bsg_done() causing double free
  scsi: qla2xxx: Validate sp before freeing associated memory
  scsi: qla2xxx: Free sp in error path to fix system crash
  crypto: virtio - Remove duplicated virtqueue_kick in virtio_crypto_skcipher_crypt_req
  fs: dlm: fix invalid derefence of sb_lvbptr
  gpiolib: acpi: Fix gpio count with string references
  platform/x86: classmate-laptop: Add missing NULL pointer checks
  drm/tegra: hdmi: sor: Fix error: variable ‘j’ set but not used
  gpio: sprd: Change sprd_gpio lock to raw_spin_lock
  gpio: omap: do not register driver in probe()
  scsi: qla2xxx: Query FW again before proceeding with login
  scsi: qla2xxx: Delay module unload while fabric scan in progress
  nilfs2: Fix potential block overflow that cause system hang
  crypto: virtio - Add spinlock protection with virtqueue notification
  crypto: omap - Allocate OMAP_CRYPTO_FORCE_COPY scatterlists correctly
  CIP: Bump version suffix to -cip129 after merge from cip/linux-4.19.y-st tree
  Update localversion-st, tree is up-to-date with 5.10.250.
  fbdev: ssd1307fb: fix build failure
  macvlan: fix possible UAF in macvlan_forward_source()
  HID: uclogic: Correct devm device reference for hidinput input_dev name
  xfs: set max_agbno to allow sparse alloc of last full inode chunk
  l2tp: avoid one data-race in l2tp_tunnel_del_work()
  platform/x86: intel_telemetry: Fix swapped arrays in PSS output
  macvlan: fix error recovery in macvlan_common_newlink()
  net: liquidio: Initialize netdev pointer before queue setup
  platform/x86: intel_telemetry: Fix PSS event register mask
  platform/x86: toshiba_haps: Fix memory leaks in add/remove routines
  scsi: target: iscsi: Fix use-after-free in iscsit_dec_conn_usage_count()
  scsi: target: iscsi: Fix use-after-free in iscsit_dec_session_usage_count()
  wifi: cfg80211: Fix bitrate calculation overflow for HE rates
  wifi: mac80211: collect station statistics earlier when disconnect
  ring-buffer: Avoid softlockup in ring_buffer_resize() during memory free
  HID: Apply quirk HID_QUIRK_ALWAYS_POLL to Edifier QR30 (2d99:a101)
  HID: quirks: Add another Chicony HP 5MP Cameras to hid_ignore_list
  HID: intel-ish-hid: Reset enum_devices_done before enumeration
  HID: multitouch: add MT_QUIRK_STICKY_FINGERS to MT_CLS_VTL
  net: usb: sr9700: support devices with virtual driver CD
  wifi: wlcore: ensure skb headroom before skb_push
  wifi: mac80211: ocb: skip rx_no_sta when interface is not joined
  ARM: 9468/1: fix memset64() on big-endian
  pinctrl: meson: mark the GPIO controller as sleeping
  writeback: fix 100% CPU usage when dirtytime_expire_interval is 0
  netfilter: nf_tables: typo NULL check in _clone() function
  ipv6: sr: Fix MAC comparison to be constant-time
  of: platform: Use default match table for /firmware
  can: esd_usb: esd_usb_read_bulk_callback(): fix URB memory leak
  driver core: fix potential null-ptr-deref in device_add()
  mei: trace: treat reg parameter as string
  iio: adc: exynos_adc: fix OF populate on driver rebind
  scsi: xen: scsiback: Fix potential memory leak in scsiback_remove()
  dmaengine: stm32: dmamux: fix device leak on route allocation
  nvme-fc: rename free_ctrl callback to match name pattern
  net/sched: act_ife: convert comma to semicolon
  scsi: be2iscsi: Fix a memory leak in beiscsi_boot_get_sinfo()
  scsi: firewire: sbp-target: Fix overflow in sbp_make_tpg()
  nfc: nci: Fix race between rfkill and nci_unregister_device().
  net/mlx5e: Report rx_discards_phy via rx_dropped
  rocker: fix memory leak in rocker_world_port_post_fini()
  Bluetooth: hci_uart: fix null-ptr-deref in hci_uart_write_work
  can: usb_8dev: usb_8dev_read_bulk_callback(): fix URB memory leak
  can: mcba_usb: mcba_usb_read_bulk_callback(): fix URB memory leak
  can: kvaser_usb: kvaser_usb_read_bulk_callback(): fix URB memory leak
  can: ems_usb: ems_usb_read_bulk_callback(): fix URB memory leak
  perf/x86/intel: Do not enable BTS for guests
  netrom: fix double-free in nr_route_frame()
  slimbus: core: fix device reference leak on report present
  slimbus: core: fix runtime PM imbalance on report present
  wifi: rsi: Fix memory corruption due to not set vif driver data size
  wifi: mwifiex: Fix a loop in mwifiex_update_ampdu_rxwinsize()
  wifi: ath10k: fix dma_free_coherent() pointer
  mmc: rtsx_pci_sdmmc: implement sdmmc_card_busy function
  ALSA: usb-audio: Fix use-after-free in snd_usb_mixer_free()
  ALSA: ctxfi: Fix potential OOB access in audio mixer handling
  iio: dac: ad5686: add AD5695R to ad5686_chip_info_tbl
  iio: adc: at91-sama5d2_adc: Fix potential use-after-free in sama5d2_adc driver
  of: fix reference count leak in of_alias_scan()
  leds: led-class: Only Add LED to leds_list when it is fully ready
  net/sched: act_ife: avoid possible NULL deref
  be2net: Fix NULL pointer dereference in be_cmd_get_mac_from_list
  drm/amd/pm: Workaround SI powertune issue on Radeon 430 (v2)
  drm/amd/pm: Don't clear SI SMC table when setting power limit
  usbnet: limit max_mtu based on device's hard_mtu
  mISDN: annotate data-race around dev->work
  ALSA: usb: Increase volume range that triggers a warning
  regmap: Fix race condition in hwspinlock irqsave routine
  iio: adc: ad7280a: handle spi_setup() errors in probe()
  Input: i8042 - add quirk for ASUS Zenbook UX425QA_UM425QA
  w1: fix redundant counter decrement in w1_attach_slave_device()
  comedi: dmm32at: serialize use of paged registers
  crypto: authencesn - reject too-short AAD (assoclen<8) to match ESP/ESN spec
  net/sched: Enforce that teql can only be used as root qdisc
  ipvlan: Make the addrs_lock be per port
  net: fou: rename the source for linking
  netlink: add a proto specification for FOU
  gue: Fix skb memleak with inner IP protocol 0.
  amd-xgbe: avoid misleading per-packet error log
  sctp: move SCTP_CMD_ASSOC_SHKEY right after SCTP_CMD_PEER_INIT
  sctp: sm_statefuns: Fix spelling mistakes
  net: usb: dm9601: remove broken SR9700 support
  macvlan: Fix leaking skb in source mode with nodst option
  btrfs: fix deadlock in wait_current_trans() due to ignored transaction type
  dmaengine: ti: dma-crossbar: fix device leak on am335x route allocation
  dmaengine: ti: dma-crossbar: fix device leak on dra7x route allocation
  dmaengine: lpc18xx-dmamux: fix device leak on route allocation
  dmaengine: bcm-sba-raid: fix device leak on probe
  dmaengine: at_hdmac: fix device leak on of_dma_xlate()
  drm/vmwgfx: Fix an error return check in vmw_compat_shader_add()
  drm/nouveau/disp/nv50-: Set lock_core in curs507a_prepare
  EDAC/i3200: Fix a resource leak in i3200_probe1()
  EDAC/x38: Fix a resource leak in x38_probe1()
  USB: serial: ftdi_sio: add support for PICAXE AXE027 cable
  USB: serial: option: add Telit LE910 MBIM composition
  USB: OHCI/UHCI: Add soft dependencies on ehci_platform
  ALSA: pcm: Improve the fix for race of buffer access at PCM OSS layer
  HID: usbhid: paper over wrong bNumDescriptor field
  dmaengine: omap-dma: fix dma_pool resource leak in error paths
  phy: stm32-usphyc: Fix off by one in probe()
  dmaengine: tegra-adma: Fix use-after-free
  textsearch: describe @list member in ts_ops search
  net/sched: sch_qfq: do not free existing class in qfq_change_class()
  ipv4: ip_gre: make ipgre_header() robust
  macvlan: Use 'hash' iterators to simplify code
  macvlan: Add nodst option to macvlan type source
  pnfs/flexfiles: Fix memory leak in nfs4_ff_alloc_deviceid_node()

Change-Id: I4b06f63aef42258de0c0415a055c47d8e60bba88
2026-03-20 15:21:00 +00:00
981eb73054 macvlan: Add nodst option to macvlan type source
[ Upstream commit 427f0c8c194b22edcafef1b0a42995ddc5c2227d ]

The default behavior for source MACVLAN is to duplicate packets to
appropriate type source devices, and then do the normal destination MACVLAN
flow. This patch adds an option to skip destination MACVLAN processing if
any matching source MACVLAN device has the option set.

This allows setting up a "catch all" device for source MACVLAN: create one
or more devices with type source nodst, and one device with e.g. type vepa,
and incoming traffic will be received on exactly one device.

v2: netdev wants non-standard line length

Signed-off-by: Jethro Beekman <kernel@jbeekman.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: 7470a7a63dc1 ("macvlan: fix possible UAF in macvlan_forward_source()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
2026-02-20 13:22:27 +08:00
16e1462480 UPSTREAM: net: netlink: rename NETLINK_DUMP_STRICT_CHK -> NETLINK_GET_STRICT_CHK
NETLINK_DUMP_STRICT_CHK can be used for all GET requests,
dumps as well as doit handlers.  Replace the DUMP in the
name with GET make that clearer.

Change-Id: I912fa2ee9b3caf975aefc8614d3ca59543d0f566
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2026-02-02 18:01:37 -05:00
c28685175d UPSTREAM: netlink: Add new socket option to enable strict checking on dumps
Add a new socket option, NETLINK_DUMP_STRICT_CHK, that userspace
can use via setsockopt to request strict checking of headers and
attributes on dump requests.

To get dump features such as kernel side filtering based on data in
the header or attributes appended to the dump request, userspace
must call setsockopt() for NETLINK_DUMP_STRICT_CHK and a non-zero
value. Since the netlink sock and its flags are private to the
af_netlink code, the strict checking flag is passed to dump handlers
via a flag in the netlink_callback struct.

For old userspace on new kernel there is no impact as all of the data
checks in later patches are wrapped in a check on the new strict flag.

For new userspace on old kernel, the setsockopt will fail and even if
new userspace sets data in the headers and appended attributes the
kernel will silently ignore it. Moving forward when the setsockopt
succeeds, the new userspace on old kernel means the dump request can
pass an attribute the kernel does not understand. The dump will then
fail as the older kernel does not understand it.

New userspace on new kernel setting the socket option gets the benefit
of the improved data dump.

Kernel side the NETLINK_DUMP_STRICT_CHK uapi is converted to a generic
NETLINK_F_STRICT_CHK flag which can potentially be leveraged for tighter
checking on the NEW, DEL, and SET commands.

Change-Id: I7a4c0edf096e6a49cf0d1b5b919908408ba8e1e4
Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Christian Brauner <christian@brauner.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
2026-02-02 18:01:37 -05:00
4d9e209b46 UPSTREAM: fs, close_range: add flag CLOSE_RANGE_CLOEXEC
When the flag CLOSE_RANGE_CLOEXEC is set, close_range doesn't
immediately close the files but it sets the close-on-exec bit.

It is useful for e.g. container runtimes that usually install a
seccomp profile "as late as possible" before execv'ing the container
process itself.  The container runtime could either do:
  1                                  2
- install_seccomp_profile();       - close_range(MIN_FD, MAX_INT, 0);
- close_range(MIN_FD, MAX_INT, 0); - install_seccomp_profile();
- execve(...);                     - execve(...);

Both alternative have some disadvantages.

In the first variant the seccomp_profile cannot block the close_range
syscall, as well as opendir/read/close/... for the fallback on older
kernels.
In the second variant, close_range() can be used only on the fds
that are not going to be needed by the runtime anymore, and it must be
potentially called multiple times to account for the different ranges
that must be closed.

Using close_range(..., ..., CLOSE_RANGE_CLOEXEC) solves these issues.
The runtime is able to use the existing open fds, the seccomp profile
can block close_range() and the syscalls used for its fallback.

Change-Id: I1c84a733698c2853a0126cd22960ada25b229c5a
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Link: https://lore.kernel.org/r/20201118104746.873084-2-gscrivan@redhat.com
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2025-12-31 12:15:31 +02:00
e3ff5b0bc5 UPSTREAM: close_range: add CLOSE_RANGE_UNSHARE
One of the use-cases of close_range() is to drop file descriptors just before
execve(). This would usually be expressed in the sequence:

unshare(CLONE_FILES);
close_range(3, ~0U);

as pointed out by Linus it might be desirable to have this be a part of
close_range() itself under a new flag CLOSE_RANGE_UNSHARE.

This expands {dup,unshare)_fd() to take a max_fds argument that indicates the
maximum number of file descriptors to copy from the old struct files. When the
user requests that all file descriptors are supposed to be closed via
close_range(min, max) then we can cap via unshare_fd(min) and hence don't need
to do any of the heavy fput() work for everything above min.

The patch makes it so that if CLOSE_RANGE_UNSHARE is requested and we do in
fact currently share our file descriptor table we create a new private copy.
We then close all fds in the requested range and finally after we're done we
install the new fd table.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Change-Id: I0813045886501e40a45693ee1edad50bdf2b66e5
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2025-12-31 12:15:31 +02:00
1dd9f9066b Merge tag 'v4.19.325-cip126' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip into android13-4.19-kona
version 4.19.325-cip126

* tag 'v4.19.325-cip126' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip:
  CIP: Bump version suffix to -cip126 after merge from cip/linux-4.19.y-st tree
  net: ravb: Ensure memory write completes before ringing TX doorbell
  Update localversion-st, tree is up-to-date with 5.4.301.
  net: ravb: Ensure memory write completes before ringing TX doorbell
  net/ip6_tunnel: Prevent perpetual tunnel growth
  tracing: Fix race condition in kprobe initialization causing NULL pointer dereference
  rtc: interface: Ensure alarm irq is enabled when UIE is enabled
  tpm_tis: Fix incorrect arguments in tpm_tis_probe_irq_single
  media: s5p-mfc: remove an unused/uninitialized variable
  NFSD: Fix last write offset handling in layoutcommit
  NFSD: Minor cleanup in layoutcommit processing
  KEYS: trusted_tpm1: Compare HMAC values in constant time
  NFSD: Define a proc_layoutcommit for the FlexFiles layout type
  vfs: Don't leak disconnected dentries on umount
  ext4: detect invalid INLINE_DATA + EXTENTS flag combination
  drm/amdgpu: use atomic functions with memory barriers for vm fault info
  ext4: avoid potential buffer over-read in parse_apply_sb_mount_options()
  spi: cadence-quadspi: Flush posted register writes before DAC access
  spi: cadence-quadspi: Flush posted register writes before INDAC access
  memory: samsung: exynos-srom: Fix of_iomap leak in exynos_srom_probe
  memory: samsung: exynos-srom: Correct alignment
  arm64: cputype: Add Neoverse-V3AE definitions
  comedi: fix divide-by-zero in comedi_buf_munge()
  binder: remove "invalid inc weak" check
  xhci: dbc: enable back DbC in resume if it was enabled before suspend
  usb/core/quirks: Add Huawei ME906S to wakeup quirk
  USB: serial: option: add Telit FN920C04 ECM compositions
  USB: serial: option: add Quectel RG255C
  USB: serial: option: add UNISOC UIS7720
  net: usb: rtl8150: Fix frame padding
  ocfs2: clear extent cache after moving/defragmenting extents
  MIPS: Malta: Fix keyboard resource preventing i8042 driver from registering
  Revert "cpuidle: menu: Avoid discarding useful information"
  sctp: avoid NULL dereference when chunk data buffer is missing
  arm64, mm: avoid always making PTE dirty in pte_mkwrite()
  net: add ndo_fdb_del_bulk
  net: netlink: add NLM_F_BULK delete request modifier
  net: rtnetlink: use BIT for flag values
  net: rtnetlink: add helper to extract msg type's kind
  net: rtnetlink: add msg kind names
  net: rtnetlink: remove redundant assignment to variable err
  m68k: bitops: Fix find_*_bit() signatures
  hfsplus: return EIO when type of hidden directory mismatch in hfsplus_fill_super()
  hfs: fix KMSAN uninit-value issue in hfs_find_set_zero_bits()
  dlm: check for defined force value in dlm_lockspace_release
  hfsplus: fix KMSAN uninit-value issue in hfsplus_delete_cat()
  hfs: validate record offset in hfsplus_bmap_alloc
  hfsplus: fix KMSAN uninit-value issue in __hfsplus_ext_cache_extent()
  hfs: make proper initalization of struct hfs_find_data
  hfs: clear offset and space out of valid records in b-tree node
  exec: Fix incorrect type for ret
  hfsplus: fix slab-out-of-bounds read in hfsplus_strcasecmp()
  tls: always set record_type in tls_process_cmsg
  tg3: prevent use of uninitialized remote_adv and local_adv variables
  amd-xgbe: Avoid spurious link down messages during interface toggle
  net: dlink: handle dma_map_single() failure properly
  net: dl2k: switch from 'pci_' to 'dma_' API
  xen/events: Update virq_to_irq on migration
  media: lirc: Fix error handling in lirc_register()
  media: rc: Directly use ida_free()
  drm/exynos: exynos7_drm_decon: remove ctx->suspended
  btrfs: avoid potential out-of-bounds in btrfs_encode_fh()
  pwm: berlin: Fix wrong register in suspend/resume
  media: cx18: Add missing check after DMA map
  xen/events: Cleanup find_virq() return codes
  cramfs: Verify inode mode when loading from disk
  pid: Add a judgment for ns null in pid_nr_ns
  minixfs: Verify inode mode when loading from disk
  mfd: intel_soc_pmic_chtdc_ti: Drop unneeded assignment for cache_type
  mfd: intel_soc_pmic_chtdc_ti: Fix invalid regmap-config max_register value
  Squashfs: reject negative file sizes in squashfs_read_inode()
  Squashfs: add additional inode sanity checking
  mfd: vexpress-sysreg: Check the return value of devm_gpiochip_add_data()
  fs: udf: fix OOB read in lengthAllocDescs handling
  KVM: x86: Don't (re)check L1 intercepts when completing userspace I/O
  net/9p: fix double req put in p9_fd_cancelled
  ext4: guard against EA inode refcount underflow in xattr update
  ext4: correctly handle queries for metadata mappings
  ext4: increase i_disksize to offset + len in ext4_update_disksize_before_punch()
  nfsd: nfserr_jukebox in nlm_fopen should lead to a retry
  x86/umip: Fix decoding of register forms of 0F 01 (SGDT and SIDT aliases)
  x86/umip: Check that the instruction opcode is at least two bytes
  PCI/AER: Fix missing uevent on recovery when a reset is requested
  rtc: interface: Fix long-standing race when setting alarm
  mmc: core: SPI mode remove cmd7
  mtd: rawnand: fsmc: Default to autodetect buswidth
  sparc64: fix hugetlb for sun4u
  sctp: Fix MAC comparison to be constant-time
  scsi: hpsa: Fix potential memory leak in hpsa_big_passthru_ioctl()
  parisc: don't reference obsolete termio struct for TC* constants
  lib/genalloc: fix device leak in of_gen_pool_get()
  iio: frequency: adf4350: Fix prescaler usage.
  iio: dac: ad5421: use int type to store negative error codes
  iio: dac: ad5360: use int type to store negative error codes
  crypto: atmel - Fix dma_unmap_sg() direction
  drm/nouveau: fix bad ret code in nouveau_bo_move_prep
  media: i2c: mt9v111: fix incorrect type for ret
  ACPI: debug: fix signedness issues in read/write helpers
  tools build: Align warning options with perf
  net: fsl_pq_mdio: Fix device node reference leak in fsl_pq_mdio_probe
  tcp: Don't call reqsk_fastopen_remove() in tcp_conn_request().
  net/sctp: fix a null dereference in sctp_disposition sctp_sf_do_5_1D_ce()
  net/mlx4: prevent potential use after free in mlx4_en_do_uc_filter()
  scsi: mvsas: Fix use-after-free bugs in mvs_work_queue
  clk: nxp: Fix pll0 rate check condition in LPC18xx CGU driver
  clk: nxp: lpc18xx-cgu: convert from round_rate() to determine_rate()
  perf session: Fix handling when buffer exceeds 2 GiB
  perf util: Fix compression checks returning -1 as bool
  iio: frequency: adf4350: Fix ADF4350_REG3_12BIT_CLKDIV_MODE
  pinctrl: check the return value of pinmux_ops::get_function_name()
  Input: uinput - zero-initialize uinput_ff_upload_compat to avoid info leak
  mm: hugetlb: avoid soft lockup when mprotect to large memory area
  Squashfs: fix uninit-value in squashfs_get_parent
  net: ena: return 0 in ena_get_rxfh_key_size() when RSS hash key is not configurable
  nfp: fix RSS hash key size when RSS is not supported
  drivers/base/node: fix double free in register_one_node()
  ocfs2: fix double free in user_cluster_connect()
  net: usb: Remove disruptive netif_wake_queue in rtl8150_set_multicast
  usb: vhci-hcd: Prevent suspending virtually attached devices
  scsi: mpt3sas: Fix crash in transport port remove by using ioc_info()
  ipvs: Defer ip_vs_ftp unregister during netns cleanup
  NFSv4.1: fix backchannel max_resp_sz verification check
  remoteproc: qcom: q6v5: Avoid disabling handover IRQ twice
  sparc: fix accurate exception reporting in copy_{from,to}_user for M7
  sparc: fix accurate exception reporting in copy_to_user for Niagara 4
  sparc: fix accurate exception reporting in copy_{from_to}_user for Niagara
  sparc: fix accurate exception reporting in copy_{from_to}_user for UltraSPARC III
  sparc: fix accurate exception reporting in copy_{from_to}_user for UltraSPARC
  IB/sa: Fix sa_local_svc_timeout_ms read race
  drivers/base/node: handle error properly in register_one_node()
  watchdog: mpc8xxx_wdt: Reload the watchdog timer when enabling the watchdog
  iio: consumers: Fix offset handling in iio_convert_raw_to_processed()
  ASoC: Intel: bytcr_rt5651: Fix invalid quirk input mapping
  ASoC: Intel: bytcr_rt5640: Fix invalid quirk input mapping
  pps: fix warning in pps_register_cdev when register device fail
  misc: genwqe: Fix incorrect cmd field being reported in error
  usb: gadget: configfs: Correctly set use_os_string at bind
  usb: phy: twl6030: Fix incorrect type for ret
  tcp: fix __tcp_close() to only send RST when required
  PCI: tegra: Fix devm_kcalloc() argument order for port->phys allocation
  wifi: mwifiex: send world regulatory domain to driver
  ALSA: lx_core: use int type to store negative error codes
  media: rj54n1cb0c: Fix memleak in rj54n1_probe()
  scsi: pm80xx: Fix array-index-out-of-of-bounds on rmmod
  usb: host: max3421-hcd: Fix error pointer dereference in probe cleanup
  drm/radeon/r600_cs: clean up of dead code in r600_cs
  i2c: designware: Add disabling clocks when probe fails
  i2c: mediatek: fix potential incorrect use of I2C_MASTER_WRRD
  pwm: tiehrpwm: Fix corner case in clock divisor calculation
  block: use int to store blk_stack_limits() return value
  blk-mq: check kobject state_in_sysfs before deleting in blk_mq_unregister_hctx
  pinctrl: meson-gxl: add missing i2c_d pinmux
  soc: qcom: rpmh-rsc: Unconditionally clear _TRIGGER bit for TCS
  ACPI: processor: idle: Fix memory leak when register cpuidle device failed
  perf: arm_spe: Prevent overflow in PERF_IDX2OFF()
  staging: axis-fifo: fix maximum TX packet length check
  perf subcmd: avoid crash in exclude_cmds when excludes is empty
  dm-integrity: limit MAX_TAG_SIZE to 255
  wifi: rtlwifi: rtl8192cu: Don't claim USB ID 07b8:8188
  USB: serial: option: add SIMCom 8230C compositions
  media: rc: fix races with imon_disconnect()
  media: imon: grab lock earlier in imon_ir_change_protocol()
  media: imon: reorganize serialization
  media: rc: Add support for another iMON 0xffdc device
  media: i2c: tc358743: Fix use-after-free bugs caused by orphan timer in probe
  media: tuner: xc5000: Fix use-after-free in xc5000_release
  media: tunner: xc5000: Refactor firmware load
  udp: Fix memory accounting leak.
  media: b2c2: Fix use-after-free causing by irq_check_work in flexcop_pci_remove
  scsi: target: target_core_configfs: Add length check to avoid buffer overflow

Change-Id: If7e75950e2cad63499e2cfffecac3dc9b432d06c
2025-11-21 22:57:50 +00:00
d02eedbb87 net: netlink: add NLM_F_BULK delete request modifier
[ Upstream commit 545528d788556c724eeb5400757f828ef27782a8 ]

Add a new delete request modifier called NLM_F_BULK which, when
supported, would cause the request to delete multiple objects. The flag
is a convenient way to signal that a multiple delete operation is
requested which can be gradually added to different delete requests. In
order to make sure older kernels will error out if the operation is not
supported instead of doing something unintended we have to break a
required condition when implementing support for this flag, f.e. for
neighbors we will omit the mandatory mac address attribute.
Initially it will be used to add flush with filtering support for bridge
fdbs, but it also opens the door to add similar support to others.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: bf29555f5bdc ("rtnetlink: Allow deleting FDB entries in user namespace")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
2025-11-17 10:36:43 +01:00
7eae4047ae BACKPORT: ANDROID: fuse-bpf: Use fuse_bpf_args in uapi
fuse_args is not suitable for use in the uapi - it is not stable, and
contains internal pointers. Replace with stable equivalent.

The end_offset values are currently unused and unset, but will be used
in a follow up patch by the verifier.

Test: fuse_test, atest ScopedStorageDeviceTest pass
Bug: 202785178
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: Ic1c12f9706aeae233cc30a0d68ed2533030e485b
2025-10-16 21:01:13 +01:00
a7fdd9a651 UPSTREAM: ANDROID: fuse-bpf: Avoid reusing uint64_t for file
This moves the backing/fd files to their own space, instead of reusing
the userspace provided fds.

Bug: 222619123
Test: fuse_test passes, on cuttlefish CtsCameraTestCases passes
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: I5d3b1ea8299f249ef5adc1ce2b7f45404a041208
2025-10-16 21:01:13 +01:00
e65cdbc4e7 BACKPORT: ANDROID: fuse-bpf v1
Bug: 202785178
Test: test_fuse passes on linux, feature works on cuttlefish
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: I987684b799b07391ccde350e98fde7976f5601aa
2025-10-16 21:01:12 +01:00
7ed921f3d9 BACKPORT: ANDROID: fuse: Move functions in preparation for fuse-bpf
Contains squash of this commit:

Author: Nathan Chancellor <nathan@kernel.org>
Date:   Fri Jan 20 09:40:12 2023 -0700

    ANDROID: fuse: Restore upstream type of bitfields in fuse_args

    Commit 88b7179fcdb59 ("ANDROID: fuse: Move functions in preparation for
    fuse-bpf") changed the type of these bitfields from the upstream type of
    'bool' to 'int', which causes several warnings with recent versions of
    clang:

        /builds/linux/fs/fuse/dir.c:168:19: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bi
t-bitfield-constant-conversion]
                args->out_argvar = true;
                                 ^ ~~~~
        /builds/linux/fs/fuse/dir.c:492:18: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bi
t-bitfield-constant-conversion]
                args.out_argvar = 1;
                                ^ ~
        /builds/linux/fs/fuse/dir.c:1649:20: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-b
it-bitfield-constant-conversion]
                ap.args.out_pages = true;
                                  ^ ~~~~
        /builds/linux/fs/fuse/dir.c:1650:21: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-b
it-bitfield-constant-conversion]
                ap.args.out_argvar = true;
                                   ^ ~~~~
        /builds/linux/fs/fuse/dir.c:1651:23: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-b
it-bitfield-constant-conversion]
                ap.args.page_zeroing = true;
                                     ^ ~~~~
        5 errors generated.
    When fuse_args was moved back to the internal implementation in commit
    9a5023967b4d2 ("ANDROID: fuse-bpf: Use fuse_bpf_args in uapi"), the type
    was not restored. Do so now to fix the warnings and reduce the delta
    with upstream.

    Bug: 265200230
    Change-Id: I4d51f331d842a1faff9a937140f0275130e70d73
    Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Bug: 202785178
Test: test_fuse passes on linux, feature works on cuttlefish
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: Ie738893a821d1f5f252c4c6e86274d55a6f09965
2025-10-16 21:01:12 +01:00
0cfdec7866 UPSTREAM: fuse: add submount support to <uapi/linux/fuse.h>
- Add fuse_attr.flags

- Add FUSE_ATTR_SUBMOUNT

  This is a flag for fuse_attr.flags that indicates that the given entry
  resides on a different filesystem than the parent, and as such should
  have a different st_dev.

- Add FUSE_SUBMOUNTS

  The client sets this flag if it supports automounting directories.

Change-Id: Ibea2d75d0a93dc3c269555fdb7d0ee58af7860b4
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:11 +01:00
ba8289c7e7 UPSTREAM: virtiofs: implement dax read/write operations
This patch implements basic DAX support. mmap() is not implemented
yet and will come in later patches. This patch looks into implemeting
read/write.

We make use of interval tree to keep track of per inode dax mappings.

Do not use dax for file extending writes, instead just send WRITE message
to daemon (like we do for direct I/O path). This will keep write and
i_size change atomic w.r.t crash.

Change-Id: Ia135d8554026720dc87e4ef5858b230e91533de8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
Signed-off-by: Peng Tao <tao.peng@linux.alibaba.com>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:11 +01:00
4c54ef663b UPSTREAM: virtiofs: introduce setupmapping/removemapping commands
Introduce two new fuse commands to setup/remove memory mappings. This
will be used to setup/tear down file mapping in dax window.

Change-Id: I9a5686146f83a72bdef0147bd1a96ec4dd1a278d
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Peng Tao <tao.peng@linux.alibaba.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:11 +01:00
42fcf61c88 UPSTREAM: virtiofs: implement FUSE_INIT map_alignment field
The device communicates FUSE_SETUPMAPPING/FUSE_REMOVMAPPING alignment
constraints via the FUST_INIT map_alignment field.  Parse this field and
ensure our DAX mappings meet the alignment constraints.

We don't actually align anything differently since our mappings are
already 2MB aligned.  Just check the value when the connection is
established.  If it becomes necessary to honor arbitrary alignments in
the future we'll have to adjust how mappings are sized.

The upshot of this commit is that we can be confident that mappings will
work even when emulating x86 on Power and similar combinations where the
host page sizes are different.

Change-Id: I8c7b002aa413dbdae43dc159d82cba672e671351
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:11 +01:00
be509850e3 UPSTREAM: virtiofs: set up virtio_fs dax_device
Setup a dax device.

Use the shm capability to find the cache entry and map it.

The DAX window is accessed by the fs/dax.c infrastructure and must have
struct pages (at least on x86).  Use devm_memremap_pages() to map the
DAX window PCI BAR and allocate struct page.

Change-Id: I46c5a56c7add5d3afb9799db8ab0f64d3ea3ee0f
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:10 +01:00
d0673c97a0 UPSTREAM: fuse: Add changelog entries for protocols 7.1 - 7.8
Retroactively add changelog entry for FUSE protocols 7.1 through 7.8.

Change-Id: Ic89a3685306d1de1ca283bbaa070476eaf94ab9d
Signed-off-by: Alan Somers <asomers@FreeBSD.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:09 +01:00
38bc31e39f UPSTREAM: virtio-fs: add virtiofs filesystem
Add a basic file system module for virtio-fs.  This does not yet contain
shared data support between host and guest or metadata coherency speedups.
However it is already significantly faster than virtio-9p.

Design Overview
===============

With the goal of designing something with better performance and local file
system semantics, a bunch of ideas were proposed.

 - Use fuse protocol (instead of 9p) for communication between guest and
   host.  Guest kernel will be fuse client and a fuse server will run on
   host to serve the requests.

 - For data access inside guest, mmap portion of file in QEMU address space
   and guest accesses this memory using dax.  That way guest page cache is
   bypassed and there is only one copy of data (on host).  This will also
   enable mmap(MAP_SHARED) between guests.

 - For metadata coherency, there is a shared memory region which contains
   version number associated with metadata and any guest changing metadata
   updates version number and other guests refresh metadata on next access.
   This is yet to be implemented.

How virtio-fs differs from existing approaches
==============================================

The unique idea behind virtio-fs is to take advantage of the co-location of
the virtual machine and hypervisor to avoid communication (vmexits).

DAX allows file contents to be accessed without communication with the
hypervisor.  The shared memory region for metadata avoids communication in
the common case where metadata is unchanged.

By replacing expensive communication with cheaper shared memory accesses,
we expect to achieve better performance than approaches based on network
file system protocols.  In addition, this also makes it easier to achieve
local file system semantics (coherency).

These techniques are not applicable to network file system protocols since
the communications channel is bypassed by taking advantage of shared memory
on a local machine.  This is why we decided to build virtio-fs rather than
focus on 9P or NFS.

Caching Modes
=============

Like virtio-9p, different caching modes are supported which determine the
coherency level as well.  The “cache=FOO” and “writeback” options control
the level of coherence between the guest and host filesystems.

 - cache=none
   metadata, data and pathname lookup are not cached in guest.  They are
   always fetched from host and any changes are immediately pushed to host.

 - cache=always
   metadata, data and pathname lookup are cached in guest and never expire.

 - cache=auto
   metadata and pathname lookup cache expires after a configured amount of
   time (default is 1 second).  Data is cached while the file is open
   (close to open consistency).

 - writeback/no_writeback
   These options control the writeback strategy.  If writeback is disabled,
   then normal writes will immediately be synchronized with the host fs.
   If writeback is enabled, then writes may be cached in the guest until
   the file is closed or an fsync(2) performed.  This option has no effect
   on mmap-ed writes or writes going through the DAX mechanism.

Change-Id: I2c64b98beb17e4c0bbf1c0e0234b956cbc2d25ef
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:08 +01:00
a45104f05b UPSTREAM: iommu: Add virtio-iommu driver
The virtio IOMMU is a para-virtualized device, allowing to send IOMMU
requests such as map/unmap over virtio transport without emulating page
tables. This implementation handles ATTACH, DETACH, MAP and UNMAP
requests.

The bulk of the code transforms calls coming from the IOMMU API into
corresponding virtio requests. Mappings are kept in an interval tree
instead of page tables. A little more work is required for modular and x86
support, so for the moment the driver depends on CONFIG_VIRTIO=y and
CONFIG_ARM64.

Tested-by: Bharat Bhushan <bharat.bhushan@nxp.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Change-Id: I54ee8ad06e95e3f2fbc6bb0f22d3f61bfa28248a
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2025-10-16 21:01:08 +01:00
206d3e0251 UPSTREAM: fuse: reserve byteswapped init opcodes
virtio fs tunnels fuse over a virtio channel.  One issue is two sides might
be speaking different endian-ness. To detects this, host side looks at the
opcode value in the FUSE_INIT command.  Works fine at the moment but might
fail if a future version of fuse will use such an opcode for
initialization.  Let's reserve this opcode so we remember and don't do
this.

Same for CUSE_INIT.

Change-Id: I619381322edf6ebb9306d01cf460581093bba17b
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:08 +01:00
d8592372fa UPSTREAM: fuse: reserve values for mapping protocol
SETUPMAPPING is a command for use with 'virtiofsd', a fuse-over-virtio
implementation; it may find use in other fuse impelementations as well in
which the kernel does not have access to the address space of the daemon
directly.

A SETUPMAPPING operation causes a section of a file to be mapped into a
memory window visible to the kernel.  The offsets in the file and the
window are defined by the kernel performing the operation.

The daemon may reject the request, for reasons including permissions and
limited resources.

When a request perfectly overlaps a previous mapping, the previous mapping
is replaced.  When a mapping partially overlaps a previous mapping, the
previous mapping is split into one or two smaller mappings.

REMOVEMAPPING is the complement to SETUPMAPPING; it unmaps a range of
mapped files from the window visible to the kernel.

The map_alignment field communicates the alignment constraint for
FUSE_SETUPMAPPING/FUSE_REMOVEMAPPING and allows the daemon to constrain the
addresses and file offsets chosen by the kernel.

Change-Id: I65309b76cfcab10c98855a011464648783fdff00
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:08 +01:00
e50c9e87c9 UPSTREAM: fuse: add FUSE_WRITE_KILL_PRIV
In the FOPEN_DIRECT_IO case the write path doesn't call file_remove_privs()
and that means setuid bit is not cleared if unpriviliged user writes to a
file with setuid bit set.

pjdfstest chmod test 12.t tests this and fails.

Fix this by adding a flag to the FUSE_WRITE message that requests clearing
privileges on the given file.  This needs

This better than just calling fuse_remove_privs(), because the attributes
may not be up to date, so in that case a write may miss clearing the
privileges.

Test case:

  $ passthrough_ll /mnt/pasthrough-mnt -o default_permissions,allow_other,cache=never
  $ mkdir /mnt/pasthrough-mnt/testdir
  $ cd /mnt/pasthrough-mnt/testdir
  $ prove -rv pjdfstests/tests/chmod/12.t

Reported-by: Vivek Goyal <vgoyal@redhat.com>
Change-Id: Ibbdc754c6c5c96f33dc87a8a906c6c58b68b414b
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Tested-by: Vivek Goyal <vgoyal@redhat.com>
2025-10-16 21:01:06 +01:00
ea32dcc39c UPSTREAM: fuse: Add ioctl flag for x32 compat ioctl
Currently, a CUSE server running on a 64-bit kernel can tell when an ioctl
request comes from a process running a 32-bit ABI, but cannot tell whether
the requesting process is using legacy IA32 emulation or x32 ABI.  In
particular, the server does not know the size of the client process's
`time_t` type.

For 64-bit kernels, the `FUSE_IOCTL_COMPAT` and `FUSE_IOCTL_32BIT` flags
are currently set in the ioctl input request (`struct fuse_ioctl_in` member
`flags`) for a 32-bit requesting process.  This patch defines a new flag
`FUSE_IOCTL_COMPAT_X32` and sets it if the 32-bit requesting process is
using the x32 ABI.  This allows the server process to distinguish between
requests coming from client processes using IA32 emulation or the x32 ABI
and so infer the size of the client process's `time_t` type and any other
IA32/x32 differences.

Change-Id: Ic3d8a59a29f351fd9f2f734209bb1836b3d3875d
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:06 +01:00
0a651a8c8f UPSTREAM: fuse: fix changelog entry for protocol 7.9
Retroactively add changelog entry for the atime and mtime "now" flags.
This was an oversight in commit 17637cbaba ("fuse: improve utimes
support").

Change-Id: I7600f6f0bc36f49f2aaeb483aff01cd1b963d42d
Signed-off-by: Alan Somers <asomers@FreeBSD.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:05 +01:00
9add8b1018 UPSTREAM: fuse: fix changelog entry for protocol 7.12
This was a mistake in the comment in commit e0a43ddcc0 ("fuse: allow
umask processing in userspace").

Change-Id: Ibd09829687718de6eb5e4bebd8ac4d4d5fb95719
Signed-off-by: Alan Somers <asomers@FreeBSD.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:05 +01:00
69ee941b53 UPSTREAM: fuse: document fuse_fsync_in.fsync_flags
The FUSE_FSYNC_DATASYNC flag was introduced by commit b6aeadeda2
("[PATCH] FUSE - file operations") as a magic number.  No new values have
been added to fsync_flags since.

Change-Id: I1f104ba24b929de613589ebe4f1f9bafb2c994b8
Signed-off-by: Alan Somers <asomers@FreeBSD.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:05 +01:00
fac29b02f0 BACKPORT: fuse: allow filesystems to have precise control over data cache
On networked filesystems file data can be changed externally.  FUSE
provides notification messages for filesystem to inform kernel that
metadata or data region of a file needs to be invalidated in local page
cache. That provides the basis for filesystem implementations to invalidate
kernel cache explicitly based on observed filesystem-specific events.

FUSE has also "automatic" invalidation mode(*) when the kernel
automatically invalidates data cache of a file if it sees mtime change.  It
also automatically invalidates whole data cache of a file if it sees file
size being changed.

The automatic mode has corresponding capability - FUSE_AUTO_INVAL_DATA.
However, due to probably historical reason, that capability controls only
whether mtime change should be resulting in automatic invalidation or
not. A change in file size always results in invalidating whole data cache
of a file irregardless of whether FUSE_AUTO_INVAL_DATA was negotiated(+).

The filesystem I write[1] represents data arrays stored in networked
database as local files suitable for mmap. It is read-only filesystem -
changes to data are committed externally via database interfaces and the
filesystem only glues data into contiguous file streams suitable for mmap
and traditional array processing. The files are big - starting from
hundreds gigabytes and more. The files change regularly, and frequently by
data being appended to their end. The size of files thus changes
frequently.

If a file was accessed locally and some part of its data got into page
cache, we want that data to stay cached unless there is memory pressure, or
unless corresponding part of the file was actually changed. However current
FUSE behaviour - when it sees file size change - is to invalidate the whole
file. The data cache of the file is thus completely lost even on small size
change, and despite that the filesystem server is careful to accurately
translate database changes into FUSE invalidation messages to kernel.

Let's fix it: if a filesystem, through new FUSE_EXPLICIT_INVAL_DATA
capability, indicates to kernel that it is fully responsible for data cache
invalidation, then the kernel won't invalidate files data cache on size
change and only truncate that cache to new size in case the size decreased.

(*) see 72d0d248ca "fuse: add FUSE_AUTO_INVAL_DATA init flag",
eed2179efe "fuse: invalidate inode mapping if mtime changes"

(+) in writeback mode the kernel does not invalidate data cache on file
size change, but neither it allows the filesystem to set the size due to
external event (see 8373200b12 "fuse: Trust kernel i_size only")

[1] https://lab.nexedi.com/kirr/wendelin.core/blob/a50f1d9f/wcfs/wcfs.go#L20

Change-Id: I63aa1e9bab244f78ca4b8ecead65a3044b921319
Signed-off-by: Kirill Smelkov <kirr@nexedi.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:05 +01:00
e3909946f4 BACKPORT: fuse: support clients that don't implement 'opendir'
Allow filesystems to return ENOSYS from opendir, preventing the kernel from
sending opendir and releasedir messages in the future. This avoids
userspace transitions when filesystems don't need to keep track of state
per directory handle.

A new capability flag, FUSE_NO_OPENDIR_SUPPORT, parallels
FUSE_NO_OPEN_SUPPORT, indicating the new semantics for returning ENOSYS
from opendir.

Change-Id: Ifaa4007ef09e2dfb67432d40d3e1e595f95c868d
Signed-off-by: Chad Austin <chadaustin@fb.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:05 +01:00
1cc2a925cc BACKPORT: fuse: enable caching of symlinks
FUSE file reads are cached in the page cache, but symlink reads are
not. This patch enables FUSE READLINK operations to be cached which
can improve performance of some FUSE workloads.

In particular, I'm working on a FUSE filesystem for access to source
code and discovered that about a 10% improvement to build times is
achieved with this patch (there are a lot of symlinks in the source
tree).

Change-Id: Ib62a80d4156ca40d0c4ddb8c34bfff1e1c920659
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:04 +01:00
0efd72e5a3 BACKPORT: fuse: add max_pages to init_out
Replace FUSE_MAX_PAGES_PER_REQ with the configurable parameter max_pages to
improve performance.

Old RFC with detailed description of the problem and many fixes by Mitsuo
Hayasaka (mitsuo.hayasaka.hu@hitachi.com):
 - https://lkml.org/lkml/2012/7/5/136

We've encountered performance degradation and fixed it on a big and complex
virtual environment.

Environment to reproduce degradation and improvement:

1. Add lag to user mode FUSE
Add nanosleep(&(struct timespec){ 0, 1000 }, NULL); to xmp_write_buf in
passthrough_fh.c

2. patch UM fuse with configurable max_pages parameter. The patch will be
provided latter.

3. run test script and perform test on tmpfs
fuse_test()
{

       cd /tmp
       mkdir -p fusemnt
       passthrough_fh -o max_pages=$1 /tmp/fusemnt
       grep fuse /proc/self/mounts
       dd conv=fdatasync oflag=dsync if=/dev/zero of=fusemnt/tmp/tmp \
		count=1K bs=1M 2>&1 | grep -v records
       rm fusemnt/tmp/tmp
       killall passthrough_fh
}

Test results:

passthrough_fh /tmp/fusemnt fuse.passthrough_fh \
	rw,nosuid,nodev,relatime,user_id=0,group_id=0 0 0
1073741824 bytes (1.1 GB) copied, 1.73867 s, 618 MB/s

passthrough_fh /tmp/fusemnt fuse.passthrough_fh \
	rw,nosuid,nodev,relatime,user_id=0,group_id=0,max_pages=256 0 0
1073741824 bytes (1.1 GB) copied, 1.15643 s, 928 MB/s

Obviously with bigger lag the difference between 'before' and 'after'
will be more significant.

Mitsuo Hayasaka, in 2012 (https://lkml.org/lkml/2012/7/5/136),
observed improvement from 400-550 to 520-740.

Change-Id: If8edb81c163720e974a106e258cf1f2e10e44127
Signed-off-by: Constantine Shulyupin <const@MakeLinux.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:04 +01:00
5979034173 UPSTREAM: fuse: add FOPEN_CACHE_DIR
Add flag returned by OPENDIR request to allow kernel to cache directory
contents in page cache.  The effect of FOPEN_CACHE_DIR is twofold:

 a) if not already cached, it writes entries into the cache

 b) if already cached, it allows reading entries from the cache

The FOPEN_KEEP_CACHE has the same effect as on regular files: unless this
flag is given the cache is cleared upon completion of open.

So FOPEN_KEEP_CACHE and FOPEN_KEEP_CACHE flags should be used together to
make use of the directory caching facility introduced in the following
patches.

The FUSE_AUTO_INVAL_DATA flag returned in INIT reply also has the same
affect on the directory cache as it has on data cache for regular files.

Change-Id: I5bb254e4636ab3df0c529aa2f3593f36265f49cd
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:04 +01:00
a773e3fbac BACKPORT: fuse: add support for copy_file_range()
There are several FUSE filesystems that can implement server-side copy
or other efficient copy/duplication/clone methods. The copy_file_range()
syscall is the standard interface that users have access to while not
depending on external libraries that bypass FUSE.

Change-Id: Iec1598a71c9294d8e7f98bae6913b9ef3568d100
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2025-10-16 21:01:03 +01:00
5d8a052b84 Merge tag 'v4.19.325-cip124' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip into android13-4.19-kona
version 4.19.325-cip124

* tag 'v4.19.325-cip124' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip:
  CIP: Bump version suffix to -cip124 after merge from cip/linux-4.19.y-st tree
  Update localversion-st, tree is up-to-date with 5.4.298.
  f2fs: fix to do sanity check on ino and xnid
  squashfs: fix memory leak in squashfs_fill_super
  pNFS: Handle RPC size limit for layoutcommits
  wifi: iwlwifi: fw: Fix possible memory leak in iwl_fw_dbg_collect
  usb: core: usb_submit_urb: downgrade type check
  udf: Verify partition map count
  f2fs: fix to avoid panic in f2fs_evict_inode
  usb: hub: Fix flushing and scheduling of delayed work that tunes runtime pm
  Revert "drm/dp: Change AUX DPCD probe address from DPCD_REV to LANE0_1_STATUS"
  net: usb: qmi_wwan: add Telit Cinterion LE910C4-WWX new compositions
  HID: hid-ntrig: fix unable to handle page fault in ntrig_report_version()
  HID: asus: fix UAF via HID_CLAIMED_INPUT validation
  efivarfs: Fix slab-out-of-bounds in efivarfs_d_compare
  sctp: initialize more fields in sctp_v6_from_sk()
  net: stmmac: xgmac: Do not enable RX FIFO Overflow interrupts
  net/mlx5e: Set local Xoff after FW update
  net: dlink: fix multicast stats being counted incorrectly
  atm: atmtcp: Prevent arbitrary write in atmtcp_recv_control().
  net/atm: remove the atmdev_ops {get, set}sockopt methods
  Bluetooth: hci_event: Detect if HCI_EV_NUM_COMP_PKTS is unbalanced
  powerpc/kvm: Fix ifdef to remove build warning
  net: ipv4: fix regression in local-broadcast routes
  vhost/net: Protect ubufs with rcu read lock in vhost_net_ubuf_put()
  scsi: core: sysfs: Correct sysfs attributes access rights
  ftrace: Fix potential warning in trace_printk_seq during ftrace_dump
  alloc_fdtable(): change calling conventions.
  ALSA: usb-audio: Use correct sub-type for UAC3 feature unit validation
  net/sched: Make cake_enqueue return NET_XMIT_CN when past buffer_limit
  ipv6: sr: validate HMAC algorithm ID in seg6_hmac_info_add
  ALSA: usb-audio: Fix size validation in convert_chmap_v3()
  scsi: qla4xxx: Prevent a potential error pointer dereference
  usb: xhci: Fix slot_id resource race conflict
  nfs: fix UAF in direct writes
  NFS: Fix up commit deadlocks
  Bluetooth: fix use-after-free in device_for_each_child()
  selftests: forwarding: tc_actions.sh: add matchall mirror test
  codel: remove sch->q.qlen check before qdisc_tree_reduce_backlog()
  sch_qfq: make qfq_qlen_notify() idempotent
  sch_hfsc: make hfsc_qlen_notify() idempotent
  sch_drr: make drr_qlen_notify() idempotent
  btrfs: populate otime when logging an inode item
  media: venus: hfi: explicitly release IRQ during teardown
  f2fs: fix to avoid out-of-boundary access in dnode page
  media: venus: protect against spurious interrupts during probe
  media: venus: vdec: Clamp param smaller than 1fps and bigger than 240.
  drm/dp: Change AUX DPCD probe address from DPCD_REV to LANE0_1_STATUS
  media: rainshadow-cec: fix TOCTOU race condition in rain_interrupt()
  media: v4l2-ctrls: Don't reset handler's error in v4l2_ctrl_handler_free()
  ata: Fix SATA_MOBILE_LPM_POLICY description in Kconfig
  usb: musb: omap2430: fix device leak at unbind
  NFS: Fix the setting of capabilities when automounting a new filesystem
  NFS: Fix up handling of outstanding layoutcommit in nfs_update_inode()
  NFSv4: Fix nfs4_bitmap_copy_adjust()
  usb: typec: fusb302: cache PD RX state
  cdc-acm: fix race between initial clearing halt and open
  USB: cdc-acm: do not log successful probe on later errors
  nfsd: handle get_client_locked() failure in nfsd4_setclientid_confirm()
  tracing: Add down_write(trace_event_sem) when adding trace event
  usb: hub: Don't try to recover devices lost during warm reset.
  usb: hub: avoid warm port reset during USB3 disconnect
  x86/mce/amd: Add default names for MCA banks and blocks
  iio: hid-sensor-prox: Fix incorrect OFFSET calculation
  mm/zsmalloc: do not pass __GFP_MOVABLE if CONFIG_COMPACTION=n
  mm/zsmalloc.c: convert to use kmem_cache_zalloc in cache_alloc_zspage()
  net: usbnet: Fix the wrong netif_carrier_on() call
  net: usbnet: Avoid potential RCU stall on LINK_CHANGE event
  PCI/ACPI: Fix runtime PM ref imbalance on Hot-Plug Capable ports
  ACPI: processor: idle: Check acpi_fetch_acpi_dev() return value
  kbuild: Add KBUILD_CPPFLAGS to as-option invocation
  kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS
  kbuild: Add CLANG_FLAGS to as-instr
  mips: Include KBUILD_CPPFLAGS in CHECKFLAGS invocation
  kbuild: Update assembler calls to use proper flags and language target
  ARM: 9448/1: Use an absolute path to unified.h in KBUILD_AFLAGS
  usb: dwc3: Ignore late xferNotReady event to prevent halt timeout
  USB: storage: Ignore driver CD mode for Realtek multi-mode Wi-Fi dongles
  usb: storage: realtek_cr: Use correct byte order for bcs->Residue
  USB: storage: Add unusual-devs entry for Novatek NTK96550-based camera
  usb: quirks: Add DELAY_INIT quick for another SanDisk 3.2Gen1 Flash Drive
  iio: proximity: isl29501: fix buffered read on big-endian systems
  ftrace: Also allocate and copy hash for reading of filter files
  fpga: zynq_fpga: Fix the wrong usage of dma_map_sgtable()
  fs/buffer: fix use-after-free when call bh_read() helper
  drm/amd/display: Fix fractional fb divider in set_pixel_clock_v3
  media: venus: Add a check for packet size after reading from shared memory
  media: ov2659: Fix memory leaks in ov2659_probe()
  media: usbtv: Lock resolution while streaming
  media: gspca: Add bounds checking to firmware parser
  jbd2: prevent softlockup in jbd2_log_do_checkpoint()
  PCI: endpoint: Fix configfs group removal on driver teardown
  PCI: endpoint: Fix configfs group list head handling
  mtd: rawnand: fsmc: Add missing check after DMA map
  wifi: brcmsmac: Remove const from tbl_ptr parameter in wlc_lcnphy_common_read_table()
  zynq_fpga: use sgtable-based scatterlist wrappers
  ata: libata-scsi: Fix ata_to_sense_error() status handling
  ext4: fix reserved gdt blocks handling in fsmap
  ext4: fix fsmap end of range reporting with bigalloc
  ext4: check fast symlink for ea_inode correctly
  Revert "vgacon: Add check for vc_origin address range in vgacon_scroll()"
  vt: defkeymap: Map keycodes above 127 to K_HOLE
  usb: gadget: udc: renesas_usb3: fix device leak at unbind
  usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init()
  m68k: Fix lost column on framebuffer debug console
  serial: 8250: fix panic due to PSLVERR
  media: uvcvideo: Do not mark valid metadata as invalid
  media: uvcvideo: Fix 1-byte out-of-bounds read in uvc_parse_format()
  btrfs: fix log tree replay failure due to file with 0 links and extents
  thunderbolt: Fix copy+paste error in match_service_id()
  misc: rtsx: usb: Ensure mmc child device is active when card is present
  scsi: lpfc: Remove redundant assignment to avoid memory leak
  rtc: ds1307: remove clear of oscillator stop flag (OSF) in probe
  pNFS: Fix uninited ptr deref in block/scsi layout
  pNFS: Fix disk addr range check in block/scsi layout
  pNFS: Fix stripe mapping in block/scsi layout
  ipmi: Fix strcpy source and destination the same
  kconfig: lxdialog: fix 'space' to (de)select options
  kconfig: gconf: fix potential memory leak in renderer_edited()
  kconfig: gconf: avoid hardcoding model2 in on_treeview2_cursor_changed()
  scsi: aacraid: Stop using PCI_IRQ_AFFINITY
  scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans
  kconfig: nconf: Ensure null termination where strncpy is used
  kconfig: lxdialog: replace strcpy() with strncpy() in inputbox.c
  PCI: pnv_php: Work around switches with broken presence detection
  media: uvcvideo: Fix bandwidth issue for Alcor camera
  media: dvb-frontends: w7090p: fix null-ptr-deref in w7090p_tuner_write_serpar and w7090p_tuner_read_serpar
  media: dvb-frontends: dib7090p: fix null-ptr-deref in dib7090p_rw_on_apb()
  media: usb: hdpvr: disable zero-length read messages
  media: tc358743: Increase FIFO trigger level to 374
  media: tc358743: Return an appropriate colorspace from tc358743_set_fmt
  media: tc358743: Check I2C succeeded during probe
  pinctrl: stm32: Manage irq affinity settings
  scsi: mpt3sas: Correctly handle ATA device errors
  RDMA: hfi1: fix possible divide-by-zero in find_hw_thread_mask()
  MIPS: Don't crash in stack_top() for tasks without ABI or vDSO
  jfs: upper bound check of tree index in dbAllocAG
  jfs: Regular file corruption check
  jfs: truncate good inode pages when hard link is 0
  scsi: bfa: Double-free fix
  MIPS: vpe-mt: add missing prototypes for vpe_{alloc,start,stop,free}
  watchdog: dw_wdt: Fix default timeout
  fs/orangefs: use snprintf() instead of sprintf()
  scsi: libiscsi: Initialize iscsi_conn->dd_data only if memory is allocated
  ext4: do not BUG when INLINE_DATA_FL lacks system.data xattr
  vhost: fail early when __vhost_add_used() fails
  uapi: in6: restore visibility of most IPv6 socket options
  net: ncsi: Fix buffer overflow in fetching version id
  net: dsa: b53: fix b53_imp_vlan_setup for BCM5325
  net: vlan: Replace BUG() with WARN_ON_ONCE() in vlan_dev_* stubs
  wifi: iwlegacy: Check rate_idx range after addition
  netmem: fix skb_frag_address_safe with unreadable skbs
  wifi: rtlwifi: fix possible skb memory leak in `_rtl_pci_rx_interrupt()`.
  wifi: iwlwifi: dvm: fix potential overflow in rs_fill_link_cmd()
  net: fec: allow disable coalescing
  (powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer
  s390/stp: Remove udelay from stp_sync_clock()
  wifi: iwlwifi: mvm: fix scan request validation
  net: thunderx: Fix format-truncation warning in bgx_acpi_match_id()
  net: ipv4: fix incorrect MTU in broadcast routes
  wifi: cfg80211: Fix interface type validation
  et131x: Add missing check after DMA map
  be2net: Use correct byte order and format string for TCP seq and ack_seq
  s390/time: Use monotonic clock in get_cycles()
  wifi: cfg80211: reject HTC bit for management frames
  ktest.pl: Prevent recursion of default variable options
  ASoC: codecs: rt5640: Retry DEVICE_ID verification
  ALSA: usb-audio: Avoid precedence issues in mixer_quirks macros
  ALSA: hda/ca0132: Fix buffer overflow in add_tuning_control
  platform/x86: thinkpad_acpi: Handle KCOV __init vs inline mismatches
  pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop()
  ALSA: intel8x0: Fix incorrect codec index usage in mixer for ICH4
  ASoC: hdac_hdmi: Rate limit logging on connection and disconnection
  mmc: rtsx_usb_sdmmc: Fix error-path in sd_set_power_mode()
  ACPI: processor: fix acpi_object initialization
  PM: sleep: console: Fix the black screen issue
  thermal: sysfs: Return ENODATA instead of EAGAIN for reads
  selftests: tracing: Use mutex_unlock for testing glob filter
  ARM: tegra: Use I/O memcpy to write to IRAM
  gpio: tps65912: check the return value of regmap_update_bits()
  ASoC: soc-dapm: set bias_level if snd_soc_dapm_set_bias_level() was successed
  cpufreq: Exit governor when failed to start old governor
  usb: xhci: Avoid showing errors during surprise removal
  usb: xhci: Set avg_trb_len = 8 for EP0 during Address Device Command
  usb: xhci: Avoid showing warnings for dying controller
  selftests/futex: Define SYS_futex on 32-bit architectures with 64-bit time_t
  usb: xhci: print xhci->xhc_state when queue_command failed
  securityfs: don't pin dentries twice, once is enough...
  hfs: fix not erasing deleted b-tree node issue
  drbd: add missing kref_get in handle_write_conflicts
  arm64: Handle KCOV __init vs inline mismatches
  hfsplus: don't use BUG_ON() in hfsplus_create_attributes_file()
  hfsplus: fix slab-out-of-bounds read in hfsplus_uni2asc()
  hfsplus: fix slab-out-of-bounds in hfsplus_bnode_read()
  hfs: fix slab-out-of-bounds in hfs_bnode_read()
  sctp: linearize cloned gso packets in sctp_rcv
  netfilter: ctnetlink: fix refcount leak on table dump
  udp: also consider secpath when evaluating ipsec use for checksumming
  fs: Prevent file descriptor table allocations exceeding INT_MAX
  sunvdc: Balance device refcount in vdc_port_mpgroup_check
  NFSD: detect mismatch of file handle and delegation stateid in OPEN op
  net: dpaa: fix device leak when querying time stamp info
  net: gianfar: fix device leak when querying time stamp info
  netlink: avoid infinite retry looping in netlink_unicast()
  ALSA: usb-audio: Validate UAC3 cluster segment descriptors
  ALSA: usb-audio: Validate UAC3 power domain descriptors, too
  usb: gadget : fix use-after-free in composite_dev_cleanup()
  MIPS: mm: tlb-r4k: Uniquify TLB entries on init
  USB: serial: option: add Foxconn T99W709
  vsock: Do not allow binding to VMADDR_PORT_ANY
  net/packet: fix a race in packet_set_ring() and packet_notifier()
  perf/core: Prevent VMA split of buffer mappings
  perf/core: Exit early on perf_mmap() fail
  perf/core: Don't leak AUX buffer refcount on allocation failure
  pptp: fix pptp_xmit() error path
  smb: client: let recv_done() cleanup before notifying the callers.
  benet: fix BUG when creating VFs
  ipv6: reject malicious packets in ipv6_gso_segment()
  pptp: ensure minimal skb length in pptp_xmit()
  netpoll: prevent hanging NAPI when netcons gets enabled
  NFS: Fix filehandle bounds checking in nfs_fh_to_dentry()
  pci/hotplug/pnv-php: Wrap warnings in macro
  pci/hotplug/pnv-php: Improve error msg on power state change failure
  usb: chipidea: udc: fix sleeping function called from invalid context
  f2fs: fix to avoid out-of-boundary access in devs.path
  f2fs: fix to avoid UAF in f2fs_sync_inode_meta()
  rtc: pcf8563: fix incorrect maximum clock rate handling
  rtc: hym8563: fix incorrect maximum clock rate handling
  rtc: ds1307: fix incorrect maximum clock rate handling
  mtd: rawnand: atmel: set pmecc data setup time
  mtd: rawnand: atmel: Fix dma_mapping_error() address
  jfs: fix metapage reference count leak in dbAllocCtl
  fbdev: imxfb: Check fb_add_videomode to prevent null-ptr-deref
  crypto: qat - fix seq_file position update in adf_ring_next()
  dmaengine: nbpfaxi: Add missing check after DMA map
  dmaengine: mv_xor: Fix missing check after DMA map and missing unmap
  fs/orangefs: Allow 2 more characters in do_c_string()
  crypto: img-hash - Fix dma_unmap_sg() nents value
  scsi: isci: Fix dma_unmap_sg() nents value
  scsi: mvsas: Fix dma_unmap_sg() nents value
  scsi: ibmvscsi_tgt: Fix dma_unmap_sg() nents value
  perf tests bp_account: Fix leaked file descriptor
  crypto: ccp - Fix crash when rebind ccp device for ccp.ko
  pinctrl: sunxi: Fix memory leak on krealloc failure
  power: supply: max14577: Handle NULL pdata when CONFIG_OF is not set
  clk: davinci: Add NULL check in davinci_lpsc_clk_register()
  mtd: fix possible integer overflow in erase_xfer()
  crypto: marvell/cesa - Fix engine load inaccuracy
  PCI: rockchip-host: Fix "Unexpected Completion" log message
  vrf: Drop existing dst reference in vrf_ip6_input_dst
  netfilter: xt_nfacct: don't assume acct name is null-terminated
  can: kvaser_usb: Assign netdev.dev_port based on device channel index
  wifi: brcmfmac: fix P2P discovery failure in P2P peer due to missing P2P IE
  Reapply "wifi: mac80211: Update skb's control block key in ieee80211_tx_dequeue()"
  mwl8k: Add missing check after DMA map
  wifi: rtl8xxxu: Fix RX skb size for aggregation disabled
  net/sched: Restrict conditions for adding duplicating netems to qdisc tree
  arch: powerpc: defconfig: Drop obsolete CONFIG_NET_CLS_TCINDEX
  netfilter: nf_tables: adjust lockdep assertions handling
  drm/amd/pm/powerplay/hwmgr/smu_helper: fix order of mask and value
  m68k: Don't unregister boot console needlessly
  tcp: fix tcp_ofo_queue() to avoid including too much DUP SACK range
  iwlwifi: Add missing check for alloc_ordered_workqueue
  wifi: iwlwifi: Fix memory leak in iwl_mvm_init()
  wifi: rtl818x: Kill URBs before clearing tx status queue
  caif: reduce stack size, again
  staging: nvec: Fix incorrect null termination of battery manufacturer
  samples: mei: Fix building on musl libc
  usb: early: xhci-dbc: Fix early_ioremap leak
  Revert "vmci: Prevent the dispatching of uninitialized payloads"
  pps: fix poll support
  vmci: Prevent the dispatching of uninitialized payloads
  staging: fbtft: fix potential memory leak in fbtft_framebuffer_alloc()
  ARM: dts: vfxxx: Correctly use two tuples for timer address
  ASoC: ops: dynamically allocate struct snd_ctl_elem_value
  hfsplus: remove mutex_lock check in hfsplus_free_extents
  ASoC: Intel: fix SND_SOC_SOF dependencies
  ethernet: intel: fix building with large NR_CPUS
  usb: phy: mxs: disconnect line when USB charger is attached
  usb: chipidea: udc: protect usb interrupt enable
  usb: chipidea: udc: add new API ci_hdrc_gadget_connect
  comedi: comedi_test: Fix possible deletion of uninitialized timers
  nilfs2: reject invalid file types when reading inodes
  i2c: qup: jump out of the loop in case of timeout
  net/sched: sch_qfq: Avoid triggering might_sleep in atomic context in qfq_delete_class
  net: appletalk: Fix use-after-free in AARP proxy probe
  net: appletalk: fix kerneldoc warnings
  RDMA/core: Rate limit GID cache warning messages
  usb: hub: fix detection of high tier USB3 devices behind suspended hubs
  net_sched: sch_sfq: reject invalid perturb period
  net_sched: sch_sfq: move the limit validation
  net_sched: sch_sfq: use a temporary work area for validating configuration
  net_sched: sch_sfq: don't allow 1 packet limit
  net_sched: sch_sfq: handle bigger packets
  net_sched: sch_sfq: annotate data-races around q->perturb_period
  power: supply: bq24190_charger: Fix runtime PM imbalance on error
  xhci: Disable stream for xHC controller with XHCI_BROKEN_STREAMS
  virtio-net: ensure the received length does not exceed allocated size
  usb: dwc3: qcom: Don't leave BCR asserted
  usb: musb: fix gadget state on disconnect
  net/sched: Return NULL when htb_lookup_leaf encounters an empty rbtree
  net: vlan: fix VLAN 0 refcount imbalance of toggling filtering during runtime
  Bluetooth: L2CAP: Fix attempting to adjust outgoing MTU
  Bluetooth: SMP: Fix using HCI_ERROR_REMOTE_USER_TERM on timeout
  Bluetooth: SMP: If an unallowed command is received consider it a failure
  Bluetooth: Fix null-ptr-deref in l2cap_sock_resume_cb()
  usb: net: sierra: check for no status endpoint
  net/sched: sch_qfq: Fix race condition on qfq_aggregate
  net: emaclite: Fix missing pointer increment in aligned_read()
  comedi: Fix use of uninitialized data in insn_rw_emulate_bits()
  comedi: Fix some signed shift left operations
  comedi: das6402: Fix bit shift out of bounds
  comedi: das16m1: Fix bit shift out of bounds
  comedi: aio_iiro_16: Fix bit shift out of bounds
  comedi: pcl812: Fix bit shift out of bounds
  iio: adc: max1363: Reorder mode_list[] entries
  iio: adc: max1363: Fix MAX1363_4X_CHANS/MAX1363_8X_CHANS[]
  soc: aspeed: lpc-snoop: Don't disable channels that aren't enabled
  soc: aspeed: lpc-snoop: Cleanup resources in stack-order
  mmc: sdhci-pci: Quirk for broken command queuing on Intel GLK-based Positivo models
  memstick: core: Zero initialize id_reg in h_memstick_read_dev_id()
  isofs: Verify inode mode when loading from disk
  dmaengine: nbpfaxi: Fix memory corruption in probe()
  af_packet: fix soft lockup issue caused by tpacket_snd()
  af_packet: fix the SO_SNDTIMEO constraint not effective on tpacked_snd()
  phonet/pep: Move call to pn_skb_get_dst_sockaddr() earlier in pep_sock_accept()
  HID: core: do not bypass hid_hw_raw_request
  HID: core: ensure __hid_request reserves the report ID as the first byte
  HID: core: ensure the allocated report buffer can contain the reserved report ID
  pch_uart: Fix dma_sync_sg_for_device() nents value
  Input: xpad - set correct controller type for Acer NGR200
  i2c: stm32: fix the device used for the DMA map
  usb: gadget: configfs: Fix OOB read on empty string write
  USB: serial: ftdi_sio: add support for NDI EMGUIDE GEMINI
  USB: serial: option: add Foxconn T99W640
  USB: serial: option: add Telit Cinterion FE910C04 (ECM) composition
  dma-mapping: add generic helpers for mapping sgtable objects
  usb: renesas_usbhs: Flush the notify_hotplug_work
  gpio: rcar: Use raw_spinlock to protect register access

Change-Id: I03484e31376795f9823adc2824120ec86da6e3bf
2025-10-05 09:11:31 +00:00
b1dafc35b9 UPSTREAM: bpf: Fix L4 csum update on IPv6 in CHECKSUM_COMPLETE
commit ead7f9b8de65632ef8060b84b0c55049a33cfea1 upstream.

In Cilium, we use bpf_csum_diff + bpf_l4_csum_replace to, among other
things, update the L4 checksum after reverse SNATing IPv6 packets. That
use case is however not currently supported and leads to invalid
skb->csum values in some cases. This patch adds support for IPv6 address
changes in bpf_l4_csum_update via a new flag.

When calling bpf_l4_csum_replace in Cilium, it ends up calling
inet_proto_csum_replace_by_diff:

    1:  void inet_proto_csum_replace_by_diff(__sum16 *sum, struct sk_buff *skb,
    2:                                       __wsum diff, bool pseudohdr)
    3:  {
    4:      if (skb->ip_summed != CHECKSUM_PARTIAL) {
    5:          csum_replace_by_diff(sum, diff);
    6:          if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr)
    7:              skb->csum = ~csum_sub(diff, skb->csum);
    8:      } else if (pseudohdr) {
    9:          *sum = ~csum_fold(csum_add(diff, csum_unfold(*sum)));
    10:     }
    11: }

The bug happens when we're in the CHECKSUM_COMPLETE state. We've just
updated one of the IPv6 addresses. The helper now updates the L4 header
checksum on line 5. Next, it updates skb->csum on line 7. It shouldn't.

For an IPv6 packet, the updates of the IPv6 address and of the L4
checksum will cancel each other. The checksums are set such that
computing a checksum over the packet including its checksum will result
in a sum of 0. So the same is true here when we update the L4 checksum
on line 5. We'll update it as to cancel the previous IPv6 address
update. Hence skb->csum should remain untouched in this case.

The same bug doesn't affect IPv4 packets because, in that case, three
fields are updated: the IPv4 address, the IP checksum, and the L4
checksum. The change to the IPv4 address and one of the checksums still
cancel each other in skb->csum, but we're left with one checksum update
and should therefore update skb->csum accordingly. That's exactly what
inet_proto_csum_replace_by_diff does.

This special case for IPv6 L4 checksums is also described atop
inet_proto_csum_replace16, the function we should be using in this case.

This patch introduces a new bpf_l4_csum_replace flag, BPF_F_IPV6,
to indicate that we're updating the L4 checksum of an IPv6 packet. When
the flag is set, inet_proto_csum_replace_by_diff will skip the
skb->csum update.

Fixes: 7d672345ed ("bpf: add generic bpf_csum_diff helper")
Change-Id: Ia07e6770587fff91588ba133a9efadab92372ed9
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://patch.msgid.link/96a6bc3a443e6f0b21ff7b7834000e17fb549e05.1748509484.git.paul.chaignon@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ Note: Fixed conflict due to unrelated comment change. ]
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-09-30 21:35:05 +01:00
d1a013010f fixup! BACKPORT: bpf: Switch most helper return values from 32-bit int to 64-bit long
Correct formatting of the comments.

Change-Id: If8040d4df7f295c476431102df1e8017b82e0b65
2025-09-30 21:35:04 +01:00