4.19.285-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainercover 4.19.285-rc1 review
This is the start of the stable review cycle for the 4.19.285 release. There are 88 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 09 Jun 2023 20:07:31 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.285-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.19.285-rc1
Ping-Ke Shih <[email protected]>
wifi: rtlwifi: 8192de: correct checking of IQK reload
Ben Hutchings <[email protected]>
scsi: dpt_i2o: Do not process completions with invalid addresses
Ben Hutchings <[email protected]>
scsi: dpt_i2o: Remove broken pass-through ioctl (I2OUSERCMD)
Jim Wylder <[email protected]>
regmap: Account for register length when chunking
Helge Deller <[email protected]>
fbcon: Fix null-ptr-deref in soft_cursor
Theodore Ts'o <[email protected]>
ext4: add lockdep annotations for i_data_sem for ea_inode's
Paul Moore <[email protected]>
selinux: don't use make's grouped targets feature yet
Sherry Sun <[email protected]>
tty: serial: fsl_lpuart: use UARTCTRL_TXINV to send break instead of UARTCTRL_SBK
Deren Wu <[email protected]>
mmc: vub300: fix invalid response handling
Nathan Chancellor <[email protected]>
rsi: Remove unnecessary boolean condition
Nathan Chancellor <[email protected]>
regulator: da905{2,5}: Remove unnecessary array check
Nathan Chancellor <[email protected]>
hwmon: (scmi) Remove redundant pointer check
Jakub Kicinski <[email protected]>
wifi: rtlwifi: remove always-true condition pointed out by GCC 12
Nathan Chancellor <[email protected]>
lib/dynamic_debug.c: use address-of operator on section symbols
Nathan Chancellor <[email protected]>
kernel/extable.c: use address-of operator on section symbols
Martin Liška <[email protected]>
eth: sun: cassini: remove dead code
Linus Torvalds <[email protected]>
gcc-12: disable '-Wdangling-pointer' warning for now
Adam Borowski <[email protected]>
ACPI: thermal: drop an always true check
Kees Cook <[email protected]>
x86/boot: Wrap literal addresses in absolute_pointer()
Damien Le Moal <[email protected]>
ata: libata-scsi: Use correct device no in ata_find_dev()
Bart Van Assche <[email protected]>
scsi: stex: Fix gcc 13 warnings
Uttkarsh Aggarwal <[email protected]>
usb: gadget: f_fs: Add unbind event before functionfs_unbind
Sebastian Krzyszkowiak <[email protected]>
net: usb: qmi_wwan: Set DTR quirk for BroadMobi BM818
Lukas Bulwahn <[email protected]>
iio: dac: build ad5758 driver when AD5758 is selected
Marek Vasut <[email protected]>
iio: dac: mcp4725: Fix i2c_master_send() return value handling
Nikita Zhandarovich <[email protected]>
HID: wacom: avoid integer overflow in wacom_intuos_inout()
Sung-Chi Li <[email protected]>
HID: google: add jewel USB id
Jiakai Luo <[email protected]>
iio: adc: mxs-lradc: fix the order of two cleanup operations
Dan Carpenter <[email protected]>
mailbox: mailbox-test: fix a locking issue in mbox_test_message_write()
Arnd Bergmann <[email protected]>
atm: hide unused procfs functions
Arnd Bergmann <[email protected]>
ALSA: oss: avoid missing-prototype warnings
Tom Rix <[email protected]>
netfilter: conntrack: define variables exp_nat_nla_policy and any_addr with CONFIG_NF_NAT
Arnd Bergmann <[email protected]>
wifi: b43: fix incorrect __packed annotation
Wenchao Hao <[email protected]>
scsi: core: Decrease scsi_device's iorequest_cnt if dispatch failed
Min-Hua Chen <[email protected]>
arm64/mm: mark private VM_FAULT_X defines as vm_fault_t
Dario Binacchi <[email protected]>
ARM: dts: stm32: add pin map for CAN controller on stm32f7
Yun Lu <[email protected]>
wifi: rtl8xxxu: fix authentication timeout due to incorrect RCR value
Hyunwoo Kim <[email protected]>
media: dvb-core: Fix use-after-free due to race condition at dvb_ca_en50221
Takashi Iwai <[email protected]>
media: dvb-core: Fix kernel WARNING for blocking operation in wait_event*()
Hyunwoo Kim <[email protected]>
media: dvb-core: Fix use-after-free due on race condition at dvb_net
Krzysztof Kozlowski <[email protected]>
media: mn88443x: fix !CONFIG_OF error by drop of_match_ptr from ID table
Hyunwoo Kim <[email protected]>
media: ttusb-dec: fix memory leak in ttusb_dec_exit_dvb()
YongSu Yoo <[email protected]>
media: dvb_ca_en50221: fix a size write bug
Wei Chen <[email protected]>
media: netup_unidvb: fix irq init by register it at the end of probe
Wei Chen <[email protected]>
media: dvb-usb: dw2102: fix uninit-value in su3000_read_mac_address
Wei Chen <[email protected]>
media: dvb-usb: digitv: fix null-ptr-deref in digitv_i2c_xfer()
Zhang Shurong <[email protected]>
media: dvb-usb-v2: rtl28xxu: fix null-ptr-deref in rtl28xxu_i2c_xfer
Wei Chen <[email protected]>
media: dvb-usb-v2: ce6230: fix null-ptr-deref in ce6230_i2c_master_xfer()
Wei Chen <[email protected]>
media: dvb-usb-v2: ec168: fix null-ptr-deref in ec168_i2c_xfer()
Wei Chen <[email protected]>
media: dvb-usb: az6027: fix three null-ptr-deref in az6027_i2c_xfer()
YongSu Yoo <[email protected]>
media: dvb_demux: fix a bug for the continuity counter
Paweł Anikiel <[email protected]>
ASoC: ssm2602: Add workaround for playback distortions
Benedict Wong <[email protected]>
xfrm: Check if_id in inbound policy/secpath match
Maxim Kochetkov <[email protected]>
ASoC: dwc: limit the number of overrun messages
Ivan Orlov <[email protected]>
nbd: Fix debugfs_create_dir error checking
Helge Deller <[email protected]>
fbdev: stifb: Fix info entry in sti_struct on error path
Helge Deller <[email protected]>
fbdev: modedb: Add 1920x1080 at 60 Hz video mode
Niklas Söderlund <[email protected]>
media: rcar-vin: Select correct interrupt mode for V4L2_FIELD_ALTERNATE
Haibo Li <[email protected]>
ARM: 9295/1: unwind:fix unwind abort for uleb128 case
Lee Jones <[email protected]>
mailbox: mailbox-test: Fix potential double-free in mbox_test_message_write()
Johannes Thumshirn <[email protected]>
watchdog: menz069_wdt: fix watchdog initialisation
Andreas Svensson <[email protected]>
net: dsa: mv88e6xxx: Increase wait after reset deactivation
Hangyu Hua <[email protected]>
net/sched: flower: fix possible OOB write in fl_set_geneve_opt()
Vladislav Efanov <[email protected]>
udp6: Fix race condition in udp6_sendmsg & connect
Pedro Tammela <[email protected]>
net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report
Andy Shevchenko <[email protected]>
ocfs2/dlm: move BITS_TO_BYTES() to bitops.h for wider use
Zhengchao Shao <[email protected]>
net: sched: fix NULL pointer dereference in mq_attach
Peilin Ye <[email protected]>
net/sched: Prohibit regrafting ingress or clsact Qdiscs
Peilin Ye <[email protected]>
net/sched: Reserve TC_H_INGRESS (TC_H_CLSACT) for ingress (clsact) Qdiscs
Peilin Ye <[email protected]>
net/sched: sch_clsact: Only create under TC_H_CLSACT
Peilin Ye <[email protected]>
net/sched: sch_ingress: Only create under TC_H_INGRESS
Cambda Zhu <[email protected]>
tcp: Return user_mss for TCP_MAXSEG in CLOSE/LISTEN state if user_mss set
Eric Dumazet <[email protected]>
tcp: deny tcp_disconnect() when threads are waiting
Eric Dumazet <[email protected]>
af_packet: do not use READ_ONCE() in packet_bind()
Raju Rangoju <[email protected]>
amd-xgbe: fix the false linkup in xgbe_phy_status
Kuniyuki Iwashima <[email protected]>
af_packet: Fix data-races of pkt_sk(sk)->num.
Eric Dumazet <[email protected]>
netrom: fix info-leak in nr_write_internal()
Shay Drory <[email protected]>
net/mlx5: fw_tracer, Fix event handling
Randy Dunlap <[email protected]>
dmaengine: pl330: rename _start to prevent build error
Paul Blakey <[email protected]>
netfilter: ctnetlink: Support offloaded conntrack entry deletion
Nicolas Dichtel <[email protected]>
ipv{4,6}/raw: fix output xfrm lookup wrt protocol
Ruihan Li <[email protected]>
bluetooth: Add cmd validity checks at the start of hci_sock_ioctl()
Alexander Bersenev <[email protected]>
cdc_ncm: Fix the build warning
Hans de Goede <[email protected]>
power: supply: bq24190: Call power_supply_changed() after updating input current
Hans de Goede <[email protected]>
power: supply: core: Refactor power_supply_set_input_current_limit_from_supplier()
Hans de Goede <[email protected]>
power: supply: bq27xxx: After charger plug in/out wait 0.5s for things to stabilize
Tudor Ambarus <[email protected]>
net: cdc_ncm: Deal with too low values of dwNtbOutMaxSize
Alexander Bersenev <[email protected]>
cdc_ncm: Implement the 32-bit version of NCM Transfer Block
-------------
Diffstat:
Makefile | 8 +- arch/arm/boot/dts/stm32f7-pinctrl.dtsi | 82 ++++ arch/arm/kernel/unwind.c | 25 +- arch/arm64/mm/fault.c | 4 +- arch/x86/boot/boot.h | 36 +- arch/x86/boot/main.c | 2 +- drivers/acpi/thermal.c | 2 - drivers/ata/libata-scsi.c | 34 +- drivers/base/regmap/regmap.c | 6 +- drivers/block/nbd.c | 4 +- drivers/dma/pl330.c | 8 +- drivers/hid/hid-google-hammer.c | 2 + drivers/hid/hid-ids.h | 1 + drivers/hid/wacom_wac.c | 2 +- drivers/hwmon/scmi-hwmon.c | 2 +- drivers/iio/adc/mxs-lradc-adc.c | 10 +- drivers/iio/dac/Makefile | 2 +- drivers/iio/dac/mcp4725.c | 16 +- drivers/mailbox/mailbox-test.c | 13 +- drivers/media/dvb-core/dvb_ca_en50221.c | 49 ++- drivers/media/dvb-core/dvb_demux.c | 4 +- drivers/media/dvb-core/dvb_frontend.c | 16 +- drivers/media/dvb-core/dvb_net.c | 38 +- drivers/media/dvb-frontends/mn88443x.c | 2 +- drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 17 +- drivers/media/platform/rcar-vin/rcar-dma.c | 1 + drivers/media/usb/dvb-usb-v2/ce6230.c | 8 + drivers/media/usb/dvb-usb-v2/ec168.c | 12 + drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 20 + drivers/media/usb/dvb-usb/az6027.c | 12 + drivers/media/usb/dvb-usb/digitv.c | 4 + drivers/media/usb/dvb-usb/dw2102.c | 2 +- drivers/media/usb/ttusb-dec/ttusb_dec.c | 3 +- drivers/mmc/host/vub300.c | 3 + drivers/net/dsa/mv88e6xxx/chip.c | 2 +- drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 12 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h | 1 - .../ethernet/mellanox/mlx5/core/diag/fw_tracer.c | 2 +- drivers/net/ethernet/sun/cassini.c | 4 +- drivers/net/usb/cdc_ncm.c | 435 ++++++++++++++++----- drivers/net/usb/huawei_cdc_ncm.c | 8 +- drivers/net/usb/qmi_wwan.c | 2 +- drivers/net/wireless/broadcom/b43/b43.h | 2 +- .../net/wireless/broadcom/b43legacy/b43legacy.h | 2 +- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 4 +- .../net/wireless/realtek/rtlwifi/rtl8192de/phy.c | 10 +- drivers/net/wireless/rsi/rsi_91x_mac80211.c | 2 +- drivers/power/supply/bq24190_charger.c | 13 +- drivers/power/supply/bq27xxx_battery.c | 4 +- drivers/power/supply/power_supply_core.c | 57 +-- drivers/regulator/da9052-regulator.c | 2 +- drivers/regulator/da9055-regulator.c | 2 +- drivers/scsi/Kconfig | 2 +- drivers/scsi/dpt_i2o.c | 269 +------------ drivers/scsi/dpti.h | 1 - drivers/scsi/scsi_lib.c | 2 + drivers/scsi/stex.c | 4 + drivers/tty/serial/fsl_lpuart.c | 44 ++- drivers/usb/gadget/function/f_fs.c | 2 +- drivers/video/fbdev/core/bitblit.c | 3 + drivers/video/fbdev/core/modedb.c | 5 + drivers/video/fbdev/stifb.c | 1 + drivers/watchdog/menz69_wdt.c | 16 +- fs/ext4/ext4.h | 2 + fs/ext4/xattr.c | 4 + fs/ocfs2/dlm/dlmcommon.h | 4 - include/linux/bitops.h | 1 + include/linux/power_supply.h | 5 +- include/linux/usb/cdc_ncm.h | 15 +- include/media/dvb_net.h | 4 + include/net/ip.h | 2 + include/net/sock.h | 4 + include/uapi/linux/in.h | 2 + kernel/extable.c | 3 +- lib/dynamic_debug.c | 2 +- net/atm/resources.c | 2 + net/bluetooth/hci_sock.c | 28 ++ net/core/sock.c | 2 +- net/ipv4/af_inet.c | 2 + net/ipv4/inet_connection_sock.c | 1 + net/ipv4/ip_sockglue.c | 12 +- net/ipv4/raw.c | 5 +- net/ipv4/tcp.c | 9 +- net/ipv6/raw.c | 3 +- net/netfilter/nf_conntrack_netlink.c | 12 +- net/netlink/af_netlink.c | 2 +- net/netrom/nr_subr.c | 7 +- net/packet/af_packet.c | 8 +- net/packet/diag.c | 2 +- net/sched/cls_flower.c | 3 + net/sched/sch_api.c | 16 +- net/sched/sch_ingress.c | 16 +- net/xfrm/xfrm_policy.c | 11 +- security/selinux/Makefile | 6 +- sound/core/oss/pcm_plugin.h | 16 +- sound/soc/codecs/ssm2602.c | 15 + sound/soc/dwc/dwc-i2s.c | 4 +- 98 files changed, 1018 insertions(+), 576 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/88 cdc_ncm: Implement the 32-bit version of NCM Transfer Block
From: Alexander Bersenev <[email protected]>
[ Upstream commit 0fa81b304a7973a499f844176ca031109487dd31 ]
The NCM specification defines two formats of transfer blocks: with 16-bit fields (NTB-16) and with 32-bit fields (NTB-32). Currently only NTB-16 is implemented.
This patch adds the support of NTB-32. The motivation behind this is that some devices such as E5785 or E5885 from the current generation of Huawei LTE routers do not support NTB-16. The previous generations of Huawei devices are also use NTB-32 by default.
Also this patch enables NTB-32 by default for Huawei devices.
During the 2019 ValdikSS made five attempts to contact Huawei to add the NTB-16 support to their router firmware, but they were unsuccessful.
Stable-dep-of: 7e01c7f7046e ("net: cdc_ncm: Deal with too low values of dwNtbOutMaxSize")
--- drivers/net/usb/cdc_ncm.c | 411 ++++++++++++++++++++++++------- drivers/net/usb/huawei_cdc_ncm.c | 8 +- include/linux/usb/cdc_ncm.h | 15 +- 3 files changed, 340 insertions(+), 94 deletions(-)
drivers/net/usb/cdc_ncm.c +324 -87
@@ -175,7 +175,11 @@ static u32 cdc_ncm_check_tx_max(struct usbnet *dev, u32 new_tx)u32 val, max, min;/* clamp new_tx to sane values */ - min = ctx->max_datagram_size + ctx->max_ndp_size +sizeof (struct usb_cdc_ncm_nth16 ); +if (ctx->is_ndp16) + min = ctx->max_datagram_size + ctx->max_ndp_size +sizeof (struct usb_cdc_ncm_nth16 ); +else + min = ctx->max_datagram_size + ctx->max_ndp_size +sizeof (struct usb_cdc_ncm_nth32 ); + max =min_t (u32,CDC_NCM_NTB_MAX_SIZE_TX ,le32_to_cpu (ctx->ncm_parm.dwNtbOutMaxSize));if (max ==0 ) max =CDC_NCM_NTB_MAX_SIZE_TX ;/* dwNtbOutMaxSize not set */
@@ -309,10 +313,17 @@ static ssize_t ndp_to_end_store(struct device *d, struct device_attribute *attrif (enable == (ctx->drvflags &CDC_NCM_FLAG_NDP_TO_END ))return len; -if (enable && !ctx->delayed_ndp16) { - ctx->delayed_ndp16 =kzalloc (ctx->max_ndp_size,GFP_KERNEL ); -if (!ctx->delayed_ndp16) -return -ENOMEM ; +if (enable) { +if (ctx->is_ndp16 && !ctx->delayed_ndp16) { + ctx->delayed_ndp16 =kzalloc (ctx->max_ndp_size,GFP_KERNEL ); +if (!ctx->delayed_ndp16) +return -ENOMEM ; + } +if (!ctx->is_ndp16 && !ctx->delayed_ndp32) { + ctx->delayed_ndp32 =kzalloc (ctx->max_ndp_size,GFP_KERNEL ); +if (!ctx->delayed_ndp32) +return -ENOMEM ; + } }/* flush pending data before changing flag */
@@ -514,6 +525,9 @@ static int cdc_ncm_init(struct usbnet *dev)dev_err (&dev->intf->dev,"SET_CRC_MODE failed\n" ); } +/* use ndp16 by default */ + ctx->is_ndp16 =1 ; +/* set NTB format, if both formats are supported. * * "The host shall only send this command while the NCM Data
@@ -521,14 +535,27 @@ static int cdc_ncm_init(struct usbnet *dev)*/ if (le16_to_cpu (ctx->ncm_parm.bmNtbFormatsSupported) &USB_CDC_NCM_NTB32_SUPPORTED ) { -dev_dbg (&dev->intf->dev,"Setting NTB format to 16-bit\n" ); - err =usbnet_write_cmd (dev,USB_CDC_SET_NTB_FORMAT , -USB_TYPE_CLASS |USB_DIR_OUT - |USB_RECIP_INTERFACE , -USB_CDC_NCM_NTB16_FORMAT , - iface_no,NULL ,0 ); -if (err <0 ) +if (ctx->drvflags &CDC_NCM_FLAG_PREFER_NTB32 ) { + ctx->is_ndp16 =0 ; +dev_dbg (&dev->intf->dev,"Setting NTB format to 32-bit\n" ); + err =usbnet_write_cmd (dev,USB_CDC_SET_NTB_FORMAT , +USB_TYPE_CLASS |USB_DIR_OUT + |USB_RECIP_INTERFACE , +USB_CDC_NCM_NTB32_FORMAT , + iface_no,NULL ,0 ); + }else { + ctx->is_ndp16 =1 ; +dev_dbg (&dev->intf->dev,"Setting NTB format to 16-bit\n" ); + err =usbnet_write_cmd (dev,USB_CDC_SET_NTB_FORMAT , +USB_TYPE_CLASS |USB_DIR_OUT + |USB_RECIP_INTERFACE , +USB_CDC_NCM_NTB16_FORMAT , + iface_no,NULL ,0 ); + } +if (err <0 ) { + ctx->is_ndp16 =1 ;dev_err (&dev->intf->dev,"SET_NTB_FORMAT failed\n" ); + } }/* set initial device values */
@@ -551,7 +578,10 @@ static int cdc_ncm_init(struct usbnet *dev) ctx->tx_max_datagrams =CDC_NCM_DPT_DATAGRAMS_MAX ;/* set up maximum NDP size */ - ctx->max_ndp_size =sizeof (struct usb_cdc_ncm_ndp16 ) + (ctx->tx_max_datagrams +1 ) *sizeof (struct usb_cdc_ncm_dpe16 ); +if (ctx->is_ndp16) + ctx->max_ndp_size =sizeof (struct usb_cdc_ncm_ndp16 ) + (ctx->tx_max_datagrams +1 ) *sizeof (struct usb_cdc_ncm_dpe16 ); +else + ctx->max_ndp_size =sizeof (struct usb_cdc_ncm_ndp32 ) + (ctx->tx_max_datagrams +1 ) *sizeof (struct usb_cdc_ncm_dpe32 );/* initial coalescing timer interval */ ctx->timer_interval =CDC_NCM_TIMER_INTERVAL_USEC *NSEC_PER_USEC ;
@@ -736,7 +766,10 @@ static void cdc_ncm_free(struct cdc_ncm_ctx *ctx) ctx->tx_curr_skb =NULL ; } -kfree (ctx->delayed_ndp16); +if (ctx->is_ndp16) +kfree (ctx->delayed_ndp16); +else +kfree (ctx->delayed_ndp32);kfree (ctx); }
@@ -774,10 +807,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_u8 *buf;int len;int temp; -int err;u8 iface_no;struct usb_cdc_parsed_header hdr; -__le16 curr_ntb_format; ctx =kzalloc (sizeof (*ctx),GFP_KERNEL );if (!ctx)
@@ -882,32 +913,6 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ goto error2; } -/* -* Some Huawei devices have been observed to come out of reset in NDP32 mode. -* Let's check if this is the case, and set the device to NDP16 mode again if -* needed. -*/ -if (ctx->drvflags &CDC_NCM_FLAG_RESET_NTB16 ) { - err =usbnet_read_cmd (dev,USB_CDC_GET_NTB_FORMAT , -USB_TYPE_CLASS |USB_DIR_IN |USB_RECIP_INTERFACE , -0 , iface_no, &curr_ntb_format,2 ); -if (err <0 ) { - goto error2; - } - -if (curr_ntb_format ==cpu_to_le16 (USB_CDC_NCM_NTB32_FORMAT )) { -dev_info (&intf->dev,"resetting NTB format to 16-bit" ); - err =usbnet_write_cmd (dev,USB_CDC_SET_NTB_FORMAT , -USB_TYPE_CLASS |USB_DIR_OUT - |USB_RECIP_INTERFACE , -USB_CDC_NCM_NTB16_FORMAT , - iface_no,NULL ,0 ); - -if (err <0 ) - goto error2; - } - } -cdc_ncm_find_endpoints (dev, ctx->data);cdc_ncm_find_endpoints (dev, ctx->control);if (!dev->in || !dev->out || !dev->status) {
@@ -932,9 +937,15 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_/* Allocate the delayed NDP if needed. */ if (ctx->drvflags &CDC_NCM_FLAG_NDP_TO_END ) { - ctx->delayed_ndp16 =kzalloc (ctx->max_ndp_size,GFP_KERNEL ); -if (!ctx->delayed_ndp16) - goto error2; +if (ctx->is_ndp16) { + ctx->delayed_ndp16 =kzalloc (ctx->max_ndp_size,GFP_KERNEL ); +if (!ctx->delayed_ndp16) + goto error2; + }else { + ctx->delayed_ndp32 =kzalloc (ctx->max_ndp_size,GFP_KERNEL ); +if (!ctx->delayed_ndp32) + goto error2; + }dev_info (&intf->dev,"NDP will be placed at end of frame for this device." ); }
@@ -1058,7 +1069,7 @@ static void cdc_ncm_align_tail(struct sk_buff *skb, size_t modulus, size_t remai/* return a pointer to a valid struct usb_cdc_ncm_ndp16 of type sign, possibly * allocating a new one within skb */ -static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp (struct cdc_ncm_ctx *ctx,struct sk_buff *skb,__le32 sign,size_t reserve) +static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp16 (struct cdc_ncm_ctx *ctx,struct sk_buff *skb,__le32 sign,size_t reserve) {struct usb_cdc_ncm_ndp16 *ndp16 =NULL ;struct usb_cdc_ncm_nth16 *nth16 = (void *)skb->data;
@@ -1113,12 +1124,73 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_return ndp16; } +static struct usb_cdc_ncm_ndp32 *cdc_ncm_ndp32 (struct cdc_ncm_ctx *ctx,struct sk_buff *skb,__le32 sign,size_t reserve) +{ +struct usb_cdc_ncm_ndp32 *ndp32 =NULL ; +struct usb_cdc_ncm_nth32 *nth32 = (void *)skb->data; +size_t ndpoffset =le32_to_cpu (nth32->dwNdpIndex); + +/* If NDP should be moved to the end of the NCM package, we can't follow the +* NTH32 header as we would normally do. NDP isn't written to the SKB yet, and +* the wNdpIndex field in the header is actually not consistent with reality. It will be later. +*/ +if (ctx->drvflags &CDC_NCM_FLAG_NDP_TO_END ) { +if (ctx->delayed_ndp32->dwSignature == sign) +return ctx->delayed_ndp32; + +/* We can only push a single NDP to the end. Return +* NULL to send what we've already got and queue this +* skb for later. +*/ +else if (ctx->delayed_ndp32->dwSignature) +return NULL ; + } + +/* follow the chain of NDPs, looking for a match */ +while (ndpoffset) { + ndp32 = (struct usb_cdc_ncm_ndp32 *)(skb->data + ndpoffset); +if (ndp32->dwSignature == sign) +return ndp32; + ndpoffset =le32_to_cpu (ndp32->dwNextNdpIndex); + } + +/* align new NDP */ +if (!(ctx->drvflags &CDC_NCM_FLAG_NDP_TO_END )) +cdc_ncm_align_tail (skb, ctx->tx_ndp_modulus,0 , ctx->tx_curr_size); + +/* verify that there is room for the NDP and the datagram (reserve) */ +if ((ctx->tx_curr_size - skb->len - reserve) < ctx->max_ndp_size) +return NULL ; + +/* link to it */ +if (ndp32) + ndp32->dwNextNdpIndex =cpu_to_le32 (skb->len); +else + nth32->dwNdpIndex =cpu_to_le32 (skb->len); + +/* push a new empty NDP */ +if (!(ctx->drvflags &CDC_NCM_FLAG_NDP_TO_END )) + ndp32 =skb_put_zero (skb, ctx->max_ndp_size); +else + ndp32 = ctx->delayed_ndp32; + + ndp32->dwSignature = sign; + ndp32->wLength =cpu_to_le32 (sizeof (struct usb_cdc_ncm_ndp32 ) +sizeof (struct usb_cdc_ncm_dpe32 )); +return ndp32; +} +struct sk_buff *cdc_ncm_fill_tx_frame (struct usbnet *dev,struct sk_buff *skb,__le32 sign) {struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0 ]; -struct usb_cdc_ncm_nth16 *nth16; -struct usb_cdc_ncm_ndp16 *ndp16; +union { +struct usb_cdc_ncm_nth16 *nth16; +struct usb_cdc_ncm_nth32 *nth32; + } nth; +union { +struct usb_cdc_ncm_ndp16 *ndp16; +struct usb_cdc_ncm_ndp32 *ndp32; + } ndp;struct sk_buff *skb_out;u16 n =0 , index, ndplen;u8 ready2send =0 ;
@@ -1185,11 +1257,19 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign) } ctx->tx_low_mem_val--; } -/* fill out the initial 16-bit NTB header */ - nth16 =skb_put_zero (skb_out,sizeof (struct usb_cdc_ncm_nth16 )); - nth16->dwSignature =cpu_to_le32 (USB_CDC_NCM_NTH16_SIGN ); - nth16->wHeaderLength =cpu_to_le16 (sizeof (struct usb_cdc_ncm_nth16 )); - nth16->wSequence =cpu_to_le16 (ctx->tx_seq++); +if (ctx->is_ndp16) { +/* fill out the initial 16-bit NTB header */ + nth.nth16 =skb_put_zero (skb_out,sizeof (struct usb_cdc_ncm_nth16 )); + nth.nth16->dwSignature =cpu_to_le32 (USB_CDC_NCM_NTH16_SIGN ); + nth.nth16->wHeaderLength =cpu_to_le16 (sizeof (struct usb_cdc_ncm_nth16 )); + nth.nth16->wSequence =cpu_to_le16 (ctx->tx_seq++); + }else { +/* fill out the initial 32-bit NTB header */ + nth.nth32 =skb_put_zero (skb_out,sizeof (struct usb_cdc_ncm_nth32 )); + nth.nth32->dwSignature =cpu_to_le32 (USB_CDC_NCM_NTH32_SIGN ); + nth.nth32->wHeaderLength =cpu_to_le16 (sizeof (struct usb_cdc_ncm_nth32 )); + nth.nth32->wSequence =cpu_to_le16 (ctx->tx_seq++); + }/* count total number of frames in this NTB */ ctx->tx_curr_frame_num =0 ;
@@ -1211,13 +1291,17 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign) }/* get the appropriate NDP for this skb */ - ndp16 =cdc_ncm_ndp (ctx, skb_out, sign, skb->len + ctx->tx_modulus + ctx->tx_remainder); +if (ctx->is_ndp16) + ndp.ndp16 =cdc_ncm_ndp16 (ctx, skb_out, sign, skb->len + ctx->tx_modulus + ctx->tx_remainder); +else + ndp.ndp32 =cdc_ncm_ndp32 (ctx, skb_out, sign, skb->len + ctx->tx_modulus + ctx->tx_remainder);/* align beginning of next frame */ cdc_ncm_align_tail (skb_out, ctx->tx_modulus, ctx->tx_remainder, ctx->tx_curr_size);/* check if we had enough room left for both NDP and frame */ -if (!ndp16 || skb_out->len + skb->len + delayed_ndp_size > ctx->tx_curr_size) { +if ((ctx->is_ndp16 && !ndp.ndp16) || (!ctx->is_ndp16 && !ndp.ndp32) || + skb_out->len + skb->len + delayed_ndp_size > ctx->tx_curr_size) {if (n ==0 ) {/* won't fit, MTU problem? */ dev_kfree_skb_any (skb);
@@ -1239,13 +1323,22 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign) }/* calculate frame number withing this NDP */ - ndplen =le16_to_cpu (ndp16->wLength); - index = (ndplen -sizeof (struct usb_cdc_ncm_ndp16 )) /sizeof (struct usb_cdc_ncm_dpe16 ) -1 ; +if (ctx->is_ndp16) { + ndplen =le16_to_cpu (ndp.ndp16->wLength); + index = (ndplen -sizeof (struct usb_cdc_ncm_ndp16 )) /sizeof (struct usb_cdc_ncm_dpe16 ) -1 ; + +/* OK, add this skb */ + ndp.ndp16->dpe16[index].wDatagramLength =cpu_to_le16 (skb->len); + ndp.ndp16->dpe16[index].wDatagramIndex =cpu_to_le16 (skb_out->len); + ndp.ndp16->wLength =cpu_to_le16 (ndplen +sizeof (struct usb_cdc_ncm_dpe16 )); + }else { + ndplen =le16_to_cpu (ndp.ndp32->wLength); + index = (ndplen -sizeof (struct usb_cdc_ncm_ndp32 )) /sizeof (struct usb_cdc_ncm_dpe32 ) -1 ; -/* OK, add this skb */ - ndp16->dpe16[index].wDatagramLength =cpu_to_le16 (skb->len); - ndp16->dpe16[index].wDatagramIndex =cpu_to_le16 (skb_out->len); - ndp16->wLength =cpu_to_le16 (ndplen +sizeof (struct usb_cdc_ncm_dpe16 )); + ndp.ndp32->dpe32[index].dwDatagramLength =cpu_to_le32 (skb->len); + ndp.ndp32->dpe32[index].dwDatagramIndex =cpu_to_le32 (skb_out->len); + ndp.ndp32->wLength =cpu_to_le16 (ndplen +sizeof (struct usb_cdc_ncm_dpe32 )); + }skb_put_data (skb_out, skb->data, skb->len); ctx->tx_curr_frame_payload += skb->len;/* count real tx payload data */ dev_kfree_skb_any (skb);
@@ -1292,13 +1385,22 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)/* If requested, put NDP at end of frame. */ if (ctx->drvflags &CDC_NCM_FLAG_NDP_TO_END ) { - nth16 = (struct usb_cdc_ncm_nth16 *)skb_out->data; -cdc_ncm_align_tail (skb_out, ctx->tx_ndp_modulus,0 , ctx->tx_curr_size - ctx->max_ndp_size); - nth16->wNdpIndex =cpu_to_le16 (skb_out->len); -skb_put_data (skb_out, ctx->delayed_ndp16, ctx->max_ndp_size); +if (ctx->is_ndp16) { + nth.nth16 = (struct usb_cdc_ncm_nth16 *)skb_out->data; +cdc_ncm_align_tail (skb_out, ctx->tx_ndp_modulus,0 , ctx->tx_curr_size - ctx->max_ndp_size); + nth.nth16->wNdpIndex =cpu_to_le16 (skb_out->len); +skb_put_data (skb_out, ctx->delayed_ndp16, ctx->max_ndp_size); + +/* Zero out delayed NDP - signature checking will naturally fail. */ + ndp.ndp16 =memset (ctx->delayed_ndp16,0 , ctx->max_ndp_size); + }else { + nth.nth32 = (struct usb_cdc_ncm_nth32 *)skb_out->data; +cdc_ncm_align_tail (skb_out, ctx->tx_ndp_modulus,0 , ctx->tx_curr_size - ctx->max_ndp_size); + nth.nth32->dwNdpIndex =cpu_to_le32 (skb_out->len); +skb_put_data (skb_out, ctx->delayed_ndp32, ctx->max_ndp_size); -/* Zero out delayed NDP - signature checking will naturally fail. */ - ndp16 =memset (ctx->delayed_ndp16,0 , ctx->max_ndp_size); + ndp.ndp32 =memset (ctx->delayed_ndp32,0 , ctx->max_ndp_size); + } }/* If collected data size is less or equal ctx->min_tx_pkt
@@ -1321,8 +1423,13 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign) }/* set final frame length */ - nth16 = (struct usb_cdc_ncm_nth16 *)skb_out->data; - nth16->wBlockLength =cpu_to_le16 (skb_out->len); +if (ctx->is_ndp16) { + nth.nth16 = (struct usb_cdc_ncm_nth16 *)skb_out->data; + nth.nth16->wBlockLength =cpu_to_le16 (skb_out->len); + }else { + nth.nth32 = (struct usb_cdc_ncm_nth32 *)skb_out->data; + nth.nth32->dwBlockLength =cpu_to_le32 (skb_out->len); + }/* return skb */ ctx->tx_curr_skb =NULL ;
@@ -1405,7 +1512,12 @@ cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) goto error;spin_lock_bh (&ctx->mtx); - skb_out =cdc_ncm_fill_tx_frame (dev, skb,cpu_to_le32 (USB_CDC_NCM_NDP16_NOCRC_SIGN )); + +if (ctx->is_ndp16) + skb_out =cdc_ncm_fill_tx_frame (dev, skb,cpu_to_le32 (USB_CDC_NCM_NDP16_NOCRC_SIGN )); +else + skb_out =cdc_ncm_fill_tx_frame (dev, skb,cpu_to_le32 (USB_CDC_NCM_NDP32_NOCRC_SIGN )); +spin_unlock_bh (&ctx->mtx);return skb_out;
@@ -1466,6 +1578,54 @@ int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in) }EXPORT_SYMBOL_GPL (cdc_ncm_rx_verify_nth16); +int cdc_ncm_rx_verify_nth32 (struct cdc_ncm_ctx *ctx,struct sk_buff *skb_in) +{ +struct usbnet *dev =netdev_priv (skb_in->dev); +struct usb_cdc_ncm_nth32 *nth32; +int len; +int ret = -EINVAL ; + +if (ctx ==NULL ) + goto error; + +if (skb_in->len < (sizeof (struct usb_cdc_ncm_nth32 ) + +sizeof (struct usb_cdc_ncm_ndp32 ))) { +netif_dbg (dev, rx_err, dev->net,"frame too short\n" ); + goto error; + } + + nth32 = (struct usb_cdc_ncm_nth32 *)skb_in->data; + +if (nth32->dwSignature !=cpu_to_le32 (USB_CDC_NCM_NTH32_SIGN )) { +netif_dbg (dev, rx_err, dev->net, +"invalid NTH32 signature <%#010x>\n" , +le32_to_cpu (nth32->dwSignature)); + goto error; + } + + len =le32_to_cpu (nth32->dwBlockLength); +if (len > ctx->rx_max) { +netif_dbg (dev, rx_err, dev->net, +"unsupported NTB block length %u/%u\n" , len, + ctx->rx_max); + goto error; + } + +if ((ctx->rx_seq +1 ) !=le16_to_cpu (nth32->wSequence) && + (ctx->rx_seq ||le16_to_cpu (nth32->wSequence)) && + !((ctx->rx_seq ==0xffff ) && !le16_to_cpu (nth32->wSequence))) { +netif_dbg (dev, rx_err, dev->net, +"sequence number glitch prev=%d curr=%d\n" , + ctx->rx_seq,le16_to_cpu (nth32->wSequence)); + } + ctx->rx_seq =le16_to_cpu (nth32->wSequence); + + ret =le32_to_cpu (nth32->dwNdpIndex); +error: +return ret; +} +EXPORT_SYMBOL_GPL (cdc_ncm_rx_verify_nth32); +/* verify NDP header and return number of datagrams, or negative error */ int cdc_ncm_rx_verify_ndp16 (struct sk_buff *skb_in,int ndpoffset) {
@@ -1502,6 +1662,42 @@ int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset) }EXPORT_SYMBOL_GPL (cdc_ncm_rx_verify_ndp16); +/* verify NDP header and return number of datagrams, or negative error */ +int cdc_ncm_rx_verify_ndp32 (struct sk_buff *skb_in,int ndpoffset) +{ +struct usbnet *dev =netdev_priv (skb_in->dev); +struct usb_cdc_ncm_ndp32 *ndp32; +int ret = -EINVAL ; + +if ((ndpoffset +sizeof (struct usb_cdc_ncm_ndp32 )) > skb_in->len) { +netif_dbg (dev, rx_err, dev->net,"invalid NDP offset <%u>\n" , + ndpoffset); + goto error; + } + ndp32 = (struct usb_cdc_ncm_ndp32 *)(skb_in->data + ndpoffset); + +if (le16_to_cpu (ndp32->wLength) <USB_CDC_NCM_NDP32_LENGTH_MIN ) { +netif_dbg (dev, rx_err, dev->net,"invalid DPT32 length <%u>\n" , +le16_to_cpu (ndp32->wLength)); + goto error; + } + + ret = ((le16_to_cpu (ndp32->wLength) - +sizeof (struct usb_cdc_ncm_ndp32 )) / +sizeof (struct usb_cdc_ncm_dpe32 )); + ret--;/* we process NDP entries except for the last one */ + +if ((sizeof (struct usb_cdc_ncm_ndp32 ) + + ret * (sizeof (struct usb_cdc_ncm_dpe32 ))) > skb_in->len) { +netif_dbg (dev, rx_err, dev->net,"Invalid nframes = %d\n" , ret); + ret = -EINVAL ; + } + +error: +return ret; +} +EXPORT_SYMBOL_GPL (cdc_ncm_rx_verify_ndp32); +int cdc_ncm_rx_fixup (struct usbnet *dev,struct sk_buff *skb_in) {struct sk_buff *skb;
@@ -1510,34 +1706,66 @@ int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)int nframes;int x;int offset; -struct usb_cdc_ncm_ndp16 *ndp16; -struct usb_cdc_ncm_dpe16 *dpe16; +union { +struct usb_cdc_ncm_ndp16 *ndp16; +struct usb_cdc_ncm_ndp32 *ndp32; + } ndp; +union { +struct usb_cdc_ncm_dpe16 *dpe16; +struct usb_cdc_ncm_dpe32 *dpe32; + } dpe; +int ndpoffset;int loopcount =50 ;/* arbitrary max preventing infinite loop */ u32 payload =0 ; - ndpoffset =cdc_ncm_rx_verify_nth16 (ctx, skb_in); +if (ctx->is_ndp16) + ndpoffset =cdc_ncm_rx_verify_nth16 (ctx, skb_in); +else + ndpoffset =cdc_ncm_rx_verify_nth32 (ctx, skb_in); +if (ndpoffset <0 ) goto error; next_ndp: - nframes =cdc_ncm_rx_verify_ndp16 (skb_in, ndpoffset); -if (nframes <0 ) - goto error; +if (ctx->is_ndp16) { + nframes =cdc_ncm_rx_verify_ndp16 (skb_in, ndpoffset); +if (nframes <0 ) + goto error; - ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb_in->data + ndpoffset); + ndp.ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb_in->data + ndpoffset); -if (ndp16->dwSignature !=cpu_to_le32 (USB_CDC_NCM_NDP16_NOCRC_SIGN )) { -netif_dbg (dev, rx_err, dev->net, -"invalid DPT16 signature <%#010x>\n" , -le32_to_cpu (ndp16->dwSignature)); - goto err_ndp; +if (ndp.ndp16->dwSignature !=cpu_to_le32 (USB_CDC_NCM_NDP16_NOCRC_SIGN )) { +netif_dbg (dev, rx_err, dev->net, +"invalid DPT16 signature <%#010x>\n" , +le32_to_cpu (ndp.ndp16->dwSignature)); + goto err_ndp; + } + dpe.dpe16 = ndp.ndp16->dpe16; + }else { + nframes =cdc_ncm_rx_verify_ndp32 (skb_in, ndpoffset); +if (nframes <0 ) + goto error; + + ndp.ndp32 = (struct usb_cdc_ncm_ndp32 *)(skb_in->data + ndpoffset); + +if (ndp.ndp32->dwSignature !=cpu_to_le32 (USB_CDC_NCM_NDP32_NOCRC_SIGN )) { +netif_dbg (dev, rx_err, dev->net, +"invalid DPT32 signature <%#010x>\n" , +le32_to_cpu (ndp.ndp32->dwSignature)); + goto err_ndp; + } + dpe.dpe32 = ndp.ndp32->dpe32; } - dpe16 = ndp16->dpe16; -for (x =0 ; x < nframes; x++, dpe16++) { - offset =le16_to_cpu (dpe16->wDatagramIndex); - len =le16_to_cpu (dpe16->wDatagramLength); +for (x =0 ; x < nframes; x++) { +if (ctx->is_ndp16) { + offset =le16_to_cpu (dpe.dpe16->wDatagramIndex); + len =le16_to_cpu (dpe.dpe16->wDatagramLength); + }else { + offset =le32_to_cpu (dpe.dpe32->dwDatagramIndex); + len =le32_to_cpu (dpe.dpe32->dwDatagramLength); + }/* * CDC NCM ch. 3.7
@@ -1568,10 +1796,19 @@ int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)usbnet_skb_return (dev, skb); payload += len;/* count payload bytes in this NTB */ } + +if (ctx->is_ndp16) + dpe.dpe16++; +else + dpe.dpe32++; } err_ndp:/* are there more NDPs to process? */ - ndpoffset =le16_to_cpu (ndp16->wNextNdpIndex); +if (ctx->is_ndp16) + ndpoffset =le16_to_cpu (ndp.ndp16->wNextNdpIndex); +else + ndpoffset =le32_to_cpu (ndp.ndp32->dwNextNdpIndex); +if (ndpoffset && loopcount--) goto next_ndp;
drivers/net/usb/huawei_cdc_ncm.c +4 -4
@@ -81,11 +81,11 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,*/ drvflags |=CDC_NCM_FLAG_NDP_TO_END ; -/* Additionally, it has been reported that some Huawei E3372H devices, with -* firmware version 21.318.01.00.541, come out of reset in NTB32 format mode, hence -* needing to be set to the NTB16 one again. +/* For many Huawei devices the NTB32 mode is the default and the best mode +* they work with. Huawei E5785 and E5885 devices refuse to work in NTB16 mode at all. */ - drvflags |=CDC_NCM_FLAG_RESET_NTB16 ; + drvflags |=CDC_NCM_FLAG_PREFER_NTB32 ; + ret =cdc_ncm_bind_common (usbnet_dev, intf,1 , drvflags);if (ret) goto err;
include/linux/usb/cdc_ncm.h +12 -3
@@ -46,9 +46,12 @@#define CDC_NCM_DATA_ALTSETTING_NCM 1#define CDC_NCM_DATA_ALTSETTING_MBIM 2 -/* CDC NCM subclass 3.2.1 */ +/* CDC NCM subclass 3.3.1 */ #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 +/* CDC NCM subclass 3.3.2 */ +#define USB_CDC_NCM_NDP32_LENGTH_MIN 0x20 +/* Maximum NTB length */ #define CDC_NCM_NTB_MAX_SIZE_TX 32768/* bytes */ #define CDC_NCM_NTB_MAX_SIZE_RX 32768/* bytes */
@@ -84,7 +87,7 @@/* Driver flags */ #define CDC_NCM_FLAG_NDP_TO_END 0x02/* NDP is placed at end of frame */ #define CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE 0x04/* Avoid altsetting toggle during init */ -#define CDC_NCM_FLAG_RESET_NTB16 0x08/* set NDP16 one more time after altsetting switch */ +#define CDC_NCM_FLAG_PREFER_NTB32 0x08/* prefer NDP32 over NDP16 */ #define cdc_ncm_comm_intf_is_mbim (x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \ (x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE)
@@ -113,7 +116,11 @@ struct cdc_ncm_ctx {u32 timer_interval;u32 max_ndp_size; -struct usb_cdc_ncm_ndp16 *delayed_ndp16; +u8 is_ndp16; +union { +struct usb_cdc_ncm_ndp16 *delayed_ndp16; +struct usb_cdc_ncm_ndp32 *delayed_ndp32; + };u32 tx_timer_pending;u32 tx_curr_frame_num;
@@ -150,6 +157,8 @@ void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf);struct sk_buff *cdc_ncm_fill_tx_frame (struct usbnet *dev,struct sk_buff *skb,__le32 sign);int cdc_ncm_rx_verify_nth16 (struct cdc_ncm_ctx *ctx,struct sk_buff *skb_in);int cdc_ncm_rx_verify_ndp16 (struct sk_buff *skb_in,int ndpoffset); +int cdc_ncm_rx_verify_nth32 (struct cdc_ncm_ctx *ctx,struct sk_buff *skb_in); +int cdc_ncm_rx_verify_ndp32 (struct sk_buff *skb_in,int ndpoffset);struct sk_buff *cdc_ncm_tx_fixup (struct usbnet *dev,struct sk_buff *skb,gfp_t flags);int cdc_ncm_rx_fixup (struct usbnet *dev,struct sk_buff *skb_in);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 2/88 net: cdc_ncm: Deal with too low values of dwNtbOutMaxSize
In reply to Greg Kroah-HartmanFrom: Tudor Ambarus <[email protected]>
[ Upstream commit 7e01c7f7046efc2c7c192c3619db43292b98e997 ]
Currently in cdc_ncm_check_tx_max(), if dwNtbOutMaxSize is lower than the calculated "min" value, but greater than zero, the logic sets tx_max to dwNtbOutMaxSize. This is then used to allocate a new SKB in cdc_ncm_fill_tx_frame() where all the data is handled.
For small values of dwNtbOutMaxSize the memory allocated during alloc_skb(dwNtbOutMaxSize, GFP_ATOMIC) will have the same size, due to how size is aligned at alloc time:
size = SKB_DATA_ALIGN(size);
size += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));Thus we hit the same bug that we tried to squash with
commit 2be6d4d16a084 ("net: cdc_ncm: Allow for dwNtbOutMaxSize to be unset or zero")
Low values of dwNtbOutMaxSize do not cause an issue presently because at alloc_skb() time more memory (512b) is allocated than required for the SKB headers alone (320b), leaving some space (512b - 320b = 192b) for CDC data (172b).
However, if more elements (for example 3 x u64 = [24b]) were added to one of the SKB header structs, say 'struct skb_shared_info', increasing its original size (320b [320b aligned]) to something larger (344b [384b aligned]), then suddenly the CDC data (172b) no longer fits in the spare SKB data area (512b - 384b = 128b).
Consequently the SKB bounds checking semantics fails and panics:
skbuff: skb_over_panic: text:ffffffff831f755b len:184 put:172 head:ffff88811f1c6c00 data:ffff88811f1c6c00 tail:0xb8 end:0x80 dev:<NULL>
------------[ cut here ]------------ kernel BUG at net/core/skbuff.c:113! invalid opcode: 0000 [#1] PREEMPT SMP KASAN CPU: 0 PID: 57 Comm: kworker/0:2 Not tainted 5.15.106-syzkaller-00249-g19c0ed55a470 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023 Workqueue: mld mld_ifc_work RIP: 0010:skb_panic net/core/skbuff.c:113 [inline] RIP: 0010:skb_over_panic+0x14c/0x150 net/core/skbuff.c:118 [snip] Call Trace: <TASK> skb_put+0x151/0x210 net/core/skbuff.c:2047 skb_put_zero include/linux/skbuff.h:2422 [inline] cdc_ncm_ndp16 drivers/net/usb/cdc_ncm.c:1131 [inline] cdc_ncm_fill_tx_frame+0x11ab/0x3da0 drivers/net/usb/cdc_ncm.c:1308 cdc_ncm_tx_fixup+0xa3/0x100
Deal with too low values of dwNtbOutMaxSize, clamp it in the range [USB_CDC_NCM_NTB_MIN_OUT_SIZE, CDC_NCM_NTB_MAX_SIZE_TX]. We ensure enough data space is allocated to handle CDC data by making sure dwNtbOutMaxSize is not smaller than USB_CDC_NCM_NTB_MIN_OUT_SIZE.
--- drivers/net/usb/cdc_ncm.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/net/usb/cdc_ncm.c +15 -9
@@ -180,9 +180,12 @@ static u32 cdc_ncm_check_tx_max(struct usbnet *dev, u32 new_tx)else min = ctx->max_datagram_size + ctx->max_ndp_size +sizeof (struct usb_cdc_ncm_nth32 ); - max =min_t (u32,CDC_NCM_NTB_MAX_SIZE_TX ,le32_to_cpu (ctx->ncm_parm.dwNtbOutMaxSize)); -if (max ==0 ) +if (le32_to_cpu (ctx->ncm_parm.dwNtbOutMaxSize) ==0 ) max =CDC_NCM_NTB_MAX_SIZE_TX ;/* dwNtbOutMaxSize not set */ +else + max =clamp_t (u32,le32_to_cpu (ctx->ncm_parm.dwNtbOutMaxSize), +USB_CDC_NCM_NTB_MIN_OUT_SIZE , +CDC_NCM_NTB_MAX_SIZE_TX );/* some devices set dwNtbOutMaxSize too low for the above default */ min =min (min, max);
@@ -1230,6 +1233,9 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)* further. */ if (skb_out ==NULL ) { +/* If even the smallest allocation fails, abort. */ +if (ctx->tx_curr_size ==USB_CDC_NCM_NTB_MIN_OUT_SIZE ) + goto alloc_failed; ctx->tx_low_mem_max_cnt =min (ctx->tx_low_mem_max_cnt +1 , (unsigned )CDC_NCM_LOW_MEM_MAX_CNT ); ctx->tx_low_mem_val = ctx->tx_low_mem_max_cnt;
@@ -1248,13 +1254,8 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign) skb_out =alloc_skb (ctx->tx_curr_size,GFP_ATOMIC );/* No allocation possible so we will abort */ -if (skb_out ==NULL ) { -if (skb !=NULL ) { -dev_kfree_skb_any (skb); - dev->net->stats.tx_dropped++; - } - goto exit_no_skb; - } +if (!skb_out) + goto alloc_failed; ctx->tx_low_mem_val--; }if (ctx->is_ndp16) {
@@ -1447,6 +1448,11 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)return skb_out; +alloc_failed: +if (skb) { +dev_kfree_skb_any (skb); + dev->net->stats.tx_dropped++; + } exit_no_skb:/* Start timer, if there is a remaining non-empty skb */ if (ctx->tx_curr_skb !=NULL && n >0 )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 3/88 power: supply: bq27xxx: After charger plug in/out wait 0.5s for things to stabilize
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 59a99cd462fbdf71f4e845e09f37783035088b4f ]
bq27xxx_external_power_changed() gets called when the charger is plugged in or out. Rather then immediately scheduling an update wait 0.5 seconds for things to stabilize, so that e.g. the (dis)charge current is stable when bq27xxx_battery_update() runs.
--- drivers/power/supply/bq27xxx_battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/bq27xxx_battery.c +2 -2
@@ -1864,8 +1864,8 @@ static void bq27xxx_external_power_changed(struct power_supply *psy) {struct bq27xxx_device_info *di =power_supply_get_drvdata (psy); -cancel_delayed_work_sync (&di->work); -schedule_delayed_work (&di->work,0 ); +/* After charger plug in/out wait 0.5s for things to stabilize */ +mod_delayed_work (system_wq, &di->work,HZ /2 ); }int bq27xxx_battery_setup (struct bq27xxx_device_info *di)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 4/88 power: supply: core: Refactor power_supply_set_input_current_limit_from_supplier()
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 2220af8ca61ae67de4ec3deec1c6395a2f65b9fd ]
Some (USB) charger ICs have variants with USB D+ and D- pins to do their own builtin charger-type detection, like e.g. the bq24190 and bq25890 and also variants which lack this functionality, e.g. the bq24192 and bq25892.
In case the charger-type; and thus the input-current-limit detection is done outside the charger IC then we need some way to communicate this to the charger IC. In the past extcon was used for this, but if the external detection does e.g. full USB PD negotiation then the extcon cable-types do not convey enough information.
For these setups it was decided to model the external charging "brick" and the parameters negotiated with it as a power_supply class-device itself; and power_supply_set_input_current_limit_from_supplier() was introduced to allow drivers to get the input-current-limit this way.
But in some cases psy drivers may want to know other properties, e.g. the bq25892 can do "quick-charge" negotiation by pulsing its current draw, but this should only be done if the usb_type psy-property of its supplier is set to DCP (and device-properties indicate the board allows higher voltages).
Instead of adding extra helper functions for each property which a psy-driver wants to query from its supplier, refactor power_supply_set_input_current_limit_from_supplier() into a more generic power_supply_get_property_from_supplier() function.
Stable-dep-of: 77c2a3097d70 ("power: supply: bq24190: Call power_supply_changed() after updating input current")
--- drivers/power/supply/bq24190_charger.c | 12 ++++- drivers/power/supply/power_supply_core.c | 57 +++++++++++++----------- include/linux/power_supply.h | 5 ++- 3 files changed, 44 insertions(+), 30 deletions(-)
drivers/power/supply/bq24190_charger.c +11 -1
@@ -1228,8 +1228,18 @@ static void bq24190_input_current_limit_work(struct work_struct *work)struct bq24190_dev_info *bdi = container_of(work, struct bq24190_dev_info, input_current_limit_work.work); +union power_supply_propval val; +int ret; + + ret =power_supply_get_property_from_supplier (bdi->charger, +POWER_SUPPLY_PROP_CURRENT_MAX , + &val); +if (ret) +return ; -power_supply_set_input_current_limit_from_supplier (bdi->charger); +bq24190_charger_set_property (bdi->charger, +POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT , + &val); }/* Sync the input-current-limit with our parent supply (if we have one) */
drivers/power/supply/power_supply_core.c +30 -27
76 lines not on this page · raw message
include/linux/power_supply.h +3 -2
@@ -351,8 +351,9 @@ extern int power_supply_get_battery_info(struct power_supply *psy, struct power_supply_battery_info *info);extern void power_supply_changed (struct power_supply *psy);extern int power_supply_am_i_supplied (struct power_supply *psy); -extern int power_supply_set_input_current_limit_from_supplier ( -struct power_supply *psy); +int power_supply_get_property_from_supplier (struct power_supply *psy, +enum power_supply_property psp, +union power_supply_propval *val);extern int power_supply_set_battery_charged (struct power_supply *psy);#ifdef CONFIG_POWER_SUPPLY
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 5/88 power: supply: bq24190: Call power_supply_changed() after updating input current
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 77c2a3097d7029441e8a91aa0de1b4e5464593da ]
The bq24192 model relies on external charger-type detection and once that is done the bq24190_charger code will update the input current.
In this case, when the initial power_supply_changed() call is made from the interrupt handler, the input settings are 5V/0.5A which on many devices is not enough power to charge (while the device is on).
On many devices the fuel-gauge relies in its external_power_changed callback to timely signal userspace about charging <-> discharging status changes. Add a power_supply_changed() call after updating the input current. This allows the fuel-gauge driver to timely recheck if the battery is charging after the new input current has been applied and then it can immediately notify userspace about this.
--- drivers/power/supply/bq24190_charger.c | 1 + 1 file changed, 1 insertion(+)
drivers/power/supply/bq24190_charger.c +1 -0
@@ -1240,6 +1240,7 @@ static void bq24190_input_current_limit_work(struct work_struct *work)bq24190_charger_set_property (bdi->charger,POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT , &val); +power_supply_changed (bdi->charger); }/* Sync the input-current-limit with our parent supply (if we have one) */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 6/88 cdc_ncm: Fix the build warning
In reply to Greg Kroah-HartmanFrom: Alexander Bersenev <[email protected]>
[ Upstream commit 5d0ab06b63fc9c727a7bb72c81321c0114be540b ]
The ndp32->wLength is two bytes long, so replace cpu_to_le32 with cpu_to_le16.
--- drivers/net/usb/cdc_ncm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/cdc_ncm.c +1 -1
@@ -1178,7 +1178,7 @@ static struct usb_cdc_ncm_ndp32 *cdc_ncm_ndp32(struct cdc_ncm_ctx *ctx, struct s ndp32 = ctx->delayed_ndp32; ndp32->dwSignature = sign; - ndp32->wLength =cpu_to_le32 (sizeof (struct usb_cdc_ncm_ndp32 ) +sizeof (struct usb_cdc_ncm_dpe32 )); + ndp32->wLength =cpu_to_le16 (sizeof (struct usb_cdc_ncm_ndp32 ) +sizeof (struct usb_cdc_ncm_dpe32 ));return ndp32; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 7/88 bluetooth: Add cmd validity checks at the start of hci_sock_ioctl()
In reply to Greg Kroah-HartmanFrom: Ruihan Li <[email protected]>
commit 000c2fa2c144c499c881a101819cf1936a1f7cf2 upstream.
Previously, channel open messages were always sent to monitors on the first ioctl() call for unbound HCI sockets, even if the command and arguments were completely invalid. This can leave an exploitable hole with the abuse of invalid ioctl calls.
This commit hardens the ioctl processing logic by first checking if the command is valid, and immediately returning with an ENOIOCTLCMD error code if it is not. This ensures that ioctl calls with invalid commands are free of side effects, and increases the difficulty of further exploitation by forcing exploitation to find a way to pass a valid command first.
--- net/bluetooth/hci_sock.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
net/bluetooth/hci_sock.c +28 -0
@@ -973,6 +973,34 @@ static int hci_sock_ioctl(struct socketBT_DBG ("cmd %x arg %lx" , cmd, arg); +/* Make sure the cmd is valid before doing anything */ +switch (cmd) { +case HCIGETDEVLIST : +case HCIGETDEVINFO : +case HCIGETCONNLIST : +case HCIDEVUP : +case HCIDEVDOWN : +case HCIDEVRESET : +case HCIDEVRESTAT : +case HCISETSCAN : +case HCISETAUTH : +case HCISETENCRYPT : +case HCISETPTYPE : +case HCISETLINKPOL : +case HCISETLINKMODE : +case HCISETACLMTU : +case HCISETSCOMTU : +case HCIINQUIRY : +case HCISETRAW : +case HCIGETCONNINFO : +case HCIGETAUTHINFO : +case HCIBLOCKADDR : +case HCIUNBLOCKADDR : +break ; +default : +return -ENOIOCTLCMD ; + } +lock_sock (sk);if (hci_pi (sk)->channel !=HCI_CHANNEL_RAW ) {
Greg Kroah-Hartman
maintainerPATCH 8/88 ipv{4,6}/raw: fix output xfrm lookup wrt protocol
In reply to Greg Kroah-HartmanFrom: Nicolas Dichtel <[email protected]>
commit 3632679d9e4f879f49949bb5b050e0de553e4739 upstream.
With a raw socket bound to IPPROTO_RAW (ie with hdrincl enabled), the protocol field of the flow structure, build by raw_sendmsg() / rawv6_sendmsg()), is set to IPPROTO_RAW. This breaks the ipsec policy lookup when some policies are defined with a protocol in the selector.
For ipv6, the sin6_port field from 'struct sockaddr_in6' could be used to specify the protocol. Just accept all values for IPPROTO_RAW socket.
For ipv4, the sin_port field of 'struct sockaddr_in' could not be used without breaking backward compatibility (the value of this field was never checked). Let's add a new kind of control message, so that the userland could specify which protocol is used.
--- include/net/ip.h | 2 ++ include/uapi/linux/in.h | 2 ++ net/ipv4/ip_sockglue.c | 12 +++++++++++- net/ipv4/raw.c | 5 ++++- net/ipv6/raw.c | 3 ++- 5 files changed, 21 insertions(+), 3 deletions(-)
include/net/ip.h +2 -0
@@ -73,6 +73,7 @@ struct ipcm_cookie {__be32 addr;int oif;struct ip_options_rcu *opt; +__u8 protocol;__u8 ttl;__s16 tos;char priority;
@@ -92,6 +93,7 @@ static inline void ipcm_init_sk(struct i ipcm->sockc.tsflags = inet->sk.sk_tsflags; ipcm->oif = inet->sk.sk_bound_dev_if; ipcm->addr = inet->inet_saddr; + ipcm->protocol = inet->inet_num; }#define IPCB (skb) ((struct inet_skb_parm*)((skb)->cb))
include/uapi/linux/in.h +2 -0
@@ -154,6 +154,8 @@ struct in_addr {#define MCAST_MSFILTER 48#define IP_MULTICAST_ALL 49#define IP_UNICAST_IF 50 +#define IP_LOCAL_PORT_RANGE 51 +#define IP_PROTOCOL 52#define MCAST_EXCLUDE 0#define MCAST_INCLUDE 1
net/ipv4/ip_sockglue.c +11 -1
@@ -316,7 +316,14 @@ int ip_cmsg_send(struct sock *sk, struct ipc->tos = val; ipc->priority =rt_tos2priority (ipc->tos);break ; - +case IP_PROTOCOL : +if (cmsg->cmsg_len !=CMSG_LEN (sizeof (int ))) +return -EINVAL ; + val = *(int *)CMSG_DATA (cmsg); +if (val <1 || val >255 ) +return -EINVAL ; + ipc->protocol = val; +break ;default :return -EINVAL ; }
@@ -1522,6 +1529,9 @@ static int do_ip_getsockopt(struct sockcase IP_MINTTL : val = inet->min_ttl;break ; +case IP_PROTOCOL : + val =inet_sk (sk)->inet_num; +break ;default :release_sock (sk);return -ENOPROTOOPT ;
net/ipv4/raw.c +4 -1
@@ -563,6 +563,9 @@ static int raw_sendmsg(struct sock *sk, }ipcm_init_sk (&ipc, inet); +/* Keep backward compat */ +if (hdrincl) + ipc.protocol =IPPROTO_RAW ;if (msg->msg_controllen) { err =ip_cmsg_send (sk, msg, &ipc, false);
@@ -630,7 +633,7 @@ static int raw_sendmsg(struct sock *sk,flowi4_init_output (&fl4, ipc.oif, sk->sk_mark, tos,RT_SCOPE_UNIVERSE , - hdrincl ?IPPROTO_RAW : sk->sk_protocol, + hdrincl ? ipc.protocol : sk->sk_protocol,inet_sk_flowi_flags (sk) | (hdrincl ?FLOWI_FLAG_KNOWN_NH :0 ), daddr, saddr,0 ,0 , sk->sk_uid);
net/ipv6/raw.c +2 -1
@@ -832,7 +832,8 @@ static int rawv6_sendmsg(struct sock *skif (!proto) proto = inet->inet_num; -else if (proto != inet->inet_num) +else if (proto != inet->inet_num && + inet->inet_num !=IPPROTO_RAW )return -EINVAL ;if (proto >255 )
Greg Kroah-Hartman
maintainerPATCH 9/88 netfilter: ctnetlink: Support offloaded conntrack entry deletion
In reply to Greg Kroah-HartmanFrom: Paul Blakey <[email protected]>
commit 9b7c68b3911aef84afa4cbfc31bce20f10570d51 upstream.
Currently, offloaded conntrack entries (flows) can only be deleted after they are removed from offload, which is either by timeout, tcp state change or tc ct rule deletion. This can cause issues for users wishing to manually delete or flush existing entries.
Support deletion of offloaded conntrack entries.
Example usage:
# Delete all offloaded (and non offloaded) conntrack entries
# whose source address is 1.2.3.4 $ conntrack -D -s 1.2.3.4 # Delete all entries $ conntrack -F
--- net/netfilter/nf_conntrack_netlink.c | 8 -------- 1 file changed, 8 deletions(-)
net/netfilter/nf_conntrack_netlink.c +0 -8
@@ -1216,9 +1216,6 @@ static const struct nla_policy ct_nla_postatic int ctnetlink_flush_iterate (struct nf_conn *ct,void *data) { -if (test_bit (IPS_OFFLOAD_BIT , &ct->status)) -return 0 ; -return ctnetlink_filter_match (ct, data); }
@@ -1280,11 +1277,6 @@ static int ctnetlink_del_conntrack(struc ct =nf_ct_tuplehash_to_ctrack (h); -if (test_bit (IPS_OFFLOAD_BIT , &ct->status)) { -nf_ct_put (ct); -return -EBUSY ; - } -if (cda[CTA_ID ]) {__be32 id =nla_get_be32 (cda[CTA_ID ]);
Greg Kroah-Hartman
maintainerPATCH 10/88 dmaengine: pl330: rename _start to prevent build error
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit a1a5f2c887252dec161c1e12e04303ca9ba56fa9 ]
"_start" is used in several arches and proably should be reserved for ARCH usage. Using it in a driver for a private symbol can cause a build error when it conflicts with ARCH usage of the same symbol.
Therefore rename pl330's "_start" to "pl330_start_thread" so that there is no conflict and no build error.
drivers/dma/pl330.c:1053:13: error: '_start' redeclared as different kind of symbol
1053 | static bool _start(struct pl330_thread *thrd)
| ^~~~~~
In file included from ../include/linux/interrupt.h:21,
from ../drivers/dma/pl330.c:18:
arch/riscv/include/asm/sections.h:11:13: note: previous declaration of '_start' with type 'char[]'
11 | extern char _start[];
| ^~~~~~--- drivers/dma/pl330.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/dma/pl330.c +4 -4
@@ -1042,7 +1042,7 @@ static bool _trigger(struct pl330_thread *thrd)return true; } -static bool _start (struct pl330_thread *thrd) +static bool pl330_start_thread (struct pl330_thread *thrd) {switch (_state (thrd)) {case PL330_STATE_FAULT_COMPLETING :
@@ -1690,7 +1690,7 @@ static int pl330_update(struct pl330_dmac *pl330) thrd->req_running =-1 ;/* Get going again ASAP */ -_start (thrd); +pl330_start_thread (thrd);/* For now, just make a list of callbacks to be done */ list_add_tail (&descdone->rqd, &pl330->req_done);
@@ -2076,7 +2076,7 @@ static void pl330_tasklet(unsigned long data) }else {/* Make sure the PL330 Channel thread is active */ spin_lock (&pch->thread->dmac->lock); -_start (pch->thread); +pl330_start_thread (pch->thread);spin_unlock (&pch->thread->dmac->lock); }
@@ -2094,7 +2094,7 @@ static void pl330_tasklet(unsigned long data)if (power_down) { pch->active = true;spin_lock (&pch->thread->dmac->lock); -_start (pch->thread); +pl330_start_thread (pch->thread);spin_unlock (&pch->thread->dmac->lock); power_down = false; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 11/88 net/mlx5: fw_tracer, Fix event handling
In reply to Greg Kroah-HartmanFrom: Shay Drory <[email protected]>
[ Upstream commit 341a80de2468f481b1f771683709b5649cbfe513 ]
mlx5 driver needs to parse traces with event_id inside the range of first_string_trace and num_string_trace. However, mlx5 is parsing all events with event_id >= first_string_trace.
Fix it by checking for the correct range.
--- drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c +1 -1
@@ -466,7 +466,7 @@ static void poll_trace(struct mlx5_fw_tracer *tracer, (u64 )timestamp_low;break ;default : -if (tracer_event->event_id >= tracer->str_db.first_string_trace || +if (tracer_event->event_id >= tracer->str_db.first_string_trace && tracer_event->event_id <= tracer->str_db.first_string_trace + tracer->str_db.num_string_trace) { tracer_event->type =TRACER_EVENT_TYPE_STRING ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 12/88 netrom: fix info-leak in nr_write_internal()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 31642e7089df8fd3f54ca7843f7ee2952978cad1 ]
Simon Kapadia reported the following issue:
<quote>
The Online Amateur Radio Community (OARC) has recently been experimenting with building a nationwide packet network in the UK.
As part of our experimentation, we have been testing out packet on 300bps HF, and playing with net/rom. For HF packet at this baud rate you really need to make sure that your MTU is relatively low; AX.25 suggests a PACLEN of 60, and a net/rom PACLEN of 40 to go with that.
However the Linux net/rom support didn't work with a low PACLEN;
the mkiss module would truncate packets if you set the PACLEN below about 200 or so, e.g.:
Apr 19 14:00:51 radio kernel: [12985.747310] mkiss: ax1: truncating oversized transmit packet!
This didn't make any sense to me (if the packets are smaller why would they be truncated?) so I started investigating.
I looked at the packets using ethereal, and found that many were just huge compared to what I would expect.
A simple net/rom connection request packet had the request and then a bunch of what appeared to be random data following it:
</quote>
Simon provided a patch that I slightly revised:
Not only we must not use skb_tailroom(), we also do not want to count NR_NETWORK_LEN twice.
--- net/netrom/nr_subr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/netrom/nr_subr.c +4 -3
@@ -126,7 +126,7 @@ void nr_write_internal(struct sock *sk, int frametype)unsigned char *dptr;int len, timeout; - len =NR_NETWORK_LEN +NR_TRANSPORT_LEN ; + len =NR_TRANSPORT_LEN ;switch (frametype &0x0F ) {case NR_CONNREQ :
@@ -144,7 +144,8 @@ void nr_write_internal(struct sock *sk, int frametype)return ; } -if ((skb =alloc_skb (len,GFP_ATOMIC )) ==NULL ) + skb =alloc_skb (NR_NETWORK_LEN + len,GFP_ATOMIC ); +if (!skb)return ;/*
@@ -152,7 +153,7 @@ void nr_write_internal(struct sock *sk, int frametype)*/ skb_reserve (skb,NR_NETWORK_LEN ); - dptr =skb_put (skb,skb_tailroom (skb)); + dptr =skb_put (skb, len);switch (frametype &0x0F ) {case NR_CONNREQ :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 13/88 af_packet: Fix data-races of pkt_sk(sk)->num.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 822b5a1c17df7e338b9f05d1cfe5764e37c7f74f ]
syzkaller found a data race of pkt_sk(sk)->num.
The value is changed under lock_sock() and po->bind_lock, so we need READ_ONCE() to access pkt_sk(sk)->num without these locks in packet_bind_spkt(), packet_bind(), and sk_diag_fill().
Note that WRITE_ONCE() is already added by commit c7d2ef5dd4b0 ("net/packet: annotate accesses to po->bind").
BUG: KCSAN: data-race in packet_bind / packet_do_bind
write (marked) to 0xffff88802ffd1cee of 2 bytes by task 7322 on cpu 0:
packet_do_bind+0x446/0x640 net/packet/af_packet.c:3236 packet_bind+0x99/0xe0 net/packet/af_packet.c:3321 __sys_bind+0x19b/0x1e0 net/socket.c:1803 __do_sys_bind net/socket.c:1814 [inline] __se_sys_bind net/socket.c:1812 [inline] __x64_sys_bind+0x40/0x50 net/socket.c:1812 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x72/0xdc
read to 0xffff88802ffd1cee of 2 bytes by task 7318 on cpu 1:
packet_bind+0xbf/0xe0 net/packet/af_packet.c:3322 __sys_bind+0x19b/0x1e0 net/socket.c:1803 __do_sys_bind net/socket.c:1814 [inline] __se_sys_bind net/socket.c:1812 [inline] __x64_sys_bind+0x40/0x50 net/socket.c:1812 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x72/0xdc
value changed: 0x0300 -> 0x0000
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 7318 Comm: syz-executor.4 Not tainted 6.3.0-13380-g7fddb5b5300c #4 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
--- net/packet/af_packet.c | 4 ++-- net/packet/diag.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
net/packet/af_packet.c +2 -2
@@ -3219,7 +3219,7 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr,memcpy (name, uaddr->sa_data,sizeof (uaddr->sa_data)); name[sizeof (uaddr->sa_data)] =0 ; -return packet_do_bind (sk, name,0 ,pkt_sk (sk)->num); +return packet_do_bind (sk, name,0 ,READ_ONCE (pkt_sk (sk)->num)); }static int packet_bind (struct socket *sock,struct sockaddr *uaddr,int addr_len)
@@ -3237,7 +3237,7 @@ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_lenreturn -EINVAL ;return packet_do_bind (sk,NULL , sll->sll_ifindex, - sll->sll_protocol ? :pkt_sk (sk)->num); + sll->sll_protocol ? :READ_ONCE (pkt_sk (sk)->num)); }static struct proto packet_proto = {
net/packet/diag.c +1 -1
@@ -142,7 +142,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, rp =nlmsg_data (nlh); rp->pdiag_family =AF_PACKET ; rp->pdiag_type = sk->sk_type; - rp->pdiag_num =ntohs (po->num); + rp->pdiag_num =ntohs (READ_ONCE (po->num)); rp->pdiag_ino = sk_ino;sock_diag_save_cookie (sk, rp->pdiag_cookie);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 14/88 amd-xgbe: fix the false linkup in xgbe_phy_status
In reply to Greg Kroah-HartmanFrom: Raju Rangoju <[email protected]>
[ Upstream commit dc362e20cd6ab7a93d1b09669730c406f0910c35 ]
In the event of a change in XGBE mode, the current auto-negotiation needs to be reset and the AN cycle needs to be re-triggerred. However, the current code ignores the return value of xgbe_set_mode(), leading to false information as the link is declared without checking the status register.
Fix this by propagating the mode switch status information to xgbe_phy_status().
--- drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +9 -3
@@ -1312,7 +1312,7 @@ static enum xgbe_mode xgbe_phy_status_aneg(struct xgbe_prv_data *pdata)return pdata->phy_if.phy_impl.an_outcome (pdata); } -static void xgbe_phy_status_result (struct xgbe_prv_data *pdata) +static bool xgbe_phy_status_result (struct xgbe_prv_data *pdata) {struct ethtool_link_ksettings *lks = &pdata->phy.lks;enum xgbe_mode mode;
@@ -1347,8 +1347,13 @@ static void xgbe_phy_status_result(struct xgbe_prv_data *pdata) pdata->phy.duplex =DUPLEX_FULL ; -if (xgbe_set_mode (pdata, mode) && pdata->an_again) +if (!xgbe_set_mode (pdata, mode)) +return false; + +if (pdata->an_again)xgbe_phy_reconfig_aneg (pdata); + +return true; }static void xgbe_phy_status (struct xgbe_prv_data *pdata)
@@ -1378,7 +1383,8 @@ static void xgbe_phy_status(struct xgbe_prv_data *pdata)return ; } -xgbe_phy_status_result (pdata); +if (xgbe_phy_status_result (pdata)) +return ;if (test_bit (XGBE_LINK_INIT , &pdata->dev_state))clear_bit (XGBE_LINK_INIT , &pdata->dev_state);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 15/88 af_packet: do not use READ_ONCE() in packet_bind()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 6ffc57ea004234d9373c57b204fd10370a69f392 ]
A recent patch added READ_ONCE() in packet_bind() and packet_bind_spkt()
This is better handled by reading pkt_sk(sk)->num later in packet_do_bind() while appropriate lock is held.
READ_ONCE() in writers are often an evidence of something being wrong.
--- net/packet/af_packet.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/packet/af_packet.c +5 -3
@@ -3117,6 +3117,9 @@ static int packet_do_bind(struct sock *sk, const char *name, int ifindex,lock_sock (sk);spin_lock (&po->bind_lock); +if (!proto) + proto = po->num; +rcu_read_lock ();if (po->fanout) {
@@ -3219,7 +3222,7 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr,memcpy (name, uaddr->sa_data,sizeof (uaddr->sa_data)); name[sizeof (uaddr->sa_data)] =0 ; -return packet_do_bind (sk, name,0 ,READ_ONCE (pkt_sk (sk)->num)); +return packet_do_bind (sk, name,0 ,0 ); }static int packet_bind (struct socket *sock,struct sockaddr *uaddr,int addr_len)
@@ -3236,8 +3239,7 @@ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_lenif (sll->sll_family !=AF_PACKET )return -EINVAL ; -return packet_do_bind (sk,NULL , sll->sll_ifindex, - sll->sll_protocol ? :READ_ONCE (pkt_sk (sk)->num)); +return packet_do_bind (sk,NULL , sll->sll_ifindex, sll->sll_protocol); }static struct proto packet_proto = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 16/88 tcp: deny tcp_disconnect() when threads are waiting
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 4faeee0cf8a5d88d63cdbc3bab124fb0e6aed08c ]
Historically connect(AF_UNSPEC) has been abused by syzkaller and other fuzzers to trigger various bugs.
A recent one triggers a divide-by-zero [1], and Paolo Abeni was able to diagnose the issue.
tcp_recvmsg_locked() has tests about sk_state being not TCP_LISTEN and TCP REPAIR mode being not used.
Then later if socket lock is released in sk_wait_data(), another thread can call connect(AF_UNSPEC), then make this socket a TCP listener.
When recvmsg() is resumed, it can eventually call tcp_cleanup_rbuf() and attempt a divide by 0 in tcp_rcv_space_adjust() [1]
This patch adds a new socket field, counting number of threads blocked in sk_wait_event() and inet_wait_for_connect().
If this counter is not zero, tcp_disconnect() returns an error.
This patch adds code in blocking socket system calls, thus should not hurt performance of non blocking ones.
Note that we probably could revert commit 499350a5a6e7 ("tcp:
initialize rcv_mss to TCP_MIN_MSS instead of 0") to restore original tcpi_rcv_mss meaning (was 0 if no payload was ever received on a socket)
[1]
divide error: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 13832 Comm: syz-executor.5 Not tainted 6.3.0-rc4-syzkaller-00224-g00c7b5f4ddc5 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023 RIP: 0010:tcp_rcv_space_adjust+0x36e/0x9d0 net/ipv4/tcp_input.c:740 Code: 00 00 00 00 fc ff df 4c 89 64 24 48 8b 44 24 04 44 89 f9 41 81 c7 80 03 00 00 c1 e1 04 44 29 f0 48 63 c9 48 01 e9 48 0f af c1 <49> f7 f6 48 8d 04 41 48 89 44 24 40 48 8b 44 24 30 48 c1 e8 03 48 RSP: 0018:ffffc900033af660 EFLAGS: 00010206 RAX: 4a66b76cbade2c48 RBX: ffff888076640cc0 RCX: 00000000c334e4ac RDX: 0000000000000000 RSI: dffffc0000000000 RDI: 0000000000000001 RBP: 00000000c324e86c R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880766417f8 R13: ffff888028fbb980 R14: 0000000000000000 R15: 0000000000010344 FS: 00007f5bffbfe700(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b32f25000 CR3: 000000007ced0000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> tcp_recvmsg_locked+0x100e/0x22e0 net/ipv4/tcp.c:2616 tcp_recvmsg+0x117/0x620 net/ipv4/tcp.c:2681 inet6_recvmsg+0x114/0x640 net/ipv6/af_inet6.c:670 sock_recvmsg_nosec net/socket.c:1017 [inline] sock_recvmsg+0xe2/0x160 net/socket.c:1038 ____sys_recvmsg+0x210/0x5a0 net/socket.c:2720 ___sys_recvmsg+0xf2/0x180 net/socket.c:2762 do_recvmmsg+0x25e/0x6e0 net/socket.c:2856 __sys_recvmmsg net/socket.c:2935 [inline] __do_sys_recvmmsg net/socket.c:2958 [inline] __se_sys_recvmmsg net/socket.c:2951 [inline] __x64_sys_recvmmsg+0x20f/0x260 net/socket.c:2951 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f5c0108c0f9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f5bffbfe168 EFLAGS: 00000246 ORIG_RAX: 000000000000012b RAX: ffffffffffffffda RBX: 00007f5c011ac050 RCX: 00007f5c0108c0f9 RDX: 0000000000000001 RSI: 0000000020000bc0 RDI: 0000000000000003 RBP: 00007f5c010e7b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000122 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f5c012cfb1f R14: 00007f5bffbfe300 R15: 0000000000022000 </TASK>
--- include/net/sock.h | 4 ++++ net/ipv4/af_inet.c | 2 ++ net/ipv4/inet_connection_sock.c | 1 + net/ipv4/tcp.c | 6 ++++++ 4 files changed, 13 insertions(+)
include/net/sock.h +4 -0
@@ -312,6 +312,7 @@ struct sock_common {* @sk_cgrp_data: cgroup data for this cgroup * @sk_memcg: this socket's memory cgroup association * @sk_write_pending: a write to stream socket waits to start +* @sk_wait_pending: number of threads blocked on this socket * @sk_state_change: callback to indicate change in the state of the sock * @sk_data_ready: callback to indicate there is data to be processed * @sk_write_space: callback to indicate there is bf sending space available
@@ -392,6 +393,7 @@ struct sock {unsigned int sk_napi_id;#endif int sk_rcvbuf; +int sk_wait_pending;struct sk_filter __rcu *sk_filter;union {
@@ -1010,6 +1012,7 @@ static inline void sock_rps_reset_rxhash(struct sock *sk)#define sk_wait_event (__sk, __timeo, __condition, __wait) \ ({ int __rc; \ + __sk->sk_wait_pending++; \ release_sock(__sk); \ __rc = __condition; \ if (!__rc) { \
@@ -1019,6 +1022,7 @@ static inline void sock_rps_reset_rxhash(struct sock *sk) } \sched_annotate_sleep (); \lock_sock (__sk); \ + __sk->sk_wait_pending--; \ __rc = __condition; \ __rc; \ })
net/ipv4/af_inet.c +2 -0
@@ -578,6 +578,7 @@ static long inet_wait_for_connect(struct sock *sk, long timeo, int writebias)add_wait_queue (sk_sleep (sk), &wait); sk->sk_write_pending += writebias; + sk->sk_wait_pending++;/* Basic assumption: if someone sets sk->sk_err, he _must_ * change state of the socket from TCP_SYN_*.
@@ -593,6 +594,7 @@ static long inet_wait_for_connect(struct sock *sk, long timeo, int writebias) }remove_wait_queue (sk_sleep (sk), &wait); sk->sk_write_pending -= writebias; + sk->sk_wait_pending--;return timeo; }
net/ipv4/inet_connection_sock.c +1 -0
@@ -826,6 +826,7 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,if (newsk) {struct inet_connection_sock *newicsk =inet_csk (newsk); + newsk->sk_wait_pending =0 ;inet_sk_set_state (newsk,TCP_SYN_RECV ); newicsk->icsk_bind_hash =NULL ;
net/ipv4/tcp.c +6 -0
@@ -2568,6 +2568,12 @@ int tcp_disconnect(struct sock *sk, int flags)int old_state = sk->sk_state;u32 seq; +/* Deny disconnect if other threads are blocked in sk_wait_event() +* or inet_wait_for_connect(). +*/ +if (sk->sk_wait_pending) +return -EBUSY ; +if (old_state !=TCP_CLOSE )tcp_set_state (sk,TCP_CLOSE );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 17/88 tcp: Return user_mss for TCP_MAXSEG in CLOSE/LISTEN state if user_mss set
In reply to Greg Kroah-HartmanFrom: Cambda Zhu <[email protected]>
[ Upstream commit 34dfde4ad87b84d21278a7e19d92b5b2c68e6c4d ]
This patch replaces the tp->mss_cache check in getting TCP_MAXSEG with tp->rx_opt.user_mss check for CLOSE/LISTEN sock. Since tp->mss_cache is initialized with TCP_MSS_DEFAULT, checking if it's zero is probably a bug.
With this change, getting TCP_MAXSEG before connecting will return default MSS normally, and return user_mss if user_mss is set.
--- net/ipv4/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/tcp.c +2 -1
@@ -3376,7 +3376,8 @@ static int do_tcp_getsockopt(struct sock *sk, int level,switch (optname) {case TCP_MAXSEG : val = tp->mss_cache; -if (!val && ((1 << sk->sk_state) & (TCPF_CLOSE |TCPF_LISTEN ))) +if (tp->rx_opt.user_mss && + ((1 << sk->sk_state) & (TCPF_CLOSE |TCPF_LISTEN ))) val = tp->rx_opt.user_mss;if (tp->repair) val = tp->rx_opt.mss_clamp;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 18/88 net/sched: sch_ingress: Only create under TC_H_INGRESS
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
[ Upstream commit c7cfbd115001f94de9e4053657946a383147e803 ]
ingress Qdiscs are only supposed to be created under TC_H_INGRESS. Return -EOPNOTSUPP if 'parent' is not TC_H_INGRESS, similar to mq_init().
--- net/sched/sch_ingress.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/sched/sch_ingress.c +6 -0
@@ -83,6 +83,9 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt,struct ingress_sched_data *q =qdisc_priv (sch);struct net_device *dev =qdisc_dev (sch); +if (sch->parent !=TC_H_INGRESS ) +return -EOPNOTSUPP ; +net_inc_ingress_queue ();mini_qdisc_pair_init (&q->miniqp, sch, &dev->miniq_ingress);
@@ -98,6 +101,9 @@ static void ingress_destroy(struct Qdisc *sch) {struct ingress_sched_data *q =qdisc_priv (sch); +if (sch->parent !=TC_H_INGRESS ) +return ; +tcf_block_put_ext (q->block, sch, &q->block_info);net_dec_ingress_queue (); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 19/88 net/sched: sch_clsact: Only create under TC_H_CLSACT
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
[ Upstream commit 5eeebfe6c493192b10d516abfd72742900f2a162 ]
clsact Qdiscs are only supposed to be created under TC_H_CLSACT (which equals TC_H_INGRESS). Return -EOPNOTSUPP if 'parent' is not TC_H_CLSACT.
--- net/sched/sch_ingress.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/sched/sch_ingress.c +6 -0
@@ -221,6 +221,9 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt,struct net_device *dev =qdisc_dev (sch);int err; +if (sch->parent !=TC_H_CLSACT ) +return -EOPNOTSUPP ; +net_inc_ingress_queue ();net_inc_egress_queue ();
@@ -248,6 +251,9 @@ static void clsact_destroy(struct Qdisc *sch) {struct clsact_sched_data *q =qdisc_priv (sch); +if (sch->parent !=TC_H_CLSACT ) +return ; +tcf_block_put_ext (q->egress_block, sch, &q->egress_block_info);tcf_block_put_ext (q->ingress_block, sch, &q->ingress_block_info);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 20/88 net/sched: Reserve TC_H_INGRESS (TC_H_CLSACT) for ingress (clsact) Qdiscs
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
[ Upstream commit f85fa45d4a9408d98c46c8fa45ba2e3b2f4bf219 ]
Currently it is possible to add e.g. an HTB Qdisc under ffff:fff1 (TC_H_INGRESS, TC_H_CLSACT):
$ ip link add name ifb0 type ifb $ tc qdisc add dev ifb0 parent ffff:fff1 htb $ tc qdisc add dev ifb0 clsact Error: Exclusivity flag on, cannot modify. $ drgn ...
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
ifb0 =
netdev_get_by_name(prog, "ifb0")
qdisc = ifb0.ingress_queue.qdisc_sleeping
print(qdisc.ops.id.string_().decode())
htb
Quoted 1 line
Quoted 1 line
Quoted 1 line
qdisc.flags.value_()#TCQ_F_INGRESS
2
Only allow ingress and clsact Qdiscs under ffff:fff1. Return -EINVAL for everything else. Make TCQ_F_INGRESS a static flag of ingress and clsact Qdiscs.
--- net/sched/sch_api.c | 7 ++++++- net/sched/sch_ingress.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-)
net/sched/sch_api.c +6 -1
@@ -1148,7 +1148,12 @@ static struct Qdisc *qdisc_create(struct net_device *dev, sch->parent = parent;if (handle ==TC_H_INGRESS ) { - sch->flags |=TCQ_F_INGRESS ; +if (!(sch->flags &TCQ_F_INGRESS )) { +NL_SET_ERR_MSG (extack, +"Specified parent ID is reserved for ingress and clsact Qdiscs" ); + err = -EINVAL ; + goto err_out3; + } handle =TC_H_MAKE (TC_H_INGRESS ,0 );lockdep_set_class (qdisc_lock (sch), &qdisc_rx_lock); }else {
net/sched/sch_ingress.c +2 -2
@@ -136,7 +136,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = { .cl_ops = &ingress_class_ops, .id = "ingress", .priv_size = sizeof(struct ingress_sched_data), - .static_flags = TCQ_F_CPUSTATS, + .static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS, .init = ingress_init, .destroy = ingress_destroy, .dump = ingress_dump,
@@ -274,7 +274,7 @@ static struct Qdisc_ops clsact_qdisc_ops __read_mostly = { .cl_ops = &clsact_class_ops, .id = "clsact", .priv_size = sizeof(struct clsact_sched_data), - .static_flags = TCQ_F_CPUSTATS, + .static_flags = TCQ_F_INGRESS | TCQ_F_CPUSTATS, .init = clsact_init, .destroy = clsact_destroy, .dump = ingress_dump,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 21/88 net/sched: Prohibit regrafting ingress or clsact Qdiscs
In reply to Greg Kroah-HartmanFrom: Peilin Ye <[email protected]>
[ Upstream commit 9de95df5d15baa956c2b70b9e794842e790a8a13 ]
Currently, after creating an ingress (or clsact) Qdisc and grafting it under TC_H_INGRESS (TC_H_CLSACT), it is possible to graft it again under e.g. a TBF Qdisc:
$ ip link add ifb0 type ifb
$ tc qdisc add dev ifb0 handle 1: root tbf rate 20kbit buffer 1600 limit 3000
$ tc qdisc add dev ifb0 clsact
$ tc qdisc link dev ifb0 handle ffff: parent 1:1
$ tc qdisc show dev ifb0
qdisc tbf 1: root refcnt 2 rate 20Kbit burst 1600b lat 560.0ms
qdisc clsact ffff: parent ffff:fff1 refcnt 2
^^^^^^^^clsact's refcount has increased: it is now grafted under both TC_H_CLSACT and 1:1.
ingress and clsact Qdiscs should only be used under TC_H_INGRESS (TC_H_CLSACT). Prohibit regrafting them.
--- net/sched/sch_api.c | 5 +++++ 1 file changed, 5 insertions(+)
net/sched/sch_api.c +5 -0
@@ -1514,6 +1514,11 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,NL_SET_ERR_MSG (extack,"Invalid qdisc name" );return -EINVAL ; } +if (q->flags &TCQ_F_INGRESS ) { +NL_SET_ERR_MSG (extack, +"Cannot regraft ingress or clsact Qdiscs" ); +return -EINVAL ; + }if (q == p || (p &&check_loop (q, p,0 ))) {NL_SET_ERR_MSG (extack,"Qdisc parent/child loop detected" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 22/88 net: sched: fix NULL pointer dereference in mq_attach
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 36eec020fab668719b541f34d97f44e232ffa165 ]
When use the following command to test:
1)ip link add bond0 type bond
2)ip link set bond0 up
3)tc qdisc add dev bond0 root handle ffff: mq
4)tc qdisc replace dev bond0 parent ffff:fff1 handle ffff: mq
The kernel reports NULL pointer dereference issue. The stack information is as follows:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 Internal error: Oops: 0000000096000006 [#1] SMP Modules linked in: pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : mq_attach+0x44/0xa0 lr : qdisc_graft+0x20c/0x5cc
sp : ffff80000e2236a0
x29: ffff80000e2236a0 x28: ffff0000c0e59d80 x27: ffff0000c0be19c0
x26: ffff0000cae3e800 x25: 0000000000000010 x24: 00000000fffffff1
x23: 0000000000000000 x22: ffff0000cae3e800 x21: ffff0000c9df4000
x20: ffff0000c9df4000 x19: 0000000000000000 x18: ffff80000a934000
x17: ffff8000f5b56000 x16: ffff80000bb08000 x15: 0000000000000000
x14: 0000000000000000 x13: 6b6b6b6b6b6b6b6b x12: 6b6b6b6b00000001
x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000 x8 : ffff0000c0be0730 x7 : bbbbbbbbbbbbbbbb x6 : 0000000000000008 x5 : ffff0000cae3e864 x4 : 0000000000000000 x3 : 0000000000000001 x2 : 0000000000000001 x1 : ffff8000090bc23c x0 : 0000000000000000
Call trace: mq_attach+0x44/0xa0 qdisc_graft+0x20c/0x5cc tc_modify_qdisc+0x1c4/0x664 rtnetlink_rcv_msg+0x354/0x440 netlink_rcv_skb+0x64/0x144 rtnetlink_rcv+0x28/0x34 netlink_unicast+0x1e8/0x2a4 netlink_sendmsg+0x308/0x4a0 sock_sendmsg+0x64/0xac ____sys_sendmsg+0x29c/0x358 ___sys_sendmsg+0x90/0xd0 __sys_sendmsg+0x7c/0xd0 __arm64_sys_sendmsg+0x2c/0x38 invoke_syscall+0x54/0x114 el0_svc_common.constprop.1+0x90/0x174 do_el0_svc+0x3c/0xb0 el0_svc+0x24/0xec el0t_64_sync_handler+0x90/0xb4 el0t_64_sync+0x174/0x178
This is because when mq is added for the first time, qdiscs in mq is set to NULL in mq_attach(). Therefore, when replacing mq after adding mq, we need to initialize qdiscs in the mq before continuing to graft. Otherwise, it will couse NULL pointer dereference issue in mq_attach(). And the same issue will occur in the attach functions of mqprio, taprio and htb. ffff:fff1 means that the repalce qdisc is ingress. Ingress does not allow any qdisc to be attached. Therefore, ffff:fff1 is incorrectly used, and the command should be dropped.
--- net/sched/sch_api.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sched/sch_api.c +4 -0
@@ -1524,6 +1524,10 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,NL_SET_ERR_MSG (extack,"Qdisc parent/child loop detected" );return -ELOOP ; } +if (clid ==TC_H_INGRESS ) { +NL_SET_ERR_MSG (extack,"Ingress cannot graft directly" ); +return -EINVAL ; + }qdisc_refcount_inc (q); goto graft; }else {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 23/88 ocfs2/dlm: move BITS_TO_BYTES() to bitops.h for wider use
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit dd3e7cba16274831f5a69f071ed3cf13ffb352ea ]
There are users already and will be more of BITS_TO_BYTES() macro. Move it to bitops.h for wider use.
In the case of ocfs2 the replacement is identical.
As for bnx2x, there are two places where floor version is used. In the first case to calculate the amount of structures that can fit one memory page. In this case obviously the ceiling variant is correct and original code might have a potential bug, if amount of bits % 8 is not
0. In the second case the macro is used to calculate bytes transmitted in one microsecond. This will work for all speeds which is multiply of 1Gbps without any change, for the rest new code will give ceiling value, for instance 100Mbps will give 13 bytes, while old code gives 12 bytes and the arithmetically correct one is 12.5 bytes. Further the value is used to setup timer threshold which in any case has its own margins due to certain resolution. I don't see here an issue with slightly shifting thresholds for low speed connections, the card is supposed to utilize highest available rate, which is usually 10Gbps.
Stable-dep-of: f4e4534850a9 ("net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report")
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h | 1 - fs/ocfs2/dlm/dlmcommon.h | 4 ---- include/linux/bitops.h | 1 + 3 files changed, 1 insertion(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h +0 -1
@@ -296,7 +296,6 @@ static inline void bnx2x_dcb_config_qm(struct bnx2x *bp, enum cos_mode mode,* possible, the driver should only write the valid vnics into the internal * ram according to the appropriate port mode. */ -#define BITS_TO_BYTES (x) ((x)/8)/* CMNG constants, as derived from system spec calculations */
fs/ocfs2/dlm/dlmcommon.h +0 -4
@@ -704,10 +704,6 @@ struct dlm_begin_reco__be32 pad2; }; - -#define BITS_PER_BYTE 8 -#define BITS_TO_BYTES (bits) (((bits)+BITS_PER_BYTE-1)/BITS_PER_BYTE) -struct dlm_query_join_request {u8 node_idx;
include/linux/bitops.h +1 -0
@@ -6,6 +6,7 @@#define BITS_PER_TYPE (type) (sizeof(type) * BITS_PER_BYTE)#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(long)) +#define BITS_TO_BYTES (nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(char))extern unsigned int __sw_hweight8 (unsigned int w);extern unsigned int __sw_hweight16 (unsigned int w);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 24/88 net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report
In reply to Greg Kroah-HartmanFrom: Pedro Tammela <[email protected]>
[ Upstream commit f4e4534850a9d18c250a93f8d7fbb51310828110 ]
The current code for the length calculation wrongly truncates the reported length of the groups array, causing an under report of the subscribed groups. To fix this, use 'BITS_TO_BYTES()' which rounds up the division by 8.
--- net/netlink/af_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netlink/af_netlink.c +1 -1
@@ -1775,7 +1775,7 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,break ; } } -if (put_user (ALIGN (nlk->ngroups /8 ,sizeof (u32)), optlen)) +if (put_user (ALIGN (BITS_TO_BYTES (nlk->ngroups),sizeof (u32)), optlen)) err = -EFAULT ;netlink_unlock_table ();return err;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 25/88 udp6: Fix race condition in udp6_sendmsg & connect
In reply to Greg Kroah-HartmanFrom: Vladislav Efanov <[email protected]>
[ Upstream commit 448a5ce1120c5bdbce1f1ccdabcd31c7d029f328 ]
Syzkaller got the following report:
BUG: KASAN: use-after-free in sk_setup_caps+0x621/0x690 net/core/sock.c:2018 Read of size 8 at addr ffff888027f82780 by task syz-executor276/3255
The function sk_setup_caps (called by ip6_sk_dst_store_flow-> ip6_dst_store) referenced already freed memory as this memory was freed by parallel task in udpv6_sendmsg->ip6_sk_dst_lookup_flow-> sk_dst_check.
task1 (connect) task2 (udp6_sendmsg)
sk_setup_caps->sk_dst_set |
| sk_dst_check->
| sk_dst_set
| dst_release
sk_setup_caps references |
to already freed dst_entry|
The reason for this race condition is: sk_setup_caps() keeps using the dst after transferring the ownership to the dst cache.
Found by Linux Verification Center (linuxtesting.org) with syzkaller.
--- net/core/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/sock.c +1 -1
@@ -1795,7 +1795,6 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst) {u32 max_segs =1 ; -sk_dst_set (sk, dst); sk->sk_route_caps = dst->dev->features | sk->sk_route_forced_caps;if (sk->sk_route_caps &NETIF_F_GSO ) sk->sk_route_caps |=NETIF_F_GSO_SOFTWARE ;
@@ -1810,6 +1809,7 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst) } } sk->sk_gso_max_segs = max_segs; +sk_dst_set (sk, dst); }EXPORT_SYMBOL_GPL (sk_setup_caps);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 26/88 net/sched: flower: fix possible OOB write in fl_set_geneve_opt()
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
[ Upstream commit 4d56304e5827c8cc8cc18c75343d283af7c4825c ]
If we send two TCA_FLOWER_KEY_ENC_OPTS_GENEVE packets and their total size is 252 bytes(key->enc_opts.len = 252) then key->enc_opts.len = opt->length = data_len / 4 = 0 when the third TCA_FLOWER_KEY_ENC_OPTS_GENEVE packet enters fl_set_geneve_opt. This bypasses the next bounds check and results in an out-of-bounds.
--- net/sched/cls_flower.c | 3 +++ 1 file changed, 3 insertions(+)
net/sched/cls_flower.c +3 -0
@@ -640,6 +640,9 @@ static int fl_set_geneve_opt(const struct nlattr *nla, struct fl_flow_key *key,if (option_len >sizeof (struct geneve_opt )) data_len = option_len -sizeof (struct geneve_opt ); +if (key->enc_opts.len >FLOW_DIS_TUN_OPTS_MAX -4 ) +return -ERANGE ; + opt = (struct geneve_opt *)&key->enc_opts.data[key->enc_opts.len];memset (opt,0xff , option_len); opt->length = data_len /4 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 27/88 net: dsa: mv88e6xxx: Increase wait after reset deactivation
In reply to Greg Kroah-HartmanFrom: Andreas Svensson <[email protected]>
[ Upstream commit 3c27f3d53d588618d81d30d6712459a3cc9489b8 ]
A switch held in reset by default needs to wait longer until we can reliably detect it.
An issue was observed when testing on the Marvell 88E6393X (Link Street). The driver failed to detect the switch on some upstarts. Increasing the wait time after reset deactivation solves this issue.
The updated wait time is now also the same as the wait time in the mv88e6xxx_hardware_reset function.
--- drivers/net/dsa/mv88e6xxx/chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/chip.c +1 -1
@@ -4840,7 +4840,7 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev) goto out; }if (chip->reset) -usleep_range (1000 ,2000 ); +usleep_range (10000 ,20000 ); err =mv88e6xxx_detect (chip);if (err)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 28/88 watchdog: menz069_wdt: fix watchdog initialisation
In reply to Greg Kroah-HartmanFrom: Johannes Thumshirn <[email protected]>
[ Upstream commit 87b22656ca6a896d0378e9e60ffccb0c82f48b08 ]
Doing a 'cat /dev/watchdog0' with menz069_wdt as watchdog0 will result in a NULL pointer dereference.
This happens because we're passing the wrong pointer to watchdog_register_device(). Fix this by getting rid of the static watchdog_device structure and use the one embedded into the driver's per-instance private data.
--- drivers/watchdog/menz69_wdt.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/watchdog/menz69_wdt.c +6 -10
@@ -98,14 +98,6 @@ static const struct watchdog_ops men_z069_ops = { .set_timeout = men_z069_wdt_set_timeout, }; -static struct watchdog_device men_z069_wdt = { - .info = &men_z069_info, - .ops = &men_z069_ops, - .timeout =MEN_Z069_DEFAULT_TIMEOUT , - .min_timeout =1 , - .max_timeout =MEN_Z069_WDT_COUNTER_MAX /MEN_Z069_TIMER_FREQ , -}; -static int men_z069_probe (struct mcb_device *dev,const struct mcb_device_id *id) {
@@ -125,15 +117,19 @@ static int men_z069_probe(struct mcb_device *dev, goto release_mem; drv->mem = mem; + drv->wdt.info = &men_z069_info; + drv->wdt.ops = &men_z069_ops; + drv->wdt.timeout =MEN_Z069_DEFAULT_TIMEOUT ; + drv->wdt.min_timeout =1 ; + drv->wdt.max_timeout =MEN_Z069_WDT_COUNTER_MAX /MEN_Z069_TIMER_FREQ ; - drv->wdt = men_z069_wdt;watchdog_init_timeout (&drv->wdt,0 , &dev->dev);watchdog_set_nowayout (&drv->wdt, nowayout);watchdog_set_drvdata (&drv->wdt, drv); drv->wdt.parent = &dev->dev;mcb_set_drvdata (dev, drv); -return watchdog_register_device (&men_z069_wdt); +return watchdog_register_device (&drv->wdt); release_mem:mcb_release_mem (mem);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 29/88 mailbox: mailbox-test: Fix potential double-free in mbox_test_message_write()
In reply to Greg Kroah-HartmanFrom: Lee Jones <[email protected]>
[ Upstream commit 2d1e952a2b8e5e92d8d55ac88a7cf7ca5ea591ad ]
If a user can make copy_from_user() fail, there is a potential for UAF/DF due to a lack of locking around the allocation, use and freeing of the data buffers.
This issue is not theoretical. I managed to author a POC for it:
BUG: KASAN: double-free in kfree+0x5c/0xac
Free of addr ffff29280be5de00 by task poc/356
CPU: 1 PID: 356 Comm: poc Not tainted 6.1.0-00001-g961aa6552c04-dirty #20
Hardware name: linux,dummy-virt (DT)
Call trace:
dump_backtrace.part.0+0xe0/0xf0
show_stack+0x18/0x40
dump_stack_lvl+0x64/0x80
print_report+0x188/0x48c
kasan_report_invalid_free+0xa0/0xc0
____kasan_slab_free+0x174/0x1b0
__kasan_slab_free+0x18/0x24
__kmem_cache_free+0x130/0x2e0
kfree+0x5c/0xac
mbox_test_message_write+0x208/0x29c
full_proxy_write+0x90/0xf0
vfs_write+0x154/0x440
ksys_write+0xcc/0x180
__arm64_sys_write+0x44/0x60
invoke_syscall+0x60/0x190
el0_svc_common.constprop.0+0x7c/0x160
do_el0_svc+0x40/0xf0
el0_svc+0x2c/0x6c
el0t_64_sync_handler+0xf4/0x120
el0t_64_sync+0x18c/0x190
Allocated by task 356:
kasan_save_stack+0x3c/0x70
kasan_set_track+0x2c/0x40
kasan_save_alloc_info+0x24/0x34
__kasan_kmalloc+0xb8/0xc0
kmalloc_trace+0x58/0x70
mbox_test_message_write+0x6c/0x29c
full_proxy_write+0x90/0xf0
vfs_write+0x154/0x440
ksys_write+0xcc/0x180
__arm64_sys_write+0x44/0x60
invoke_syscall+0x60/0x190
el0_svc_common.constprop.0+0x7c/0x160
do_el0_svc+0x40/0xf0
el0_svc+0x2c/0x6c
el0t_64_sync_handler+0xf4/0x120
el0t_64_sync+0x18c/0x190
Freed by task 357:
kasan_save_stack+0x3c/0x70
kasan_set_track+0x2c/0x40
kasan_save_free_info+0x38/0x5c
____kasan_slab_free+0x13c/0x1b0
__kasan_slab_free+0x18/0x24
__kmem_cache_free+0x130/0x2e0
kfree+0x5c/0xac
mbox_test_message_write+0x208/0x29c
full_proxy_write+0x90/0xf0
vfs_write+0x154/0x440
ksys_write+0xcc/0x180
__arm64_sys_write+0x44/0x60
invoke_syscall+0x60/0x190
el0_svc_common.constprop.0+0x7c/0x160
do_el0_svc+0x40/0xf0
el0_svc+0x2c/0x6c
el0t_64_sync_handler+0xf4/0x120
el0t_64_sync+0x18c/0x190--- drivers/mailbox/mailbox-test.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mailbox/mailbox-test.c +7 -0
@@ -16,6 +16,7 @@#include <linux/kernel.h> #include <linux/mailbox_client.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/of.h> #include <linux/platform_device.h> #include <linux/poll.h>
@@ -43,6 +44,7 @@ struct mbox_test_device {char *signal;char *message;spinlock_t lock; +struct mutex mutex;wait_queue_head_t waitq;struct fasync_struct *async_queue; };
@@ -114,6 +116,8 @@ static ssize_t mbox_test_message_write(struct file *filp,return -EINVAL ; } +mutex_lock (&tdev->mutex); + tdev->message =kzalloc (MBOX_MAX_MSG_LEN ,GFP_KERNEL );if (!tdev->message)return -ENOMEM ;
@@ -148,6 +152,8 @@ static ssize_t mbox_test_message_write(struct file *filp,kfree (tdev->message); tdev->signal =NULL ; +mutex_unlock (&tdev->mutex); +return ret <0 ? ret : count; }
@@ -396,6 +402,7 @@ static int mbox_test_probe(struct platform_device *pdev)platform_set_drvdata (pdev, tdev);spin_lock_init (&tdev->lock); +mutex_init (&tdev->mutex);if (tdev->rx_channel) { tdev->rx_buffer = devm_kzalloc(&pdev->dev,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 30/88 ARM: 9295/1: unwind:fix unwind abort for uleb128 case
In reply to Greg Kroah-HartmanFrom: Haibo Li <[email protected]>
[ Upstream commit fa3eeb638de0c1a9d2d860e5b48259facdd65176 ]
When unwind instruction is 0xb2,the subsequent instructions are uleb128 bytes.
For now,it uses only the first uleb128 byte in code.
For vsp increments of 0x204~0x400,use one uleb128 byte like below:0xc06a00e4 <unwind_test_work>: 0x80b27fac
Compact model index: 0
0xb2 0x7f vsp = vsp + 1024
0xac pop {r4, r5, r6, r7, r8, r14}
For vsp increments larger than 0x400,use two uleb128 bytes like below:0xc06a00e4 <unwind_test_work>: @0xc0cc9e0c
Compact model index: 1
0xb2 0x81 0x01 vsp = vsp + 1032
0xac pop {r4, r5, r6, r7, r8, r14}
The unwind works well since the decoded uleb128 byte is also 0x81.
For vsp increments larger than 0x600,use two uleb128 bytes like below:0xc06a00e4 <unwind_test_work>: @0xc0cc9e0c
Compact model index: 1
0xb2 0x81 0x02 vsp = vsp + 1544
0xac pop {r4, r5, r6, r7, r8, r14}
In this case,the decoded uleb128 result is 0x101(vsp=0x204+(0x101<<2)). While the uleb128 used in code is 0x81(vsp=0x204+(0x81<<2)). The unwind aborts at this frame since it gets incorrect vsp.
To fix this,add uleb128 decode to cover all the above case.
--- arch/arm/kernel/unwind.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
arch/arm/kernel/unwind.c +24 -1
@@ -313,6 +313,29 @@ static int unwind_exec_pop_subset_r0_to_r3(struct unwind_ctrl_block *ctrl,return URC_OK ; } +static unsigned long unwind_decode_uleb128 (struct unwind_ctrl_block *ctrl) +{ +unsigned long bytes =0 ; +unsigned long insn; +unsigned long result =0 ; + +/* +* unwind_get_byte() will advance `ctrl` one instruction at a time, so +* loop until we get an instruction byte where bit 7 is not set. +* +* Note: This decodes a maximum of 4 bytes to output 28 bits data where +* max is 0xfffffff: that will cover a vsp increment of 1073742336, hence +* it is sufficient for unwinding the stack. +*/ +do { + insn =unwind_get_byte (ctrl); + result |= (insn &0x7f ) << (bytes *7 ); + bytes++; + }while (!!(insn &0x80 ) && (bytes !=sizeof (result))); + +return result; +} +/* * Execute the current unwind instruction. */
@@ -366,7 +389,7 @@ static int unwind_exec_insn(struct unwind_ctrl_block *ctrl)if (ret) goto error; }else if (insn ==0xb2 ) { -unsigned long uleb128 =unwind_get_byte (ctrl); +unsigned long uleb128 =unwind_decode_uleb128 (ctrl); ctrl->vrs[SP ] +=0x204 + (uleb128 <<2 ); }else {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 31/88 media: rcar-vin: Select correct interrupt mode for V4L2_FIELD_ALTERNATE
In reply to Greg Kroah-HartmanFrom: Niklas Söderlund <[email protected]>
[ Upstream commit e10707d5865c90d3dfe4ef589ce02ff4287fef85 ]
When adding proper support for V4L2_FIELD_ALTERNATE it was missed that this field format should trigger an interrupt for each field, not just for the whole frame. Fix this by marking it as progressive in the capture setup, which will then select the correct interrupt mode.
Tested on both Gen2 and Gen3 with the result of a doubling of the frame rate for V4L2_FIELD_ALTERNATE. From a PAL video source the frame rate is now 50, which is expected for alternate field capture.
--- drivers/media/platform/rcar-vin/rcar-dma.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/rcar-vin/rcar-dma.c +1 -0
@@ -633,6 +633,7 @@ static int rvin_setup(struct rvin_dev *vin) vnmc =VNMC_IM_FULL |VNMC_FOC ;break ;case V4L2_FIELD_NONE : +case V4L2_FIELD_ALTERNATE : vnmc =VNMC_IM_ODD_EVEN ; progressive = true;break ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 32/88 fbdev: modedb: Add 1920x1080 at 60 Hz video mode
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
[ Upstream commit c8902258b2b8ecaa1b8d88c312853c5b14c2553d ]
Add typical resolution for Full-HD monitors.
--- drivers/video/fbdev/core/modedb.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/video/fbdev/core/modedb.c +5 -0
@@ -257,6 +257,11 @@ static const struct fb_videomode modedb[] = { {NULL ,72 ,480 ,300 ,33386 ,40 ,24 ,11 ,19 ,80 ,3 ,0 , FB_VMODE_DOUBLE }, +/* 1920x1080 @ 60 Hz, 67.3 kHz hsync */ + { NULL, 60, 1920, 1080, 6734, 148, 88, 36, 4, 44, 5, 0, +FB_SYNC_HOR_HIGH_ACT |FB_SYNC_VERT_HIGH_ACT , + FB_VMODE_NONINTERLACED }, +/* 1920x1200 @ 60 Hz, 74.5 Khz hsync */ { NULL, 60, 1920, 1200, 5177, 128, 336, 1, 38, 208, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 33/88 fbdev: stifb: Fix info entry in sti_struct on error path
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
[ Upstream commit 0bdf1ad8d10bd4e50a8b1a2c53d15984165f7fea ]
Minor fix to reset the info field to NULL in case of error.
--- drivers/video/fbdev/stifb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/stifb.c +1 -0
@@ -1371,6 +1371,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)iounmap (info->screen_base); out_err0:kfree (fb); + sti->info =NULL ;return -ENXIO ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 34/88 nbd: Fix debugfs_create_dir error checking
In reply to Greg Kroah-HartmanFrom: Ivan Orlov <[email protected]>
[ Upstream commit 4913cfcf014c95f0437db2df1734472fd3e15098 ]
The debugfs_create_dir function returns ERR_PTR in case of error, and the only correct way to check if an error occurred is 'IS_ERR' inline function. This patch will replace the null-comparison with IS_ERR.
--- drivers/block/nbd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/nbd.c +2 -2
@@ -1547,7 +1547,7 @@ static int nbd_dev_dbg_init(struct nbd_device *nbd)return -EIO ; dir =debugfs_create_dir (nbd_name (nbd), nbd_dbg_dir); -if (!dir) { +if (IS_ERR (dir)) {dev_err (nbd_to_dev (nbd),"Failed to create debugfs dir for '%s'\n" ,nbd_name (nbd));return -EIO ;
@@ -1573,7 +1573,7 @@ static int nbd_dbg_init(void)struct dentry *dbg_dir; dbg_dir =debugfs_create_dir ("nbd" ,NULL ); -if (!dbg_dir) +if (IS_ERR (dbg_dir))return -EIO ; nbd_dbg_dir = dbg_dir;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 35/88 ASoC: dwc: limit the number of overrun messages
In reply to Greg Kroah-HartmanFrom: Maxim Kochetkov <[email protected]>
[ Upstream commit ab6ecfbf40fccf74b6ec2ba7ed6dd2fc024c3af2 ]
On slow CPU (FPGA/QEMU emulated) printing overrun messages from interrupt handler to uart console may leads to more overrun errors. So use dev_err_ratelimited to limit the number of error messages.
--- sound/soc/dwc/dwc-i2s.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/dwc/dwc-i2s.c +2 -2
@@ -132,13 +132,13 @@ static irqreturn_t i2s_irq_handler(int irq, void *dev_id)/* Error Handling: TX */ if (isr[i] &ISR_TXFO ) { -dev_err (dev->dev,"TX overrun (ch_id=%d)\n" , i); +dev_err_ratelimited (dev->dev,"TX overrun (ch_id=%d)\n" , i); irq_valid = true; }/* Error Handling: TX */ if (isr[i] &ISR_RXFO ) { -dev_err (dev->dev,"RX overrun (ch_id=%d)\n" , i); +dev_err_ratelimited (dev->dev,"RX overrun (ch_id=%d)\n" , i); irq_valid = true; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 36/88 xfrm: Check if_id in inbound policy/secpath match
In reply to Greg Kroah-HartmanFrom: Benedict Wong <[email protected]>
[ Upstream commit 8680407b6f8f5fba59e8f1d63c869abc280f04df ]
This change ensures that if configured in the policy, the if_id set in the policy and secpath states match during the inbound policy check. Without this, there is potential for ambiguity where entries in the secpath differing by only the if_id could be mismatched.
Notably, this is checked in the outbound direction when resolving templates to SAs, but not on the inbound path when matching SAs and policies.
Test: Tested against Android kernel unit tests & CTS
--- net/xfrm/xfrm_policy.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/xfrm/xfrm_policy.c +6 -5
@@ -2240,7 +2240,7 @@ xfrm_secpath_reject(int idx, struct sk_buff *skb, const struct flowi *fl)static inline int xfrm_state_ok (const struct xfrm_tmpl *tmpl,const struct xfrm_state *x, -unsigned short family) +unsigned short family,u32 if_id) {if (xfrm_state_kern (x))return tmpl->optional && !xfrm_state_addr_cmp (tmpl, x, tmpl->encap_family);
@@ -2251,7 +2251,8 @@ xfrm_state_ok(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x, (tmpl->allalgs || (tmpl->aalgos & (1 <<x->props.aalgo)) || !(xfrm_id_proto_match (tmpl->id.proto,IPSEC_PROTO_ANY ))) && !(x->props.mode !=XFRM_MODE_TRANSPORT && -xfrm_state_addr_cmp (tmpl, x, family)); +xfrm_state_addr_cmp (tmpl, x, family)) && + (if_id ==0 || if_id == x->if_id); }/*
@@ -2263,7 +2264,7 @@ xfrm_state_ok(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x,*/ static inline int xfrm_policy_ok (const struct xfrm_tmpl *tmpl,const struct sec_path *sp,int start, -unsigned short family) +unsigned short family,u32 if_id) {int idx = start;
@@ -2273,7 +2274,7 @@ xfrm_policy_ok(const struct xfrm_tmpl *tmpl, const struct sec_path *sp, int star }else start =-1 ;for (; idx < sp->len; idx++) { -if (xfrm_state_ok (tmpl, sp->xvec[idx], family)) +if (xfrm_state_ok (tmpl, sp->xvec[idx], family, if_id))return ++idx;if (sp->xvec[idx]->props.mode !=XFRM_MODE_TRANSPORT ) {if (start ==-1 )
@@ -2450,7 +2451,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,* are implied between each two transformations. */ for (i = xfrm_nr-1 , k =0 ; i >=0 ; i--) { - k =xfrm_policy_ok (tpp[i], sp, k, family); + k =xfrm_policy_ok (tpp[i], sp, k, family, if_id);if (k <0 ) {if (k <-1 )/* "-2 - errored_index" returned */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 37/88 ASoC: ssm2602: Add workaround for playback distortions
In reply to Greg Kroah-HartmanFrom: Paweł Anikiel <[email protected]>
[ Upstream commit f63550e2b165208a2f382afcaf5551df9569e1d4 ]
Apply a workaround for what appears to be a hardware quirk.
The problem seems to happen when enabling "whole chip power" (bit D7 register R6) for the very first time after the chip receives power. If either "output" (D4) or "DAC" (D3) aren't powered on at that time, playback becomes very distorted later on.
This happens on the Google Chameleon v3, as well as on a ZYBO Z7-10:
https://ez.analog.com/audio/f/q-a/543726/solved-ssm2603-right-output-offset-issue/480229
I suspect this happens only when using an external MCLK signal (which is the case for both of these boards).
Here are some experiments run on a Google Chameleon v3. These were run in userspace using a wrapper around the i2cset utility:
ssmset() {
i2cset -y 0 0x1a $(($1*2)) $2
}For each of the following sequences, we apply power to the ssm2603 chip, set the configuration registers R0-R5 and R7-R8, run the selected sequence, and check for distortions on playback.
ssmset 0x09 0x01 # core
ssmset 0x06 0x07 # chip, out, dac
OK
ssmset 0x09 0x01 # core
ssmset 0x06 0x87 # out, dac
ssmset 0x06 0x07 # chip
OK
(disable MCLK)
ssmset 0x09 0x01 # core
ssmset 0x06 0x1f # chip
ssmset 0x06 0x07 # out, dac
(enable MCLK)
OK
ssmset 0x09 0x01 # core
ssmset 0x06 0x1f # chip
ssmset 0x06 0x07 # out, dac
NOT OK
ssmset 0x06 0x1f # chip
ssmset 0x09 0x01 # core
ssmset 0x06 0x07 # out, dac
NOT OK
ssmset 0x09 0x01 # core
ssmset 0x06 0x0f # chip, out
ssmset 0x06 0x07 # dac
NOT OK
ssmset 0x09 0x01 # core
ssmset 0x06 0x17 # chip, dac
ssmset 0x06 0x07 # out
NOT OK
For each of the following sequences, we apply power to the ssm2603 chip, run the selected sequence, issue a reset with R15, configure R0-R5 and R7-R8, run one of the NOT OK sequences from above, and check for distortions.
ssmset 0x09 0x01 # core
ssmset 0x06 0x07 # chip, out, dac
OK
(disable MCLK)
ssmset 0x09 0x01 # core
ssmset 0x06 0x07 # chip, out, dac
(enable MCLK after reset)
NOT OK
ssmset 0x09 0x01 # core
ssmset 0x06 0x17 # chip, dac
NOT OK
ssmset 0x09 0x01 # core
ssmset 0x06 0x0f # chip, out
NOT OK
ssmset 0x06 0x07 # chip, out, dac
NOT OK
--- sound/soc/codecs/ssm2602.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
sound/soc/codecs/ssm2602.c +15 -0
@@ -67,6 +67,18 @@ static const struct reg_default ssm2602_reg[SSM2602_CACHEREGNUM] = { { .reg = 0x09, .def = 0x0000 } }; +/* +* ssm2602 register patch +* Workaround for playback distortions after power up: activates digital +* core, and then powers on output, DAC, and whole chip at the same time +*/ + +static const struct reg_sequence ssm2602_patch[] = { + {SSM2602_ACTIVE ,0x01 }, + {SSM2602_PWR ,0x07 }, + {SSM2602_RESET ,0x00 }, +}; +/*Appending several "None"s just for OSS mixer use*/ static const char *ssm2602_input_select[] = {
@@ -577,6 +589,9 @@ static int ssm260x_component_probe(struct snd_soc_component *component)return ret; } +regmap_register_patch (ssm2602->regmap, ssm2602_patch, +ARRAY_SIZE (ssm2602_patch)); +/* set the update bits */ regmap_update_bits (ssm2602->regmap,SSM2602_LINVOL ,LINVOL_LRIN_BOTH ,LINVOL_LRIN_BOTH );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 38/88 media: dvb_demux: fix a bug for the continuity counter
In reply to Greg Kroah-HartmanFrom: YongSu Yoo <[email protected]>
[ Upstream commit 7efb10d8dc70ea3000cc70dca53407c52488acd1 ]
In dvb_demux.c, some logics exist which compare the expected continuity counter and the real continuity counter. If they are not matched each other, both of the expected continuity counter and the real continuity counter should be printed. But there exists a bug that the expected continuity counter is not correctly printed. The expected continuity counter is replaced with the real countinuity counter + 1 so that the epected continuity counter is not correclty printed. This is wrong. This bug is fixed.
--- drivers/media/dvb-core/dvb_demux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/dvb-core/dvb_demux.c +2 -2
@@ -125,12 +125,12 @@ static inline int dvb_dmx_swfilter_payload(struct dvb_demux_feed *feed, cc = buf[3 ] &0x0f ; ccok = ((feed->cc +1 ) &0x0f ) == cc; - feed->cc = cc;if (!ccok) {set_buf_flags (feed,DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED );dprintk_sect_loss ("missed packet: %d instead of %d!\n" , cc, (feed->cc +1 ) &0x0f ); } + feed->cc = cc;if (buf[1 ] &0x40 )// PUSI ? feed->peslen =0xfffa ;
@@ -310,7 +310,6 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, cc = buf[3 ] &0x0f ; ccok = ((feed->cc +1 ) &0x0f ) == cc; - feed->cc = cc;if (buf[3 ] &0x20 ) {/* adaption field present, check for discontinuity_indicator */
@@ -346,6 +345,7 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, feed->pusi_seen = false;dvb_dmx_swfilter_section_new (feed); } + feed->cc = cc;if (buf[1 ] &0x40 ) {/* PUSI=1 (is set), section boundary is here */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 39/88 media: dvb-usb: az6027: fix three null-ptr-deref in az6027_i2c_xfer()
In reply to Greg Kroah-HartmanFrom: Wei Chen <[email protected]>
[ Upstream commit 858e97d7956d17a2cb56a9413468704a4d5abfe1 ]
In az6027_i2c_xfer, msg is controlled by user. When msg[i].buf is null, commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()") fix the null-ptr-deref bug when msg[i].addr is 0x99. However, null-ptr-deref also happens when msg[i].addr is 0xd0 and 0xc0. We add check on msg[i].len to prevent null-ptr-deref.
--- drivers/media/usb/dvb-usb/az6027.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/media/usb/dvb-usb/az6027.c +12 -0
@@ -991,6 +991,10 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n/* write/read request */ if (i +1 < num && (msg[i +1 ].flags &I2C_M_RD )) { req =0xB9 ; +if (msg[i].len <1 ) { + i = -EOPNOTSUPP ; +break ; + } index = (((msg[i].buf[0 ] <<8 ) &0xff00 ) | (msg[i].buf[1 ] &0x00ff )); value = msg[i].addr + (msg[i].len <<8 ); length = msg[i +1 ].len +6 ;
@@ -1004,6 +1008,10 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n/* demod 16bit addr */ req =0xBD ; +if (msg[i].len <1 ) { + i = -EOPNOTSUPP ; +break ; + } index = (((msg[i].buf[0 ] <<8 ) &0xff00 ) | (msg[i].buf[1 ] &0x00ff )); value = msg[i].addr + (2 <<8 ); length = msg[i].len -2 ;
@@ -1029,6 +1037,10 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n }else { req =0xBD ; +if (msg[i].len <1 ) { + i = -EOPNOTSUPP ; +break ; + } index = msg[i].buf[0 ] &0x00FF ; value = msg[i].addr + (1 <<8 ); length = msg[i].len -1 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 40/88 media: dvb-usb-v2: ec168: fix null-ptr-deref in ec168_i2c_xfer()
In reply to Greg Kroah-HartmanFrom: Wei Chen <[email protected]>
[ Upstream commit a6dcefcc08eca1bf4e3d213c97c3cfb75f377935 ]
In ec168_i2c_xfer, msg is controlled by user. When msg[i].buf is null and msg[i].len is zero, former checks on msg[i].buf would be passed. If accessing msg[i].buf[0] without sanity check, null pointer deref would happen. We add check on msg[i].len to prevent crash.
Similar commit:
commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
--- drivers/media/usb/dvb-usb-v2/ec168.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/media/usb/dvb-usb-v2/ec168.c +12 -0
@@ -125,6 +125,10 @@ static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],while (i < num) {if (num > i +1 && (msg[i+1 ].flags &I2C_M_RD )) {if (msg[i].addr == ec168_ec100_config.demod_address) { +if (msg[i].len <1 ) { + i = -EOPNOTSUPP ; +break ; + } req.cmd =READ_DEMOD ; req.value =0 ; req.index =0xff00 + msg[i].buf[0 ];/* reg */
@@ -141,6 +145,10 @@ static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], } }else {if (msg[i].addr == ec168_ec100_config.demod_address) { +if (msg[i].len <1 ) { + i = -EOPNOTSUPP ; +break ; + } req.cmd =WRITE_DEMOD ; req.value = msg[i].buf[1 ];/* val */ req.index =0xff00 + msg[i].buf[0 ];/* reg */
@@ -149,6 +157,10 @@ static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], ret =ec168_ctrl_msg (d, &req); i +=1 ; }else { +if (msg[i].len <1 ) { + i = -EOPNOTSUPP ; +break ; + } req.cmd =WRITE_I2C ; req.value = msg[i].buf[0 ];/* val */ req.index =0x0100 + msg[i].addr;/* I2C addr */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 41/88 media: dvb-usb-v2: ce6230: fix null-ptr-deref in ce6230_i2c_master_xfer()
In reply to Greg Kroah-HartmanFrom: Wei Chen <[email protected]>
[ Upstream commit dff919090155fb22679869e8469168f270dcd97f ]
In ce6230_i2c_master_xfer, msg is controlled by user. When msg[i].buf is null and msg[i].len is zero, former checks on msg[i].buf would be passed. Malicious data finally reach ce6230_i2c_master_xfer. If accessing msg[i].buf[0] without sanity check, null ptr deref would happen. We add check on msg[i].len to prevent crash.
Similar commit:
commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
--- drivers/media/usb/dvb-usb-v2/ce6230.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/media/usb/dvb-usb-v2/ce6230.c +8 -0
@@ -111,6 +111,10 @@ static int ce6230_i2c_master_xfer(struct i2c_adapter *adap,if (num > i +1 && (msg[i+1 ].flags &I2C_M_RD )) {if (msg[i].addr == ce6230_zl10353_config.demod_address) { +if (msg[i].len <1 ) { + i = -EOPNOTSUPP ; +break ; + } req.cmd =DEMOD_READ ; req.value = msg[i].addr >>1 ; req.index = msg[i].buf[0 ];
@@ -127,6 +131,10 @@ static int ce6230_i2c_master_xfer(struct i2c_adapter *adap, }else {if (msg[i].addr == ce6230_zl10353_config.demod_address) { +if (msg[i].len <1 ) { + i = -EOPNOTSUPP ; +break ; + } req.cmd =DEMOD_WRITE ; req.value = msg[i].addr >>1 ; req.index = msg[i].buf[0 ];
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 42/88 media: dvb-usb-v2: rtl28xxu: fix null-ptr-deref in rtl28xxu_i2c_xfer
In reply to Greg Kroah-HartmanFrom: Zhang Shurong <[email protected]>
[ Upstream commit aa4a447b81b84f69c1a89ad899df157f386d7636 ]
In rtl28xxu_i2c_xfer, msg is controlled by user. When msg[i].buf is null and msg[i].len is zero, former checks on msg[i].buf would be passed. Malicious data finally reach rtl28xxu_i2c_xfer. If accessing msg[i].buf[0] without sanity check, null ptr deref would happen. We add check on msg[i].len to prevent crash.
Similar commit:
commit 0ed554fd769a
("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
--- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/media/usb/dvb-usb-v2/rtl28xxu.c +20 -0
@@ -189,6 +189,10 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], ret = -EOPNOTSUPP ; goto err_mutex_unlock; }else if (msg[0 ].addr ==0x10 ) { +if (msg[0 ].len <1 || msg[1 ].len <1 ) { + ret = -EOPNOTSUPP ; + goto err_mutex_unlock; + }/* method 1 - integrated demod */ if (msg[0 ].buf[0 ] ==0x00 ) {/* return demod page from driver cache */
@@ -202,6 +206,10 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], ret =rtl28xxu_ctrl_msg (d, &req); } }else if (msg[0 ].len <2 ) { +if (msg[0 ].len <1 ) { + ret = -EOPNOTSUPP ; + goto err_mutex_unlock; + }/* method 2 - old I2C */ req.value = (msg[0 ].buf[0 ] <<8 ) | (msg[0 ].addr <<1 ); req.index =CMD_I2C_RD ;
@@ -230,8 +238,16 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], ret = -EOPNOTSUPP ; goto err_mutex_unlock; }else if (msg[0 ].addr ==0x10 ) { +if (msg[0 ].len <1 ) { + ret = -EOPNOTSUPP ; + goto err_mutex_unlock; + }/* method 1 - integrated demod */ if (msg[0 ].buf[0 ] ==0x00 ) { +if (msg[0 ].len <2 ) { + ret = -EOPNOTSUPP ; + goto err_mutex_unlock; + }/* save demod page for later demod access */ dev->page = msg[0 ].buf[1 ]; ret =0 ;
@@ -244,6 +260,10 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], ret =rtl28xxu_ctrl_msg (d, &req); } }else if ((msg[0 ].len <23 ) && (!dev->new_i2c_write)) { +if (msg[0 ].len <1 ) { + ret = -EOPNOTSUPP ; + goto err_mutex_unlock; + }/* method 2 - old I2C */ req.value = (msg[0 ].buf[0 ] <<8 ) | (msg[0 ].addr <<1 ); req.index =CMD_I2C_WR ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 43/88 media: dvb-usb: digitv: fix null-ptr-deref in digitv_i2c_xfer()
In reply to Greg Kroah-HartmanFrom: Wei Chen <[email protected]>
[ Upstream commit 9ded5bd2a49ce3015b7c936743eec0a0e6e11f0c ]
In digitv_i2c_xfer, msg is controlled by user. When msg[i].buf is null and msg[i].len is zero, former checks on msg[i].buf would be passed. Malicious data finally reach digitv_i2c_xfer. If accessing msg[i].buf[0] without sanity check, null ptr deref would happen. We add check on msg[i].len to prevent crash.
Similar commit:
commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
--- drivers/media/usb/dvb-usb/digitv.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/usb/dvb-usb/digitv.c +4 -0
@@ -66,6 +66,10 @@ static int digitv_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int numwarn ("more than 2 i2c messages at a time is not handled yet. TODO." );for (i =0 ; i < num; i++) { +if (msg[i].len <1 ) { + i = -EOPNOTSUPP ; +break ; + }/* write/read request */ if (i+1 < num && (msg[i+1 ].flags &I2C_M_RD )) { if (digitv_ctrl_msg(d, USB_READ_COFDM, msg[i].buf[0], NULL, 0,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 44/88 media: dvb-usb: dw2102: fix uninit-value in su3000_read_mac_address
In reply to Greg Kroah-HartmanFrom: Wei Chen <[email protected]>
[ Upstream commit a3fd1ef27aa686d871cefe207bd6168c4b0cd29e ]
In su3000_read_mac_address, if i2c_transfer fails to execute two messages, array mac address will not be initialized. Without handling such error, later in function dvb_usb_adapter_dvb_init, proposed_mac is accessed before initialization.
Fix this error by returning a negative value if message execution fails.
--- drivers/media/usb/dvb-usb/dw2102.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb/dw2102.c +1 -1
@@ -949,7 +949,7 @@ static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])for (i =0 ; i <6 ; i++) { obuf[1 ] =0xf0 + i;if (i2c_transfer (&d->i2c_adap, msg,2 ) !=2 ) -break ; +return -1 ;else mac[i] = ibuf[0 ]; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 45/88 media: netup_unidvb: fix irq init by register it at the end of probe
In reply to Greg Kroah-HartmanFrom: Wei Chen <[email protected]>
[ Upstream commit e6ad6233592593079db5c8fa592c298e51bc1356 ]
IRQ handler netup_spi_interrupt() takes spinlock spi->lock. The lock is initialized in netup_spi_init(). However, irq handler is registered before initializing the lock.
Spinlock dma->lock and i2c->lock suffer from the same problem.
Fix this by registering the irq at the end of probe.
--- .../media/pci/netup_unidvb/netup_unidvb_core.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/media/pci/netup_unidvb/netup_unidvb_core.c +9 -8
@@ -896,12 +896,7 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev, ndev->lmmio0, (u32 )pci_resource_len (pci_dev,0 ), ndev->lmmio1, (u32 )pci_resource_len (pci_dev,1 ), pci_dev->irq); -if (request_irq (pci_dev->irq, netup_unidvb_isr,IRQF_SHARED , -"netup_unidvb" , pci_dev) <0 ) { -dev_err (&pci_dev->dev, -"%s(): can't get IRQ %d\n" , __func__, pci_dev->irq); - goto irq_request_err; - } + ndev->dma_size =2 *188 *NETUP_DMA_BLOCKS_COUNT *NETUP_DMA_PACKETS_COUNT ; ndev->dma_virt = dma_alloc_coherent(&pci_dev->dev,
@@ -942,6 +937,14 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev,dev_err (&pci_dev->dev,"netup_unidvb: DMA setup failed\n" ); goto dma_setup_err; } + +if (request_irq (pci_dev->irq, netup_unidvb_isr,IRQF_SHARED , +"netup_unidvb" , pci_dev) <0 ) { +dev_err (&pci_dev->dev, +"%s(): can't get IRQ %d\n" , __func__, pci_dev->irq); + goto dma_setup_err; + } +dev_info (&pci_dev->dev,"netup_unidvb: device has been initialized\n" );return 0 ;
@@ -960,8 +963,6 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev,dma_free_coherent (&pci_dev->dev, ndev->dma_size, ndev->dma_virt, ndev->dma_phys); dma_alloc_err: -free_irq (pci_dev->irq, pci_dev); -irq_request_err:iounmap (ndev->lmmio1); pci_bar1_error:iounmap (ndev->lmmio0);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 46/88 media: dvb_ca_en50221: fix a size write bug
In reply to Greg Kroah-HartmanFrom: YongSu Yoo <[email protected]>
[ Upstream commit a4315e5be7020aac9b24a8151caf4bb85224cd0e ]
The function of "dvb_ca_en50221_write_data" at source/drivers/media /dvb-core/dvb_ca_en50221.c is used for two cases.
The first case is for writing APDU data in the function of "dvb_ca_en50221_io_write" at source/drivers/media/dvb-core/ dvb_ca_en50221.c.
The second case is for writing the host link buf size on the Command Register in the function of "dvb_ca_en50221_link_init" at source/drivers/media/dvb-core/dvb_ca_en50221.c.
In the second case, there exists a bug like following. In the function of the "dvb_ca_en50221_link_init",
after a TV host calculates the host link buf_size,
the TV host writes the calculated host link buf_size on the Size Register.
Accroding to the en50221 Spec (the page 60 of
https://dvb.org/wp-content/uploads/2020/02/En50221.V1.pdf),
before this writing operation, the "SW(CMDREG_SW)" flag in the Command Register should be set. We can see this setting operation in the function of the "dvb_ca_en50221_link_init" like below.
...
if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SW)) != 0) return ret;
...
But, after that, the real writing operation is implemented using the function of the "dvb_ca_en50221_write_data" in the function of "dvb_ca_en50221_link_init", and the "dvb_ca_en50221_write_data" includes the function of "ca->pub->write_cam_control", and the function of the "ca->pub->write_cam_control" in the function of the "dvb_ca_en50221_wrte_data" does not include "CMDREG_SW" flag like below.
...
if ((status = ca->pub->write_cam_control(ca->pub, slot,
CTRLIF_COMMAND, IRQEN | CMDREG_HC)) != 0)
...
In the above source code, we can see only the "IRQEN | CMDREG_HC", but we cannot see the "CMDREG_SW".
The "CMDREG_SW" flag which was set in the function of the "dvb_ca_en50221_link_init" was rollbacked by the follwoing function of the "dvb_ca_en50221_write_data".
This is a bug. and this bug causes that the calculated host link buf_size is not properly written in the CI module.
Through this patch, we fix this bug.
--- drivers/media/dvb-core/dvb_ca_en50221.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/media/dvb-core/dvb_ca_en50221.c +7 -5
@@ -198,7 +198,7 @@ static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca);static int dvb_ca_en50221_read_data (struct dvb_ca_private *ca,int slot,u8 *ebuf,int ecount);static int dvb_ca_en50221_write_data (struct dvb_ca_private *ca,int slot, -u8 *ebuf,int ecount); +u8 *ebuf,int ecount,int size_write_flag);/** * Safely find needle in haystack.
@@ -381,7 +381,7 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot) ret =dvb_ca_en50221_wait_if_status (ca, slot,STATUSREG_FR ,HZ /10 );if (ret)return ret; - ret =dvb_ca_en50221_write_data (ca, slot, buf,2 ); + ret =dvb_ca_en50221_write_data (ca, slot, buf,2 ,CMDREG_SW );if (ret !=2 )return -EIO ; ret = ca->pub->write_cam_control (ca->pub, slot,CTRLIF_COMMAND ,IRQEN );
@@ -789,11 +789,13 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,* @buf: The data in this buffer is treated as a complete link-level packet to * be written. * @bytes_write: Size of ebuf. +* @size_write_flag: A flag on Command Register which says whether the link size +* information will be writen or not. * * return: Number of bytes written, or < 0 on error. */ static int dvb_ca_en50221_write_data (struct dvb_ca_private *ca,int slot, -u8 *buf,int bytes_write) +u8 *buf,int bytes_write,int size_write_flag) {struct dvb_ca_slot *sl = &ca->slot_info[slot];int status;
@@ -828,7 +830,7 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,/* OK, set HC bit */ status = ca->pub->write_cam_control (ca->pub, slot,CTRLIF_COMMAND , -IRQEN |CMDREG_HC ); +IRQEN |CMDREG_HC | size_write_flag);if (status) goto exit;
@@ -1516,7 +1518,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,mutex_lock (&sl->slot_lock); status =dvb_ca_en50221_write_data (ca, slot, fragbuf, - fraglen +2 ); + fraglen +2 ,0 );mutex_unlock (&sl->slot_lock);if (status == (fraglen +2 )) { written =1 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 47/88 media: ttusb-dec: fix memory leak in ttusb_dec_exit_dvb()
In reply to Greg Kroah-HartmanFrom: Hyunwoo Kim <[email protected]>
[ Upstream commit 517a281338322ff8293f988771c98aaa7205e457 ]
Since dvb_frontend_detach() is not called in ttusb_dec_exit_dvb(), which is called when the device is disconnected, dvb_frontend_free() is not finally called.
This causes a memory leak just by repeatedly plugging and unplugging the device.
Fix this issue by adding dvb_frontend_detach() to ttusb_dec_exit_dvb().
--- drivers/media/usb/ttusb-dec/ttusb_dec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/usb/ttusb-dec/ttusb_dec.c +1 -2
@@ -1561,8 +1561,7 @@ static void ttusb_dec_exit_dvb(struct ttusb_dec *dec)dvb_dmx_release (&dec->demux);if (dec->fe) {dvb_unregister_frontend (dec->fe); -if (dec->fe->ops.release) - dec->fe->ops.release (dec->fe); +dvb_frontend_detach (dec->fe); }dvb_unregister_adapter (&dec->adapter); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 48/88 media: mn88443x: fix !CONFIG_OF error by drop of_match_ptr from ID table
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit ae11c0efaec32fb45130ee9886689f467232eebc ]
The driver will match mostly by DT table (even thought there is regular ID table) so there is little benefit in of_match_ptr (this also allows ACPI matching via PRP0001, even though it might not be relevant here). This also fixes !CONFIG_OF error:
drivers/media/dvb-frontends/mn88443x.c:782:34: error: ‘mn88443x_of_match’ defined but not used [-Werror=unused-const-variable=]
--- drivers/media/dvb-frontends/mn88443x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/mn88443x.c +1 -1
@@ -800,7 +800,7 @@ MODULE_DEVICE_TABLE(i2c, mn88443x_i2c_id);static struct i2c_driver mn88443x_driver = { .driver = { .name ="mn88443x" , - .of_match_table =of_match_ptr (mn88443x_of_match), + .of_match_table = mn88443x_of_match, }, .probe = mn88443x_probe, .remove = mn88443x_remove,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 49/88 media: dvb-core: Fix use-after-free due on race condition at dvb_net
In reply to Greg Kroah-HartmanFrom: Hyunwoo Kim <[email protected]>
[ Upstream commit 4172385b0c9ac366dcab78eda48c26814b87ed1a ]
A race condition may occur between the .disconnect function, which is called when the device is disconnected, and the dvb_device_open() function, which is called when the device node is open()ed. This results in several types of UAFs.
The root cause of this is that you use the dvb_device_open() function, which does not implement a conditional statement
that checks 'dvbnet->exit'.
So, add 'remove_mutex` to protect 'dvbnet->exit' and use locked_dvb_net_open() function to check 'dvbnet->exit'.
[mchehab: fix a checkpatch warning]
--- drivers/media/dvb-core/dvb_net.c | 38 +++++++++++++++++++++++++++++--- include/media/dvb_net.h | 4 ++++ 2 files changed, 39 insertions(+), 3 deletions(-)
drivers/media/dvb-core/dvb_net.c +35 -3
@@ -1575,15 +1575,43 @@ static long dvb_net_ioctl(struct file *file,return dvb_usercopy (file, cmd, arg, dvb_net_do_ioctl); } +static int locked_dvb_net_open (struct inode *inode,struct file *file) +{ +struct dvb_device *dvbdev = file->private_data; +struct dvb_net *dvbnet = dvbdev->priv; +int ret; + +if (mutex_lock_interruptible (&dvbnet->remove_mutex)) +return -ERESTARTSYS ; + +if (dvbnet->exit) { +mutex_unlock (&dvbnet->remove_mutex); +return -ENODEV ; + } + + ret =dvb_generic_open (inode, file); + +mutex_unlock (&dvbnet->remove_mutex); + +return ret; +} +static int dvb_net_close (struct inode *inode,struct file *file) {struct dvb_device *dvbdev = file->private_data;struct dvb_net *dvbnet = dvbdev->priv; +mutex_lock (&dvbnet->remove_mutex); +dvb_generic_release (inode, file); -if (dvbdev->users ==1 && dvbnet->exit ==1 ) +if (dvbdev->users ==1 && dvbnet->exit ==1 ) { +mutex_unlock (&dvbnet->remove_mutex);wake_up (&dvbdev->wait_queue); + }else { +mutex_unlock (&dvbnet->remove_mutex); + } +return 0 ; }
@@ -1591,7 +1619,7 @@ static int dvb_net_close(struct inode *inode, struct file *file)static const struct file_operations dvb_net_fops = { .owner =THIS_MODULE , .unlocked_ioctl = dvb_net_ioctl, - .open = dvb_generic_open, + .open = locked_dvb_net_open, .release = dvb_net_close, .llseek = noop_llseek, };
@@ -1610,10 +1638,13 @@ void dvb_net_release (struct dvb_net *dvbnet) {int i; +mutex_lock (&dvbnet->remove_mutex); dvbnet->exit =1 ; +mutex_unlock (&dvbnet->remove_mutex); +if (dvbnet->dvbdev->users <1 )wait_event (dvbnet->dvbdev->wait_queue, - dvbnet->dvbdev->users==1 ); + dvbnet->dvbdev->users ==1 );dvb_unregister_device (dvbnet->dvbdev);
@@ -1632,6 +1663,7 @@ int dvb_net_init (struct dvb_adapter *adap, struct dvb_net *dvbnet,int i;mutex_init (&dvbnet->ioctl_mutex); +mutex_init (&dvbnet->remove_mutex); dvbnet->demux = dmx;for (i=0 ; i<DVB_NET_DEVICES_MAX ; i++)
include/media/dvb_net.h +4 -0
@@ -41,6 +41,9 @@* @exit: flag to indicate when the device is being removed. * @demux: pointer to &struct dmx_demux. * @ioctl_mutex: protect access to this struct. +* @remove_mutex: mutex that avoids a race condition between a callback +* called when the hardware is disconnected and the +* file_operations of dvb_net. * * Currently, the core supports up to %DVB_NET_DEVICES_MAX (10) network * devices.
@@ -53,6 +56,7 @@ struct dvb_net { unsigned int exit:1;struct dmx_demux *demux;struct mutex ioctl_mutex; +struct mutex remove_mutex; };/**
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 50/88 media: dvb-core: Fix kernel WARNING for blocking operation in wait_event*()
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit b8c75e4a1b325ea0a9433fa8834be97b5836b946 ]
Using a semaphore in the wait_event*() condition is no good idea. It hits a kernel WARN_ON() at prepare_to_wait_event() like:
do not call blocking ops when !TASK_RUNNING; state=1 set at prepare_to_wait_event+0x6d/0x690
For avoiding the potential deadlock, rewrite to an open-coded loop instead. Unlike the loop in wait_event*(), this uses wait_woken() after the condition check, hence the task state stays consistent.
CVE-2023-31084 was assigned to this bug.
--- drivers/media/dvb-core/dvb_frontend.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/media/dvb-core/dvb_frontend.c +12 -4
@@ -304,14 +304,22 @@ static int dvb_frontend_get_event(struct dvb_frontend *fe, }if (events->eventw == events->eventr) { -int ret; +struct wait_queue_entry wait; +int ret =0 ;if (flags &O_NONBLOCK )return -EWOULDBLOCK ; - ret =wait_event_interruptible (events->wait_queue, -dvb_frontend_test_event (fepriv, events)); - +init_waitqueue_entry (&wait, current); +add_wait_queue (&events->wait_queue, &wait); +while (!dvb_frontend_test_event (fepriv, events)) { +wait_woken (&wait,TASK_INTERRUPTIBLE ,0 ); +if (signal_pending (current)) { + ret = -ERESTARTSYS ; +break ; + } + } +remove_wait_queue (&events->wait_queue, &wait);if (ret <0 )return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 51/88 media: dvb-core: Fix use-after-free due to race condition at dvb_ca_en50221
In reply to Greg Kroah-HartmanFrom: Hyunwoo Kim <[email protected]>
[ Upstream commit 280a8ab81733da8bc442253c700a52c4c0886ffd ]
If the device node of dvb_ca_en50221 is open() and the device is disconnected, a UAF may occur when calling close() on the device node.
The root cause is that wake_up() and wait_event() for dvbdev->wait_queue are not implemented.
So implement wait_event() function in dvb_ca_en50221_release() and add 'remove_mutex' which prevents race condition for 'ca->exit'.
[mchehab: fix a checkpatch warning]
--- drivers/media/dvb-core/dvb_ca_en50221.c | 37 ++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
drivers/media/dvb-core/dvb_ca_en50221.c +36 -1
@@ -162,6 +162,12 @@ struct dvb_ca_private {/* mutex serializing ioctls */ struct mutex ioctl_mutex; + +/* A mutex used when a device is disconnected */ +struct mutex remove_mutex; + +/* Whether the device is disconnected */ +int exit; };static void dvb_ca_private_free (struct dvb_ca_private *ca)
@@ -1719,12 +1725,22 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)dprintk ("%s\n" , __func__); -if (!try_module_get (ca->pub->owner)) +mutex_lock (&ca->remove_mutex); + +if (ca->exit) { +mutex_unlock (&ca->remove_mutex); +return -ENODEV ; + } + +if (!try_module_get (ca->pub->owner)) { +mutex_unlock (&ca->remove_mutex);return -EIO ; + } err =dvb_generic_open (inode, file);if (err <0 ) {module_put (ca->pub->owner); +mutex_unlock (&ca->remove_mutex);return err; }
@@ -1749,6 +1765,7 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)dvb_ca_private_get (ca); +mutex_unlock (&ca->remove_mutex);return 0 ; }
@@ -1768,6 +1785,8 @@ static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file)dprintk ("%s\n" , __func__); +mutex_lock (&ca->remove_mutex); +/* mark the CA device as closed */ ca->open =0 ;dvb_ca_en50221_thread_update_delay (ca);
@@ -1778,6 +1797,13 @@ static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file)dvb_ca_private_put (ca); +if (dvbdev->users ==1 && ca->exit ==1 ) { +mutex_unlock (&ca->remove_mutex); +wake_up (&dvbdev->wait_queue); + }else { +mutex_unlock (&ca->remove_mutex); + } +return err; }
@@ -1902,6 +1928,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, }mutex_init (&ca->ioctl_mutex); +mutex_init (&ca->remove_mutex);if (signal_pending (current)) { ret = -EINTR ;
@@ -1944,6 +1971,14 @@ void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca)dprintk ("%s\n" , __func__); +mutex_lock (&ca->remove_mutex); + ca->exit =1 ; +mutex_unlock (&ca->remove_mutex); + +if (ca->dvbdev->users <1 ) +wait_event (ca->dvbdev->wait_queue, + ca->dvbdev->users ==1 ); +/* shutdown the thread if there was one */ kthread_stop (ca->thread);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 52/88 wifi: rtl8xxxu: fix authentication timeout due to incorrect RCR value
In reply to Greg Kroah-HartmanFrom: Yun Lu <[email protected]>
[ Upstream commit 20429444e653ee8242dfbf815c0c37866beb371b ]
When using rtl8192cu with rtl8xxxu driver to connect wifi, there is a probability of failure, which shows "authentication with ... timed out". Through debugging, it was found that the RCR register has been inexplicably modified to an incorrect value, resulting in the nic not being able to receive authenticated frames.
To fix this problem, add regrcr in rtl8xxxu_priv struct, and store the RCR value every time the register is written, and use it the next time the register need to be modified.
--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +1 -0
@@ -1272,6 +1272,7 @@ struct rtl8xxxu_priv {u32 rege9c;u32 regeb4;u32 regebc; +u32 regrcr;int next_mbox;int nr_out_eps;
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +3 -1
@@ -4051,6 +4051,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)RCR_ACCEPT_MGMT_FRAME |RCR_HTC_LOC_CTRL |RCR_APPEND_PHYSTAT |RCR_APPEND_ICV |RCR_APPEND_MIC ;rtl8xxxu_write32 (priv,REG_RCR , val32); + priv->regrcr = val32;/* * Accept all multicast
@@ -5591,7 +5592,7 @@ static void rtl8xxxu_configure_filter(struct ieee80211_hw *hw, unsigned int *total_flags, u64 multicast) {struct rtl8xxxu_priv *priv = hw->priv; -u32 rcr =rtl8xxxu_read32 (priv,REG_RCR ); +u32 rcr = priv->regrcr;dev_dbg (&priv->udev->dev,"%s: changed_flags %08x, total_flags %08x\n" , __func__, changed_flags, *total_flags);
@@ -5637,6 +5638,7 @@ static void rtl8xxxu_configure_filter(struct ieee80211_hw *hw,*/ rtl8xxxu_write32 (priv,REG_RCR , rcr); + priv->regrcr = rcr; *total_flags &= (FIF_ALLMULTI | FIF_FCSFAIL | FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL | FIF_OTHER_BSS | FIF_PSPOLL |
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 53/88 ARM: dts: stm32: add pin map for CAN controller on stm32f7
In reply to Greg Kroah-HartmanFrom: Dario Binacchi <[email protected]>
[ Upstream commit 011644249686f2675e142519cd59e81e04cfc231 ]
Add pin configurations for using CAN controller on stm32f7.
--- arch/arm/boot/dts/stm32f7-pinctrl.dtsi | 82 ++++++++++++++++++++++++++ 1 file changed, 82 insertions(+)
arch/arm/boot/dts/stm32f7-pinctrl.dtsi +82 -0
@@ -284,6 +284,88 @@ slew-rate = <2>; }; }; + + can1_pins_a: can1-0 { + pins1 { + pinmux = <STM32_PINMUX('A', 12, AF9)>; /* CAN1_TX */ + }; + pins2 { + pinmux = <STM32_PINMUX('A', 11, AF9)>; /* CAN1_RX */ + bias-pull-up; + }; + }; + + can1_pins_b: can1-1 { + pins1 { + pinmux = <STM32_PINMUX('B', 9, AF9)>; /* CAN1_TX */ + }; + pins2 { + pinmux = <STM32_PINMUX('B', 8, AF9)>; /* CAN1_RX */ + bias-pull-up; + }; + }; + + can1_pins_c: can1-2 { + pins1 { + pinmux = <STM32_PINMUX('D', 1, AF9)>; /* CAN1_TX */ + }; + pins2 { + pinmux = <STM32_PINMUX('D', 0, AF9)>; /* CAN1_RX */ + bias-pull-up; + + }; + }; + + can1_pins_d: can1-3 { + pins1 { + pinmux = <STM32_PINMUX('H', 13, AF9)>; /* CAN1_TX */ + }; + pins2 { + pinmux = <STM32_PINMUX('H', 14, AF9)>; /* CAN1_RX */ + bias-pull-up; + + }; + }; + + can2_pins_a: can2-0 { + pins1 { + pinmux = <STM32_PINMUX('B', 6, AF9)>; /* CAN2_TX */ + }; + pins2 { + pinmux = <STM32_PINMUX('B', 5, AF9)>; /* CAN2_RX */ + bias-pull-up; + }; + }; + + can2_pins_b: can2-1 { + pins1 { + pinmux = <STM32_PINMUX('B', 13, AF9)>; /* CAN2_TX */ + }; + pins2 { + pinmux = <STM32_PINMUX('B', 12, AF9)>; /* CAN2_RX */ + bias-pull-up; + }; + }; + + can3_pins_a: can3-0 { + pins1 { + pinmux = <STM32_PINMUX('A', 15, AF11)>; /* CAN3_TX */ + }; + pins2 { + pinmux = <STM32_PINMUX('A', 8, AF11)>; /* CAN3_RX */ + bias-pull-up; + }; + }; + + can3_pins_b: can3-1 { + pins1 { + pinmux = <STM32_PINMUX('B', 4, AF11)>; /* CAN3_TX */ + }; + pins2 { + pinmux = <STM32_PINMUX('B', 3, AF11)>; /* CAN3_RX */ + bias-pull-up; + }; + }; }; }; };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 54/88 arm64/mm: mark private VM_FAULT_X defines as vm_fault_t
In reply to Greg Kroah-HartmanFrom: Min-Hua Chen <[email protected]>
[ Upstream commit d91d580878064b880f3574ac35b98d8b70ee8620 ]
This patch fixes several sparse warnings for fault.c:
arch/arm64/mm/fault.c:493:24: sparse: warning: incorrect type in return expression (different base types)arch/arm64/mm/fault.c:493:24: sparse: expected restricted vm_fault_tarch/arm64/mm/fault.c:493:24: sparse: got intarch/arm64/mm/fault.c:501:32: sparse: warning: incorrect type in return expression (different base types)arch/arm64/mm/fault.c:501:32: sparse: expected restricted vm_fault_tarch/arm64/mm/fault.c:501:32: sparse: got intarch/arm64/mm/fault.c:503:32: sparse: warning: incorrect type in return expression (different base types)arch/arm64/mm/fault.c:503:32: sparse: expected restricted vm_fault_tarch/arm64/mm/fault.c:503:32: sparse: got intarch/arm64/mm/fault.c:511:24: sparse: warning: incorrect type in return expression (different base types)arch/arm64/mm/fault.c:511:24: sparse: expected restricted vm_fault_tarch/arm64/mm/fault.c:511:24: sparse: got intarch/arm64/mm/fault.c:670:13: sparse: warning: restricted vm_fault_t degrades to integer arch/arm64/mm/fault.c:670:13: sparse: warning: restricted vm_fault_t degrades to integer arch/arm64/mm/fault.c:713:39: sparse: warning: restricted vm_fault_t degrades to integer
--- arch/arm64/mm/fault.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/mm/fault.c +2 -2
@@ -376,8 +376,8 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re } } -#define VM_FAULT_BADMAP 0x010000 -#define VM_FAULT_BADACCESS 0x020000 +#define VM_FAULT_BADMAP ((__force vm_fault_t)0x010000) +#define VM_FAULT_BADACCESS ((__force vm_fault_t)0x020000) static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int mm_flags, unsigned long vm_flags,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 55/88 scsi: core: Decrease scsi_devices iorequest_cnt if dispatch failed
In reply to Greg Kroah-HartmanFrom: Wenchao Hao <[email protected]>
[ Upstream commit 09e797c8641f6ad435c33ae24c223351197ea29a ]
If scsi_dispatch_cmd() failed, the SCSI command was not sent to the target, scsi_queue_rq() would return BLK_STS_RESOURCE and the related request would be requeued. The timeout of this request would not fire, no one would increase iodone_cnt.
The above flow would result the iodone_cnt smaller than iorequest_cnt. So decrease the iorequest_cnt if dispatch failed to workaround the issue.
--- drivers/scsi/scsi_lib.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/scsi_lib.c +2 -0
@@ -1804,6 +1804,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)*/ SCSI_LOG_MLQUEUE (3 ,scmd_printk (KERN_INFO , cmd,"queuecommand : device blocked\n" )); +atomic_dec (&cmd->device->iorequest_cnt);return SCSI_MLQUEUE_DEVICE_BUSY ; }
@@ -1836,6 +1837,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)trace_scsi_dispatch_cmd_start (cmd); rtn = host->hostt->queuecommand (host, cmd);if (rtn) { +atomic_dec (&cmd->device->iorequest_cnt);trace_scsi_dispatch_cmd_error (cmd, rtn);if (rtn !=SCSI_MLQUEUE_DEVICE_BUSY && rtn !=SCSI_MLQUEUE_TARGET_BUSY )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 56/88 wifi: b43: fix incorrect __packed annotation
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 212457ccbd60dba34f965e4ffbe62f0e4f970538 ]
clang warns about an unpacked structure inside of a packed one:
drivers/net/wireless/broadcom/b43/b43.h:654:4: error: field data within 'struct b43_iv' is less aligned than 'union (unnamed union at /home/arnd/arm-soc/drivers/net/wireless/broadcom/b43/b43.h:651:2)' and is usually due to 'struct b43_iv' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
The problem here is that the anonymous union has the default alignment from its members, apparently because the original author mixed up the placement of the __packed attribute by placing it next to the struct member rather than the union definition. As the struct itself is also marked as __packed, there is no need to mark its members, so just move the annotation to the inner type instead.
As Michael noted, the same problem is present in b43legacy, so change both at the same time.
--- drivers/net/wireless/broadcom/b43/b43.h | 2 +- drivers/net/wireless/broadcom/b43legacy/b43legacy.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/b43/b43.h +1 -1
@@ -651,7 +651,7 @@ struct b43_iv {union {__be16 d16;__be32 d32; - } data __packed; + } __packed data; } __packed;
drivers/net/wireless/broadcom/b43legacy/b43legacy.h +1 -1
@@ -379,7 +379,7 @@ struct b43legacy_iv {union {__be16 d16;__be32 d32; - } data __packed; + } __packed data; } __packed;#define B43legacy_PHYMODE (phytype) (1 << (phytype))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 57/88 netfilter: conntrack: define variables exp_nat_nla_policy and any_addr with CONFIG_NF_NAT
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
[ Upstream commit 224a876e37543eee111bf9b6aa4935080e619335 ]
gcc with W=1 and ! CONFIG_NF_NAT net/netfilter/nf_conntrack_netlink.c:3463:32: error:
‘exp_nat_nla_policy’ defined but not used [-Werror=unused-const-variable=]
3463 | static const struct nla_policy exp_nat_nla_policy[CTA_EXPECT_NAT_MAX+1] = {
| ^~~~~~~~~~~~~~~~~~net/netfilter/nf_conntrack_netlink.c:2979:33: error:
‘any_addr’ defined but not used [-Werror=unused-const-variable=]
2979 | static const union nf_inet_addr any_addr;
| ^~~~~~~~
These variables use is controlled by CONFIG_NF_NAT, so should their definitions.
--- net/netfilter/nf_conntrack_netlink.c | 4 ++++ 1 file changed, 4 insertions(+)
net/netfilter/nf_conntrack_netlink.c +4 -0
@@ -2681,7 +2681,9 @@ static int ctnetlink_exp_dump_mask(struct sk_buff *skb,return -1 ; } +#if IS_ENABLED (CONFIG_NF_NAT )static const union nf_inet_addr any_addr; +#endif static __be32 nf_expect_get_id (const struct nf_conntrack_expect *exp) {
@@ -3181,10 +3183,12 @@ ctnetlink_change_expect(struct nf_conntrack_expect *x,return 0 ; } +#if IS_ENABLED (CONFIG_NF_NAT )static const struct nla_policy exp_nat_nla_policy[CTA_EXPECT_NAT_MAX +1 ] = { [CTA_EXPECT_NAT_DIR ] = { .type =NLA_U32 }, [CTA_EXPECT_NAT_TUPLE ] = { .type =NLA_NESTED }, }; +#endif static int ctnetlink_parse_expect_nat(const struct nlattr *attr,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 58/88 ALSA: oss: avoid missing-prototype warnings
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 040b5a046a9e18098580d3ccd029e2318fca7859 ]
Two functions are defined and used in pcm_oss.c but also optionally used from io.c, with an optional prototype. If CONFIG_SND_PCM_OSS_PLUGINS is disabled, this causes a warning as the functions are not static and have no prototype:
sound/core/oss/pcm_oss.c:1235:19: error: no previous prototype for 'snd_pcm_oss_write3' [-Werror=missing-prototypes] sound/core/oss/pcm_oss.c:1266:19: error: no previous prototype for 'snd_pcm_oss_read3' [-Werror=missing-prototypes]
Avoid this by making the prototypes unconditional.
--- sound/core/oss/pcm_plugin.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
sound/core/oss/pcm_plugin.h +8 -8
@@ -156,6 +156,14 @@ int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_channel,void *snd_pcm_plug_buf_alloc (struct snd_pcm_substream *plug,snd_pcm_uframes_t size);void snd_pcm_plug_buf_unlock (struct snd_pcm_substream *plug,void *ptr); +#else + +static inline snd_pcm_sframes_t snd_pcm_plug_client_size (struct snd_pcm_substream *handle,snd_pcm_uframes_t drv_size) {return drv_size; } +static inline snd_pcm_sframes_t snd_pcm_plug_slave_size (struct snd_pcm_substream *handle,snd_pcm_uframes_t clt_size) {return clt_size; } +static inline int snd_pcm_plug_slave_format (int format,const struct snd_mask *format_mask) {return format; } + +#endif +snd_pcm_sframes_t snd_pcm_oss_write3 (struct snd_pcm_substream *substream,const char *ptr,snd_pcm_uframes_t size,int in_kernel);
@@ -166,14 +174,6 @@ snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream,snd_pcm_sframes_t snd_pcm_oss_readv3 (struct snd_pcm_substream *substream,void **bufs,snd_pcm_uframes_t frames); -#else - -static inline snd_pcm_sframes_t snd_pcm_plug_client_size (struct snd_pcm_substream *handle,snd_pcm_uframes_t drv_size) {return drv_size; } -static inline snd_pcm_sframes_t snd_pcm_plug_slave_size (struct snd_pcm_substream *handle,snd_pcm_uframes_t clt_size) {return clt_size; } -static inline int snd_pcm_plug_slave_format (int format,const struct snd_mask *format_mask) {return format; } - -#endif -#ifdef PLUGIN_DEBUG #define pdprintf(fmt, args...) printk(KERN_DEBUG "plugin: " fmt, ##args)#else
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 59/88 atm: hide unused procfs functions
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit fb1b7be9b16c1f4626969ba4e95a97da2a452b41 ]
When CONFIG_PROC_FS is disabled, the function declarations for some procfs functions are hidden, but the definitions are still build, as shown by this compiler warning:
net/atm/resources.c:403:7: error: no previous prototype for 'atm_dev_seq_start' [-Werror=missing-prototypes] net/atm/resources.c:409:6: error: no previous prototype for 'atm_dev_seq_stop' [-Werror=missing-prototypes] net/atm/resources.c:414:7: error: no previous prototype for 'atm_dev_seq_next' [-Werror=missing-prototypes]
Add another #ifdef to leave these out of the build.
--- net/atm/resources.c | 2 ++ 1 file changed, 2 insertions(+)
net/atm/resources.c +2 -0
@@ -447,6 +447,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat)return error; } +#ifdef CONFIG_PROC_FS void *atm_dev_seq_start (struct seq_file *seq,loff_t *pos) {mutex_lock (&atm_dev_mutex);
@@ -462,3 +463,4 @@ void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) {return seq_list_next (v, &atm_devs, pos); } +#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 60/88 mailbox: mailbox-test: fix a locking issue in mbox_test_message_write()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 8fe72b76db79d694858e872370df49676bc3be8c ]
There was a bug where this code forgot to unlock the tdev->mutex if the kzalloc() failed. Fix this issue, by moving the allocation outside the lock.
--- drivers/mailbox/mailbox-test.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/mailbox/mailbox-test.c +6 -4
@@ -101,6 +101,7 @@ static ssize_t mbox_test_message_write(struct file *filp, size_t count, loff_t *ppos) { struct mbox_test_device *tdev = filp->private_data; +char *message;void *data;int ret;
@@ -116,12 +117,13 @@ static ssize_t mbox_test_message_write(struct file *filp,return -EINVAL ; } -mutex_lock (&tdev->mutex); - - tdev->message =kzalloc (MBOX_MAX_MSG_LEN ,GFP_KERNEL ); -if (!tdev->message) + message =kzalloc (MBOX_MAX_MSG_LEN ,GFP_KERNEL ); +if (!message)return -ENOMEM ; +mutex_lock (&tdev->mutex); + + tdev->message = message; ret =copy_from_user (tdev->message, userbuf, count);if (ret) { ret = -EFAULT ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 61/88 iio: adc: mxs-lradc: fix the order of two cleanup operations
In reply to Greg Kroah-HartmanFrom: Jiakai Luo <[email protected]>
commit 27b2ed5b6d53cd62fc61c3f259ae52f5cac23b66 upstream.
Smatch reports:drivers/iio/adc/mxs-lradc-adc.c:766 mxs_lradc_adc_probe() warn:
missing unwind goto?
the order of three init operation:
1.mxs_lradc_adc_trigger_init
2.iio_triggered_buffer_setup
3.mxs_lradc_adc_hw_init
thus, the order of three cleanup operation should be:
1.mxs_lradc_adc_hw_stop 2.iio_triggered_buffer_cleanup 3.mxs_lradc_adc_trigger_remove
we exchange the order of two cleanup operations, introducing the following differences:
1.if mxs_lradc_adc_trigger_init fails, returns directly; 2.if trigger_init succeeds but iio_triggered_buffer_setup fails, goto err_trig and remove the trigger.
In addition, we also reorder the unwind that goes on in the remove() callback to match the new ordering.
--- drivers/iio/adc/mxs-lradc-adc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/iio/adc/mxs-lradc-adc.c +5 -5
@@ -767,13 +767,13 @@ static int mxs_lradc_adc_probe(struct pl ret =mxs_lradc_adc_trigger_init (iio);if (ret) - goto err_trig; +return ret; ret =iio_triggered_buffer_setup (iio, &iio_pollfunc_store_time, &mxs_lradc_adc_trigger_handler, &mxs_lradc_adc_buffer_ops);if (ret) -return ret; + goto err_trig; adc->vref_mv = mxs_lradc_adc_vref_mv[lradc->soc];
@@ -811,9 +811,9 @@ static int mxs_lradc_adc_probe(struct pl err_dev:mxs_lradc_adc_hw_stop (adc); -mxs_lradc_adc_trigger_remove (iio); -err_trig:iio_triggered_buffer_cleanup (iio); +err_trig: +mxs_lradc_adc_trigger_remove (iio);return ret; }
@@ -824,8 +824,8 @@ static int mxs_lradc_adc_remove(struct piio_device_unregister (iio);mxs_lradc_adc_hw_stop (adc); -mxs_lradc_adc_trigger_remove (iio);iio_triggered_buffer_cleanup (iio); +mxs_lradc_adc_trigger_remove (iio);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 62/88 HID: google: add jewel USB id
In reply to Greg Kroah-HartmanFrom: Sung-Chi Li <[email protected]>
commit ed84c4517a5bc536e8572a01dfa11bc22a280d06 upstream.
Add 1 additional hammer-like device.
--- drivers/hid/hid-google-hammer.c | 2 ++ drivers/hid/hid-ids.h | 1 + 2 files changed, 3 insertions(+)
drivers/hid/hid-google-hammer.c +2 -0
@@ -125,6 +125,8 @@ static const struct hid_device_id hammer {HID_DEVICE (BUS_USB ,HID_GROUP_GENERIC , USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_HAMMER) }, { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, + USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_JEWEL) }, + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MAGNEMITE) }, { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MASTERBALL) },
drivers/hid/hid-ids.h +1 -0
@@ -480,6 +480,7 @@#define USB_DEVICE_ID_GOOGLE_MOONBALL 0x5044#define USB_DEVICE_ID_GOOGLE_DON 0x5050#define USB_DEVICE_ID_GOOGLE_EEL 0x5057 +#define USB_DEVICE_ID_GOOGLE_JEWEL 0x5061#define USB_VENDOR_ID_GOTOP 0x08f2#define USB_DEVICE_ID_SUPER_Q2 0x007f
Greg Kroah-Hartman
maintainerPATCH 63/88 HID: wacom: avoid integer overflow in wacom_intuos_inout()
In reply to Greg Kroah-HartmanFrom: Nikita Zhandarovich <[email protected]>
commit bd249b91977b768ea02bf84d04625d2690ad2b98 upstream.
If high bit is set to 1 in ((data[3] & 0x0f << 28), after all arithmetic operations and integer promotions are done, high bits in wacom->serial[idx] will be filled with 1s as well.
Avoid this, albeit unlikely, issue by specifying left operand's __u64 type for the right operand.
Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE.
--- drivers/hid/wacom_wac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/wacom_wac.c +1 -1
@@ -781,7 +781,7 @@ static int wacom_intuos_inout(struct wac/* Enter report */ if ((data[1 ] &0xfc ) ==0xc0 ) {/* serial number of the tool */ - wacom->serial[idx] = ((data[3 ] &0x0f ) <<28 ) + + wacom->serial[idx] = ((__u64)(data[3 ] &0x0f ) <<28 ) + (data[4 ] <<20 ) + (data[5 ] <<12 ) + (data[6 ] <<4 ) + (data[7 ] >>4 );
Greg Kroah-Hartman
maintainerPATCH 64/88 iio: dac: mcp4725: Fix i2c_master_send() return value handling
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
commit 09d3bec7009186bdba77039df01e5834788b3f95 upstream.
The i2c_master_send() returns number of sent bytes on success, or negative on error. The suspend/resume callbacks expect zero on success and non-zero on error. Adapt the return value of the i2c_master_send() to the expectation of the suspend and resume callbacks, including proper validation of the return value.
--- drivers/iio/dac/mcp4725.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/iio/dac/mcp4725.c +14 -2
@@ -50,12 +50,18 @@ static int mcp4725_suspend(struct devicestruct mcp4725_data *data =iio_priv (i2c_get_clientdata (to_i2c_client (dev)));u8 outbuf[2 ]; +int ret; outbuf[0 ] = (data->powerdown_mode +1 ) <<4 ; outbuf[1 ] =0 ; data->powerdown = true; -return i2c_master_send (data->client, outbuf,2 ); + ret =i2c_master_send (data->client, outbuf,2 ); +if (ret <0 ) +return ret; +else if (ret !=2 ) +return -EIO ; +return 0 ; }static int mcp4725_resume (struct device *dev)
@@ -63,13 +69,19 @@ static int mcp4725_resume(struct devicestruct mcp4725_data *data =iio_priv (i2c_get_clientdata (to_i2c_client (dev)));u8 outbuf[2 ]; +int ret;/* restore previous DAC value */ outbuf[0 ] = (data->dac_value >>8 ) &0xf ; outbuf[1 ] = data->dac_value &0xff ; data->powerdown = false; -return i2c_master_send (data->client, outbuf,2 ); + ret =i2c_master_send (data->client, outbuf,2 ); +if (ret <0 ) +return ret; +else if (ret !=2 ) +return -EIO ; +return 0 ; }#ifdef CONFIG_PM_SLEEP
Greg Kroah-Hartman
maintainerPATCH 65/88 iio: dac: build ad5758 driver when AD5758 is selected
In reply to Greg Kroah-HartmanFrom: Lukas Bulwahn <[email protected]>
commit a146eccb68be161ae9eab5f3f68bb0ed7c0fbaa8 upstream.
Commit 28d1a7ac2a0d ("iio: dac: Add AD5758 support") adds the config AD5758 and the corresponding driver ad5758.c. In the Makefile, the ad5758 driver is however included when AD5755 is selected, not when AD5758 is selected.
Probably, this was simply a mistake that happened by copy-and-paste and forgetting to adjust the actual line. Surprisingly, no one has ever noticed that this driver is actually only included when AD5755 is selected and that the config AD5758 has actually no effect on the build.
--- drivers/iio/dac/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/Makefile +1 -1
@@ -16,7 +16,7 @@ obj-$(CONFIG_AD5592R_BASE) += ad5592r-ba obj-$(CONFIG_AD5592R) += ad5592r.o obj-$(CONFIG_AD5593R) += ad5593r.o obj-$(CONFIG_AD5755) += ad5755.o -obj-$(CONFIG_AD5755) += ad5758.o +obj-$(CONFIG_AD5758) += ad5758.o obj-$(CONFIG_AD5761) += ad5761.o obj-$(CONFIG_AD5764) += ad5764.o obj-$(CONFIG_AD5791) += ad5791.o
Greg Kroah-Hartman
maintainerPATCH 66/88 net: usb: qmi_wwan: Set DTR quirk for BroadMobi BM818
In reply to Greg Kroah-HartmanFrom: Sebastian Krzyszkowiak <[email protected]>
commit 36936a56e1814f6c526fe71fbf980beab4f5577a upstream.
BM818 is based on Qualcomm MDM9607 chipset.
--- drivers/net/usb/qmi_wwan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/qmi_wwan.c +1 -1
@@ -1285,7 +1285,7 @@ static const struct usb_device_id produc {QMI_FIXED_INTF(0x2001, 0x7e3d, 4)}, /* D-Link DWM-222 A2 */ {QMI_FIXED_INTF(0x2020, 0x2031, 4)}, /* Olicard 600 */ {QMI_FIXED_INTF(0x2020, 0x2033, 4)}, /* BroadMobi BM806U */ - {QMI_FIXED_INTF(0x2020, 0x2060, 4)}, /* BroadMobi BM818 */ + {QMI_QUIRK_SET_DTR(0x2020, 0x2060, 4)}, /* BroadMobi BM818 */ {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */ {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */ {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */
Greg Kroah-Hartman
maintainerPATCH 67/88 usb: gadget: f_fs: Add unbind event before functionfs_unbind
In reply to Greg Kroah-HartmanFrom: Uttkarsh Aggarwal <[email protected]>
commit efb6b535207395a5c7317993602e2503ca8cb4b3 upstream.
While exercising the unbind path, with the current implementation the functionfs_unbind would be calling which waits for the ffs->mutex to be available, however within the same time ffs_ep0_read is invoked & if no setup packets are pending, it will invoke function wait_event_interruptible_exclusive_locked_irq which by definition waits for the ev.count to be increased inside the same mutex for which functionfs_unbind is waiting.
This creates deadlock situation because the functionfs_unbind won't get the lock until ev.count is increased which can only happen if the caller ffs_func_unbind can proceed further.
Following is the illustration:
CPU1 CPU2
ffs_func_unbind() ffs_ep0_read()
mutex_lock(ffs->mutex) wait_event(ffs->ev.count)
functionfs_unbind()
mutex_lock(ffs->mutex)
mutex_unlock(ffs->mutex)
ffs_event_add()
<deadlock>
Fix this by moving the event unbind before functionfs_unbind to ensure the ev.count is incrased properly.
--- drivers/usb/gadget/function/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_fs.c +1 -1
@@ -3510,6 +3510,7 @@ static void ffs_func_unbind(struct usb_c/* Drain any pending AIO completions */ drain_workqueue (ffs->io_completion_wq); +ffs_event_add (ffs,FUNCTIONFS_UNBIND );if (!--opts->refcnt)functionfs_unbind (ffs);
@@ -3534,7 +3535,6 @@ static void ffs_func_unbind(struct usb_c func->function.ssp_descriptors =NULL ; func->interfaces_nums =NULL ; -ffs_event_add (ffs,FUNCTIONFS_UNBIND ); }static struct usb_function *ffs_alloc (struct usb_function_instance *fi)
Greg Kroah-Hartman
maintainerPATCH 68/88 scsi: stex: Fix gcc 13 warnings
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
commit 6d074ce231772c66e648a61f6bd2245e7129d1f5 upstream.
gcc 13 may assign another type to enumeration constants than gcc 12. Split the large enum at the top of source file stex.c such that the type of the constants used in time expressions is changed back to the same type chosen by gcc 12. This patch suppresses compiler warnings like this one:
In file included from ./include/linux/bitops.h:7,
from ./include/linux/kernel.h:22,
from drivers/scsi/stex.c:13:drivers/scsi/stex.c: In function ‘stex_common_handshake’:./include/linux/typecheck.h:12:25: error: comparison of distinct pointer types lacks a cast [-Werror]
12 | (void)(&__dummy == &__dummy2); \
| ^~./include/linux/jiffies.h:106:10: note: in expansion of macro ‘typecheck’
106 | typecheck(unsigned long, b) && \
| ^~~~~~~~~
drivers/scsi/stex.c:1035:29: note: in expansion of macro ‘time_after’
1035 | if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) {
| ^~~~~~~~~~See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107405.
--- drivers/scsi/stex.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/stex.c +4 -0
@@ -114,7 +114,9 @@ enum {TASK_ATTRIBUTE_HEADOFQUEUE =0x1 ,TASK_ATTRIBUTE_ORDERED =0x2 , TASK_ATTRIBUTE_ACA = 0x4, +}; +enum {SS_STS_NORMAL =0x80000000 ,SS_STS_DONE =0x40000000 , SS_STS_HANDSHAKE = 0x20000000,
@@ -126,7 +128,9 @@ enum {SS_I2H_REQUEST_RESET =0x2000 , SS_MU_OPERATIONAL = 0x80000000, +}; +enum {STEX_CDB_LENGTH =16 , STATUS_VAR_LEN = 128,
Greg Kroah-Hartman
maintainerPATCH 69/88 ata: libata-scsi: Use correct device no in ata_find_dev()
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
commit 7f875850f20a42f488840c9df7af91ef7db2d576 upstream.
For devices not attached to a port multiplier and managed directly by libata, the device number passed to ata_find_dev() must always be lower than the maximum number of devices returned by ata_link_max_devices(). That is 1 for SATA devices or 2 for an IDE link with master+slave devices. This device number is the SCSI device ID which matches these constraints as the IDs are generated per port and so never exceed the maximum number of devices for the link being used.
However, for libsas managed devices, SCSI device IDs are assigned per struct scsi_host, leading to device IDs for SATA devices that can be well in excess of libata per-link maximum number of devices. This results in ata_find_dev() to always return NULL for libsas managed devices except for the first device of the target scsi_host with ID (device number) equal to 0. This issue is visible by executing the hdparm utility, which fails. E.g.:
hdparm -i /dev/sdX/dev/sdX:
HDIO_GET_IDENTITY failed: No message of desired type
Fix this by rewriting ata_find_dev() to ignore the device number for non-PMP attached devices with a link with at most 1 device, that is SATA devices. For these, the device number 0 is always used to return the correct pointer to the struct ata_device of the port link. This change excludes IDE master/slave setups (maximum number of devices per link is 2) and port-multiplier attached devices. Also, to be consistant with the fact that SCSI device IDs and channel numbers used as device numbers are both unsigned int, change the devno argument of ata_find_dev() to unsigned int.
--- drivers/ata/libata-scsi.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)
drivers/ata/libata-scsi.c +26 -8
@@ -3053,18 +3053,36 @@ static unsigned int atapi_xlat(struct atreturn 0 ; } -static struct ata_device *ata_find_dev (struct ata_port *ap,int devno) +static struct ata_device *ata_find_dev (struct ata_port *ap,unsigned int devno) { -if (!sata_pmp_attached (ap)) { -if (likely (devno >=0 && - devno <ata_link_max_devices (&ap->link))) +/* +* For the non-PMP case, ata_link_max_devices() returns 1 (SATA case), +* or 2 (IDE master + slave case). However, the former case includes +* libsas hosted devices which are numbered per scsi host, leading +* to devno potentially being larger than 0 but with each struct +* ata_device having its own struct ata_port and struct ata_link. +* To accommodate these, ignore devno and always use device number 0. +*/ +if (likely (!sata_pmp_attached (ap))) { +int link_max_devices =ata_link_max_devices (&ap->link); + +if (link_max_devices ==1 ) +return &ap->link.device[0 ]; + +if (devno < link_max_devices)return &ap->link.device[devno]; - }else { -if (likely (devno >=0 && - devno < ap->nr_pmp_links)) -return &ap->pmp_link[devno].device[0 ]; + +return NULL ; } +/* +* For PMP-attached devices, the device number corresponds to C +* (channel) of SCSI [H:C:I:L], indicating the port pmp link +* for the device. +*/ +if (devno < ap->nr_pmp_links) +return &ap->pmp_link[devno].device[0 ]; +return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 70/88 x86/boot: Wrap literal addresses in absolute_pointer()
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit aeb84412037b89e06f45e382f044da6f200e12f8 upstream.
GCC 11 (incorrectly[1]) assumes that literal values cast to (void *) should be treated like a NULL pointer with an offset, and raises diagnostics when doing bounds checking under -Warray-bounds. GCC 12 got "smarter" about finding these:
In function 'rdfs8',
inlined from 'vga_recalc_vertical' at /srv/code/arch/x86/boot/video-mode.c:124:29,
inlined from 'set_mode' at /srv/code/arch/x86/boot/video-mode.c:163:3:
/srv/code/arch/x86/boot/boot.h:114:9: warning: array subscript 0 is outside array bounds of 'u8[0]' {aka 'unsigned char[]'} [-Warray-bounds]
114 | asm volatile("movb %%fs:%1,%0" : "=q" (v) : "m" (*(u8 *)addr));
| ^~~This has been solved in other places[2] already by using the recently added absolute_pointer() macro. Do the same here.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
[2] https://lore.kernel.org/all/[email protected]/
--- arch/x86/boot/boot.h | 36 ++++++++++++++++++++++++------------ arch/x86/boot/main.c | 2 +- 2 files changed, 25 insertions(+), 13 deletions(-)
arch/x86/boot/boot.h +24 -12
@@ -114,66 +114,78 @@ typedef unsigned int addr_t;static inline u8 rdfs8 (addr_t addr) { +u8 *ptr = (u8 *)absolute_pointer (addr);u8 v; - asmvolatile ("movb %%fs:%1,%0" :"=q" (v) :"m" (*(u8 *)addr)); + asmvolatile ("movb %%fs:%1,%0" :"=q" (v) :"m" (*ptr));return v; }static inline u16 rdfs16 (addr_t addr) { +u16 *ptr = (u16 *)absolute_pointer (addr);u16 v; - asmvolatile ("movw %%fs:%1,%0" :"=r" (v) :"m" (*(u16 *)addr)); + asmvolatile ("movw %%fs:%1,%0" :"=r" (v) :"m" (*ptr));return v; }static inline u32 rdfs32 (addr_t addr) { +u32 *ptr = (u32 *)absolute_pointer (addr);u32 v; - asmvolatile ("movl %%fs:%1,%0" :"=r" (v) :"m" (*(u32 *)addr)); + asmvolatile ("movl %%fs:%1,%0" :"=r" (v) :"m" (*ptr));return v; }static inline void wrfs8 (u8 v,addr_t addr) { - asmvolatile ("movb %1,%%fs:%0" :"+m" (*(u8 *)addr) :"qi" (v)); +u8 *ptr = (u8 *)absolute_pointer (addr); + asmvolatile ("movb %1,%%fs:%0" :"+m" (*ptr) :"qi" (v)); }static inline void wrfs16 (u16 v,addr_t addr) { - asmvolatile ("movw %1,%%fs:%0" :"+m" (*(u16 *)addr) :"ri" (v)); +u16 *ptr = (u16 *)absolute_pointer (addr); + asmvolatile ("movw %1,%%fs:%0" :"+m" (*ptr) :"ri" (v)); }static inline void wrfs32 (u32 v,addr_t addr) { - asmvolatile ("movl %1,%%fs:%0" :"+m" (*(u32 *)addr) :"ri" (v)); +u32 *ptr = (u32 *)absolute_pointer (addr); + asmvolatile ("movl %1,%%fs:%0" :"+m" (*ptr) :"ri" (v)); }static inline u8 rdgs8 (addr_t addr) { +u8 *ptr = (u8 *)absolute_pointer (addr);u8 v; - asmvolatile ("movb %%gs:%1,%0" :"=q" (v) :"m" (*(u8 *)addr)); + asmvolatile ("movb %%gs:%1,%0" :"=q" (v) :"m" (*ptr));return v; }static inline u16 rdgs16 (addr_t addr) { +u16 *ptr = (u16 *)absolute_pointer (addr);u16 v; - asmvolatile ("movw %%gs:%1,%0" :"=r" (v) :"m" (*(u16 *)addr)); + asmvolatile ("movw %%gs:%1,%0" :"=r" (v) :"m" (*ptr));return v; }static inline u32 rdgs32 (addr_t addr) { +u32 *ptr = (u32 *)absolute_pointer (addr);u32 v; - asmvolatile ("movl %%gs:%1,%0" :"=r" (v) :"m" (*(u32 *)addr)); + asmvolatile ("movl %%gs:%1,%0" :"=r" (v) :"m" (*ptr));return v; }static inline void wrgs8 (u8 v,addr_t addr) { - asmvolatile ("movb %1,%%gs:%0" :"+m" (*(u8 *)addr) :"qi" (v)); +u8 *ptr = (u8 *)absolute_pointer (addr); + asmvolatile ("movb %1,%%gs:%0" :"+m" (*ptr) :"qi" (v)); }static inline void wrgs16 (u16 v,addr_t addr) { - asmvolatile ("movw %1,%%gs:%0" :"+m" (*(u16 *)addr) :"ri" (v)); +u16 *ptr = (u16 *)absolute_pointer (addr); + asmvolatile ("movw %1,%%gs:%0" :"+m" (*ptr) :"ri" (v)); }static inline void wrgs32 (u32 v,addr_t addr) { - asmvolatile ("movl %1,%%gs:%0" :"+m" (*(u32 *)addr) :"ri" (v)); +u32 *ptr = (u32 *)absolute_pointer (addr); + asmvolatile ("movl %1,%%gs:%0" :"+m" (*ptr) :"ri" (v)); }/* Note: these only return true/false, not a signed return value! */
arch/x86/boot/main.c +1 -1
@@ -34,7 +34,7 @@ static void copy_boot_params(void)u16 cl_offset; };const struct old_cmdline *const oldcmd = - (const struct old_cmdline *)OLD_CL_ADDRESS ; +absolute_pointer (OLD_CL_ADDRESS );BUILD_BUG_ON (sizeof boot_params !=4096 );memcpy (&boot_params.hdr, &hdr,sizeof hdr);
Greg Kroah-Hartman
maintainerPATCH 71/88 ACPI: thermal: drop an always true check
In reply to Greg Kroah-HartmanFrom: Adam Borowski <[email protected]>
commit e5b5d25444e9ee3ae439720e62769517d331fa39 upstream.
Address of a field inside a struct can't possibly be null; gcc-12 warns about this.
--- drivers/acpi/thermal.c | 2 -- 1 file changed, 2 deletions(-)
drivers/acpi/thermal.c +0 -2
@@ -1172,8 +1172,6 @@ static int acpi_thermal_resume(struct dereturn -EINVAL ;for (i =0 ; i <ACPI_THERMAL_MAX_ACTIVE ; i++) { -if (!(&tz->trips.active[i])) -break ;if (!tz->trips.active[i].flags.valid)break ; tz->trips.active[i].flags.enabled =1 ;
Greg Kroah-Hartman
maintainerPATCH 72/88 gcc-12: disable -Wdangling-pointer warning for now
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit f7d63b50898172b9eb061b9e2daad61b428792d0 upstream.
[ Upstream commit 49beadbd47c270a00754c107a837b4f29df4c822 ]
While the concept of checking for dangling pointers to local variables at function exit is really interesting, the gcc-12 implementation is not compatible with reality, and results in false positives.
For example, gcc sees us putting things on a local list head allocated on the stack, which involves exactly those kinds of pointers to the local stack entry:
In function ‘__list_add’,
inlined from ‘list_add_tail’ at include/linux/list.h:102:2,
inlined from ‘rebuild_snap_realms’ at fs/ceph/snap.c:434:2:
include/linux/list.h:74:19: warning: storing the address of local variable ‘realm_queue’ in ‘*&realm_27(D)->rebuild_item.prev’ [-Wdangling-pointer=]
74 | new->prev = prev;
| ~~~~~~~~~~^~~~~~But then gcc - understandably - doesn't really understand the big picture how the doubly linked list works, so doesn't see how we then end up emptying said list head in a loop and the pointer we added has been removed.
Gcc also complains about us (intentionally) using this as a way to store a kind of fake stack trace, eg
drivers/acpi/acpica/utdebug.c:40:38: warning: storing the address of local variable ‘current_sp’ in ‘acpi_gbl_entry_stack_pointer’ [-Wdangling-pointer=]
40 | acpi_gbl_entry_stack_pointer = ¤t_sp;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~which is entirely reasonable from a compiler standpoint, and we may want to change those kinds of patterns, but not not.
So this is one of those "it would be lovely if the compiler were to complain about us leaving dangling pointers to the stack", but not this way.
--- Makefile | 4 ++++ 1 file changed, 4 insertions(+)
Makefile +4 -0
@@ -730,6 +730,10 @@ endif KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) + +# These result in bogus false positives +KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer) + ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls else
Greg Kroah-Hartman
maintainerPATCH 73/88 eth: sun: cassini: remove dead code
In reply to Greg Kroah-HartmanFrom: Martin Liška <[email protected]>
commit 32329216ca1d6ee29c41215f18b3053bb6158541 upstream.
Fixes the following GCC warning:
drivers/net/ethernet/sun/cassini.c:1316:29: error: comparison between two arrays [-Werror=array-compare] drivers/net/ethernet/sun/cassini.c:3783:34: error: comparison between two arrays [-Werror=array-compare]
Note that 2 arrays should be compared by comparing of their addresses:
note: use ‘&cas_prog_workaroundtab[0] == &cas_prog_null[0]’ to compare the addresses
--- drivers/net/ethernet/sun/cassini.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/sun/cassini.c +2 -2
@@ -1337,7 +1337,7 @@ static void cas_init_rx_dma(struct cas *writel (val, cp->regs +REG_RX_PAGE_SIZE );/* enable the header parser if desired */ -if (CAS_HP_FIRMWARE == cas_prog_null) +if (&CAS_HP_FIRMWARE [0 ] == &cas_prog_null[0 ])return ; val =CAS_BASE (HP_CFG_NUM_CPU ,CAS_NCPUS >63 ?0 :CAS_NCPUS );
@@ -3807,7 +3807,7 @@ static void cas_reset(struct cas *cp, in/* program header parser */ if ((cp->cas_flags &CAS_FLAG_TARGET_ABORT ) || - (CAS_HP_ALT_FIRMWARE == cas_prog_null)) { + (&CAS_HP_ALT_FIRMWARE [0 ] == &cas_prog_null[0 ])) {cas_load_firmware (cp,CAS_HP_FIRMWARE ); }else {cas_load_firmware (cp,CAS_HP_ALT_FIRMWARE );
Greg Kroah-Hartman
maintainerPATCH 74/88 kernel/extable.c: use address-of operator on section symbols
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 63174f61dfaef58dc0e813eaf6602636794f8942 upstream.
Clang warns:
../kernel/extable.c:37:52: warning: array comparison always evaluates to a constant [-Wtautological-compare]
if (main_extable_sort_needed && __stop___ex_table > __start___ex_table) {
^1 warning generated.
These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).
--- kernel/extable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/extable.c +2 -1
@@ -46,7 +46,8 @@ u32 __initdata __visible main_extable_so/* Sort the kernel's built-in exception table */ void __init sort_main_extable (void ) { -if (main_extable_sort_needed && __stop___ex_table > __start___ex_table) { +if (main_extable_sort_needed && + &__stop___ex_table > &__start___ex_table) {pr_notice ("Sorting __ex_table...\n" );sort_extable (__start___ex_table, __stop___ex_table); }
Greg Kroah-Hartman
maintainerPATCH 75/88 lib/dynamic_debug.c: use address-of operator on section symbols
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 8306b057a85ec07482da5d4b99d5c0b47af69be1 upstream.
Clang warns:
../lib/dynamic_debug.c:1034:24: warning: array comparison always evaluates to false [-Wtautological-compare]
if (__start___verbose == __stop___verbose) {
^1 warning generated.
These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).
--- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dynamic_debug.c +1 -1
@@ -984,7 +984,7 @@ static int __init dynamic_debug_init(voiint n =0 , entries =0 , modct =0 ;int verbose_bytes =0 ; -if (__start___verbose == __stop___verbose) { +if (&__start___verbose == &__stop___verbose) {pr_warn ("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n" );return 1 ; }
Greg Kroah-Hartman
maintainerPATCH 76/88 wifi: rtlwifi: remove always-true condition pointed out by GCC 12
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
commit ee3db469dd317e82f57b13aa3bc61be5cb60c2b4 upstream.
The .value is a two-dim array, not a pointer.
struct iqk_matrix_regs {
bool iqk_done;
long value[1][IQK_MATRIX_REG_NUM];
};--- drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c +1 -4
@@ -2414,10 +2414,7 @@ void rtl92d_phy_reload_iqk_setting(strucRT_TRACE (rtlpriv,COMP_SCAN ,DBG_LOUD ,"Just Read IQK Matrix reg for channel:%d....\n" , channel); -if ((rtlphy->iqk_matrix[indexforchannel]. - value[0 ] !=NULL ) -/*&&(regea4 != 0) */ ) - _rtl92d_phy_patha_fill_iqk_matrix(hw, true, + _rtl92d_phy_patha_fill_iqk_matrix(hw, true, rtlphy->iqk_matrix[ indexforchannel].value, 0, (rtlphy->iqk_matrix[
Greg Kroah-Hartman
maintainerPATCH 77/88 hwmon: (scmi) Remove redundant pointer check
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit a31796c30e423f58d266df30a9bbf321fc071b30 upstream.
Clang warns when the address of a pointer is used in a boolean context as it will always return true.
drivers/hwmon/scmi-hwmon.c:59:24: warning: address of array 'sensor->name' will always evaluate to 'true' [-Wpointer-bool-conversion]
if (sensor && sensor->name)
~~ ~~~~~~~~^~~~1 warning generated.
Remove the check as it isn't doing anything currently; if validation of the contents of the data structure was intended by the original author (since this line has been present from the first version of this driver), it can be added in a follow-up patch.
--- drivers/hwmon/scmi-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/scmi-hwmon.c +1 -1
@@ -56,7 +56,7 @@ scmi_hwmon_is_visible(const void *drvdatconst struct scmi_sensors *scmi_sensors = drvdata; sensor = *(scmi_sensors->info[type] + channel); -if (sensor && sensor->name) +if (sensor)return S_IRUGO ;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 78/88 regulator: da905{2,5}: Remove unnecessary array check
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 5a7d7d0f9f791b1e13f26dbbb07c86482912ad62 upstream.
Clang warns that the address of a pointer will always evaluated as true in a boolean context:
drivers/regulator/da9052-regulator.c:423:22: warning: address of array 'pdata->regulators' will always evaluate to 'true' [-Wpointer-bool-conversion]
if (pdata && pdata->regulators) {
~~ ~~~~~~~^~~~~~~~~~
drivers/regulator/da9055-regulator.c:615:22: warning: address of array
'pdata->regulators' will always evaluate to 'true'
[-Wpointer-bool-conversion]
if (pdata && pdata->regulators) {
~~ ~~~~~~~^~~~~~~~~~--- drivers/regulator/da9052-regulator.c | 2 +- drivers/regulator/da9055-regulator.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/da9052-regulator.c +1 -1
@@ -421,7 +421,7 @@ static int da9052_regulator_probe(struct config.dev = &pdev->dev; config.driver_data = regulator; config.regmap = da9052->regmap; -if (pdata && pdata->regulators) { +if (pdata) { config.init_data = pdata->regulators[cell->id]; }else {#ifdef CONFIG_OF
drivers/regulator/da9055-regulator.c +1 -1
@@ -612,7 +612,7 @@ static int da9055_regulator_probe(struct config.driver_data = regulator; config.regmap = da9055->regmap; -if (pdata && pdata->regulators) { +if (pdata) { config.init_data = pdata->regulators[pdev->id]; }else { ret = da9055_regulator_dt_init(pdev, regulator, &config,
Greg Kroah-Hartman
maintainerPATCH 79/88 rsi: Remove unnecessary boolean condition
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit f613e4803dd6d1f41a86f6406d4c994fa3d387a0 upstream.
Clang warns that the address of a pointer will always evaluated as true in a boolean context.
drivers/net/wireless/rsi/rsi_91x_mac80211.c:927:50: warning: address of array 'key->key' will always evaluate to 'true' [-Wpointer-bool-conversion]
if (vif->type == NL80211_IFTYPE_STATION && key->key &&
~~ ~~~~~^~~1 warning generated.
--- drivers/net/wireless/rsi/rsi_91x_mac80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/rsi/rsi_91x_mac80211.c +1 -1
@@ -924,7 +924,7 @@ static int rsi_hal_key_config(struct ieeif (status)return status; -if (vif->type ==NL80211_IFTYPE_STATION && key->key && +if (vif->type ==NL80211_IFTYPE_STATION && (key->cipher ==WLAN_CIPHER_SUITE_WEP104 || key->cipher ==WLAN_CIPHER_SUITE_WEP40 )) {if (!rsi_send_block_unblock_frame (adapter->priv, false))
Greg Kroah-Hartman
maintainerPATCH 80/88 mmc: vub300: fix invalid response handling
In reply to Greg Kroah-HartmanFrom: Deren Wu <[email protected]>
commit a99d21cefd351c8aaa20b83a3c942340e5789d45 upstream.
We may get an empty response with zero length at the beginning of the driver start and get following UBSAN error. Since there is no content(SDRT_NONE) for the response, just return and skip the response handling to avoid this problem.
Test pass : SDIO wifi throughput test with this patch
[ 126.980684] UBSAN: array-index-out-of-bounds in drivers/mmc/host/vub300.c:1719:12 [ 126.980709] index -1 is out of range for type 'u32 [4]' [ 126.980729] CPU: 4 PID: 9 Comm: kworker/u16:0 Tainted: G E 6.3.0-rc4-mtk-local-202304272142 #1 [ 126.980754] Hardware name: Intel(R) Client Systems NUC8i7BEH/NUC8BEB, BIOS BECFL357.86A.0081.2020.0504.1834 05/04/2020 [ 126.980770] Workqueue: kvub300c vub300_cmndwork_thread [vub300] [ 126.980833] Call Trace: [ 126.980845] <TASK> [ 126.980860] dump_stack_lvl+0x48/0x70 [ 126.980895] dump_stack+0x10/0x20 [ 126.980916] ubsan_epilogue+0x9/0x40 [ 126.980944] __ubsan_handle_out_of_bounds+0x70/0x90 [ 126.980979] vub300_cmndwork_thread+0x58e7/0x5e10 [vub300] [ 126.981018] ? _raw_spin_unlock+0x18/0x40 [ 126.981042] ? finish_task_switch+0x175/0x6f0 [ 126.981070] ? __switch_to+0x42e/0xda0 [ 126.981089] ? __switch_to_asm+0x3a/0x80 [ 126.981129] ? __pfx_vub300_cmndwork_thread+0x10/0x10 [vub300] [ 126.981174] ? __kasan_check_read+0x11/0x20 [ 126.981204] process_one_work+0x7ee/0x13d0 [ 126.981246] worker_thread+0x53c/0x1240 [ 126.981291] kthread+0x2b8/0x370 [ 126.981312] ? __pfx_worker_thread+0x10/0x10 [ 126.981336] ? __pfx_kthread+0x10/0x10 [ 126.981359] ret_from_fork+0x29/0x50 [ 126.981400] </TASK>
--- drivers/mmc/host/vub300.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/vub300.c +3 -0
@@ -1718,6 +1718,9 @@ static void construct_request_response(sint bytes =3 & less_cmd;int words = less_cmd >>2 ;u8 *r = vub300->resp.response.command_response; + +if (!resp_len) +return ;if (bytes ==3 ) { cmd->resp[words] = (r[1 + (words <<2 )] <<24 ) | (r[2 + (words <<2 )] <<16 )
Greg Kroah-Hartman
maintainerPATCH 81/88 tty: serial: fsl_lpuart: use UARTCTRL_TXINV to send break instead of UARTCTRL_SBK
In reply to Greg Kroah-HartmanFrom: Sherry Sun <[email protected]>
commit 2474e05467c00f7d51af3039b664de6886325257 upstream.
LPUART IP now has two known bugs, one is that CTS has higher priority than the break signal, which causes the break signal sending through UARTCTRL_SBK may impacted by the CTS input if the HW flow control is enabled. It exists on all platforms we support in this driver. So we add a workaround patch for this issue: commit c4c81db5cf8b ("tty: serial: fsl_lpuart: disable the CTS when send break signal").
Another IP bug is i.MX8QM LPUART may have an additional break character being sent after SBK was cleared. It may need to add some delay between clearing SBK and re-enabling CTS to ensure that the SBK latch are completely cleared.
But we found that during the delay period before CTS is enabled, there is still a risk that Bluetooth data in TX FIFO may be sent out during this period because of break off and CTS disabled(even if BT sets CTS line deasserted, data is still sent to BT).
Due to this risk, we have to drop the CTS-disabling workaround for SBK bugs, use TXINV seems to be a better way to replace SBK feature and avoid above risk. Also need to disable the transmitter to prevent any data from being sent out during break, then invert the TX line to send break. Then disable the TXINV when turn off break and re-enable transmitter.
--- drivers/tty/serial/fsl_lpuart.c | 44 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 21 deletions(-)
drivers/tty/serial/fsl_lpuart.c +23 -21
@@ -1195,34 +1195,36 @@ static void lpuart_break_ctl(struct uartstatic void lpuart32_break_ctl (struct uart_port *port,int break_state) { -unsigned long temp, modem; -struct tty_struct *tty; -unsigned int cflag =0 ; +unsigned long temp; - tty =tty_port_tty_get (&port->state->port); -if (tty) { - cflag = tty->termios.c_cflag; -tty_kref_put (tty); - } - - temp =lpuart32_read (port,UARTCTRL ) & ~UARTCTRL_SBK ; - modem =lpuart32_read (port,UARTMODIR ); + temp =lpuart32_read (port,UARTCTRL ); +/* +* LPUART IP now has two known bugs, one is CTS has higher priority than the +* break signal, which causes the break signal sending through UARTCTRL_SBK +* may impacted by the CTS input if the HW flow control is enabled. It +* exists on all platforms we support in this driver. +* Another bug is i.MX8QM LPUART may have an additional break character +* being sent after SBK was cleared. +* To avoid above two bugs, we use Transmit Data Inversion function to send +* the break signal instead of UARTCTRL_SBK. +*/ if (break_state !=0 ) { - temp |=UARTCTRL_SBK ;/* -* LPUART CTS has higher priority than SBK, need to disable CTS before -* asserting SBK to avoid any interference if flow control is enabled. +* Disable the transmitter to prevent any data from being sent out +* during break, then invert the TX line to send break. */ -if (cflag &CRTSCTS && modem &UARTMODIR_TXCTSE ) -lpuart32_write (port, modem & ~UARTMODIR_TXCTSE ,UARTMODIR ); + temp &= ~UARTCTRL_TE ; +lpuart32_write (port, temp,UARTCTRL ); + temp |=UARTCTRL_TXINV ; +lpuart32_write (port, temp,UARTCTRL ); }else { -/* Re-enable the CTS when break off. */ -if (cflag &CRTSCTS && !(modem &UARTMODIR_TXCTSE )) -lpuart32_write (port, modem |UARTMODIR_TXCTSE ,UARTMODIR ); +/* Disable the TXINV to turn off break and re-enable transmitter. */ + temp &= ~UARTCTRL_TXINV ; +lpuart32_write (port, temp,UARTCTRL ); + temp |=UARTCTRL_TE ; +lpuart32_write (port, temp,UARTCTRL ); } - -lpuart32_write (port, temp,UARTCTRL ); }static void lpuart_setup_watermark (struct lpuart_port *sport)
Greg Kroah-Hartman
maintainerPATCH 82/88 selinux: dont use makes grouped targets feature yet
In reply to Greg Kroah-HartmanFrom: Paul Moore <[email protected]>
commit 42c4e97e06a839b07d834f640a10911ad84ec8b3 upstream.
The Linux Kernel currently only requires make v3.82 while the grouped target functionality requires make v4.3. Removed the grouped target introduced in 4ce1f694eb5d ("selinux: ensure av_permissions.h is built when needed") as well as the multiple header file targets in the make rule. This effectively reverts the problem commit.
We will revisit this change when make >= 4.3 is required by the rest of the kernel.
--- security/selinux/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
security/selinux/Makefile +5 -1
@@ -22,5 +22,9 @@ quiet_cmd_flask = GEN $(obj)/flask.h cmd_flask = $< $(obj)/flask.h $(obj)/av_permissions.h targets += flask.h av_permissions.h -$(obj)/flask.h $(obj)/av_permissions.h &: scripts/selinux/genheaders/genheaders FORCE +# once make >= 4.3 is required, we can use grouped targets in the rule below, +# which basically involves adding both headers and a '&' before the colon, see +# the example below: +# $(obj)/flask.h $(obj)/av_permissions.h &: scripts/selinux/... +$(obj)/flask.h: scripts/selinux/genheaders/genheaders FORCE $(call if_changed,flask)
Greg Kroah-Hartman
maintainerPATCH 83/88 ext4: add lockdep annotations for i_data_sem for ea_inodes
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
commit aff3bea95388299eec63440389b4545c8041b357 upstream.
Treat i_data_sem for ea_inodes as being in their own lockdep class to avoid lockdep complaints about ext4_setattr's use of inode_lock() on normal inodes potentially causing lock ordering with i_data_sem on ea_inodes in ext4_xattr_inode_write(). However, ea_inodes will be operated on by ext4_setattr(), so this isn't a problem.
--- fs/ext4/ext4.h | 2 ++ fs/ext4/xattr.c | 4 ++++ 2 files changed, 6 insertions(+)
fs/ext4/ext4.h +2 -0
@@ -929,11 +929,13 @@ do { \* where the second inode has larger inode number * than the first * I_DATA_SEM_QUOTA - Used for quota inodes only +* I_DATA_SEM_EA - Used for ea_inodes only */ enum {I_DATA_SEM_NORMAL =0 ,I_DATA_SEM_OTHER ,I_DATA_SEM_QUOTA , +I_DATA_SEM_EA };
fs/ext4/xattr.c +4 -0
@@ -121,7 +121,11 @@ ext4_expand_inode_array(struct ext4_xatt#ifdef CONFIG_LOCKDEP void ext4_xattr_inode_set_class (struct inode *ea_inode) { +struct ext4_inode_info *ei =EXT4_I (ea_inode); +lockdep_set_subclass (&ea_inode->i_rwsem,1 ); + (void ) ei;/* shut up clang warning if !CONFIG_LOCKDEP */ +lockdep_set_subclass (&ei->i_data_sem,I_DATA_SEM_EA ); }#endif
Greg Kroah-Hartman
maintainerPATCH 84/88 fbcon: Fix null-ptr-deref in soft_cursor
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
commit d78bd6cc68276bd57f766f7cb98bfe32c23ab327 upstream.
syzbot repored this bug in the softcursor code:
BUG: KASAN: null-ptr-deref in soft_cursor+0x384/0x6b4 drivers/video/fbdev/core/softcursor.c:70 Read of size 16 at addr 0000000000000200 by task kworker/u4:1/12 CPU: 0 PID: 12 Comm: kworker/u4:1 Not tainted 6.4.0-rc3-syzkaller-geb0f1697d729 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023 Workqueue: events_power_efficient fb_flashcursor Call trace: dump_backtrace+0x1b8/0x1e4 arch/arm64/kernel/stacktrace.c:233 show_stack+0x2c/0x44 arch/arm64/kernel/stacktrace.c:240 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd0/0x124 lib/dump_stack.c:106 print_report+0xe4/0x514 mm/kasan/report.c:465 kasan_report+0xd4/0x130 mm/kasan/report.c:572 kasan_check_range+0x264/0x2a4 mm/kasan/generic.c:187 __asan_memcpy+0x3c/0x84 mm/kasan/shadow.c:105 soft_cursor+0x384/0x6b4 drivers/video/fbdev/core/softcursor.c:70 bit_cursor+0x113c/0x1a64 drivers/video/fbdev/core/bitblit.c:377 fb_flashcursor+0x35c/0x54c drivers/video/fbdev/core/fbcon.c:380 process_one_work+0x788/0x12d4 kernel/workqueue.c:2405 worker_thread+0x8e0/0xfe8 kernel/workqueue.c:2552 kthread+0x288/0x310 kernel/kthread.c:379 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:853
This fix let bit_cursor() bail out early when a font bitmap isn't available yet.
--- drivers/video/fbdev/core/bitblit.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/core/bitblit.c +3 -0
@@ -247,6 +247,9 @@ static void bit_cursor(struct vc_data *v cursor.set =0 ; +if (!vc->vc_font.data) +return ; + c =scr_readw ((u16 *) vc->vc_pos); attribute =get_attribute (info, c); src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height));
Greg Kroah-Hartman
maintainerPATCH 85/88 regmap: Account for register length when chunking
In reply to Greg Kroah-HartmanFrom: Jim Wylder <[email protected]>
commit 3981514180c987a79ea98f0ae06a7cbf58a9ac0f upstream.
Currently, when regmap_raw_write() splits the data, it uses the max_raw_write value defined for the bus. For any bus that includes the target register address in the max_raw_write value, the chunked transmission will always exceed the maximum transmission length. To avoid this problem, subtract the length of the register and the padding from the maximum transmission.
--- drivers/base/regmap/regmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/base/regmap/regmap.c +4 -2
@@ -1825,6 +1825,8 @@ int _regmap_raw_write(struct regmap *mapsize_t val_count = val_len / val_bytes;size_t chunk_count, chunk_bytes;size_t chunk_regs = val_count; +size_t max_data = map->max_raw_write - map->format.reg_bytes - + map->format.pad_bytes;int ret, i;if (!val_count)
@@ -1832,8 +1834,8 @@ int _regmap_raw_write(struct regmap *mapif (map->use_single_write) chunk_regs =1 ; -else if (map->max_raw_write && val_len > map->max_raw_write) - chunk_regs = map->max_raw_write / val_bytes; +else if (map->max_raw_write && val_len > max_data) + chunk_regs = max_data / val_bytes; chunk_count = val_count / chunk_regs; chunk_bytes = chunk_regs * val_bytes;
Greg Kroah-Hartman
maintainerPATCH 86/88 scsi: dpt_i2o: Remove broken pass-through ioctl (I2OUSERCMD)
In reply to Greg Kroah-HartmanFrom: Ben Hutchings <[email protected]>
adpt_i2o_passthru() takes a user-provided message and passes it through to the hardware with appropriate translation of addresses and message IDs. It has a number of bugs:
- When a message requires scatter/gather, it doesn't verify that the offset to the scatter/gather list is less than the message size.
- When a message requires scatter/gather, it overwrites the DMA addresses with the user-space virtual addresses before unmapping the DMA buffers.
- It reads the message from user memory multiple times. This allows user-space to change the message and bypass validation.
- It assumes that the message is at least 4 words long, but doesn't check that.
I tried fixing these, but even the maintainer of the corresponding user-space in Debian doesn't have the hardware any more.
Instead, remove the pass-through ioctl (I2OUSRCMD) and supporting code.
There is no corresponding upstream commit, because this driver was removed upstream.
--- drivers/scsi/dpt_i2o.c | 265 ------------------------------------------------- drivers/scsi/dpti.h | 1 2 files changed, 3 insertions(+), 263 deletions(-)
drivers/scsi/dpt_i2o.c +3 -262
@@ -628,51 +628,6 @@ static struct scsi_cmnd *return NULL ; } -/* -* Turn a pointer to ioctl reply data into an u32 'context' -*/ -static u32 adpt_ioctl_to_context (adpt_hba * pHba,void *reply) -{ -#if BITS_PER_LONG ==32 -return (u32 )(unsigned long )reply; -#else -ulong flags =0 ; -u32 nr, i; - -spin_lock_irqsave (pHba->host->host_lock, flags); - nr =ARRAY_SIZE (pHba->ioctl_reply_context); -for (i =0 ; i < nr; i++) { -if (pHba->ioctl_reply_context[i] ==NULL ) { - pHba->ioctl_reply_context[i] = reply; -break ; - } - } -spin_unlock_irqrestore (pHba->host->host_lock, flags); -if (i >= nr) { -printk (KERN_WARNING "%s: Too many outstanding " -"ioctl commands\n" , pHba->name); -return (u32)-1 ; - } - -return i; -#endif -} - -/* -* Go from an u32 'context' to a pointer to ioctl reply data. -*/ -static void *adpt_ioctl_from_context (adpt_hba *pHba,u32 context) -{ -#if BITS_PER_LONG ==32 -return (void *)(unsigned long )context; -#else -void *p = pHba->ioctl_reply_context[context]; - pHba->ioctl_reply_context[context] =NULL ; - -return p; -#endif -} -/*=========================================================================== * Error Handling routines *===========================================================================
@@ -1697,208 +1652,6 @@ static int adpt_close(struct inode *inodreturn 0 ; } - -static int adpt_i2o_passthru (adpt_hba * pHba,u32 __user *arg) -{ -u32 msg[MAX_MESSAGE_SIZE ]; -u32 * reply =NULL ; -u32 size =0 ; -u32 reply_size =0 ; -u32 __user *user_msg = arg; -u32 __user * user_reply =NULL ; -void **sg_list =NULL ; -u32 sg_offset =0 ; -u32 sg_count =0 ; -int sg_index =0 ; -u32 i =0 ; -u32 rcode =0 ; -void *p =NULL ; -dma_addr_t addr; -ulong flags =0 ; - -memset (&msg,0 ,MAX_MESSAGE_SIZE *4 ); -// get user msg size in u32s -if (get_user (size, &user_msg[0 ])){ -return -EFAULT ; - } - size = size>>16 ; - - user_reply = &user_msg[size]; -if (size >MAX_MESSAGE_SIZE ){ -return -EFAULT ; - } - size *=4 ;// Convert to bytes - -/* Copy in the user's I2O command */ -if (copy_from_user (msg, user_msg, size)) { -return -EFAULT ; - } -get_user (reply_size, &user_reply[0 ]); - reply_size = reply_size>>16 ; -if (reply_size >REPLY_FRAME_SIZE ){ - reply_size =REPLY_FRAME_SIZE ; - } - reply_size *=4 ; - reply =kzalloc (REPLY_FRAME_SIZE *4 ,GFP_KERNEL ); -if (reply ==NULL ) { -printk (KERN_WARNING "%s: Could not allocate reply buffer\n" ,pHba->name); -return -ENOMEM ; - } - sg_offset = (msg[0 ]>>4 )&0xf ; - msg[2 ] =0x40000000 ;// IOCTL context - msg[3 ] =adpt_ioctl_to_context (pHba, reply); -if (msg[3 ] == (u32)-1 ) { - rcode = -EBUSY ; - goto free; - } - - sg_list =kcalloc (pHba->sg_tablesize,sizeof (*sg_list),GFP_KERNEL ); -if (!sg_list) { - rcode = -ENOMEM ; - goto free; - } -if (sg_offset) { -// TODO add 64 bit API -struct sg_simple_element *sg = (struct sg_simple_element *) (msg+sg_offset); - sg_count = (size - sg_offset*4 ) /sizeof (struct sg_simple_element ); -if (sg_count > pHba->sg_tablesize){ -printk (KERN_DEBUG "%s:IOCTL SG List too large (%u)\n" , pHba->name,sg_count); - rcode = -EINVAL ; - goto free; - } - -for (i =0 ; i < sg_count; i++) { -int sg_size; - -if (!(sg[i].flag_count &0x10000000 /*I2O_SGL_FLAGS_SIMPLE_ADDRESS_ELEMENT*/ )) { -printk (KERN_DEBUG "%s:Bad SG element %d - not simple (%x)\n" ,pHba->name,i, sg[i].flag_count); - rcode = -EINVAL ; - goto cleanup; - } - sg_size = sg[i].flag_count &0xffffff ; -/* Allocate memory for the transfer */ - p =dma_alloc_coherent (&pHba->pDev->dev, sg_size, &addr,GFP_KERNEL ); -if (!p) { -printk (KERN_DEBUG "%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n" , - pHba->name,sg_size,i,sg_count); - rcode = -ENOMEM ; - goto cleanup; - } - sg_list[sg_index++] = p;// sglist indexed with input frame, not our internal frame. -/* Copy in the user's SG buffer if necessary */ -if (sg[i].flag_count &0x04000000 /*I2O_SGL_FLAGS_DIR*/ ) { -// sg_simple_element API is 32 bit -if (copy_from_user (p,(void __user *)(ulong )sg[i].addr_bus, sg_size)) { -printk (KERN_DEBUG "%s: Could not copy SG buf %d FROM user\n" ,pHba->name,i); - rcode = -EFAULT ; - goto cleanup; - } - } -/* sg_simple_element API is 32 bit, but addr < 4GB */ - sg[i].addr_bus = addr; - } - } - -do { -/* -* Stop any new commands from enterring the -* controller while processing the ioctl -*/ -if (pHba->host) { -scsi_block_requests (pHba->host); -spin_lock_irqsave (pHba->host->host_lock, flags); - } - rcode =adpt_i2o_post_wait (pHba, msg, size,FOREVER ); -if (rcode !=0 ) -printk ("adpt_i2o_passthru: post wait failed %d %p\n" , - rcode, reply); -if (pHba->host) { -spin_unlock_irqrestore (pHba->host->host_lock, flags); -scsi_unblock_requests (pHba->host); - } - }while (rcode == -ETIMEDOUT ); - -if (rcode){ - goto cleanup; - } - -if (sg_offset) { -/* Copy back the Scatter Gather buffers back to user space */ -u32 j; -// TODO add 64 bit API -struct sg_simple_element * sg; -int sg_size; - -// re-acquire the original message to handle correctly the sg copy operation -memset (&msg,0 ,MAX_MESSAGE_SIZE *4 ); -// get user msg size in u32s -if (get_user (size, &user_msg[0 ])){ - rcode = -EFAULT ; - goto cleanup; - } - size = size>>16 ; - size *=4 ; -if (size >MAX_MESSAGE_SIZE ) { - rcode = -EINVAL ; - goto cleanup; - } -/* Copy in the user's I2O command */ -if (copy_from_user (msg, user_msg, size)) { - rcode = -EFAULT ; - goto cleanup; - } - sg_count = (size - sg_offset*4 ) /sizeof (struct sg_simple_element ); - -// TODO add 64 bit API - sg = (struct sg_simple_element *)(msg + sg_offset); -for (j =0 ; j < sg_count; j++) { -/* Copy out the SG list to user's buffer if necessary */ -if (! (sg[j].flag_count &0x4000000 /*I2O_SGL_FLAGS_DIR*/ )) { - sg_size = sg[j].flag_count &0xffffff ; -// sg_simple_element API is 32 bit -if (copy_to_user ((void __user *)(ulong )sg[j].addr_bus,sg_list[j], sg_size)) { -printk (KERN_WARNING "%s: Could not copy %p TO user %x\n" ,pHba->name, sg_list[j], sg[j].addr_bus); - rcode = -EFAULT ; - goto cleanup; - } - } - } - } - -/* Copy back the reply to user space */ -if (reply_size) { -// we wrote our own values for context - now restore the user supplied ones -if (copy_from_user (reply+2 , user_msg+2 ,sizeof (u32)*2 )) { -printk (KERN_WARNING "%s: Could not copy message context FROM user\n" ,pHba->name); - rcode = -EFAULT ; - } -if (copy_to_user (user_reply, reply, reply_size)) { -printk (KERN_WARNING "%s: Could not copy reply TO user\n" ,pHba->name); - rcode = -EFAULT ; - } - } - - -cleanup: -if (rcode != -ETIME && rcode != -EINTR ) { -struct sg_simple_element *sg = - (struct sg_simple_element *) (msg +sg_offset); -while (sg_index) { -if (sg_list[--sg_index]) { -dma_free_coherent (&pHba->pDev->dev, - sg[sg_index].flag_count &0xffffff , - sg_list[sg_index], - sg[sg_index].addr_bus); - } - } - } - -free: -kfree (sg_list); -kfree (reply); -return rcode; -} -#if defined __ia64__static void adpt_ia64_info (sysInfo_S * si) {
@@ -2025,8 +1778,6 @@ static int adpt_ioctl(struct inode *inodreturn -EFAULT ; }break ; -case I2OUSRCMD : -return adpt_i2o_passthru (pHba, argp);case DPT_CTRLINFO :{drvrHBAinfo_S HbaInfo;
@@ -2183,13 +1934,6 @@ static irqreturn_t adpt_isr(int irq, voiadpt_send_nop (pHba, old_m); } context =readl (reply+8 ); -if (context &0x40000000 ){// IOCTL -void *p =adpt_ioctl_from_context (pHba,readl (reply+12 )); -if ( p !=NULL ) { -memcpy_fromio (p, reply,REPLY_FRAME_SIZE *4 ); - } -// All IOCTLs will also be post wait - }if (context &0x80000000 ){// Post wait message status =readl (reply+16 );if (status >>24 ){
@@ -2197,12 +1941,9 @@ static irqreturn_t adpt_isr(int irq, voi }else { status =I2O_POST_WAIT_OK ; } -if (!(context &0x40000000 )) { - cmd =adpt_cmd_from_context (pHba, -readl (reply+12 )); -if (cmd !=NULL ) { -printk (KERN_WARNING "%s: Apparent SCSI cmd in Post Wait Context - cmd=%p context=%x\n" , pHba->name, cmd, context); - } + cmd =adpt_cmd_from_context (pHba,readl (reply+12 )); +if (cmd !=NULL ) { +printk (KERN_WARNING "%s: Apparent SCSI cmd in Post Wait Context - cmd=%p context=%x\n" , pHba->name, cmd, context); }adpt_i2o_post_wait_complete (context, status); }else {// SCSI message
drivers/scsi/dpti.h +0 -1
@@ -251,7 +251,6 @@ typedef struct _adpt_hba {void __iomem *FwDebugBLEDflag_P;// Virtual Addr Of FW Debug BLED void __iomem *FwDebugBLEDvalue_P;// Virtual Addr Of FW Debug BLED u32 FwDebugFlags; -u32 *ioctl_reply_context[4 ]; } adpt_hba;struct sg_simple_element {
Greg Kroah-Hartman
maintainerPATCH 87/88 scsi: dpt_i2o: Do not process completions with invalid addresses
In reply to Greg Kroah-HartmanFrom: Ben Hutchings <[email protected]>
adpt_isr() reads reply addresses from a hardware register, which should always be within the DMA address range of the device's pool of reply address buffers. In case the address is out of range, it tries to muddle on, converting to a virtual address using bus_to_virt().
bus_to_virt() does not take DMA addresses, and it doesn't make sense to try to handle the completion in this case. Ignore it and continue looping to service the interrupt. If a completion has been lost then the SCSI core should eventually time-out and trigger a reset.
There is no corresponding upstream commit, because this driver was removed upstream.
--- drivers/scsi/Kconfig | 2 +- drivers/scsi/dpt_i2o.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/Kconfig +1 -1
@@ -473,7 +473,7 @@ config SCSI_MVUMI config SCSI_DPT_I2O tristate "Adaptec I2O RAID support " - depends on SCSI && PCI && VIRT_TO_BUS + depends on SCSI && PCI help This driver supports all of Adaptec's I2O based RAID controllers as well as the DPT SmartRaid V cards. This is an Adaptec maintained
drivers/scsi/dpt_i2o.c +2 -2
@@ -59,7 +59,7 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Dri#include <asm/processor.h> /* for boot_cpu_data */ #include <asm/pgtable.h> -#include <asm/io.h> /* for virt_to_bus, etc. */ +#include <asm/io.h> #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h>
@@ -1914,7 +1914,7 @@ static irqreturn_t adpt_isr(int irq, voi }else {/* Ick, we should *never* be here */ printk (KERN_ERR "dpti: reply frame not from pool\n" ); - reply = (u8 *)bus_to_virt (m); +continue ; }if (readl (reply) &MSG_FAIL ) {
Greg Kroah-Hartman
maintainerPATCH 88/88 wifi: rtlwifi: 8192de: correct checking of IQK reload
In reply to Greg Kroah-HartmanFrom: Ping-Ke Shih <[email protected]>
commit 93fbc1ebd978cf408ef5765e9c1630fce9a8621b upstream.
Since IQK could spend time, we make a cache of IQK result matrix that looks like iqk_matrix[channel_idx].val[x][y], and we can reload the matrix if we have made a cache. To determine a cache is made, we check iqk_matrix[channel_idx].val[0][0].
The initial commit 7274a8c22980 ("rtlwifi: rtl8192de: Merge phy routines") make a mistake that checks incorrect iqk_matrix[channel_idx].val[0] that is always true, and this mistake is found by commit ee3db469dd31 ("wifi: rtlwifi: remove always-true condition pointed out by GCC 12"), so I recall the vendor driver to find fix and apply the correctness.
--- drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c +4 -5
@@ -2414,11 +2414,10 @@ void rtl92d_phy_reload_iqk_setting(strucRT_TRACE (rtlpriv,COMP_SCAN ,DBG_LOUD ,"Just Read IQK Matrix reg for channel:%d....\n" , channel); -_rtl92d_phy_patha_fill_iqk_matrix (hw, true, - rtlphy->iqk_matrix[ - indexforchannel].value,0 , - (rtlphy->iqk_matrix[ - indexforchannel].value[0 ][2 ] ==0 )); +if (rtlphy->iqk_matrix[indexforchannel].value[0 ][0 ] !=0 ) +_rtl92d_phy_patha_fill_iqk_matrix (hw, true, + rtlphy->iqk_matrix[indexforchannel].value,0 , + rtlphy->iqk_matrix[indexforchannel].value[0 ][2 ] ==0 );if (IS_92D_SINGLEPHY (rtlhal->version)) {if ((rtlphy->iqk_matrix[ indexforchannel].value[0][4] != 0)
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.285 release. There are 88 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 09 Jun 2023 20:07:31 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.285-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Hello Greg,
Quoted 10 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Wednesday, June 7, 2023 9:15 PMThis is the start of the stable review cycle for the 4.19.285 release. There are 88 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 09 Jun 2023 20:07:31 +0000. Anything received after that time might be too late.
CIP configurations built and booted okay with Linux 4.19.285-rc1 (a1cebe658474):
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/pipelines/893073911
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/commits/linux-4.19.y
Kind regards, Chris
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.285 release. There are 88 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 09 Jun 2023 20:07:31 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.285-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 4.19.285-rc1
* git: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
* git branch: linux-4.19.y
* git commit: a1cebe658474418a36d59fa529955125794d12d8
* git describe: v4.19.284-89-ga1cebe658474
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-4.19.y/build/v4.19.284-89-ga1cebe658474
## Test Regressions (compared to v4.19.284)
## Metric Regressions (compared to v4.19.284)
## Test Fixes (compared to v4.19.284)
## Metric Fixes (compared to v4.19.284)
## Test result summary
total: 58580, pass: 51345, fail: 1808, skip: 5353, xfail: 74
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 111 total, 106 passed, 5 failed
* arm64: 37 total, 32 passed, 5 failed
* i386: 21 total, 18 passed, 3 failed
* mips: 22 total, 22 passed, 0 failed
* parisc: 3 total, 3 passed, 0 failed
* powerpc: 24 total, 24 passed, 0 failed
* s390: 6 total, 6 passed, 0 failed
* sh: 12 total, 12 passed, 0 failed
* sparc: 6 total, 6 passed, 0 failed
* x86_64: 31 total, 26 passed, 5 failed
## Test suites summary
* boot
* kselftest-android
* kselftest-arm64
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-drivers-dma-buf
* kselftest-efivarfs
* kselftest-filesystems
* kselftest-filesystems-binderfs
* kselftest-firmware
* kselftest-fpu
* kselftest-ftrace
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-lib
* kselftest-livepatch
* kselftest-membarrier
* kselftest-memfd
* kselftest-memory-hotplug
* kselftest-mincore
* kselftest-mount
* kselftest-mqueue
* kselftest-net
* kselftest-net-forwarding
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-seccomp
* kselftest-sigaltstack
* kselftest-size
* kselftest-splice
* kselftest-static_keys
* kselftest-sync
* kselftest-sysctl
* kselftest-tc-testing
* kselftest-timens
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user
* kselftest-x86
* kselftest-zram
* kunit
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* network-basic-tests
* rcutorture
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.285 release. There are 88 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 09 Jun 2023 20:07:31 +0000. Anything received after that time might be too late.
Build results:
total: 155 pass: 155 fail: 0 Qemu test results: total: 431 pass: 431 fail: 0
Guenter
Hi Greg,
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.285 release. There are 88 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Build test (gcc version 11.3.1 20230511):
mips: 63 configs -> no failure
arm: 115 configs -> no failure
arm64: 2 configs -> no failurex86_64: 4 configs -> no failure
alpha allmodconfig -> no failure
powerpc allmodconfig -> no failure
riscv allmodconfig -> no failure
s390 allmodconfig -> no failure
xtensa allmodconfig -> no failure
Boot test:x86_64: Booted on my test laptop. No regression.x86_64: Booted on qemu. No regression. [1]
[1]. https://openqa.qa.codethink.co.uk/tests/3799
Signature · 2 lines
Regards Sudip
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.285 release. There are 88 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 09 Jun 2023 20:07:31 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.285-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v4.19:
10 builds: 10 pass, 0 fail
22 boots: 22 pass, 0 fail
40 tests: 40 pass, 0 failLinux version: 4.19.285-rc1-ga1cebe658474
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04Jon