version 4.19.325-cip127
* tag 'v4.19.325-cip127' of https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip:
CIP: Bump version suffix to -cip127 after merge from cip/linux-4.19.y-st tree
Update localversion-st, tree is up-to-date with 5.10.247.
usb: uas: fix urb unmapping issue when the uas device is remove during ongoing data transfer
scsi: pm80xx: Set phy->enable_completion only when we
drm/amd/display: Check NULL before accessing
wifi: ath10k: Fix connection after GTK rekeying
pinctrl: single: fix bias pull up/down handling in pin_config_set
ovl: fix UAF in ovl_dentry_update_reval by moving dput() in ovl_link_up
fs: writeback: fix use-after-free in __mark_inode_dirty()
libceph: fix potential use-after-free in have_mon_and_osd_map()
drm: sti: fix device leaks at component probe
USB: serial: option: add support for Rolling RW101R-GL
USB: serial: ftdi_sio: add support for u-blox EVK-M101
usb: storage: sddr55: Reject out-of-bound new_pba
USB: storage: Remove subclass and protocol overrides from Novatek quirk
usb: storage: Fix memory leak in USB bulk transport
usb: gadget: f_eem: Fix memory leak in eem_unwrap
slimbus: ngd: Fix reference count leak in qcom_slim_ngd_notify_slaves
dm-verity: fix unreliable memory allocation
can: sun4i_can: sun4i_can_interrupt(): fix max irq loop handling
can: sja1000: fix max irq loop handling
atm/fore200e: Fix possible data race in fore200e_open()
MIPS: mm: Prevent a TLB shutdown on initial uniquification
iio:common:ssp_sensors: Fix an error handling path ssp_probe()
spi: bcm63xx: fix premature CS deassertion on RX-only transactions
net: sxgbe: fix potential NULL dereference in sxgbe_rx()
can: kvaser_usb: leaf: Fix potential infinite loop in command parsers
mtd: onenand: Pass correct pointer to IRQ handler
fsdax: mark the iomap argument to dax_iomap_sector as const
net: sctp: Fix some typos
iommu/amd: Skip enabling command/event buffers for kdump
nvme-fc: use lock accessing port_state and rport state
net: netpoll: fix incorrect refcount handling causing incorrect cleanup
net: ethernet: ti: netcp: Standardize knav_dma_open_channel to return NULL on error
tipc: Fix use-after-free in tipc_mon_reinit_self().
sctp: prevent possible shift-out-of-bounds in sctp_transport_update_rto
Bluetooth: btusb: reorder cleanup in btusb_disconnect to avoid UAF
wifi: brcmfmac: fix crash while sending Action Frames in standalone AP Mode
net/sched: sch_qfq: Fix null-deref in agg_dequeue
Input: pegasus-notetaker - fix potential out-of-bounds access
Input: remove third argument of usb_maxpacket()
usb: deprecate the third argument of usb_maxpacket()
ata: libata-scsi: Fix system suspend for a security locked drive
fs/proc: fix uaf in proc_readdir_de()
pmdomain: imx: Fix reference count leak in imx_gpc_remove
pmdomain: arm: scmi: Fix genpd leak on provider registration failure
net: qede: Initialize qede_ll_ops with designated initializer
uio_hv_generic: Set event for all channels on the device
ALSA: usb-audio: fix uac2 clock source at terminal parser
kconfig/nconf: Initialize the default locale at startup
kconfig/mconf: Initialize the default locale at startup
vsock: Ignore signal/timeout on connect() if already established
s390/ctcm: Fix double-kfree
net: openvswitch: remove never-working support for setting nsh fields
mlxsw: spectrum: Fix memory leak in mlxsw_sp_flower_stats()
MIPS: Malta: Fix !EVA SOC-it PCI MMIO
scsi: target: tcm_loop: Fix segfault in tcm_loop_tpg_address_show()
scsi: sg: Do not sleep in atomic context
Input: cros_ec_keyb - fix an invalid memory access
be2net: pass wrb_params in case of OS2BMC
HID: quirks: work around VID/PID conflict for 0x4c4a/0x4155
isdn: mISDN: hfcsusb: fix memory leak in hfcsusb_probe()
spi: Try to get ACPI GPIO IRQ earlier
ipv4: route: Prevent rt_bind_exception() from rebinding stale fnhe
strparser: Fix signed/unsigned mismatch bug
gcov: add support for GCC 15
mm/ksm: fix flag-dropping behavior in ksm_madvise
ALSA: usb-audio: Fix NULL pointer dereference in snd_usb_mixer_controls_badd
ASoC: cs4271: Fix regulator leak on probe failure
regulator: fixed: use dev_err_probe for register
Bluetooth: L2CAP: export l2cap_chan_hold for modules
net_sched: remove need_resched() from qdisc_run()
net/mlx5e: Fix maxrate wraparound in threshold between units
net: sched: act_ife: initialize struct tc_ife to fix KMSAN kernel-infoleak
Bluetooth: 6lowpan: Don't hold spin lock over sleeping functions
Bluetooth: 6lowpan: fix BDADDR_LE vs ADDR_LE_DEV address type confusion
Bluetooth: 6lowpan: reset link-local header on ipv6 recv path
net: fec: correct rx_bytes statistic for the case SHIFT16 is set
ASoC: max98090/91: fixed max98091 ALSA widget powering up/down
HID: quirks: avoid Cooler Master MM712 dongle wakeup bug
NFS4: Fix state renewals missing after boot
extcon: adc-jack: Cleanup wakeup source only if it was enabled
net: usb: qmi_wwan: initialize MAC header offset in qmimux_rx_fixup
sctp: Prevent TOCTOU out-of-bounds write
sctp: Hold RCU read lock while iterating over address list
net: vlan: sync VLAN features with lower device
ceph: add checking of wait_for_completion_killable() return value
fbdev: Add bounds checking in bit_putcs to fix vmalloc-out-of-bounds
ACPI: property: Return present device nodes only on fwnode interface
9p: sysfs_init: don't hardcode error to ENOMEM
9p: fix /sys/fs/9p/caches overwriting itself
fs/hpfs: Fix error code for new_inode() failure in mkdir/create/mknod/symlink
ACPICA: Update dsmethod.c to get rid of unused variable warning
page_pool: Clamp pool size to max 16K pages
Bluetooth: bcsp: receive data only if registered
Bluetooth: SCO: Fix UAF on sco_conn_free
net: macb: avoid dealing with endianness in macb_set_hwaddr()
nfs4_setup_readdir(): insufficient locking for ->d_parent->d_inode dereferencing
NFSv4.1: fix mount hang after CREATE_SESSION failure
NFSv4: handle ERR_GRACE on delegation recalls
remoteproc: qcom: q6v5: Avoid handling handover twice
sparc/module: Add R_SPARC_UA64 relocation handling
net: intel: fm10k: Fix parameter idx set but not used
jfs: fix uninitialized waitqueue in transaction manager
jfs: Verify inode mode when loading from disk
ipv6: np->rxpmtu race annotation
usb: xhci: plat: Facilitate using autosuspend for xhci plat devices
usb: mon: Increase BUFF_MAX to 64 MiB to support multi-MB URBs
allow finish_no_open(file, ERR_PTR(-E...))
scsi: lpfc: Define size of debugfs entry for xri rebalancing
scsi: lpfc: Check return status of lpfc_reset_flush_io_context during TGT_RESET
selftests/Makefile: include $(INSTALL_DEP_TARGETS) in clean target to clean net/lib dependency
net/cls_cgroup: Fix task_get_classid() during qdisc run
media: redrat3: use int type to store negative error codes
net: sh_eth: Disable WoL if system can not suspend
usb: gadget: f_hid: Fix zero length packet transfer
net: call cond_resched() less often in __release_sock()
ALSA: usb-audio: apply quirk for MOONDROP Quark2
net: nfc: nci: Increase NCI_DATA_TIMEOUT to 3000 ms
dmaengine: mv_xor: match alloc_wc and free_wc
scsi: pm8001: Use int instead of u32 to store error codes
mips: lantiq: xway: sysctrl: rename stp clock
mips: lantiq: danube: add missing properties to cpu node
media: fix uninitialized symbol warnings
extcon: adc-jack: Fix wakeup source leaks on device unbind
rds: Fix endianness annotation for RDS_MPATH_HASH
net: Call trace_sock_exceed_buf_limit() for memcg failure with SK_MEM_RECV.
char: misc: Does not request module for miscdevice with dynamic minor
usb: gadget: f_ncm: Fix MAC assignment NCM ethernet
iio: adc: spear_adc: mask SPEAR_ADC_STATUS channel and avg sample before setting register
media: imon: make send_packet() more robust
net: ipv6: fix field-spanning memcpy warning in AH output
bridge: Redirect to backup port when port is administratively down
media: pci: ivtv: Don't create fake v4l2_fh
drm/amdkfd: return -ENOTTY for unsupported IOCTLs
selftests/net: Ensure assert() triggers in psock_tpacket.c
selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8
PCI: Disable MSI on RDC PCI to PCIe bridges
drm/nouveau: replace snprintf() with scnprintf() in nvkm_snprintbf()
mfd: madera: Work around false-positive -Wininitialized warning
mfd: stmpe: Remove IRQ domain upon removal
tools/power x86_energy_perf_policy: Prefer driver HWP limits
tools/power x86_energy_perf_policy: Enhance HWP enable
tools/cpupower: Fix incorrect size in cpuidle_state_disable()
hwmon: (dell-smm) Add support for Dell OptiPlex 7040
uprobe: Do not emulate/sstep original instruction when ip is changed
clocksource/drivers/vf-pit: Replace raw_readl/writel to readl/writel
video: backlight: lp855x_bl: Set correct EPROM start for LP8556
tee: allow a driver to allocate a tee_device without a pool
ACPICA: dispatcher: Use acpi_ds_clear_operands() in acpi_ds_call_control_method()
irqchip/gic-v2m: Handle Multiple MSI base IRQ Alignment
arc: Fix __fls() const-foldability via __builtin_clzl()
cpufreq/longhaul: handle NULL policy in longhaul_exit
selftests/bpf: Fix bpf_prog_detach2 usage in test_lirc_mode2
ACPI: video: force native for Lenovo 82K8
memstick: Add timeout to prevent indefinite waiting
bpf: Don't use %pK through printk
spi: loopback-test: Don't use %pK through printk
soc: qcom: smem: Fix endian-unaware access of num_entries
usb: gadget: f_fs: Fix epfile null pointer access after ep enable.
serial: 8250_dw: Use devm_clk_get_optional() to get the input clock
can: gs_usb: increase max interface to U8_MAX
devcoredump: Fix circular locking dependency with devcd->mutex.
x86/resctrl: Fix miscount of bandwidth event when reactivating previously unavailable RMID
net: phy: dp83867: Disable EEE support as not implemented
regmap: slimbus: fix bus_context pointer in regmap init calls
usbnet: Prevents free active kevent
wifi: ath10k: Fix memory leak on unsupported WMI command
ASoC: qdsp6: q6asm: do not sleep while atomic
fbdev: pvr2fb: Fix leftover reference to ONCHIP_NR_DMA_CHANNELS
fbdev: bitblit: bound-check glyph index in bit_putcs*
ACPI: video: Fix use-after-free in acpi_video_switch_brightness()
fbdev: atyfb: Check if pll_ops->init_pll failed
net: usb: asix_devices: Check return value of usbnet_get_endpoints
btrfs: use smp_mb__after_atomic() when forcing COW in create_pending_snapshot()
x86/bugs: Fix reporting of LFENCE retpoline
Conflicts:
drivers/slimbus/qcom-ngd-ctrl.c
drivers/usb/gadget/function/f_fs.c
drivers/usb/host/xhci-plat.c
Change-Id: Id995e84f0ff2c819145f7ebd62bc8dcd47fbbb47
commit 4da4e4bde1c453ac5cc2dce5def81d504ae257ee upstream.
The `len` member of the sk_buff is an unsigned int. This is cast to
`ssize_t` (a signed type) for the first sk_buff in the comparison,
but not the second sk_buff. On 32-bit systems, this can result in
an integer underflow for certain values because unsigned arithmetic
is being used.
This appears to be an oversight: if the intention was to use unsigned
arithmetic, then the first cast would have been omitted. The change
ensures both len values are cast to `ssize_t`.
The underflow causes an issue with ktls when multiple TLS PDUs are
included in a single TCP segment. The mainline kernel does not use
strparser for ktls anymore, but this is still useful for other
features that still use strparser, and for backporting.
Signed-off-by: Nate Karstens <nate.karstens@garmin.com>
Cc: stable@vger.kernel.org
Fixes: 43a0c6751a ("strparser: Stream parser for messages")
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://patch.msgid.link/20251106222835.1871628-1-nate.karstens@garmin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
[ Upstream commit e0dc3b93bd7bcff8c3813d1df43e0908499c7cf0 ]
Strparser is reusing the qdisc_skb_cb struct to stash the skb message handling
progress, e.g. offset and length of the skb. First this is poorly named and
inherits a struct from qdisc that doesn't reflect the actual usage of cb[] at
this layer.
But, more importantly strparser is using the following to access its metadata.
(struct _strp_msg *)((void *)skb->cb + offsetof(struct qdisc_skb_cb, data))
Where _strp_msg is defined as:
struct _strp_msg {
struct strp_msg strp; /* 0 8 */
int accum_len; /* 8 4 */
/* size: 12, cachelines: 1, members: 2 */
/* last cacheline: 12 bytes */
};
So we use 12 bytes of ->data[] in struct. However in BPF code running parser
and verdict the user has read capabilities into the data[] array as well. Its
not too problematic, but we should not be exposing internal state to BPF
program. If its really needed then we can use the probe_read() APIs which allow
reading kernel memory. And I don't believe cb[] layer poses any API breakage by
moving this around because programs can't depend on cb[] across layers.
In order to fix another issue with a ctx rewrite we need to stash a temp
variable somewhere. To make this work cleanly this patch builds a cb struct
for sk_skb types called sk_skb_cb struct. Then we can use this consistently
in the strparser, sockmap space. Additionally we can start allowing ->cb[]
write access after this.
Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface")
Change-Id: I2512e377df9d6f73136b43e59c364c6c87be5d1d
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Jussi Maki <joamaki@gmail.com>
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20211103204736.248403-5-john.fastabend@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Add a generic sk_msg layer, and convert current sockmap and later
kTLS over to make use of it. While sk_buff handles network packet
representation from netdevice up to socket, sk_msg handles data
representation from application to socket layer.
This means that sk_msg framework spans across ULP users in the
kernel, and enables features such as introspection or filtering
of data with the help of BPF programs that operate on this data
structure.
Latter becomes in particular useful for kTLS where data encryption
is deferred into the kernel, and as such enabling the kernel to
perform L7 introspection and policy based on BPF for TLS connections
where the record is being encrypted after BPF has run and came to
a verdict. In order to get there, first step is to transform open
coding of scatter-gather list handling into a common core framework
that subsystems can use.
The code itself has been split and refactored into three bigger
pieces: i) the generic sk_msg API which deals with managing the
scatter gather ring, providing helpers for walking and mangling,
transferring application data from user space into it, and preparing
it for BPF pre/post-processing, ii) the plain sock map itself
where sockets can be attached to or detached from; these bits
are independent of i) which can now be used also without sock
map, and iii) the integration with plain TCP as one protocol
to be used for processing L7 application data (later this could
e.g. also be extended to other protocols like UDP). The semantics
are the same with the old sock map code and therefore no change
of user facing behavior or APIs. While pursuing this work it
also helped finding a number of bugs in the old sockmap code
that we've fixed already in earlier commits. The test_sockmap
kselftest suite passes through fine as well.
Joint work with John.
Change-Id: Iacc1636681a70825399a0f63890a65e1fc95e674
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 4a9c2e3746e6151fd5d077259d79ce9ca86d47d7 ]
This reverts the first part of commit 4e485d06bb ("strparser: Call
skb_unclone conditionally"). To build a message with multiple
fragments we need our own root of frag_list. We can't simply
use the frag_list of orig_skb, because it will lead to linking
all orig_skbs together creating very long frag chains, and causing
stack overflow on kfree_skb() (which is called recursively on
the frag_lists).
BUG: stack guard page was hit at 00000000d40fad41 (stack is 0000000029dde9f4..000000008cce03d5)
kernel stack overflow (double-fault): 0000 [#1] PREEMPT SMP
RIP: 0010:free_one_page+0x2b/0x490
Call Trace:
__free_pages_ok+0x143/0x2c0
skb_release_data+0x8e/0x140
? skb_release_data+0xad/0x140
kfree_skb+0x32/0xb0
[...]
skb_release_data+0xad/0x140
? skb_release_data+0xad/0x140
kfree_skb+0x32/0xb0
skb_release_data+0xad/0x140
? skb_release_data+0xad/0x140
kfree_skb+0x32/0xb0
skb_release_data+0xad/0x140
? skb_release_data+0xad/0x140
kfree_skb+0x32/0xb0
skb_release_data+0xad/0x140
? skb_release_data+0xad/0x140
kfree_skb+0x32/0xb0
skb_release_data+0xad/0x140
__kfree_skb+0xe/0x20
tcp_disconnect+0xd6/0x4d0
tcp_close+0xf4/0x430
? tcp_check_oom+0xf0/0xf0
tls_sk_proto_close+0xe4/0x1e0 [tls]
inet_release+0x36/0x60
__sock_release+0x37/0xa0
sock_close+0x11/0x20
__fput+0xa2/0x1d0
task_work_run+0x89/0xb0
exit_to_usermode_loop+0x9a/0xa0
do_syscall_64+0xc0/0xf0
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Let's leave the second unclone conditional, as I'm not entirely
sure what is its purpose :)
Fixes: 4e485d06bb ("strparser: Call skb_unclone conditionally")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Variable 'rd_desc' is being assigned but never used,
so can be removed.
fix this clang warning:
net/strparser/strparser.c:411:20: warning: variable ‘rd_desc’ set but not used [-Wunused-but-set-variable]
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Simple overlapping changes in stmmac driver.
Adjust skb_gro_flush_final_remcsum function signature to make GRO list
changes in net-next, as per Stephen Rothwell's example merge
resolution.
Signed-off-by: David S. Miller <davem@davemloft.net>
Calling skb_unclone() is expensive as it triggers a memcpy operation.
Instead of calling skb_unclone() unconditionally, call it only when skb
has a shared frag_list. This improves tls rx throughout significantly.
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Suggested-by: Boris Pismenny <borisp@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
On receving an incomplete message, the existing code stores the
remaining length of the cloned skb in the early_eaten field instead of
incrementing the value returned by __strp_recv. This defers invocation
of sock_rfree for the current skb until the next invocation of
__strp_recv, which returns early_eaten if early_eaten is non-zero.
This behavior causes a stall when the current message occupies the very
tail end of a massive skb, and strp_peek/need_bytes indicates that the
remainder of the current message has yet to arrive on the socket. The
TCP receive buffer is totally full, causing the TCP window to go to
zero, so the remainder of the message will never arrive.
Incrementing the value returned by __strp_recv by the amount otherwise
stored in early_eaten prevents stalls of this nature.
Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
In function strp_data_ready(), it is useless to call queue_work if
the state of strparser is already paused. The state checking should
be done before calling queue_work. The change reduces the context
switches and improves the ktls-rx throughput by approx 20% (measured
on cortex-a53 based platform).
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Acked-by: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
strp_unpause queues strp_work in order to parse any messages that
arrived while the strparser was paused. However, the process invoking
strp_unpause could eagerly parse a buffered message itself if it held
the sock lock.
__strp_unpause is an alternative to strp_pause that avoids the scheduling
overhead that results when a receiving thread unpauses the strparser
and waits for the next message to be delivered by the workqueue thread.
This patch more than doubled the IOPS achieved in a benchmark of NBD
traffic encrypted using ktls.
Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
struct sock's sk_rcvtimeo is initialized to
LONG_MAX/MAX_SCHEDULE_TIMEOUT in sock_init_data. Calling
mod_delayed_work with a timeout of LONG_MAX causes spurious execution of
the work function. timer->expires is set equal to jiffies + LONG_MAX.
When timer_base->clk falls behind the current value of jiffies,
the delta between timer_base->clk and jiffies + LONG_MAX causes the
expiration to be in the past. Returning early from strp_start_timer if
timeo == LONG_MAX solves this problem.
Found while testing net/tls_sw recv path.
Fixes: 43a0c6751a ("strparser: Stream parser for messages")
Reviewed-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
strp_data_ready resets strp->need_bytes to 0 if strp_peek_len indicates
that the remainder of the message has been received. However,
do_strp_work does not reset strp->need_bytes to 0. If do_strp_work
completes a partial message, the value of strp->need_bytes will continue
to reflect the needed bytes of the previous message, causing
future invocations of strp_data_ready to return early if
strp->need_bytes is less than strp_peek_len. Resetting strp->need_bytes
to 0 in __strp_recv on handing a full message to the upper layer solves
this problem.
__strp_recv also calculates strp->need_bytes using stm->accum_len before
stm->accum_len has been incremented by cand_len. This can cause
strp->need_bytes to be equal to the full length of the message instead
of the full length minus the accumulated length. This, in turn, causes
strp_data_ready to return early, even when there is sufficient data to
complete the partial message. Incrementing stm->accum_len before using
it to calculate strp->need_bytes solves this problem.
Found while testing net/tls_sw recv path.
Fixes: 43a0c6751a ("strparser: Stream parser for messages")
Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
strp_parser_err is called with a negative code everywhere, which then
calls abort_parser with a negative code. strp_msg_timeout calls
abort_parser directly with a positive code. Negate ETIMEDOUT
to match signed-ness of other calls.
The default abort_parser callback, strp_abort_strp, sets
sk->sk_err to err. Also negate the error here so sk_err always
holds a positive value, as the rest of the net code expects. Currently
a negative sk_err can result in endless loops, or user code that
thinks it actually sent/received err bytes.
Found while testing net/tls_sw recv path.
Fixes: 43a0c6751a ("strparser: Stream parser for messages")
Signed-off-by: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Sock lock may be taken in the message timer function which is a
problem since timers run in BH. Instead of timers use delayed_work.
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Fixes: bbb03029a8 ("strparser: Generalize strparser")
Signed-off-by: Tom Herbert <tom@quantonium.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
It is useful to allow strparser to init sockets before the read_sock
callback has been established.
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Generalize strparser from more than just being used in conjunction
with read_sock. strparser will also be used in the send path with
zero proxy. The primary change is to create strp_process function
that performs the critical processing on skbs. The documentation
is also updated to reflect the new uses.
Signed-off-by: Tom Herbert <tom@quantonium.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
With m68k-linux-gnu-gcc-4.1:
net/strparser/strparser.c: In function ‘strp_recv’:
net/strparser/strparser.c:98: warning: ‘err’ may be used uninitialized in this function
Pass "len" (which is an error code when negative) instead of the
uninitialized "err" variable to fix this.
Fixes: 43a0c6751a ("strparser: Stream parser for messages")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
kcm and strparser need to work with any type of stream socket not just
TCP. Eliminate references to TCP and call generic proto_ops functions of
read_sock and peek_len. Also in strp_init check if the socket support
the proto_ops read_sock and peek_len.
Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
When the upper layer unpauses a stream parser connection we need to
queue rx_work to make sure no events are missed.
Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
sk_user_data mismatch between what kcm expects (psock) and what strparser expects (strparser).
Queued rx_work, for example calling strp_check_rcv after socket buffer changes, will never complete.
sk_user_data is unused in strparser, so just remove the check.
Signed-off-by: Dave Watson <davejwatson@fb.com>
Acked-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This patch introduces a utility for parsing application layer protocol
messages in a TCP stream. This is a generalization of the mechanism
implemented of Kernel Connection Multiplexor.
The API includes a context structure, a set of callbacks, utility
functions, and a data ready function.
A stream parser instance is defined by a strparse structure that
is bound to a TCP socket. The function to initialize the structure
is:
int strp_init(struct strparser *strp, struct sock *csk,
struct strp_callbacks *cb);
csk is the TCP socket being bound to and cb are the parser callbacks.
The upper layer calls strp_tcp_data_ready when data is ready on the lower
socket for strparser to process. This should be called from a data_ready
callback that is set on the socket:
void strp_tcp_data_ready(struct strparser *strp);
A parser is bound to a TCP socket by setting data_ready function to
strp_tcp_data_ready so that all receive indications on the socket
go through the parser. This is assumes that sk_user_data is set to
the strparser structure.
There are four callbacks.
- parse_msg is called to parse the message (returns length or error).
- rcv_msg is called when a complete message has been received
- read_sock_done is called when data_ready function exits
- abort_parser is called to abort the parser
The input to parse_msg is an skbuff which contains next message under
construction. The backend processing of parse_msg will parse the
application layer protocol headers to determine the length of
the message in the stream. The possible return values are:
>0 : indicates length of successfully parsed message
0 : indicates more data must be received to parse the message
-ESTRPIPE : current message should not be processed by the
kernel, return control of the socket to userspace which
can proceed to read the messages itself
other < 0 : Error is parsing, give control back to userspace
assuming that synchronzation is lost and the stream
is unrecoverable (application expected to close TCP socket)
In the case of error return (< 0) strparse will stop the parser
and report and error to userspace. The application must deal
with the error. To handle the error the strparser is unbound
from the TCP socket. If the error indicates that the stream
TCP socket is at recoverable point (ESTRPIPE) then the application
can read the TCP socket to process the stream. Once the application
has dealt with the exceptions in the stream, it may again bind the
socket to a strparser to continue data operations.
Note that ENODATA may be returned to the application. In this case
parse_msg returned -ESTRPIPE, however strparser was unable to maintain
synchronization of the stream (i.e. some of the message in question
was already read by the parser).
strp_pause and strp_unpause are used to provide flow control. For
instance, if rcv_msg is called but the upper layer can't immediately
consume the message it can hold the message and pause strparser.
Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>