5.15.226-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 949/2214 media: uvcvideo: Force UVC version for Avermedia GC515
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
[ Upstream commit 65444446f0c595c0e250368cde88735b59ccc446 ]
The device announces itself as UVC 1.5, but it only accepts UVC 1.1 controls.
The camera can probably be handled by the automatic uvc_version handler, but it is more correct to add a quirk and keep some tracking of what vendors are more or less compliant. Also it might be more robust if we introduce more UVC version-dependent code.
Bus 003 Device 021: ID 07ca:1515 AVerMedia Technologies, Inc. X'tra Go GC515 Negotiated speed: High Speed (480Mbps)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 [unknown]
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x07ca AVerMedia Technologies, Inc.
idProduct 0x1515 X'tra Go GC515
bcdDevice 0.10
iManufacturer 1 AVerMedia iProduct 2 X'tra Go GC515 iSerial 3 5313180000221 bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x03fd
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 500mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 1
iInterface 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.50
wTotalLength 0x0059
dwClockFrequency 30.000000MHz
bInCollection 1
baInterfaceNr( 0) 1
VideoControl Interface Descriptor:
bLength 18
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Camera Sensor
bAssocTerminal 0
iTerminal 0
wObjectiveFocalLengthMin 0
wObjectiveFocalLengthMax 0
wOcularFocalLength 0
bControlSize 3
bmControls 0x00000000
VideoControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 4
iTerminal 0
VideoControl Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 4 (SELECTOR_UNIT)
bUnitID 3
bNrInPins 1
baSource( 0) 1
iSelector 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
bUnitID 4
bSourceID 3
wMaxMultiplier 0
bControlSize 3
bmControls 0x00000000
iProcessing 0
bmVideoStandards 0x00
VideoControl Interface Descriptor:
bLength 29
bDescriptorType 36
bDescriptorSubtype 6 (EXTENSION_UNIT)
bUnitID 5
guidExtensionCode {55be8e1c-2fdb-4f7a-bd8d-b9b1108d20c3}
bNumControls 24
bNrInPins 1
baSourceID( 0) 4
bControlSize 4
bmControls( 0) 0xff
bmControls( 1) 0xff
bmControls( 2) 0xff
bmControls( 3) 0x00
iExtension 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
VideoControl Endpoint Descriptor:
bLength 5
bDescriptorType 37
bDescriptorSubtype 3 (EP_INTERRUPT)
wMaxTransferSize 64
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 1
iInterface 0
VideoStreaming Interface Descriptor:
bLength 16
bDescriptorType 36
bDescriptorSubtype 1 (INPUT_HEADER)
bNumFormats 3
wTotalLength 0x0303
bEndpointAddress 0x81 EP 1 IN
bmInfo 0
bTerminalLink 2
bStillCaptureMethod 1
bTriggerSupport 0
bTriggerUsage 0
bControlSize 1
bmaControls( 0) 4
bmaControls( 1) 4
bmaControls( 2) 0
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 1
bNumFrameDescriptors 8
guidFormat {34363248-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 28
bDescriptorType 36
bDescriptorSubtype 16 (FORMAT_FRAME_BASED)
bFormatIndex 2
bNumFrameDescriptors 8
guidFormat {43564548-0000-0010-8000-00aa00389b71}
bBitsPerPixel 24
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
bVariableSize 1
VideoStreaming Interface Descriptor:
bLength 62
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 9
dwBytesPerLine 0
dwFrameInterval( 0) 83333
dwFrameInterval( 1) 83416
dwFrameInterval( 2) 166666
dwFrameInterval( 3) 166833
dwFrameInterval( 4) 200000
dwFrameInterval( 5) 333333
dwFrameInterval( 6) 333667
dwFrameInterval( 7) 400000
dwFrameInterval( 8) 416666
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 2
bmCapabilities 0x01
Still image supported
wWidth 3840
wHeight 2160
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 333333
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 333333
dwFrameInterval( 1) 333667
dwFrameInterval( 2) 400000
dwFrameInterval( 3) 416666
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 3
bmCapabilities 0x01
Still image supported
wWidth 2560
wHeight 1440
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 4
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 800
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 38
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 5
bmCapabilities 0x01
Still image supported
wWidth 1280
wHeight 720
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 3
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 200000
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 6
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 576
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 200000
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 200000
dwFrameInterval( 1) 400000
VideoStreaming Interface Descriptor:
bLength 42
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 7
bmCapabilities 0x01
Still image supported
wWidth 720
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 4
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
dwFrameInterval( 2) 333333
dwFrameInterval( 3) 333667
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 17 (FRAME_FRAME_BASED)
bFrameIndex 8
bmCapabilities 0x01
Still image supported
wWidth 640
wHeight 480
dwMinBitRate 33554432
dwMaxBitRate 268435456
dwDefaultFrameInterval 166666
bFrameIntervalType 2
dwBytesPerLine 0
dwFrameInterval( 0) 166666
dwFrameInterval( 1) 166833
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
VideoStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 6 (FORMAT_MJPEG)
bFormatIndex 3
bNumFrameDescriptors 1
bFlags 0
Fixed-size samples: No
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 1 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 1
VideoStreaming Interface Descriptor:
bLength 30
bDescriptorType 36
bDescriptorSubtype 7 (FRAME_MJPEG)
bFrameIndex 1
bmCapabilities 0x01
Still image supported
wWidth 1920
wHeight 1080
dwMinBitRate 314572800
dwMaxBitRate 314572800
dwMaxVideoFrameBufferSize 4147200
dwDefaultFrameInterval 166666
bFrameIntervalType 1
dwFrameInterval( 0) 166666
VideoStreaming Interface Descriptor:
bLength 6
bDescriptorType 36
bDescriptorSubtype 13 (COLORFORMAT)
bColorPrimaries 0 (Unspecified)
bTransferCharacteristics 0 (Unspecified)
bMatrixCoefficients 0 (Unspecified)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 2
bInterfaceCount 2
bFunctionClass 1 Audio
bFunctionSubClass 2 Streaming
bFunctionProtocol 0
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 0x0026
bInCollection 1
baInterfaceNr(0) 3
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0602 Digital Audio Interface
bAssocTerminal 0
bNrChannels 2
wChannelConfig 0x0003
Left Front (L)
Right Front (R)
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 3
iTerminal 0
AudioControl Interface Descriptor:
bLength 8
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 3
bSourceID 1
bControlSize 1
bmaControls(0) 0x03
Mute Control
Volume Control
iFeature 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 2
bDelay 1 frames
wFormatTag 0x0001 PCM
AudioStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 1 Discrete
tSamFreq[ 0] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x00c4 1x 196 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioStreaming Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0x0000
--- drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +11 -0
@@ -2976,6 +2976,17 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth }, +/* Avermedia GC515 */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x07ca, + .idProduct = 0x1515, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = UVC_PC_PROTOCOL_15, + .driver_info = (kernel_ulong_t)&(const struct uvc_device_info ){ + .uvc_version =0x0110 , + } }, /* AVerMedia Live Gamer HD 2 capture card */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 950/2214 genirq/kexec: Do not take the bus lock of an interrupt chip on the crash path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Velkov <[email protected]>
commit 717862eac6eff0eea8ac30a0c0de0bed84922aab upstream.
machine_kexec_mask_interrupts() calls irq_set_irqchip_state() for every started interrupt. That function takes the bus lock of the chip and desc->lock, and syncs the chip when it drops them. On the crash path interrupts are off and the other CPUs are stopped, so a chip whose bus transfer is completed by an interrupt never returns from the sync.
On RK3399 boards with an RK808 PMIC the RTC alarm interrupt belongs to the regmap-irq chip of the RK808, which sits on I2C. rk808_irq_chip sets init_ack_masked, so regmap_irq_sync_unlock() writes the ack register on every unlock, and the I2C controller needs its own interrupt to finish the transfer. A panic with a crash kernel loaded prints
SMP: stopping secondary CPUs
and then nothing until the watchdog resets the board.
machine_kexec_mask_interrupts() takes neither lock for the other operations on the descriptor. Move the search for the chip that implements irq_set_irqchip_state() into __irq_set_irqchip_state(), which takes no locks, and call it from machine_kexec_mask_interrupts().
--- arch/arm64/kernel/machine_kexec.c | 2 +- include/linux/interrupt.h | 1 + kernel/irq/manage.c | 49 ++++++++++++++++--------------- 3 files changed, 27 insertions(+), 25 deletions(-)
arch/arm64/kernel/machine_kexec.c +1 -1
@@ -226,7 +226,7 @@ static void machine_kexec_mask_interrupts(void)* First try to remove the active state. If this * fails, try to EOI the interrupt. */ - ret =irq_set_irqchip_state (i,IRQCHIP_STATE_ACTIVE , false); + ret =__irq_set_irqchip_state (desc,IRQCHIP_STATE_ACTIVE , false);if (ret &&irqd_irq_inprogress (&desc->irq_data) && chip->irq_eoi)
include/linux/interrupt.h +1 -0
@@ -525,6 +525,7 @@ extern int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which, bool *state);extern int irq_set_irqchip_state (unsigned int irq,enum irqchip_irq_state which,bool state); +extern int __irq_set_irqchip_state (struct irq_desc *desc,enum irqchip_irq_state which,bool val);#ifdef CONFIG_IRQ_FORCED_THREADING # ifdef CONFIG_PREEMPT_RT
kernel/irq/manage.c +25 -24
67 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 951/2214 efi/libstub: arm64: Dont use the platform register x18
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 4c86b5f3fa78347fa9cbc9e8ec06615b2f80e397 upstream
The UEFI specification designates x18, the platform register, as "do not use" on AArch64, so that UEFI code is compatible both with an OS that assigns a fixed role to x18, and with one that uses it as a temporary register.
The arm64 EFI stub and the EFI zboot decompressor only avoid x18 if the kernel is built with shadow call stacks, as that is the only case where -ffixed-x18 is added to KBUILD_CFLAGS, which the stub inherits. Otherwise, the compiler is free to use x18 as a temporary register, and it does so.
So pass -ffixed-x18 unconditionally when building the stub for arm64, so that the image can be run by loaders that rely on x18 being left alone, such as a kernel that uses it for its shadow call stack.
--- drivers/firmware/efi/libstub/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/Makefile +1 -1
@@ -19,7 +19,7 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -std=gnu89 \ # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly # disable the stackleak plugin cflags-$(CONFIG_ARM64) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ - -fpie $(DISABLE_STACKLEAK_PLUGIN) \ + -fpie $(DISABLE_STACKLEAK_PLUGIN) -ffixed-x18 \ $(call cc-option,-mbranch-protection=none) cflags-$(CONFIG_ARM) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ -fno-builtin -fpic \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 952/2214 net: atl1c: drop oversized RX frames instead of panicking
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Federico Musto <[email protected]>
[ Upstream commit c4ba1716853de5178a9df785844ebb5e397a80e6 ]
atl1c sizes its receive buffers from the netdev MTU plus a fixed set of L2 overheads, which comes to 1522 bytes at the default MTU. A link partner that sends a longer frame - in practice a MikroTik CCR2004-1G-2XS-PCIe, whose RouterOS side defaults to l2mtu 1600 while the host stays at MTU 1500
- makes the length reported by the RX return descriptor exceed what the hardware wrote, and skb_put() then either includes bytes that were never received or trips skb_over_panic and takes the host down.
Compare the descriptor length against buffer_info->length, the length the hardware was given, rather than against skb_tailroom(): the skb carries 64 bytes of slack for the DMA erratum, so tailroom is larger than the DMA buffer and a frame in between would pass the check and still be delivered with a tail the device never wrote. The same test rejects frames shorter than ETH_HLEN + ETH_FCS_LEN; before this change a reported length below ETH_FCS_LEN underflowed in skb_put().
The frame is dropped with kfree_skb_reason(SKB_DROP_REASON_PKT_TOO_BIG) so drop_monitor and the kfree_skb tracepoint see it, and counted through dev_core_stats_rx_dropped_inc(), which survives atl1c_get_stats() overwriting the hardware counters on every read. It also counts as work:atl1c_clean_rfd() has already recycled the RFD, and the refill at the end of the poll only runs when work_done is non-zero, so sustained oversized traffic would otherwise drain the ring and stop RX.
Tested on a MikroTik CCR2004-1G-2XS-PCIe (4x AR8151) in a Proxmox VE host, with atl1c built from a DKMS tree carrying this change: the l2mtu-1600 traffic that panics the stock driver is dropped and counted with the patch applied, and received normally once the host MTU is raised to match.
This complements commit 36c2009d90f2 ("net: atl1c: fix soft lockup on out-of-range tpd_cons read"), which fixed the TX side of the same "host dies while the card resets" problem.
[ Federico Musto: 5.15.y has neither dev_core_stats_rx_dropped_inc() nor
SKB_DROP_REASON_PKT_TOO_BIG: count the drop in netdev->rx_dropped, the counter dev_core_stats replaced, which dev_get_stats() adds to what atl1c_get_stats() returns, and free the skb with kfree_skb(). Build-tested only, not run on hardware. ]
--- .../net/ethernet/atheros/atl1c/atl1c_main.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/net/ethernet/atheros/atl1c/atl1c_main.c +33 -0
@@ -1943,6 +1943,39 @@ static int atl1c_clean_rx(struct napi_struct *napi, int budget)break ; }atl1c_clean_rfd (rfd_ring, rrs, rfd_num); + +/* A link partner whose l2mtu is larger than ours can hand us a +* frame that does not fit the buffer the hardware was given: +* the descriptor reports the untruncated length while at most +* buffer_info->length bytes were written. skb_put() of such a +* length would pull in whatever the tail of the buffer holds +* and, past the end of the skb, trips skb_over_panic and takes +* the host down. Bound it by what the device actually wrote +* rather than by skb_tailroom(): the skb carries 64 bytes of +* slack for the DMA erratum, so the two are not the same. +* +* Frames shorter than an Ethernet header plus its FCS are +* rejected by the same test; before this, a length below +* ETH_FCS_LEN underflowed in skb_put(). +*/ +if (unlikely (length <ETH_HLEN +ETH_FCS_LEN || + length > buffer_info->length)) { +atomic_long_inc (&netdev->rx_dropped); +if (netif_msg_rx_err (adapter)) +dev_warn_ratelimited (&pdev->dev, +"dropped rx frame: %u bytes, buffer %u\n" , + length, buffer_info->length); +kfree_skb (skb); +/* atl1c_clean_rfd() has already recycled the RFD, so +* count the drop as work: the refill at the end of the +* poll only runs when work_done is non-zero, and +* sustained oversized traffic would otherwise drain the +* ring and stop RX for good. +*/ + work_done++; +continue ; + } +skb_put (skb, length -ETH_FCS_LEN ); skb->protocol =eth_type_trans (skb, netdev);atl1c_rx_checksum (adapter, skb, rrs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 953/2214 f2fs: force out-place update for all writes on compressed file
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiucheng Xu <[email protected]>
commit a64a3fec11e77a3a0dc0009bdc58b925e45a1bb4 upstream.
For compressed file, compressed write may fail and fall back to raw write.
-Thread A - Thread B
- f2fs_write_multi_pages - f2fs_down_write(&sbi->cp_rwsem);
- f2fs_write_compressed_pages - ...
- f2fs_trylock_op - ...
- f2fs_down_read_trylock(&sbi->cp_rwsem); - ...
- f2fs_write_raw_pages - ...Thread B acquires the lock first, which causes Thread A to fail lock acquisition and fall back to raw-data write.IPU_FORCE is enabled on small-capacity storage devices (< 16GB), so f2fs_write_raw_pages() overwrites the original compressed data in-place.
The in-memory node has been updated with raw-data addresses, while the node metadata stored on eMMC still remains in compressed state. If a power-cut occurs before the node is flushed to disk, on-disk inconsistency arises: disk data is raw, yet metadata treats it as a compressed cluster, leading to decompression failure.
To eliminate this risk completely, force out-place update for all write operations on compressed file.
--- fs/f2fs/data.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/f2fs/data.c +7 -0
@@ -2670,6 +2670,13 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)return true;if (f2fs_is_atomic_file (inode))return true; +/* +* rewrite low ratio compress data w/ OPU mode to avoid fragmentation. +* If IO comes from compressed write path and fallback to raw write, +* force out-place to prevent metadata-data inconsistency. +*/ +if (f2fs_compressed_file (inode)) +return true;/* swap file is migrating in aligned write mode */ if (is_inode_flag_set (inode,FI_ALIGNED_WRITE ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 954/2214 f2fs: allow pinning empty compressed files
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joanne Chang <[email protected]>
commit 2eebc31ae5f53e1066bb6238c8087c23b688ad17 upstream.
Commit a64a3fec11e7 ("f2fs: force out-place update for all writes on compressed file") updated f2fs_should_update_outplace() to always return true for compressed files. However, this function is also called during f2fs_ioc_set_pin_file() validation, so pinning an empty file with compression enabled now fails with -EINVAL before the compression flag can be stripped.
Fix this by guarding the f2fs_compressed_file(inode) check with fio in f2fs_should_update_outplace(). This preserves forced OPU for actual compressed writes (fio != NULL), while allowing f2fs_ioc_set_pin_file() (fio == NULL) to proceed to f2fs_disable_compressed_file(inode).
--- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/data.c +1 -1
@@ -2675,7 +2675,7 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)* If IO comes from compressed write path and fallback to raw write, * force out-place to prevent metadata-data inconsistency. */ -if (f2fs_compressed_file (inode)) +if (fio &&f2fs_compressed_file (inode))return true;/* swap file is migrating in aligned write mode */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 955/2214 iommu/amd: Force device table to maximum size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suravee Suthikulpanit <[email protected]>
commit 6e2213dae78b41976c60133eb10cf99e81916638 upstream.
IOMMU can perform out-of-bounds read of the device table entry (DTE) that is adjacent to the last DTE and falls outside the device table. For example, if the device table can hold 0 to N-1 entries, then the IOMMU can be made to fetch the Nth entry, which falls outside the device table.
The device table is owned by the hypervisor (HV) and is assigned in 4KB pages that are contiguous in system physical address (SPA). If the out-of-bound DTE falls on a guest-owned page, then the guest can exploit this bug to setup malicious table walks to corrupt HV pages and/or bring down the system. Note that this bug does not manifest when the device table size is set to its maximum size of 2MB.
Therefore, force the device table size to the maximum 2MB on affected processors. These are CPU family 0x17 (Zen1/Zen2) through family 0x1a (Zen5/BRH).
This is a mitigation for CVE-2024-21963.
kdump copies the previous kernel's device table only when the size encoded in the IOMMU device-table register matches dev_table_size. A mixed rollout disagrees: the unpatched kernel uses the IVRS-derived size and the patched kernel uses 2MB, so copy_device_table() rejects the table and reinitializes translation. Kernels that both have this patch agree on 2MB and the copy succeeds. Update the production kernel and the crash kernel together.
This kernel has one global device table. Only that size is forced to 2MB. Alias and rlookup sizes stay derived from the IVRS.
This backport adds X86_FEATURE_ZEN6. Bit 3*32+6 is still X86_FEATURE_P3 here, so the new flag uses free bit 21*32+7. Family 0x1a models 0x50-0x5f, 0x80-0xaf, 0xc0-0xcf, and 0xd8-0xef are Zen6 and are excluded from the workaround. This kernel has no X86_FEATURE_ZEN5. Other family 0x1a models stay unmarked and still take the 2MB device table.
--- arch/x86/include/asm/cpufeatures.h | 5 +++++ arch/x86/kernel/cpu/amd.c | 18 ++++++++++++++++++ drivers/iommu/amd/init.c | 23 ++++++++++++++++++++++- 3 files changed, 45 insertions(+), 1 deletion(-)
arch/x86/include/asm/cpufeatures.h +5 -0
@@ -439,6 +439,11 @@#define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3)/* "" BHI_DIS_S HW control enabled */ #define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4)/* "" Clear branch history at vmexit using SW loop */ #define X86_FEATURE_INDIRECT_THUNK_ITS (21*32 + 5)/* "" Use thunk for indirect branches in lower half of cacheline */ +/* +* Upstream defines X86_FEATURE_ZEN6 as (3*32+6). That bit is still +* X86_FEATURE_P3 in this kernel, so use a free bit in this word. +*/ +#define X86_FEATURE_ZEN6 (21*32+7)/* "" CPU based on Zen6 microarchitecture */ #define X86_FEATURE_TSA_SQ_NO (21*32+11)/* "" AMD CPU not vulnerable to TSA-SQ */ #define X86_FEATURE_TSA_L1_NO (21*32+12)/* "" AMD CPU not vulnerable to TSA-L1 */
arch/x86/kernel/cpu/amd.c +18 -0
@@ -742,6 +742,24 @@ static void bsp_init_amd(struct cpuinfo_x86 *c) }break ; } +case 0x1a : { +switch (c->x86_model) { + case 0x50 ... 0x5f: + case 0x80 ... 0xaf: + case 0xc0 ... 0xcf: + case 0xd8 ... 0xef: +setup_force_cpu_cap (X86_FEATURE_ZEN6 ); +break ; +default : +/* +* Zen5 models in family 0x1a have no feature bit +* in this kernel. Leave them unmarked so the +* device-table workaround still applies. +*/ +break ; + } +break ; + }default :break ; }
drivers/iommu/amd/init.c +22 -1
@@ -22,6 +22,7 @@#include <linux/kmemleak.h> #include <linux/mem_encrypt.h> #include <linux/iopoll.h> +#include <linux/sizes.h> #include <asm/pci-direct.h> #include <asm/iommu.h> #include <asm/apic.h>
@@ -2757,6 +2758,21 @@ static void __init ivinfo_init(void *ivrs) amd_iommu_ivinfo = *((u32 *)(ivrs +IOMMU_IVINFO_OFFSET )); } +/* +* Apply workaround for Zen1 to Zen5(BRH) generation of processors. +* References: CVE-2024-21963 +*/ +static bool __init amd_iommu_force_max_dev_table (void ) +{ +if (boot_cpu_data.x86 >=0x17 && boot_cpu_data.x86 <=0x1a ) { +if (cpu_feature_enabled (X86_FEATURE_ZEN6 )) +return false; +else +return true; + } +return false; +} +/* * This is the hardware init function for AMD IOMMU in the system. * This function is called either from amd_iommu_init or from the interrupt
@@ -2824,7 +2840,12 @@ static int __init early_amd_iommu_init(void)if (ret) goto out; - dev_table_size =tbl_size (DEV_TABLE_ENTRY_SIZE ); +if (amd_iommu_force_max_dev_table ()) { +pr_info ("Force device table to maximum size\n" ); + dev_table_size =SZ_2M ; + }else { + dev_table_size =tbl_size (DEV_TABLE_ENTRY_SIZE ); + } alias_table_size =tbl_size (ALIAS_TABLE_ENTRY_SIZE ); rlookup_table_size =tbl_size (RLOOKUP_TABLE_ENTRY_SIZE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 956/2214 drm/nouveau/svm: drain fault handler before freeing svmm
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenhao Wan <[email protected]>
[ Upstream commit b46ddaf0823405f81e681eb26ec98508f3eb9a07 ]
The SVM fault handler nouveau_svm_fault() looks up each fault's nouveau_svmm under svm->mutex, caches it in the fault array, then drops svm->mutex and dereferences the svmm across blocking faults (mmu_interval_notifier_insert(), hmm_range_fault()).
nouveau_svmm is not refcounted. On DRM file close nouveau_svmm_fini() -> mmu_notifier_put() frees it asynchronously via call_srcu() without waiting for the handler, and mmget_not_zero() pins the mm, not the svmm. flush_work() on the fault buffer otherwise runs only at device removal and suspend, never on close, so a fault handled concurrently with a close can dereference a freed svmm.
The instance is already unlinked by nouveau_svmm_part() earlier in the same close, so no new fault can resolve to it. Drain the handler in nouveau_svmm_fini() before the free, guarding the flush with a NULL check on drm->svm: on device teardown nouveau_svm_fini() runs first and frees drm->svm (NULL) after blocking the notify and flushing the buffer, so the handler is already drained; on per-client close drm->svm is alive and the flush runs.
--- drivers/gpu/drm/nouveau/nouveau_svm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/nouveau/nouveau_svm.c +13 -0
@@ -305,6 +305,19 @@ nouveau_svmm_fini(struct nouveau_svmm **psvmm) {struct nouveau_svmm *svmm = *psvmm;if (svmm) { +struct nouveau_svm *svm = svmm->vmm->cli->drm->svm; + +/* The fault handler caches svmm pointers under svm->mutex and +* dereferences them after dropping it, across blocking faults. +* The instance is already unlinked (nouveau_svmm_part), so drain +* the handler before the free to release any in-flight reference. +* +* On device teardown nouveau_svm_fini() ran first and freed +* drm->svm (NULL) after draining the buffer; nothing to flush. +*/ +if (svm) +flush_work (&svm->buffer[0 ].notify.work); +mutex_lock (&svmm->mutex); svmm->vmm =NULL ;mutex_unlock (&svmm->mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 957/2214 udf: Avoid invalid LVID used on mount
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit c8f1140cb82dc843e72697dc6f8c7ee1acce5d28 ]
udf_load_logicalvolint() loads logical volume integrity descriptors. Since there can be multiple blocks with LVIDs, we verify the contents of only the last (prevailing) LVID found. However if we fail to load the last LVID (either due to IO error or because it's checksum fails to match), we never perform the verification of validity of the LVID we are going to use. If such LVID contains invalid data, we can hit out-of-bounds access or similar issues. Fix the problem by verifying each LVID we are potentially going to accept.
Stable-dep-of: a61fb39759d7 ("udf: Make sure there's enough space for LVID implementation use field")
--- fs/udf/super.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-)
fs/udf/super.c +25 -17
@@ -1575,6 +1575,20 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,return ret; } +static bool udf_lvid_valid (struct super_block *sb, +struct logicalVolIntegrityDesc *lvid) +{ +u32 parts, impuselen; + + parts =le32_to_cpu (lvid->numOfPartitions); + impuselen =le32_to_cpu (lvid->lengthOfImpUse); +if (parts >= sb->s_blocksize || impuselen >= sb->s_blocksize || +sizeof (struct logicalVolIntegrityDesc ) + impuselen + +2 * parts *sizeof (u32) > sb->s_blocksize) +return false; +return true; +} +/* * Find the prevailing Logical Volume Integrity Descriptor. */
@@ -1585,7 +1599,6 @@ static void udf_load_logicalvolint(struct super_block *sb, struct kernel_extent_struct udf_sb_info *sbi =UDF_SB (sb);struct logicalVolIntegrityDesc *lvid;int indirections =0 ; -u32 parts, impuselen;while (++indirections <=UDF_MAX_LVID_NESTING ) { final_bh =NULL ;
@@ -1607,32 +1620,27 @@ static void udf_load_logicalvolint(struct super_block *sb, struct kernel_extent_if (!final_bh)return ; -brelse (sbi->s_lvid_bh); - sbi->s_lvid_bh = final_bh; - lvid = (struct logicalVolIntegrityDesc *)final_bh->b_data; +if (udf_lvid_valid (sb, lvid)) { +brelse (sbi->s_lvid_bh); + sbi->s_lvid_bh = final_bh; + }else { +udf_warn (sb,"Corrupted LVID (parts=%u, impuselen=%u), " +"ignoring.\n" , +le32_to_cpu (lvid->numOfPartitions), +le32_to_cpu (lvid->lengthOfImpUse)); + } +if (lvid->nextIntegrityExt.extLength ==0 ) - goto check; +return ; loc =leea_to_cpu (lvid->nextIntegrityExt); }udf_warn (sb,"Too many LVID indirections (max %u), ignoring.\n" ,UDF_MAX_LVID_NESTING ); -out_err:brelse (sbi->s_lvid_bh); sbi->s_lvid_bh =NULL ; -return ; -check: - parts =le32_to_cpu (lvid->numOfPartitions); - impuselen =le32_to_cpu (lvid->lengthOfImpUse); -if (parts >= sb->s_blocksize || impuselen >= sb->s_blocksize || -sizeof (struct logicalVolIntegrityDesc ) + impuselen + -2 * parts *sizeof (u32) > sb->s_blocksize) { -udf_warn (sb,"Corrupted LVID (parts=%u, impuselen=%u), " -"ignoring.\n" , parts, impuselen); - goto out_err; - } }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 958/2214 udf: Make sure theres enough space for LVID implementation use field
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit a61fb39759d719a4f4966742b4d28387e33d81c4 ]
udf_lvid_valid() verifies that the LVID has enough space for all the tables and the reported length of ImplementationUse field. However it doesn't make sure the reported length is large enough to contain logicalVolIntegrityDescImpUse structure which OSTA specification requires. This can thus lead to accesses beyond the end of LVID buffer for suitably corrupted UDF filesystem. Add the length check.
--- fs/udf/super.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/udf/super.c +4 -1
@@ -1582,7 +1582,10 @@ static bool udf_lvid_valid(struct super_block *sb, parts =le32_to_cpu (lvid->numOfPartitions); impuselen =le32_to_cpu (lvid->lengthOfImpUse); -if (parts >= sb->s_blocksize || impuselen >= sb->s_blocksize || +if (sizeof (struct logicalVolIntegrityDescImpUse ) > impuselen || + impuselen >= sb->s_blocksize) +return false; +if (parts >= sb->s_blocksize ||sizeof (struct logicalVolIntegrityDesc ) + impuselen +2 * parts *sizeof (u32) > sb->s_blocksize)return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 959/2214 crypto: algif_skcipher - rewind rounded output bytes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
[ Upstream commit 2f90facc7b94934653eb7ebfadcc25d503b89196 ]
af_alg_get_rsgl() advances the receive iterator by the unrounded RX scatterlist length. For a continuing skcipher request, _skcipher_recvmsg() then rounds its local length down to a whole chunksize without restoring the iterator.
A later chunk starts after bytes which the provider never wrote, while the syscall returns only the processed length. When copy_splice_read() supplies non-zeroed pages and publishes that return as a dense prefix, the gap exposes stale bytes from a previous page lifetime.
With unprivileged xts(aes), a 31-byte MSG_MORE request followed by one final byte advances a 47-byte destination while returning 32 bytes. A hardened v7.2-rc5 image retained all 15 seeded stale bytes in 4,829 of 4,829 records. With init_on_alloc enabled, all 72,345 gap bytes observed were zero.
Rewind the iterator by the tail excluded during rounding, before rejecting a zero processed length. The crypto request uses only the rounded length; af_alg_free_resources() releases the entire RX list before another receive iteration.
The fixed target-like kernel returned byte-identical dense 48-byte output in 4,771 of 4,771 rounds. The unmodified kernel returned the vulnerable 32-byte short record in 2,409 of 2,409 rounds.
--- crypto/algif_skcipher.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
crypto/algif_skcipher.c +11 -2
@@ -82,8 +82,17 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,* If more buffers are to be expected to be processed, process only * full block size buffers. */ -if (ctx->more || len < ctx->used) - len -= len % bs; +if (ctx->more || len < ctx->used) { +size_t excess = len % bs; + + len -= excess; +iov_iter_revert (&msg->msg_iter, excess); + +if (!len) { + err = -EINVAL ; + goto free; + } + }/* * Create a per request TX SGL for this request which tracks the
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 960/2214 batman-adv: Limit number of aggregated packets directly
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 434becf57bdc89f939db635ed3337b9d1da5967e upstream.
The currently selected size in BATADV_MAX_AGGREGATION_BYTES (512) is chosen such that the number of possible aggregated packets is lower than 32. This number must be limited so that the type of batadv_forw_packet->direct_link_flags has enough bits to represent each packet (with the size of at least 24 bytes).
This requirement is better implemented in code instead of having it inside a comment.
--- net/batman-adv/bat_iv_ogm.c | 4 ++++ net/batman-adv/main.h | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-)
net/batman-adv/bat_iv_ogm.c +4 -0
@@ -450,6 +450,7 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,struct batadv_ogm_packet *batadv_ogm_packet;int aggregated_bytes = forw_packet->packet_len + packet_len;struct batadv_hard_iface *primary_if =NULL ; +u8 packet_num = forw_packet->num_packets +1 ;bool res = false;unsigned long aggregation_end_time;
@@ -475,6 +476,9 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,if (aggregated_bytes >BATADV_MAX_AGGREGATION_BYTES )return false; +if (packet_num >=BITS_PER_TYPE (forw_packet->direct_link_flags)) +return false; +/* packet is not leaving on the same interface. */ if (forw_packet->if_outgoing != if_outgoing)return false;
net/batman-adv/main.h +0 -3
@@ -102,9 +102,6 @@*/ #define BATADV_TQ_SIMILARITY_THRESHOLD 50 -/* should not be bigger than 512 bytes or change the size of -* forw_packet->direct_link_flags -*/ #define BATADV_MAX_AGGREGATION_BYTES 512#define BATADV_MAX_AGGREGATION_MS 100
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 961/2214 batman-adv: Close OGM aggregation before transmission
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
commit f91f64a91682c07e6c5f059804e709656364e8a6 upstream.
The OGM send worker leaves its forwarding packet on forw_bat_list until after batadv_iv_ogm_emit() returns. Aggregation holds forw_bat_list_lock, but emission reads and clones the packet without that lock.
CPU 0 can therefore start emitting a queued packet while CPU 1 takes the list lock, finds the same packet and appends another OGM. The sender can observe the new packet length before the corresponding direct-link flag is set, or clone the skb while its length and payload are being updated. This can transmit an OGM with incorrect flags or inconsistent data.
KCSAN reported:
BUG: KCSAN: data-race in batadv_iv_ogm_queue_add / batadv_iv_send_outstanding_bat_ogm_packet write to 0xffff888100fedcf8 of 2 bytes by interrupt on cpu 1: read to 0xffff888100fedcf8 of 2 bytes by task 70 on cpu 2: value changed: 0x00c0 -> 0x00d8
Mark the aggregate as full under forw_bat_list_lock before emission. This waits for any ongoing append and prevents further aggregation. Emission uses packet_len to walk the OGMs, so all queued packets are still sent. Keep the packet on the list so interface purging can find the worker, wait for it to finish and free the packet.
--- net/batman-adv/bat_iv_ogm.c | 5 +++++ net/batman-adv/types.h | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
net/batman-adv/bat_iv_ogm.c +5 -0
@@ -1794,6 +1794,11 @@ static void batadv_iv_send_outstanding_bat_ogm_packet(struct work_struct *work) goto out; } +/* Mark aggregate as full before forcing emit. */ +spin_lock_bh (&bat_priv->forw_bat_list_lock); + forw_packet->num_packets =BITS_PER_TYPE (forw_packet->direct_link_flags); +spin_unlock_bh (&bat_priv->forw_bat_list_lock); +batadv_iv_ogm_emit (forw_packet);/* we have to have at least one packet in the queue to determine the
net/batman-adv/types.h +7 -1
@@ -2177,7 +2177,13 @@ struct batadv_forw_packet {/** @direct_link_flags: direct link flags for aggregated OGM packets */ u32 direct_link_flags; -/** @num_packets: counter for aggregated OGMv1 packets */ +/** +* @num_packets: counter for aggregated OGMv1 packets. Set to +* BITS_PER_TYPE(forw_packet->direct_link_flags) (independent of the +* real number of aggregated packets) by the send worker to prevent +* further aggregation while the packet is emitted. It must therefore +* not be used to iterate over the aggregated packets +*/ u8 num_packets;/** @delayed_work: work queue callback item for packet sending */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 962/2214 batman-adv: tpmeter: fix u32 truncation of reported bytes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 1025b76d13288a311e8259a0eefde0854fa63c41 upstream.
When more than 4 GB are transferred by the throughput meter, batadv_tp_batctl_notify() will cut of the upper 32 bit of the u64 counter and thus under-report the actual transferred bytes.
The data type of the temporary storage variable must therefore still continue to use u64.
--- net/batman-adv/tp_meter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/tp_meter.c +1 -1
@@ -226,9 +226,9 @@ static void batadv_tp_batctl_notify(enum batadv_tp_meter_reason reason, unsigned long start_time, u64 total_sent, u32 cookie) { + u64 total_bytes;u32 test_time;u8 result; -u32 total_bytes;if (!batadv_tp_is_error (reason)) { result =BATADV_TP_REASON_COMPLETE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 963/2214 batman-adv: stop originator purge worker before freeing TT
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit f89eda5a9ccf82cba06b085b42ebc4886b8dfe9e upstream.
batadv_mesh_free() releases the translation tables via batadv_tt_free() before batadv_originator_free() stops orig_work. The purge worker can therefore still run while the TT is torn down. When an originator times out, batadv_purge_orig_ref() calls batadv_tt_global_del_orig(), which loads tt.global_hash and walks all buckets while taking their locks:
CPU0 CPU1
batadv_tt_free() batadv_purge_orig()
batadv_tt_global_del_orig()
hash = ...tt.global_hash;
batadv_tt_global_table_free()
batadv_hash_destroy(hash);
spin_lock_bh(&hash->list_locks[i]);Disable orig_work at the beginning of batadv_mesh_free(), directly after the mesh was marked as deactivating. The second disable_delayed_work_sync() in batadv_originator_free() is harmless because it is free'd anyway.
--- net/batman-adv/main.c | 5 +++++ 1 file changed, 5 insertions(+)
net/batman-adv/main.c +5 -0
@@ -262,6 +262,11 @@ void batadv_mesh_free(struct net_device *soft_iface)atomic_set (&bat_priv->mesh_state,BATADV_MESH_DEACTIVATING ); +/* the originator purge worker accesses (among others) the TT tables +* and must therefore be stopped before any of them are freed +*/ +cancel_delayed_work_sync (&bat_priv->orig_work); +batadv_purge_outstanding_packets (bat_priv,NULL );batadv_tp_stop_all (bat_priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 964/2214 batman-adv: tt: only transmit local ROAM flag together with DEL
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit 10f24f058417024a2c19cb8d88a6a0678a58a21b upstream.
BATADV_TT_CLIENT_ROAM is part of BATADV_TT_REMOTE_MASK but on the wire it only has a defined meaning together with BATADV_TT_CLIENT_DEL: the originator no longer serves the client because it roamed to another node. Such a DEL is only relevant for events (non-full table requests).
An ADD carrying ROAM is processed (by accident) by the receiver like aROAMING_ADV: a newly created global entry is marked as roaming and is excluded from the global CRC. But the sender includes it in its local CRC.
But such a behavior doesn't make sense for non-ROAM_ADV because a new TTVN is meant as announced commit of the local TT table of a node and should therefore not be used to create a temporary (roam) global entry in a node.
At the moment, such an ADD with the BATADV_TT_CLIENT_ROAM flag set can happen due to two mechanisms:
batadv_tt_local_valid() copies all flags of the local entry into a full table response. It is not synchronized with batadv_tt_local_mark_removed(). An entry which was marked as ROAM|PENDING by a ROAMING_ADV is still part of the current TTVN and is sent with the ROAM flag set. The receivers then create a roaming global entry for it and detect a CRC mismatch, which causes them to request the full table again.
The same can happen for an ADD change which is queued for an entry which (still) has the ROAM flag set. For example when only the dynamic WIFI or ISOLA flags were updated.
It is not triggered by batadv_send_other_tt_response() because batadv_tt_global_valid() is already taking care of filtering out BATADV_TT_CLIENT_ROAM entries.
For the two problematic announcement mechanism, only send the ROAM flag of local entries together with a DEL.
This only fixes the ROAM marking of the global entry and the resulting CRC mismatch. When the requester of the full table is the node which sent the ROAMING_ADV, the still announced entry will (independent of the ROAM flag) cause batadv_tt_global_purge_local() to remove the requester's own (new) local entry for the client. This is not addressed here.
--- net/batman-adv/translation-table.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
net/batman-adv/translation-table.c +14 -2
@@ -470,7 +470,6 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,if (!tt_change_node)return ; - tt_change_node->change.flags = flags;memset (tt_change_node->change.reserved,0 ,sizeof (tt_change_node->change.reserved));ether_addr_copy (tt_change_node->change.addr, common->addr);
@@ -478,6 +477,15 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv, del_op_requested = flags &BATADV_TT_CLIENT_DEL ; +/* the ROAM flag is only meaningful for the receiver in combination +* with a DEL. An ADD with ROAM would be interpreted as a roaming +* advertisement +*/ +if (!del_op_requested) + flags &= ~BATADV_TT_CLIENT_ROAM ; + + tt_change_node->change.flags = flags; +/* check for ADD+DEL or DEL+ADD events */ spin_lock_bh (&bat_priv->tt.changes_list_lock); list_for_each_entry_safe(entry, safe, &bat_priv->tt.changes_list,
@@ -2757,8 +2765,12 @@ static bool batadv_tt_local_valid(const void *entry_ptr,if (tt_common_entry->flags &BATADV_TT_CLIENT_NEW )return false; +/* the entry is (still) announced. A ROAM flag of an entry which is +* pending to be removed must not be transmitted. Otherwise, the +* receiver would handle it like a roaming advertisement +*/ if (flags) - *flags = tt_common_entry->flags; + *flags = tt_common_entry->flags & ~BATADV_TT_CLIENT_ROAM ;return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 965/2214 batman-adv: tt: clear ROAM flag when re-adding a pending local client
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit cc2186d7854785b30d423f5d43757b086b300e55 upstream.
When a ROAMING_ADV is received for an announced local client, batadv_tt_local_mark_removed() sets BATADV_TT_CLIENT_ROAM, queues a DEL|ROAM change and marks the entry as BATADV_TT_CLIENT_PENDING. If the client sends a frame again before the next TTVN commit, batadv_tt_local_add_existing() only clears the PENDING flag and returns early. The ADD cancels the queued DEL, but the entry keeps the ROAM flag:
* batadv_is_my_client() reports the client as not served by this node
* batadv_tt_local_client_is_roaming() reroutes unicast frames for it to the node which sent the ROAMING_ADV
The ROAM flag is only removed with the next frame of the client.
Since BATADV_TT_CLIENT_ROAM is set together with BATADV_TT_CLIENT_PENDING, it has to be cleared also at the same time with BATADV_TT_CLIENT_PENDING when the client roamed back.
--- net/batman-adv/translation-table.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/batman-adv/translation-table.c +6 -3
@@ -658,6 +658,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,int hash_added, table_size, packet_size_max;bool ret = false;bool roamed_back = false; +bool added = false;u8 remote_flags;u32 match_mark;
@@ -684,7 +685,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,* flag can be reset like it was never enqueued */ tt_local->common.flags &= ~BATADV_TT_CLIENT_PENDING ; - goto add_event; + added = true; }if (tt_local->common.flags &BATADV_TT_CLIENT_ROAM ) {
@@ -765,10 +766,12 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, goto out; } -add_event: -batadv_tt_local_event (bat_priv, tt_local,BATADV_NO_FLAGS ); + added = true; check_roaming: +if (added) +batadv_tt_local_event (bat_priv, tt_local,BATADV_NO_FLAGS ); +/* Check whether it is a roaming, but don't do anything if the roaming * process has already been handled */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 966/2214 batman-adv: tt: send ROAM_ADV on each roamed back client
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit aff4d5d10f2dcb4a9b604e27414dafa1d51b6406 upstream.
When a ROAMING_ADV is received for an announced local client, batadv_roam_tvlv_unicast_handler_v1() creates a global entry with the BATADV_TT_CLIENT_ROAM flag set.
If the client sends a frame again before the next TTVN commit, batadv_tt_local_add_roam() is expected to announce this return via a ROAM_ADV frame. But this doesn't happen because the global entry (created by the first ROAMING_ADV) carries BATADV_TT_CLIENT_ROAM until the new originator announces the client.
Let batadv_tt_local_add_roam() always handle a roamed back client - independent of the ROAM flag of the global entry:
* trigger sending of the ROAM_ADV frame(s)
* remove the (with the roaming) associated global entry
--- net/batman-adv/translation-table.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/batman-adv/translation-table.c +2 -1
@@ -775,7 +775,8 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,/* Check whether it is a roaming, but don't do anything if the roaming * process has already been handled */ -if (tt_global && !(tt_global->common.flags &BATADV_TT_CLIENT_ROAM )) { +if (tt_global && + (roamed_back || !(tt_global->common.flags &BATADV_TT_CLIENT_ROAM ))) {/* These node are probably going to update their tt table */ head = &tt_global->orig_list;rcu_read_lock ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 967/2214 batman-adv: tt: ignore ROAM flag of received ADD changes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit c5d68abe6e7f1dbd132a602cb696fe1fff0389eb upstream.
A received TT change (OGM diff or full table response) with the ROAM flag but without DEL is handled by batadv_tt_global_add() like a ROAMING_ADV:
* a newly created global entry gets BATADV_TT_CLIENT_ROAM and is therefore excluded from the global CRC. The sender has it in its local CRC and the receiver has to request the full table again
* batadv_tt_global_purge_local() removes the local entry of the receiver. The receiver's own client is considered as roamed to the sender and frames for it are rerouted
The ROAM flag only has a meaning together with DEL. Drop it on reception to keep it from populating the global table with a temporary ROAMING entry which is not part of the CRC - and therefore causing a CRC mismatch.
--- net/batman-adv/translation-table.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
net/batman-adv/translation-table.c +12 -3
@@ -3339,20 +3339,29 @@ static void _batadv_tt_update_changes(struct batadv_priv *bat_priv, {int i;int roams; +u8 flags;for (i =0 ; i < tt_num_changes; i++) { -if ((tt_change + i)->flags &BATADV_TT_CLIENT_DEL ) { - roams = (tt_change + i)->flags &BATADV_TT_CLIENT_ROAM ; + flags = (tt_change + i)->flags; + +if (flags &BATADV_TT_CLIENT_DEL ) { + roams = flags &BATADV_TT_CLIENT_ROAM ;batadv_tt_global_del (bat_priv, orig_node, (tt_change + i)->addr,ntohs ((tt_change + i)->vid),"tt removed by changes" , roams); }else { +/* an announced client cannot have roamed away from +* orig_node. Only a ROAMING_ADV is allowed to add a +* global entry with the ROAM flag +*/ + flags &= ~BATADV_TT_CLIENT_ROAM ; +if (!batadv_tt_global_add (bat_priv, orig_node, (tt_change + i)->addr,ntohs ((tt_change + i)->vid), - (tt_change + i)->flags, ttvn)) + flags, ttvn))/* In case of problem while storing a * global_entry, we stop the updating * procedure without committing the
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 968/2214 batman-adv: tt: only update flags for TT events
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit ad1fd828aa3944efc393b84b0d7c02483f1b5638 upstream.
In the first implementation of the translation table events, it was only possible to announce:
* ADD: new locally detected client
* DEL: disappeared local client
If an ADD event was queued and then a DEL event was queued in the same timeslot, it is valid to destroy both events because nothing actually changed for remode nodes
But with commit 3c4f7ab60cc2 ("batman-adv: improve the TT component to support runtime flag changes") and subsequent changes, it could also happen that there are extra ADD events:
* ADD: _NEW_ locally detected client
* ADD: already existing client with new flags
* DEL: disappeared local client
The first and the last type of event could in theory still be removed together from the (to be announced) events queue. But if the "update flags" ADD is dropped together with the DEL, it would still leave global translation table of a remote node in the incorrect state - believing that the client didn't disappear.
If a detected client was previously announced, a DEL event must only overwrite the "update flags" ADD but the DEL itself must still continue to exist in the (to be anounced) events queue. For now, adjustment of the announced flags is used for everything instead of dropping already queued up events completely.
Similarly, a DEL followed by an ADD caused both entries to be deleted. But the new ADD could announce flags changes which were not yet present for the client before it was marked for DELetion. The new ADD must therefore only overwrite the DEL - but still be kept.
--- net/batman-adv/translation-table.c | 41 ++++++++---------------------- 1 file changed, 11 insertions(+), 30 deletions(-)
net/batman-adv/translation-table.c +11 -30
@@ -455,6 +455,9 @@ batadv_tt_orig_list_entry_put(struct batadv_tt_orig_list_entry *orig_entry)* @bat_priv: the bat priv with all the soft interface information * @tt_local_entry: the TT entry involved in the event * @event_flags: flags to store in the event structure +* +* Only a single change per client is queued. It describes the latest state of +* the client and a new event therefore replaces an already queued one. */ static void batadv_tt_local_event(struct batadv_priv *bat_priv, struct batadv_tt_local_entry *tt_local_entry,
@@ -463,8 +466,7 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,struct batadv_tt_change_node *tt_change_node, *entry, *safe;struct batadv_tt_common_entry *common = &tt_local_entry->common;u8 flags = common->flags | event_flags; -bool event_removed = false; -bool del_op_requested, del_op_entry; +bool del_op_requested; tt_change_node =kmem_cache_alloc (batadv_tt_change_cache,GFP_ATOMIC );if (!tt_change_node)
@@ -496,44 +498,23 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,if (entry->change.vid != tt_change_node->change.vid)continue ; -/* DEL+ADD in the same orig interval have no effect and can be -* removed to avoid silly behaviour on the receiver side. The -* other way around (ADD+DEL) can happen in case of roaming of -* a client still in the NEW state. Roaming of NEW clients is -* now possible due to automatically recognition of "temporary" -* clients -*/ - del_op_entry = entry->change.flags &BATADV_TT_CLIENT_DEL ; -if (!del_op_requested && del_op_entry) - goto del; -if (del_op_requested && !del_op_entry) - goto del; - -/* this is a second add in the same originator interval. It -* means that flags have been changed: update them! +/* the other nodes may know the client with different +* flags. A DEL+ADD must therefore still announce the +* current flags and an ADD+DEL must still remove the +* client. ADD+ADD and DEL+DEL only update the flags */ -if (!del_op_requested && !del_op_entry) - entry->change.flags = flags; - -continue ; -del: -list_del (&entry->list); -kmem_cache_free (batadv_tt_change_cache, entry); + entry->change.flags = flags;kmem_cache_free (batadv_tt_change_cache, tt_change_node); - event_removed = true; + goto unlock; }/* track the change in the OGMinterval list */ list_add_tail (&tt_change_node->list, &bat_priv->tt.changes_list); +atomic_inc (&bat_priv->tt.local_changes); unlock:spin_unlock_bh (&bat_priv->tt.changes_list_lock); - -if (event_removed) -atomic_dec (&bat_priv->tt.local_changes); -else -atomic_inc (&bat_priv->tt.local_changes); }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 969/2214 batman-adv: tt: dont drop local events queued during TVLV update
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit ed7a0dfdd370acb48be7a281df732c1bebcc7f1d upstream.
batadv_tt_tvlv_container_update() read the number of local changes without holding changes_list_lock. batadv_tt_local_event() is not serialized by the commit_lock and can queue new events before the changes_list is flushed:
CPU0 CPU1
batadv_tt_tvlv_container_update()
num = ...local_changes;
batadv_tt_local_event()
list_add_tail(...);
...local_changes++;
spin_lock_bh(&...changes_list_lock);
/* only num events copied but all freed */The additional events were freed without ever being sent. Other nodes will only notice this via a CRC mismatch and must request the full table.
The number of changes and the changes_list must therefore be taken atomically. Events queued afterwards then stay in the tt.changes_list for the next TT round.
The changes can no longer be kept for the next round when the TVLV buffer allocation fails. But they would be sent with a skipped TTVN anyway, so the other nodes have to request the full table in this case either way. The last changeset is only dropped in this case when the TTVN was incremented. Without new changes, it still describes the current TTVN.
Previously, the unconsumed changes caused a retry of the TVLV container update in the next commit round. Since the changes are now consumed, the next round would only take the path without changes and wait for BATADV_TT_OGM_APPEND_MAX rounds before updating the container again. Until then, the outdated container with the previous TTVN would still be announced. The ogm_append_cnt is therefore reset on failure to retry the update in the next OGM interval.
This doesn't make the CRC consistent with the announced changeset. The local table modifications are still not serialized with the commit and batadv_tt_local_transition_new() can still make a client part of the CRC for which the event is only part of the next TT round. Such an inconsistency is detected by the CRC check of the other nodes and solved via a full table request.
[ Context, switch to old "mesh_iface" name "soft_iface", access
local_changes with atomic_t helpers ]
--- net/batman-adv/translation-table.c | 61 +++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 13 deletions(-)
net/batman-adv/translation-table.c +48 -13
@@ -1019,20 +1019,22 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv,* batadv_tt_tvlv_container_update() - update the translation table tvlv * container after local tt changes have been committed * @bat_priv: the bat priv with all the soft interface information +* @changes_list: list of committed changes which will be consumed +* @tt_diff_entries_num: number of entries in @changes_list */ -static void batadv_tt_tvlv_container_update (struct batadv_priv *bat_priv) +static void batadv_tt_tvlv_container_update (struct batadv_priv *bat_priv, +struct list_head *changes_list, +int tt_diff_entries_num) {struct batadv_tt_change_node *entry, *safe;struct batadv_tvlv_tt_data *tt_data;struct batadv_tvlv_tt_change *tt_change;int tt_diff_len, tt_change_len =0 ; -int tt_diff_entries_num =0 ;int tt_diff_entries_count =0 ;bool drop_changes = false;size_t tt_extra_len =0 ;u16 tvlv_len; - tt_diff_entries_num =atomic_read (&bat_priv->tt.local_changes); tt_diff_len =batadv_tt_len (tt_diff_entries_num);/* if we have too many changes for one packet don't send any
@@ -1050,19 +1052,39 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv) tvlv_len =batadv_tt_prepare_tvlv_local_data (bat_priv, &tt_data, &tt_change, &tt_diff_len); -if (!tvlv_len) +if (!tvlv_len) { +/* the changes are lost and the other nodes have to request the +* full table. Don't answer TT requests for the new TTVN with +* the stale changeset of the previous TTVN. Without changes, the +* TTVN was not incremented and the last changeset is still valid +*/ +if (drop_changes || tt_diff_entries_num >0 ) { +list_for_each_entry_safe (entry, safe, changes_list, + list) { +list_del (&entry->list); +kmem_cache_free (batadv_tt_change_cache, entry); + } + +spin_lock_bh (&bat_priv->tt.last_changeset_lock); +kfree (bat_priv->tt.last_changeset); + bat_priv->tt.last_changeset =NULL ; + bat_priv->tt.last_changeset_len =0 ; +spin_unlock_bh (&bat_priv->tt.last_changeset_lock); + } + +/* announce the already committed TTVN in the next OGM interval +* instead of waiting for BATADV_TT_OGM_APPEND_MAX idle rounds +*/ +atomic_set (&bat_priv->tt.ogm_append_cnt,0 );return ; + } tt_data->flags =BATADV_TT_OGM_DIFF ;if (!drop_changes && tt_diff_len ==0 ) goto container_register; -spin_lock_bh (&bat_priv->tt.changes_list_lock); -atomic_set (&bat_priv->tt.local_changes,0 ); - -list_for_each_entry_safe (entry, safe, &bat_priv->tt.changes_list, - list) { +list_for_each_entry_safe (entry, safe, changes_list, list) {if (tt_diff_entries_count < tt_diff_entries_num) { memcpy(tt_change + tt_diff_entries_count, &entry->change,
@@ -1072,7 +1094,6 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv)list_del (&entry->list);kmem_cache_free (batadv_tt_change_cache, entry); } -spin_unlock_bh (&bat_priv->tt.changes_list_lock); tt_extra_len =batadv_tt_len (tt_diff_entries_num - tt_diff_entries_count);
@@ -3761,11 +3782,25 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)*/ static void batadv_tt_local_commit_changes_nolock (struct batadv_priv *bat_priv) { +LIST_HEAD (changes_list); +int changes_num; +lockdep_assert_held (&bat_priv->tt.commit_lock); -if (atomic_read (&bat_priv->tt.local_changes) <1 ) { +/* atomically get the list of changes. The TTVN decision and the +* announced changeset must cover the same events. Events queued +* afterwards stay in the tt.changes_list for the next TT round +*/ +spin_lock_bh (&bat_priv->tt.changes_list_lock); +list_splice_init (&bat_priv->tt.changes_list, &changes_list); + changes_num =atomic_read (&bat_priv->tt.local_changes); +atomic_set (&bat_priv->tt.local_changes,0 ); +spin_unlock_bh (&bat_priv->tt.changes_list_lock); + +if (changes_num ==0 ) {if (!batadv_atomic_dec_not_zero (&bat_priv->tt.ogm_append_cnt)) -batadv_tt_tvlv_container_update (bat_priv); +batadv_tt_tvlv_container_update (bat_priv, &changes_list, + changes_num);return ; }
@@ -3782,7 +3817,7 @@ static void batadv_tt_local_commit_changes_nolock(struct batadv_priv *bat_priv)/* reset the sending counter */ atomic_set (&bat_priv->tt.ogm_append_cnt,BATADV_TT_OGM_APPEND_MAX ); -batadv_tt_tvlv_container_update (bat_priv); +batadv_tt_tvlv_container_update (bat_priv, &changes_list, changes_num); }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 970/2214 lib/crypto: mips: Disable Octeon SHA code on little-endian kernels
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit dd2a4edb26e1c78823c50ba10c42f2d3de2e5ec4 upstream.
Kernels built for the MIPS64-based Cavium Octeon SoCs are normally big-endian, but little-endian builds are also supported. Currently, the SHA-1, SHA-256, and SHA-512 code using the Octeon crypto co-processor is enabled in both builds.
This code is untestable without the hardware. However, based on the code itself, it is implausible that it computes hash values correctly in little-endian builds. Such builds write many incorrect values to COP2:
- SHA-1 and SHA-256: The 64-bit integer that contains the last two 32-bit message words of each block is written to COP2 entirely byte-reflected, due to missing endianness conversion in octeon_sha1_start() and octeon_sha256_start() to compensate for using native 64-bit loads from the message bytes. This differs from all the earlier message words which are written correctly.
Furthermore, the state is written to COP2 with each 32-bit word byte-reflected within each 64-bit integer, due to incorrect use of 64-bit endianness conversion in write_octeon_64bit_hash_dword() when the state is kept in memory in native-endian 32-bit words.
- SHA-512: All the 64-bit message words are written to COP2 byte-reflected, due to missing endianness conversion in write_octeon_64bit_block_sha512() and octeon_sha512_start(). The SHA-512 state words seem to be written correctly.
Big-endian kernels aren't affected by these bugs. These bugs also aren't new; this code has been broken on little-endian ever since it and Octeon little-endian support were first added in v4.1.
Commit d2a948d2db68 ("MIPS: Octeon: Make octeon-md5 driver endian-agnostic") made the MD5 code work on little-endian kernels by adding 64-bit endianness conversions to the COP2 macros used by MD5 (some of which are shared by SHA-1 and SHA-256, despite those algorithms keeping the state words in native-endian instead of MD5's little-endian, causing some of the strange behavior described above). However, SHA-1, SHA-256, and SHA-512 were never fixed to work on little-endian kernels.
Therefore, disable the Octeon SHA-1, SHA-256, and SHA-512 code in little-endian kernels. This causes the generic code that actually computes hash values correctly to be used instead.
--- crypto/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
crypto/Kconfig +3 -3
@@ -868,7 +868,7 @@ config CRYPTO_SHA512_SSSE3 config CRYPTO_SHA1_OCTEON tristate "SHA1 digest algorithm (OCTEON)" - depends on CPU_CAVIUM_OCTEON + depends on CPU_CAVIUM_OCTEON && CPU_BIG_ENDIAN select CRYPTO_SHA1 select CRYPTO_HASH help
@@ -922,7 +922,7 @@ config CRYPTO_SHA256_PPC_SPE config CRYPTO_SHA256_OCTEON tristate "SHA224 and SHA256 digest algorithm (OCTEON)" - depends on CPU_CAVIUM_OCTEON + depends on CPU_CAVIUM_OCTEON && CPU_BIG_ENDIAN select CRYPTO_SHA256 select CRYPTO_HASH help
@@ -952,7 +952,7 @@ config CRYPTO_SHA512 config CRYPTO_SHA512_OCTEON tristate "SHA384 and SHA512 digest algorithms (OCTEON)" - depends on CPU_CAVIUM_OCTEON + depends on CPU_CAVIUM_OCTEON && CPU_BIG_ENDIAN select CRYPTO_SHA512 select CRYPTO_HASH help
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 971/2214 ALSA: usx2y: Refuse a retried DSP load after a failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <[email protected]>
[ Upstream commit 1f8101b6adc87a3ddbd51fcb6609251591758026 ]
snd_usx2y_hwdep_dsp_load() sets up the asynchronous sequence URBs and the interrupt URB when the FPGA firmware image with index 1 is loaded, and then creates the ALSA devices. If usx2y_in04_init() or usx2y_create_alsa_devices() fails, the URBs that were already set up are left in place.
The core keeps the index unloaded when the callback fails, so user space may issue the same request again. The second attempt then enters usx2y_async_seq04_init() or usx2y_in04_init() with the URBs still allocated and trips WARN_ON(usx2y->as04.buffer) or WARN_ON(usx2y->in04_urb).
The URBs cannot be released at this point: the card may already have registered PCM devices that user space can still open, and the disconnect handler accesses the URBs without holding the DSP lock. Mark the chip as hung instead, so that a retried request is refused with -ENODEV and the assertions keep their meaning. The URBs are released by snd_usx2y_card_private_free() when the card is freed.
A failing usx2y_async_seq04_init() still releases its own URBs, so that path remains retryable.
--- sound/usb/usx2y/usX2Yhwdep.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/usb/usx2y/usX2Yhwdep.c +5 -0
@@ -185,6 +185,9 @@ static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw,int lret, err;char *buf; +if (priv->chip_status &USX2Y_STAT_CHIP_HUP ) +return -ENODEV ; +snd_printdd ("dsp_load %s\n" , dsp->name); buf =memdup_user (dsp->image, dsp->length);
@@ -209,11 +212,13 @@ static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw, err =usx2y_in04_init (priv);if (err) {snd_printk (KERN_ERR "usx2y_in04_init error\n" ); + priv->chip_status |=USX2Y_STAT_CHIP_HUP ;return err; } err =usx2y_create_alsa_devices (hw->card);if (err) {snd_printk (KERN_ERR "usx2y_create_alsa_devices error %i\n" , err); + priv->chip_status |=USX2Y_STAT_CHIP_HUP ;return err; } priv->chip_status |=USX2Y_STAT_CHIP_INIT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 972/2214 ALSA: bcd2000: Fix race between rawmidi and disconnect
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 221253723dc58bb901c3f27a7659823e63fc598c upstream.
The 5.15.y tree is still built with -std=gnu89, so the guard() and scoped_guard() helpers used by the upstream patch cannot be used here. Use explicit spin_lock_irqsave()/spin_unlock_irqrestore() pairs instead; the locking scope is unchanged.
Although we tried to fix the potential UAF issues at USB disconnect on bcd2000 driver, there is still an overlooked case -- namely, when a rawmidi trigger callback has been already running at USB disconnect handling, the in-flight function (e.g. bcd2000_midi_send()) could still access the URB, because the previous URB NULL-check & clearance was considered only for the URB complete callbacks, but not about the parallel rawmidi operations.
For addressing the race, this patch introduced a new spinlock that covers each rawmidi operation as well as the rawmidi handling in the complete callback. The URB is cleared with the lock, so it guarantees that the pending rawmidi task already finished or a NULL check is effective.
--- sound/usb/bcd2000/bcd2000.c | 45 +++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 7 deletions(-)
sound/usb/bcd2000/bcd2000.c +38 -7
@@ -43,6 +43,7 @@ struct bcd2000 {struct usb_interface *intf;int card_index; +spinlock_t midi_lock;int midi_out_active;struct snd_rawmidi *rmidi;struct snd_rawmidi_substream *midi_receive_substream;
@@ -90,7 +91,11 @@ static void bcd2000_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) {struct bcd2000 *bcd2k = substream->rmidi->private_data; +unsigned long flags; + +spin_lock_irqsave (&bcd2k->midi_lock, flags); bcd2k->midi_receive_substream = up ? substream :NULL ; +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); } static void bcd2000_midi_handle_input(struct bcd2000 *bcd2k,
@@ -194,6 +199,9 @@ static void bcd2000_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) {struct bcd2000 *bcd2k = substream->rmidi->private_data; +unsigned long flags; + +spin_lock_irqsave (&bcd2k->midi_lock, flags);if (up) { bcd2k->midi_out_substream = substream;
@@ -203,11 +211,14 @@ static void bcd2000_midi_output_trigger(struct snd_rawmidi_substream *substream, }else { bcd2k->midi_out_substream =NULL ; } + +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); }static void bcd2000_output_complete (struct urb *urb) {struct bcd2000 *bcd2k = urb->context; +unsigned long flags; bcd2k->midi_out_active =0 ;
@@ -219,12 +230,15 @@ static void bcd2000_output_complete(struct urb *urb)return ;/* check if there is more data userspace wants to send */ +spin_lock_irqsave (&bcd2k->midi_lock, flags);bcd2000_midi_send (bcd2k); +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); }static void bcd2000_input_complete (struct urb *urb) {int ret; +unsigned long flags;struct bcd2000 *bcd2k = urb->context;if (urb->status)
@@ -234,6 +248,8 @@ static void bcd2000_input_complete(struct urb *urb)if (!bcd2k || urb->status == -ESHUTDOWN )return ; +spin_lock_irqsave (&bcd2k->midi_lock, flags); +if (urb->actual_length >0 )bcd2000_midi_handle_input (bcd2k, urb->transfer_buffer, urb->actual_length);
@@ -244,6 +260,8 @@ static void bcd2000_input_complete(struct urb *urb)dev_err (&bcd2k->dev->dev,PREFIX "%s: usb_submit_urb() failed, ret=%d\n" , __func__, ret); + +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); }static const struct snd_rawmidi_ops bcd2000_midi_output = {
@@ -348,16 +366,28 @@ static int bcd2000_init_midi(struct bcd2000 *bcd2k)return 0 ; } +static void bcd2000_midi_free (struct bcd2000 *bcd2k, +struct urb **urb_p) +{ +struct urb *urb = *urb_p; +unsigned long flags; + +if (!urb) +return ; + +usb_poison_urb (urb); +spin_lock_irqsave (&bcd2k->midi_lock, flags); + *urb_p =NULL ; +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); + +usb_free_urb (urb); +} +static void bcd2000_free_usb_related_resources (struct bcd2000 *bcd2k,struct usb_interface *interface) { -usb_poison_urb (bcd2k->midi_out_urb); -usb_poison_urb (bcd2k->midi_in_urb); - -usb_free_urb (bcd2k->midi_out_urb); -usb_free_urb (bcd2k->midi_in_urb); - bcd2k->midi_out_urb =NULL ; - bcd2k->midi_in_urb =NULL ; +bcd2000_midi_free (bcd2k, &bcd2k->midi_out_urb); +bcd2000_midi_free (bcd2k, &bcd2k->midi_in_urb);if (bcd2k->intf) {usb_set_intfdata (bcd2k->intf,NULL );
@@ -397,6 +427,7 @@ static int bcd2000_probe(struct usb_interface *interface, bcd2k->card = card; bcd2k->card_index = card_index; bcd2k->intf = interface; +spin_lock_init (&bcd2k->midi_lock);snd_card_set_dev (card, &interface->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 973/2214 ALSA: bcd2000: Fix use-after-free of MIDI URBs on file close
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <[email protected]>
commit f6c7bb1f0799591a62be75b9bcf84245b4f208b7 upstream.
The 5.15.y tree is still built with -std=gnu89, so the guard() and scoped_guard() helpers used by the upstream patch cannot be used here. Use explicit spin_lock_irqsave()/spin_unlock_irqrestore() pairs instead; the locking scope is unchanged.
bcd2000_disconnect() calls snd_card_disconnect(), which only prevents new opens, and then frees the MIDI URBs. A rawmidi file that was already open can still be closed afterwards, and its close callback, bcd2000_midi_output_close(), calls usb_kill_urb() on midi_out_urb.
The URB pointers are cleared on disconnect and their accesses are serialized with midi_lock, but bcd2000_midi_output_close() reads midi_out_urb without that lock. The check can therefore pass just before the pointer is cleared, and usb_kill_urb() then runs on the URB that has already been freed:
BUG: KASAN: slab-use-after-free in usb_kill_urb+0x74/0x80 Read of size 8 at addr ffff8880078e7d40 usb_kill_urb bcd2000_midi_output_close close_substream rawmidi_release_priv snd_rawmidi_release
Allocated by: usb_alloc_urb <- bcd2000_init_midi <- bcd2000_probe
Freed by: usb_free_urb <- bcd2000_midi_free
<- bcd2000_disconnect
Take the lock in bcd2000_midi_output_close() and reference the URB with usb_get_urb() before releasing it. The URB then stays valid until usb_put_urb() after usb_kill_urb() has returned, even if a disconnect frees it in the meantime. usb_kill_urb() itself cannot run under midi_lock, as the completion handler takes the same lock.
--- sound/usb/bcd2000/bcd2000.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
sound/usb/bcd2000/bcd2000.c +16 -1
@@ -185,11 +185,26 @@ static int bcd2000_midi_output_open(struct snd_rawmidi_substream *substream)static int bcd2000_midi_output_close (struct snd_rawmidi_substream *substream) {struct bcd2000 *bcd2k = substream->rmidi->private_data; +struct urb *urb =NULL ; +unsigned long flags; +/* +* Reference the URB under the lock so that it stays valid until +* usb_kill_urb() returns, even if a disconnect frees it in the +* meantime. usb_kill_urb() cannot run under the lock, as the +* completion handler takes the same lock. +*/ +spin_lock_irqsave (&bcd2k->midi_lock, flags);if (bcd2k->midi_out_active && bcd2k->midi_out_urb) { -usb_kill_urb (bcd2k->midi_out_urb); + urb =usb_get_urb (bcd2k->midi_out_urb); bcd2k->midi_out_active =0 ; } +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); + +if (urb) { +usb_kill_urb (urb); +usb_put_urb (urb); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 974/2214 of/fdt: Ignore disabled memory nodes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andre Przywara <[email protected]>
commit df5cd369876114f91f9ae60658fea80acfb15890 upstream.
When we boot a machine using a devicetree, the generic DT code goes through all nodes with a 'device_type = "memory"' property, and collects all memory banks mentioned there. However it does not check for the status property, so any nodes which are explicitly "disabled" will still be added as a memblock.
This ends up badly for QEMU, when booting with secure firmware on arm/arm64 machines, because QEMU adds a node describing secure-only memory:
===================
secram@e000000 {
secure-status = "okay";
status = "disabled";
reg = <0x00 0xe000000 0x00 0x1000000>;
device_type = "memory";
};===================
The kernel will eventually use that memory block (which is located below the main DRAM bank), but accesses to that will be answered with an SError:
===================
[ 0.000000] Internal error: synchronous external abort: 96000050 [#1] PREEMPT SMP [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.18.0-rc6-00014-g10c8acb8b679 #524 [ 0.000000] Hardware name: linux,dummy-virt (DT) [ 0.000000] pstate: 200000c5 (nzCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.000000] pc : new_slab+0x190/0x340 [ 0.000000] lr : new_slab+0x184/0x340 [ 0.000000] sp : ffff80000a4b3d10
....
==================
The actual crash location and call stack will be somewhat random, and depend on the specific allocation of that physical memory range.
As the DT spec[1] explicitly mentions standard properties, add a simple check to skip over disabled memory nodes, so that we only use memory that is meant for non-secure code to use.
That fixes booting a QEMU arm64 VM with EL3 enabled ("secure=on"), when not using UEFI. In this case the QEMU generated DT will be handed on to the kernel, which will see the secram node.
This issue is reproducible when using TF-A together with U-Boot as firmware, then booting with the "booti" command.
When using U-Boot as an UEFI provider, the code there [2] explicitly filters for disabled nodes when generating the UEFI memory map, so we are safe.
EDK/2 only reads the first bank of the first DT memory node [3] to learn about memory, so we got lucky there.
[1] https://github.com/devicetree-org/devicetree-specification/blob/main/source/chapter3-devicenodes.rst#memory-node (after the table)
[2] https://source.denx.de/u-boot/u-boot/-/blob/master/lib/fdtdec.c#L1061-1063
[3] https://github.com/tianocore/edk2/blob/master/ArmVirtPkg/PrePi/FdtParser.c
[ Georgiy: 5.15 lacks commit 1f012283e936 ("of/fdt: Rework
early_init_dt_scan_memory() to call directly"), so the function still handles one node per of_scan_flat_dt() call: return 0 instead of continue and use initial_boot_params instead of the local fdt. ]
--- drivers/of/fdt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/of/fdt.c +3 -0
@@ -1102,6 +1102,9 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,if (type ==NULL ||strcmp (type,"memory" ) !=0 )return 0 ; +if (!of_fdt_device_is_available (initial_boot_params, node)) +return 0 ; + reg =of_get_flat_dt_prop (node,"linux,usable-memory" , &l);if (reg ==NULL ) reg =of_get_flat_dt_prop (node,"reg" , &l);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 975/2214 wifi: mac80211: queue frames while off-channel
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislaw Gruszka <[email protected]>
[ Upstream commit 13e51269b6656768dc595ed6025e4974f2026543 ]
Drivers without FAST_XMIT and hardware scan support currently drop TX frames during software scanning while being off-channel. This happens in ieee80211_tx_h_check_assoc() before frames reach internal TX queue.
Move the off-channel check to invoke_tx_handlers_late(), after ieee80211_queue_skb(). Frames can then remain queued and be transmitted when the interface returns on-channel. This how TX works currently when code goes via ieee80211_xmit_fast() path.
Below is rt2x00 driver ping output example while scanning, before and after the fix. After the fix, packets are no longer lost. Some have increased latency, what is expected behavior.
BEFORE:
64 bytes from 192.168.0.1: icmp_seq=29 ttl=64 time=3.61 ms 64 bytes from 192.168.0.1: icmp_seq=31 ttl=64 time=3.33 ms # Missed 30 64 bytes from 192.168.0.1: icmp_seq=32 ttl=64 time=4.03 ms 64 bytes from 192.168.0.1: icmp_seq=34 ttl=64 time=3.10 ms # Missed 33 64 bytes from 192.168.0.1: icmp_seq=36 ttl=64 time=3.04 ms # Missed 35 64 bytes from 192.168.0.1: icmp_seq=38 ttl=64 time=3.05 ms # Missed 37 64 bytes from 192.168.0.1: icmp_seq=40 ttl=64 time=4.14 ms # Missed 39 64 bytes from 192.168.0.1: icmp_seq=41 ttl=64 time=4.50 ms
AFTER:
64 bytes from 192.168.0.1: icmp_seq=29 ttl=64 time=3.40 ms 64 bytes from 192.168.0.1: icmp_seq=30 ttl=64 time=6.10 ms 64 bytes from 192.168.0.1: icmp_seq=31 ttl=64 time=4.69 ms 64 bytes from 192.168.0.1: icmp_seq=32 ttl=64 time=4.49 ms 64 bytes from 192.168.0.1: icmp_seq=33 ttl=64 time=148 ms 64 bytes from 192.168.0.1: icmp_seq=34 ttl=64 time=6.83 ms 64 bytes from 192.168.0.1: icmp_seq=35 ttl=64 time=8.66 ms 64 bytes from 192.168.0.1: icmp_seq=36 ttl=64 time=13.0 ms 64 bytes from 192.168.0.1: icmp_seq=37 ttl=64 time=4.78 ms 64 bytes from 192.168.0.1: icmp_seq=38 ttl=64 time=3.85 ms
--- net/mac80211/tx.c | 50 ++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 22 deletions(-)
net/mac80211/tx.c +28 -22
@@ -282,7 +282,6 @@ ieee80211_tx_h_dynamic_ps(struct ieee80211_tx_data *tx) static ieee80211_tx_result debug_noinlineieee80211_tx_h_check_assoc (struct ieee80211_tx_data *tx) { -struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb);bool assoc = false;
@@ -290,23 +289,6 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)if (unlikely (info->flags &IEEE80211_TX_CTL_INJECTED ))return TX_CONTINUE ; -if (unlikely (test_bit (SCAN_SW_SCANNING , &tx->local->scanning)) && -test_bit (SDATA_STATE_OFFCHANNEL , &tx->sdata->state) && - !ieee80211_is_probe_req (hdr->frame_control) && - !ieee80211_is_any_nullfunc (hdr->frame_control)) -/* -* When software scanning only nullfunc frames (to notify -* the sleep state to the AP) and probe requests (for the -* active scan) are allowed, all other frames should not be -* sent and we should not get here, but if we do -* nonetheless, drop them to avoid sending them -* off-channel. See the link below and -* ieee80211_start_scan() for more. -* -* http://article.gmane.org/gmane.linux.kernel.wireless.general/30089 -*/ -return TX_DROP ; -if (tx->sdata->vif.type ==NL80211_IFTYPE_OCB )return TX_CONTINUE ;
@@ -791,6 +773,33 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)return TX_CONTINUE ; } +static ieee80211_tx_result debug_noinline +ieee80211_tx_h_check_offchannel (struct ieee80211_tx_data *tx) +{ +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; +struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb); + +if (unlikely (info->flags &IEEE80211_TX_CTL_INJECTED )) +return TX_CONTINUE ; + +if (unlikely (test_bit (SCAN_SW_SCANNING , &tx->local->scanning)) && +test_bit (SDATA_STATE_OFFCHANNEL , &tx->sdata->state) && + !ieee80211_is_probe_req (hdr->frame_control) && + !ieee80211_is_any_nullfunc (hdr->frame_control)) { +/* +* When software scanning only nullfunc frames (to notify +* the sleep state to the AP) and probe requests (for the +* active scan) are allowed, all other frames should not be +* sent and we should not get here, but if we do +* nonetheless, drop them to avoid sending them +* off-channel. See __ieee80211_start_scan() for more. +*/ +return TX_DROP ; + } + +return TX_CONTINUE ; +} +static __le16 ieee80211_tx_next_seq (struct sta_info *sta,int tid) {u16 *seq = &sta->tid_seq[tid];
@@ -1838,6 +1847,7 @@ static int invoke_tx_handlers_late(struct ieee80211_tx_data *tx) goto txh_done; } +CALL_TXH (ieee80211_tx_h_check_offchannel);CALL_TXH (ieee80211_tx_h_michael_mic_add);CALL_TXH (ieee80211_tx_h_sequence);CALL_TXH (ieee80211_tx_h_fragment);
@@ -4477,10 +4487,6 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,skb_get_hash (skb); } -if (unlikely (test_bit (SCAN_SW_SCANNING , &local->scanning)) && -test_bit (SDATA_STATE_OFFCHANNEL , &sdata->state)) - goto out_free; -memset (info,0 ,sizeof (*info));ieee80211_aggr_check (sdata, sta, skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 976/2214 media: imx-jpeg: finish the job on device_run() error paths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit 30b35fd2b999e1b8c26f8191d974d20c8848d2d6 ]
mxc_jpeg_device_run() returns early through a shared "end" label on several error paths (no free slot, mxc_jpeg_alloc_slot_data() failure, or missing buffers or queue data), and none of them calls v4l2_m2m_job_finish(). Since the delayed work is queued only after the hardware is started, those paths neither finish the job directly nor queue timeout work that could finish it later. The job is left with TRANS_RUNNING set, so the wait_event() in v4l2_m2m_cancel_job() (reached from v4l2_m2m_ctx_release() at close) waits indefinitely and the close hangs.
mxc_jpeg_alloc_slot_data() uses dma_alloc_coherent(), so the failure path is reachable under memory pressure.
Return the src/dst buffers with VB2_BUF_STATE_ERROR and call v4l2_m2m_job_finish() on those paths: paths that have buffers use a "buf_finish" label; the no-buffer path uses "job_finish" directly. This mirrors the existing jpeg_parse_error path.
This bug was found by static analysis.
--- drivers/media/platform/imx-jpeg/mxc-jpeg.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/media/platform/imx-jpeg/mxc-jpeg.c +15 -6
@@ -999,15 +999,15 @@ static void mxc_jpeg_device_run(void *priv) dst_buf =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx);if (!src_buf || !dst_buf) {dev_err (dev,"Null src or dst buf\n" ); - goto end; + goto job_finish; } q_data_cap =mxc_jpeg_get_q_data (ctx,V4L2_BUF_TYPE_VIDEO_CAPTURE );if (!q_data_cap) - goto end; + goto buf_finish; q_data_out =mxc_jpeg_get_q_data (ctx,V4L2_BUF_TYPE_VIDEO_OUTPUT );if (!q_data_out) - goto end; + goto buf_finish; src_buf->sequence = q_data_out->sequence++; dst_buf->sequence = q_data_cap->sequence++;
@@ -1050,11 +1050,11 @@ static void mxc_jpeg_device_run(void *priv) ctx->slot =mxc_get_free_slot (jpeg->slot_data,MXC_MAX_SLOTS );if (ctx->slot >=MXC_MAX_SLOTS ) {dev_err (dev,"No more free slots\n" ); - goto end; + goto buf_finish; }if (!mxc_jpeg_alloc_slot_data (jpeg, ctx->slot)) {dev_err (dev,"Cannot allocate slot data\n" ); - goto end; + goto buf_finish; }mxc_jpeg_enable_slot (reg, ctx->slot);
@@ -1073,8 +1073,17 @@ static void mxc_jpeg_device_run(void *priv) &src_buf->vb2_buf, &dst_buf->vb2_buf);mxc_jpeg_dec_mode_go (dev, reg); } -end: +spin_unlock_irqrestore (&ctx->mxc_jpeg->hw_lock, flags); +return ; +buf_finish: +v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx); +v4l2_m2m_dst_buf_remove (ctx->fh.m2m_ctx); +v4l2_m2m_buf_done (src_buf,VB2_BUF_STATE_ERROR ); +v4l2_m2m_buf_done (dst_buf,VB2_BUF_STATE_ERROR ); +job_finish: +spin_unlock_irqrestore (&ctx->mxc_jpeg->hw_lock, flags); +v4l2_m2m_job_finish (jpeg->m2m_dev, ctx->fh.m2m_ctx); } static int mxc_jpeg_decoder_cmd(struct file *file, void *priv,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 977/2214 media: microchip-isc: fix WB offset and gain register field masking
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 6e9eaa3b93870e4edac1bd2539fe113c24663eaf ]
ISC_WB_O_* and ISC_WB_G_* each pack two 13-bit fields. A negative offset sign-extends and corrupts the adjacent field. Add masks for the two fields and write them with FIELD_PREP(), which masks each value into its field, so sign extension can no longer bleed across.
--- drivers/media/platform/atmel/atmel-isc-base.c | 17 +++++++++-------- drivers/media/platform/atmel/atmel-isc-regs.h | 6 ++++++ 2 files changed, 15 insertions(+), 8 deletions(-)
drivers/media/platform/atmel/atmel-isc-base.c +9 -8
@@ -9,6 +9,7 @@* */ +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/clkdev.h> #include <linux/clk-provider.h>
@@ -75,17 +76,17 @@ static inline void isc_update_awb_ctrls(struct isc_device *isc)/* In here we set our actual hw pipeline config */ regmap_write (isc->regmap,ISC_WB_O_RGR , - ((ctrls->offset[ISC_HIS_CFG_MODE_R ])) | - ((ctrls->offset[ISC_HIS_CFG_MODE_GR ]) <<16 )); +FIELD_PREP (ISC_WB_O_LO , ctrls->offset[ISC_HIS_CFG_MODE_R ]) | +FIELD_PREP (ISC_WB_O_HI , ctrls->offset[ISC_HIS_CFG_MODE_GR ]));regmap_write (isc->regmap,ISC_WB_O_BGB , - ((ctrls->offset[ISC_HIS_CFG_MODE_B ])) | - ((ctrls->offset[ISC_HIS_CFG_MODE_GB ]) <<16 )); +FIELD_PREP (ISC_WB_O_LO , ctrls->offset[ISC_HIS_CFG_MODE_B ]) | +FIELD_PREP (ISC_WB_O_HI , ctrls->offset[ISC_HIS_CFG_MODE_GB ]));regmap_write (isc->regmap,ISC_WB_G_RGR , - ctrls->gain[ISC_HIS_CFG_MODE_R ] | - (ctrls->gain[ISC_HIS_CFG_MODE_GR ] <<16 )); +FIELD_PREP (ISC_WB_G_LO , ctrls->gain[ISC_HIS_CFG_MODE_R ]) | +FIELD_PREP (ISC_WB_G_HI , ctrls->gain[ISC_HIS_CFG_MODE_GR ]));regmap_write (isc->regmap,ISC_WB_G_BGB , - ctrls->gain[ISC_HIS_CFG_MODE_B ] | - (ctrls->gain[ISC_HIS_CFG_MODE_GB ] <<16 )); +FIELD_PREP (ISC_WB_G_LO , ctrls->gain[ISC_HIS_CFG_MODE_B ]) | +FIELD_PREP (ISC_WB_G_HI , ctrls->gain[ISC_HIS_CFG_MODE_GB ])); }static inline void isc_reset_awb_ctrls (struct isc_device *isc)
drivers/media/platform/atmel/atmel-isc-regs.h +6 -0
@@ -149,6 +149,12 @@/* ISC White Balance Gain for B, GB Register */ #define ISC_WB_G_BGB 0x0000006c +/* Each WB offset/gain register packs two 13-bit fields, low and high */ +#define ISC_WB_O_LO GENMASK(12, 0)/* R or B offset [12:0] */ +#define ISC_WB_O_HI GENMASK(28, 16)/* GR or GB offset [28:16] */ +#define ISC_WB_G_LO GENMASK(12, 0)/* R or B gain [12:0] */ +#define ISC_WB_G_HI GENMASK(28, 16)/* GR or GB gain [28:16] */ +/* ISC Color Filter Array Control Register */ #define ISC_CFA_CTRL 0x00000070
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 978/2214 media: microchip-isc: synchronize the IRQ before disabling clocks on stop
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 19fa5407da5ef3e605cacfcd90f70d8b2c121cd7 ]
isc_stop_streaming() masks the DMA interrupt and then drops the runtime PM reference, which disables the ISC clocks. microchip_isc_interrupt() may still be executing on another CPU at that point; it reads ISC_INTSR over regmap, and touching the unclocked registers triggers an external abort.
Store the IRQ number at probe and call synchronize_irq() after masking the interrupt, before dropping the PM reference.
--- drivers/media/platform/atmel/atmel-isc-base.c | 3 +++ drivers/media/platform/atmel/atmel-isc.h | 1 + drivers/media/platform/atmel/atmel-sama5d2-isc.c | 2 ++ drivers/media/platform/atmel/atmel-sama7g5-isc.c | 2 ++ 4 files changed, 8 insertions(+)
drivers/media/platform/atmel/atmel-isc-base.c +3 -0
@@ -709,6 +709,9 @@ static void isc_stop_streaming(struct vb2_queue *vq)/* Disable DMA interrupt */ regmap_write (isc->regmap,ISC_INTDIS ,ISC_INT_DDONE ); +/* let a running IRQ handler finish before the clock is disabled */ +synchronize_irq (isc->irq); +pm_runtime_put_sync (isc->dev);/* Disable stream on the sub device */
drivers/media/platform/atmel/atmel-isc.h +1 -0
@@ -257,6 +257,7 @@ struct isc_device {u32 dcfg;struct device *dev; +int irq;struct v4l2_device v4l2_dev;struct video_device video_dev;
drivers/media/platform/atmel/atmel-sama5d2-isc.c +2 -0
@@ -415,6 +415,8 @@ static int atmel_isc_probe(struct platform_device *pdev)if (irq <0 )return irq; + isc->irq = irq; + ret =devm_request_irq (dev, irq, isc_interrupt,0 ,"atmel-sama5d2-isc" , isc);if (ret <0 ) {
drivers/media/platform/atmel/atmel-sama7g5-isc.c +2 -0
@@ -408,6 +408,8 @@ static int microchip_xisc_probe(struct platform_device *pdev)if (irq <0 )return irq; + isc->irq = irq; + ret =devm_request_irq (dev, irq, isc_interrupt,0 ,"microchip-sama7g5-xisc" , isc);if (ret <0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 979/2214 seccomp: restore knotif->state when SECCOMP_ADDFD_FLAG_SEND is interrupted
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
[ Upstream commit 832b9b176be06a20747a267db6bc0010a24b74f4 ]
In seccomp_notify_addfd(), when SECCOMP_ADDFD_FLAG_SEND is set in addfd.flags, knotif->state is optimistically transitioned from SECCOMP_NOTIFY_SENT to SECCOMP_NOTIFY_REPLIED before waking the tracee and waiting on kaddfd.completion:
if (addfd.flags & SECCOMP_ADDFD_FLAG_SEND) {
knotif->state = SECCOMP_NOTIFY_REPLIED;
...
}If wait_for_completion_interruptible(&kaddfd.completion) is interrupted by a signal before the tracee dequeues the kaddfd request (!list_empty(&kaddfd.list)), seccomp_notify_addfd() removes kaddfd from knotif->addfd and returns -EINTR to the supervisor without having installed the file descriptor.
However, knotif->state is left as SECCOMP_NOTIFY_REPLIED (with knotif->error == 0 and knotif->val == 0). This causes two problems:
1. When the tracee runs in do_user_notif(), it checks
if (knotif.state != SECCOMP_NOTIFY_REPLIED) after calling seccomp_handle_addfd(). Because knotif->state is already SECCOMP_NOTIFY_REPLIED, the tracee exits the notification wait loop prematurely and returns 0 from the trapped syscall without the file descriptor ever having been installed.
2. If the supervisor retries SECCOMP_IOCTL_NOTIF_ADDFD or SECCOMP_IOCTL_NOTIF_SEND before the tracee runs, it fails with -EINPROGRESS because knotif->state is no longer SECCOMP_NOTIFY_SENT.
Fix this by restoring knotif->state back to SECCOMP_NOTIFY_SENT if SECCOMP_ADDFD_FLAG_SEND was set and kaddfd was not consumed before the interrupted wait. Also add a seccomp_bpf selftest (user_notification_addfd_send_interrupted) covering this race.
Tested in QEMU against Linux 7.3.0-rc3 using the user_notification_addfd_send_interrupted selftest added in this patch (./seccomp_bpf -t user_notification_addfd_send_interrupted): on the unfixed kernel the test fails because the retry ioctl(listener, SECCOMP_IOCTL_NOTIF_ADDFD, &addfd) returns -EINPROGRESS (-1) and the tracee prematurely exits do_user_notif() with return value 0 instead of FD 42, whereas with this patch applied the test passes.
--- kernel/seccomp.c | 7 +- tools/testing/selftests/seccomp/seccomp_bpf.c | 179 ++++++++++++++++++ 2 files changed, 184 insertions(+), 2 deletions(-)
kernel/seccomp.c +5 -2
@@ -1663,10 +1663,13 @@ static long seccomp_notify_addfd(struct seccomp_filter *filter,* We need to check again if the addfd request has been handled, * and if not, we will remove it from the queue. */ -if (list_empty (&kaddfd.list)) +if (list_empty (&kaddfd.list)) { ret = kaddfd.ret; -else + }else {list_del (&kaddfd.list); +if (addfd.flags &SECCOMP_ADDFD_FLAG_SEND ) + knotif->state =SECCOMP_NOTIFY_SENT ; + } out_unlock:mutex_unlock (&filter->notify_lock);
tools/testing/selftests/seccomp/seccomp_bpf.c +179 -0
185 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 980/2214 media: microchip-isc: dont sleep in the clk .is_enabled callback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 61490ff518c7b3ea3ff1cd16bbc012e9e4f1ab74 ]
isc_clk_is_enabled() calls pm_runtime_resume_and_get() and pm_runtime_put_sync(), which can sleep and are not safe here, as .is_enabled must run in atomic context. clk_disable_unused() calls it so at boot, and CONFIG_DEBUG_ATOMIC_SLEEP reports a "sleeping function called from invalid context" BUG.
Use the atomic-safe pm_runtime_get_if_active() and pm_runtime_put() instead. A suspended ISC has its clocks gated, so report the clock disabled when the device is not already active.
--- drivers/media/platform/atmel/atmel-isc-base.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/platform/atmel/atmel-isc-base.c +3 -4
@@ -182,15 +182,14 @@ static int isc_clk_is_enabled(struct clk_hw *hw) {struct isc_clk *isc_clk =to_isc_clk (hw);u32 status; -int ret; - ret =pm_runtime_resume_and_get (isc_clk->dev); -if (ret <0 ) +/* Runs in atomic context, so must not sleep to resume the ISC. */ +if (pm_runtime_get_if_active (isc_clk->dev, true) <=0 )return 0 ;regmap_read (isc_clk->regmap,ISC_CLKSR , &status); -pm_runtime_put_sync (isc_clk->dev); +pm_runtime_put (isc_clk->dev);return status &ISC_CLK (isc_clk->id) ?1 :0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 981/2214 KVM: nSVM: Ignore EFER.LMA if EFER.LME=0 when preparing L2 state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 1c4c84a643b704e473cb171f7b61359ff29b12a4 ]
Force EFER.LMA=0 if EFER.LME=0 when preparing L2 state for VMRUN, i.e. mimic real hardware's behavior of ignoring EFER.LMA if EFER.LME=0. VMRUN unfortunately allows the nonsensical combination, i.e. doesn't fail, but KVM itself has an invariant EFER.LMA can be set et if and only if EFER.LME
is set. Breaking that invariant can lead to a variety of issue,
particularly in MMU code that keys off EFER.LMA when determining whether to emulate/virtualization 4/5-level paging versus PAE paging.
--- arch/x86/kvm/svm/nested.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/kvm/svm/nested.c +6 -1
@@ -461,6 +461,7 @@ void nested_vmcb02_compute_g_pat(struct vcpu_svm *svm)static void nested_vmcb02_prepare_save (struct vcpu_svm *svm,struct vmcb *vmcb12) {bool new_vmcb12 = false; +u64 efer =READ_ONCE (vmcb12->save.efer);nested_vmcb02_compute_g_pat (svm);vmcb_mark_dirty (svm->vmcb,VMCB_NPT );
@@ -488,12 +489,16 @@ static void nested_vmcb02_prepare_save(struct vcpu_svm *svm, struct vmcb *vmcb12kvm_set_rflags (&svm->vcpu, vmcb12->save.rflags |X86_EFLAGS_FIXED ); +/* SVM ignores EFER.LMA if EFER.LME=0 (instead of failing VMRUN). */ +if (!(efer &EFER_LME )) + efer &= ~EFER_LMA ; +/* * Force-set EFER_SVME even though it is checked earlier on the * VMCB12, because the guest can flip the bit between the check * and now. Clearing EFER_SVME would call svm_free_nested. */ -svm_set_efer (&svm->vcpu, vmcb12->save.efer |EFER_SVME ); +svm_set_efer (&svm->vcpu, efer |EFER_SVME );svm_set_cr0 (&svm->vcpu, vmcb12->save.cr0);svm_set_cr4 (&svm->vcpu, vmcb12->save.cr4);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 982/2214 KVM: x86/mmu: Bug the VM if a vCPU ends up in long mode without PAE enabled
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 72e2fb24a0b0528bcc16a8f6ad2cf336ac361525 ]
Promote the ASSERT(), which is quite dead code in KVM, into a KVM_BUG_ON() for KVM's sanity check that CR4.PAE=1 if the vCPU is in long mode when performing a walk of guest page tables. The sanity is quite cheap since neither EFER nor CR4.PAE requires a VMREAD, especially relative to the cost of walking the guest page tables.
More importantly, the sanity check would have prevented the true badness fixed by commit 112e66017bff ("KVM: nVMX: add missing consistency checks for CR0 and CR4"). The missed consistency check resulted in some versions of KVM corrupting the on-stack guest_walker structure due to KVM thinking there are 4/5 levels of page tables, but wiring up the MMU hooks to point at the paging32 implementation, which only allocates space for two levels of page tables in "struct guest_walker32".
Queue a page fault for injection if the assertion fails, as both callers, FNAME(gva_to_gpa) and FNAME(walk_addr_generic), assume that walker.fault contains sane info on a walk failure. E.g. not populating the fault info could result in KVM consuming and/or exposing uninitialized stack data before the vCPU is kicked out to userspace, which doesn't happen until KVM checks for KVM_REQ_VM_DEAD on the next enter.
Move the check below the initialization of "pte_access" so that the aforementioned to-be-injected page fault doesn't consume uninitialized stack data. The information _shouldn't_ reach the guest or userspace, but there's zero downside to being paranoid in this case.
Stable-dep-of: 115f9405a2ed ("KVM: x86/mmu: Bug the VM if KVM attempts to walk more levels than the MMU has")
--- arch/x86/kvm/mmu/paging_tmpl.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/x86/kvm/mmu/paging_tmpl.h +11 -1
@@ -380,7 +380,6 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, }#endif walker->max_level = walker->level; -ASSERT (!(is_long_mode (vcpu) && !is_pae (vcpu)));/* * FIXME: on Intel processors, loads of the PDPTE registers for PAE paging
@@ -390,6 +389,17 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, nested_access = (have_ad ?PFERR_WRITE_MASK :0 ) |PFERR_USER_MASK ; pte_access = ~0 ; + +/* +* Queue a page fault for injection if this assertion fails, as callers +* assume that walker.fault contains sane info on a walk failure. I.e. +* avoid making the situation worse by inducing even worse badness +* between when the assertion fails and when KVM kicks the vCPU out to +* userspace (because the VM is bugged). +*/ +if (KVM_BUG_ON (is_long_mode (vcpu) && !is_pae (vcpu), vcpu->kvm)) + goto error; + ++walker->level; do {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 983/2214 KVM: x86/mmu: Bug the VM if KVM attempts to walk more levels than the MMU has
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 115f9405a2ed6d78ee7ad8436bdd638743f6d1d4 ]
Extend the "EFER.LMA && !CR4.PAE" check, which exists largely to guard against KVM configuring a paging32 MMU with more than 2 levels of paging, with a very explicit check for exactly that: that KVM isn't trying to walk more levels of paging than the MMU template provides. I.e. harden KVM against all bugs that would cause KVM to generates accesses beyond the bounds of guest_walker's arrays, regardless of how KVM ended up with the misconfigured MMU.
Note, don't use w->cpu_role.base.level directly as the paging64 template only provides two levels of page tables for PAE paging on 32-bit hosts, and handles the third level by manually emulating the PDPTR access.
--- arch/x86/kvm/mmu/paging_tmpl.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
arch/x86/kvm/mmu/paging_tmpl.h +7 -6
@@ -391,13 +391,14 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, pte_access = ~0 ;/* -* Queue a page fault for injection if this assertion fails, as callers -* assume that walker.fault contains sane info on a walk failure. I.e. -* avoid making the situation worse by inducing even worse badness -* between when the assertion fails and when KVM kicks the vCPU out to -* userspace (because the VM is bugged). +* Queue a page fault for injection if any of the below assertions fail, +* as callers assume that walker.fault contains sane info on a walk +* failure. I.e. avoid making the situation worse by inducing even +* worse badness between when the assertion fails and when KVM kicks +* the vCPU out to userspace (because the VM is bugged). */ -if (KVM_BUG_ON (is_long_mode (vcpu) && !is_pae (vcpu), vcpu->kvm)) +if (KVM_BUG_ON (is_long_mode (vcpu) && !is_pae (vcpu), vcpu->kvm) || +KVM_BUG_ON (walker->max_level >PT_MAX_FULL_LEVELS , vcpu->kvm)) goto error; ++walker->level;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 984/2214 iio: light: isl29028: fix runtime PM reference leak on error paths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Cesari <[email protected]>
[ Upstream commit 0e30d15b15647df786e60022650613e16dd70645 ]
isl29028_read_raw() and isl29028_write_raw() take a runtime PM reference with pm_runtime_resume_and_get() but return directly on their error paths without dropping it. The usage count never balances again and the device stops entering autosuspend for good. In isl29028_read_raw() this needs a regmap access to fail; in isl29028_write_raw() one rejected sysfs write is enough, for example
echo 200 > in_proximity_sampling_frequency
which is outside the [1:100] range and returns -EINVAL with the reference still held.
Take the reference with PM_RUNTIME_ACQUIRE_AUTOSUSPEND() instead, so it is released on every return path.
This also stops the return value of pm_runtime_put_autosuspend() from reaching userspace. That value only says whether the device could be suspended right away, so -EAGAIN or -EPERM turns a successful access into a failure, and with CONFIG_PM=n the stub returns -ENOSYS on every access.
--- drivers/iio/light/isl29028.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)
drivers/iio/light/isl29028.c +4 -19
@@ -407,14 +407,9 @@ static int isl29028_write_raw(struct iio_dev *indio_dev,mutex_unlock (&chip->lock); -if (ret <0 ) -return ret; +isl29028_set_pm_runtime_busy (chip, false); - ret =isl29028_set_pm_runtime_busy (chip, false); -if (ret <0 ) -return ret; - -return 0 ; +return ret; } static int isl29028_read_raw(struct iio_dev *indio_dev,
@@ -423,7 +418,7 @@ static int isl29028_read_raw(struct iio_dev *indio_dev, {struct isl29028_chip *chip =iio_priv (indio_dev);struct device *dev =regmap_get_device (chip->regmap); -int ret, pm_ret; +int ret; ret =isl29028_set_pm_runtime_busy (chip, true);if (ret <0 )
@@ -476,17 +471,7 @@ static int isl29028_read_raw(struct iio_dev *indio_dev,mutex_unlock (&chip->lock); -if (ret <0 ) -return ret; - -/** -* Preserve the ret variable if the call to -* isl29028_set_pm_runtime_busy() is successful so the reading -* (if applicable) is returned to user space. -*/ - pm_ret =isl29028_set_pm_runtime_busy (chip, false); -if (pm_ret <0 ) -return pm_ret; +isl29028_set_pm_runtime_busy (chip, false);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 985/2214 KVM: arm64: vgic-v3: Undo assignment on iodev registration failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 8a88a46b86ca3dbbd24522760d29edfb3f24ac2a ]
vgic_register_redist_iodev() assigns a redistributor region and base address to the vCPU before adding its iodev to the MMIO bus. However, the region's free_index is advanced only after registration succeeds.
If kvm_io_bus_register_dev() fails, the vCPU retains the assignment while free_index still identifies the same slot as free. A later registration can therefore reuse a slot that remains assigned to the vCPU.
Reserve the slot before registering its iodev. The caller holds slots_lock, so a registration failure cannot race with a later assignment. Undo the reservation and clear the cached assignment on failure.
--- arch/arm64/kvm/vgic/vgic-mmio-v3.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
arch/arm64/kvm/vgic/vgic-mmio-v3.c +9 -4
@@ -739,16 +739,21 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu) rd_dev->nr_regions =ARRAY_SIZE (vgic_v3_rd_registers); rd_dev->redist_vcpu = vcpu; +/* Protected by kvm->lock */ + rdreg->free_index++; +mutex_lock (&kvm->slots_lock); ret =kvm_io_bus_register_dev (kvm,KVM_MMIO_BUS , rd_base,2 *SZ_64K , &rd_dev->dev);mutex_unlock (&kvm->slots_lock); -if (ret) -return ret; +if (ret) { + vgic_cpu->rdreg->free_index--; + vgic_cpu->rdreg =NULL ; + vgic_cpu->rd_iodev.base_addr =VGIC_ADDR_UNDEF ; + } - rdreg->free_index++; -return 0 ; +return ret; }void vgic_unregister_redist_iodev (struct kvm_vcpu *vcpu)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 986/2214 media: mtk-vpu: Remove redundant flush_workqueue() calls
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit 360c887a39cb56e75be4f558b16f1b6409ecb93f ]
'destroy_workqueue()' already drains the queue before destroying it, so there is no need to flush it explicitly.
Remove the redundant 'flush_workqueue()' calls.
This was generated with coccinelle:
@@
expression E;
@@
- flush_workqueue(E); destroy_workqueue(E);
Stable-dep-of: 2c50b58d4105 ("media: mediatek: vpu: free IRQ before destroying watchdog workqueue")
--- drivers/media/platform/mtk-vpu/mtk_vpu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/platform/mtk-vpu/mtk_vpu.c +1 -3
@@ -966,10 +966,8 @@ static int mtk_vpu_remove(struct platform_device *pdev)#ifdef CONFIG_DEBUG_FS debugfs_remove (vpu_debugfs);#endif -if (vpu->wdt.wq) { -flush_workqueue (vpu->wdt.wq); +if (vpu->wdt.wq)destroy_workqueue (vpu->wdt.wq); - }vpu_free_ext_mem (vpu,P_FW );vpu_free_ext_mem (vpu,D_FW );of_reserved_mem_device_release (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 987/2214 media: mediatek: vpu: free IRQ before destroying watchdog workqueue
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit 2c50b58d4105f6dbaa36d6306087954b9100e9ae ]
mtk_vpu_remove() destroys the watchdog workqueue while the interrupt handler requested with devm_request_irq() is still registered: the devres core frees the interrupt only after remove() has returned. If the VPU watchdog fires in that window, vpu_irq_handler() queues vpu->wdt.ws on the already destroyed vpu->wdt.wq.
Fix this by calling devm_free_irq() before destroy_workqueue(), which releases the interrupt and waits for a running handler, so no new work can be queued while the workqueue is drained and freed.
This issue was found by an in-house static analysis tool.
--- drivers/media/platform/mtk-vpu/mtk_vpu.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/mtk-vpu/mtk_vpu.c +1 -0
@@ -966,6 +966,7 @@ static int mtk_vpu_remove(struct platform_device *pdev)#ifdef CONFIG_DEBUG_FS debugfs_remove (vpu_debugfs);#endif +devm_free_irq (&pdev->dev, vpu->reg.irq, vpu);if (vpu->wdt.wq)destroy_workqueue (vpu->wdt.wq);vpu_free_ext_mem (vpu,P_FW );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 988/2214 mtd: mtdsuper: Fix MTD device reference leak in mtd_get_sb()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 62ee3da38f41bef83c1cf250f6816a0ee187674b ]
mtd_get_sb() is called with a reference to the MTD device already taken by the caller. When sget_dev() fails, the function returns the error without dropping that reference, so the device is never released and its refcount never reaches zero. Every mount attempt on an MTD device whose superblock cannot be set up leaks a reference.
Restore the put_mtd_device() that the fs_context conversion dropped on this path.
--- drivers/mtd/mtdsuper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/mtdsuper.c +3 -1
@@ -63,8 +63,10 @@ static int mtd_get_sb(struct fs_context *fc, fc->sget_key = mtd; sb =sget_fc (fc, mtd_test_super, mtd_set_super); -if (IS_ERR (sb)) +if (IS_ERR (sb)) { +put_mtd_device (mtd);return PTR_ERR (sb); + }if (sb->s_root) {/* new mountpoint for an already mounted superblock */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 989/2214 ALSA: usb-audio: Protect Roland control activation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 19b42c1fff7f220a6346c614d79ce1bda6d95b40 ]
The USB MIDI driver changes the Roland MIDI Input Mode control's access flags directly from the rawmidi open and close paths. These changes are not protected by the ALSA control core and the corresponding notifications can race with control access.
Use snd_ctl_activate_id() so that the control core updates the access flags and sends the notification under its lock. Release the USB MIDI mutex before calling it because the control write path holds controls_rwsem while roland_load_put() takes the USB MIDI mutex.
Keep the state transition and alternate-setting change under the USB MIDI mutex; rawmidi's open mutex serializes the enclosing open and close paths.
--- sound/usb/midi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
sound/usb/midi.c +11 -11
@@ -1152,7 +1152,9 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir, int open) {struct snd_usb_midi *umidi = substream->rmidi->private_data; -struct snd_kcontrol *ctl; +struct snd_ctl_elem_id ctl_id; +bool activate_ctl = false; +bool active;down_read (&umidi->disc_rwsem);if (umidi->disconnected) {
@@ -1164,11 +1166,9 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,if (open) {if (!umidi->opened[0 ] && !umidi->opened[1 ]) {if (umidi->roland_load_ctl) { - ctl = umidi->roland_load_ctl; - ctl->vd[0 ].access |= -SNDRV_CTL_ELEM_ACCESS_INACTIVE ; -snd_ctl_notify (umidi->card, -SNDRV_CTL_EVENT_MASK_INFO , &ctl->id); + ctl_id = umidi->roland_load_ctl->id; + activate_ctl = true; + active = false;update_roland_altsetting (umidi); } }
@@ -1181,15 +1181,15 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,snd_usbmidi_input_stop (&umidi->list);if (!umidi->opened[0 ] && !umidi->opened[1 ]) {if (umidi->roland_load_ctl) { - ctl = umidi->roland_load_ctl; - ctl->vd[0 ].access &= - ~SNDRV_CTL_ELEM_ACCESS_INACTIVE ; -snd_ctl_notify (umidi->card, -SNDRV_CTL_EVENT_MASK_INFO , &ctl->id); + ctl_id = umidi->roland_load_ctl->id; + activate_ctl = true; + active = true; } } }mutex_unlock (&umidi->mutex); +if (activate_ctl) +snd_ctl_activate_id (umidi->card, &ctl_id, active);up_read (&umidi->disc_rwsem);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 990/2214 hwmon: (tmp102) Fix jiffies wraparound in conversion-ready check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Verdonck <[email protected]>
[ Upstream commit 56c1d32323e773b8b927316f8beeae9238576335 ]
tmp102 records a one-shot deadline in ->ready_time at probe (and resume) and, on every temperature read, refuses the read with -EAGAIN while time_before(jiffies, ready_time) is true, in order to skip the first ~35 ms conversion.
->ready_time is an unsigned long compared with time_before(), whose signed difference is only meaningful while the two values are within LONG_MAX jiffies of each other. Because ->ready_time is set once and never refreshed, jiffies keeps advancing away from it, and after 2^31 jiffies the difference flips sign. On a 32-bit HZ=100 kernel that happens ~248.5 days after boot: time_before() then permanently reports "not ready" and the driver returns -EAGAIN on every read, without ever touching the sensor, until the next reboot.
Store the deadline as a 64-bit jiffies value and compare it with get_jiffies_64()/time_before64(), which does not wrap in any practical uptime.
--- drivers/hwmon/tmp102.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/tmp102.c +4 -4
@@ -54,7 +54,7 @@struct tmp102 {struct regmap *regmap;u16 config_orig; -unsigned long ready_time; +u64 ready_time; };/* convert left adjusted 13-bit TMP102 register value to milliCelsius */
@@ -79,7 +79,7 @@ static int tmp102_read(struct device *dev, enum hwmon_sensor_types type,switch (attr) {case hwmon_temp_input:/* Is it too early to return a conversion ? */ -if (time_before (jiffies, tmp102->ready_time)) { +if (time_before64 (get_jiffies_64 (), tmp102->ready_time)) {dev_dbg (dev,"%s: Conversion not ready yet..\n" , __func__);return -EAGAIN ; }
@@ -245,7 +245,7 @@ static int tmp102_probe(struct i2c_client *client)* Mark that we are not ready with data until the first * conversion is complete */ - tmp102->ready_time = jiffies +msecs_to_jiffies (CONVERSION_TIME_MS ); + tmp102->ready_time =get_jiffies_64 () +msecs_to_jiffies (CONVERSION_TIME_MS ); hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, tmp102,
@@ -279,7 +279,7 @@ static int tmp102_resume(struct device *dev) err =regmap_update_bits (tmp102->regmap,TMP102_CONF_REG ,TMP102_CONF_SD ,0 ); - tmp102->ready_time = jiffies +msecs_to_jiffies (CONVERSION_TIME_MS ); + tmp102->ready_time =get_jiffies_64 () +msecs_to_jiffies (CONVERSION_TIME_MS );return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 991/2214 gfs2: reject invalid inode sizes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaming Zhang <[email protected]>
[ Upstream commit 33ed0a0567e0abe66ea65e89dad2e35082890fbe ]
A corrupted GFS2 image can store a dinode size that is larger than what VFS i_size can represent. gfs2_dinode_in() reads the on-disk di_size as a u64 and writes it directly into inode->i_size. If the value is larger than S64_MAX, the incore i_size becomes negative. That negative value can bypass the existing stuffed inode size check:
inode->i_size > gfs2_max_stuffed_size(ip)
Later, gfs2_quotad may try to sync the quota file and unstuff the quota inode. gfs2_unstuffer_folio() reads the negative i_size into an unsigned length and passes it to memcpy(), turning it into a huge copy size and triggering a out-of-bound issue.
Reject dinodes whose size exceeds sb->s_maxbytes before storing the value in inode->i_size. Also make the stuffed inode check use the raw on-disk size while it is still unsigned.
--- fs/gfs2/glops.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/gfs2/glops.c +8 -2
@@ -405,6 +405,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)umode_t mode =be32_to_cpu (str->di_mode);struct inode *inode = &ip->i_inode;bool is_new = inode->i_state &I_NEW ; +u64 size;if (unlikely (ip->i_no_addr !=be64_to_cpu (str->di_num.no_addr))) {gfs2_consist_inode (ip);
@@ -430,7 +431,12 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)i_uid_write (inode,be32_to_cpu (str->di_uid));i_gid_write (inode,be32_to_cpu (str->di_gid));set_nlink (inode,be32_to_cpu (str->di_nlink)); -i_size_write (inode,be64_to_cpu (str->di_size)); + size =be64_to_cpu (str->di_size); +if (unlikely (size > inode->i_sb->s_maxbytes)) { +gfs2_consist_inode (ip); +return -EIO ; + } +i_size_write (inode, size);gfs2_set_inode_blocks (inode,be64_to_cpu (str->di_blocks)); atime.tv_sec =be64_to_cpu (str->di_atime); atime.tv_nsec =be32_to_cpu (str->di_atime_nsec);
@@ -468,7 +474,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) ip->i_depth = (u8 )depth; ip->i_entries =be32_to_cpu (str->di_entries); -if (gfs2_is_stuffed (ip) && inode->i_size >gfs2_max_stuffed_size (ip)) { +if (gfs2_is_stuffed (ip) && size >gfs2_max_stuffed_size (ip)) {gfs2_consist_inode (ip);return -EIO ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 992/2214 iio: light: ltr501: Power down chip if request irq fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esben Haabendal <[email protected]>
[ Upstream commit 8a9bcd587d7d768e6c8e9fff88bb89645e412731 ]
In case devm_request_threaded_irq() failed, we were leaving the chip powered instead of powering it down again. Power down the chip switching ALS and PS modes to standby.
--- drivers/iio/light/ltr501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/ltr501.c +1 -1
@@ -1510,7 +1510,7 @@ static int ltr501_probe(struct i2c_client *client,if (ret) {dev_err (&client->dev,"request irq (%d) failed\n" , client->irq); -return ret; + goto powerdown_on_error; } }else { indio_dev->info = data->chip_info->info_no_irq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 993/2214 media: redrat3: Error path leaves device in transmitting state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 8024d5e84531d828535365718278f1cf0ce67db0 ]
In the allocation failure error path, the transmitting boolean is not cleared. If this error path is followed the transmitter cannot be used again until the device is replugged or the module reloaded.
Fix the error path by moving the assignment statement.
Remove the check for the transmitting state in transmit, since rc-core ensures there is never a reentrant call to the driver transmit function; the transmit function is always called with dev->lock held.
The transmitting boolean is only used for interpretting firmware errors.
--- drivers/media/rc/redrat3.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/media/rc/redrat3.c +3 -8
@@ -773,17 +773,9 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,u8 curlencheck =0 ;unsigned i, sendbuf_len; -if (rr3->transmitting) { -dev_warn (dev,"%s: transmitter already in use\n" , __func__); -return -EAGAIN ; - } -if (count >RR3_MAX_SIG_SIZE -RR3_TX_TRAILER_LEN )return -EINVAL ; -/* rr3 will disable rc detector on transmit */ - rr3->transmitting = true; - sample_lens =kcalloc (RR3_DRIVER_MAXLENS ,sizeof (*sample_lens),GFP_KERNEL );
@@ -796,6 +788,9 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf, goto out; } +/* rr3 will disable rc detector on transmit */ + rr3->transmitting = true; +for (i =0 ; i < count; i++) { cur_sample_len =redrat3_us_to_len (txbuf[i]);if (cur_sample_len >0xffff ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 994/2214 media: meson-ir-tx: remove superfluous dev_err()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yihao Han <[email protected]>
[ Upstream commit 82b4737fd001247527405b19045c25bf1622ab6d ]
Remove dev_err() messages after platform_get_irq*() failures. platform_get_irq() already prints an error.
Generated by: scripts/coccinelle/api/platform_get_irq.cocci
Stable-dep-of: 2eb8a4cba70f ("media: meson-ir-tx: Ensure probe error is propagated")
--- drivers/media/rc/meson-ir-tx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/rc/meson-ir-tx.c +1 -3
@@ -327,10 +327,8 @@ static int __init meson_irtx_probe(struct platform_device *pdev)return PTR_ERR (ir->reg_base); irq =platform_get_irq (pdev,0 ); -if (irq <0 ) { -dev_err (dev,"no irq resource found\n" ); +if (irq <0 )return -ENODEV ; - } ir->dev = dev; ir->carrier =MIRTX_DEFAULT_CARRIER ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 995/2214 media: meson-ir-tx: Ensure probe error is propagated
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 2eb8a4cba70f521a8217021e227cfa28ba17724b ]
devm_clk_get_enabled() may return -EPROBE_DEFER which needs to be propagated else the probe will not be deferred, it will fail instead.
--- drivers/media/rc/meson-ir-tx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/rc/meson-ir-tx.c +2 -2
@@ -295,7 +295,7 @@ static int meson_irtx_mod_clock_probe(struct meson_irtx *ir, clock =devm_clk_get_enabled (ir->dev,"xtal" );if (IS_ERR (clock)) -return -ENODEV ; +return PTR_ERR (clock); ir->clk_rate =clk_get_rate (clock) /3 ;
@@ -328,7 +328,7 @@ static int __init meson_irtx_probe(struct platform_device *pdev) irq =platform_get_irq (pdev,0 );if (irq <0 ) -return -ENODEV ; +return irq; ir->dev = dev; ir->carrier =MIRTX_DEFAULT_CARRIER ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 996/2214 platform/x86: int3472: Fix uninitialised variable warning
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
[ Upstream commit 70e6384fe0f4cf9768944f81924f6c1478b0ce43 ]
Fix a compiler warning about an uninitialised err_msg variable by printing the error where it is handled:
drivers/platform/x86/intel/int3472/discrete.c:440:24: warning: ‘err_msg’ may be used uninitialized [-Wmaybe-uninitialized]
440 | return dev_err_probe(int3472->dev, ret, err_msg);
--- drivers/platform/x86/intel/int3472/discrete.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/platform/x86/intel/int3472/discrete.c +8 -8
@@ -227,7 +227,6 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,struct int3472_discrete_device *int3472 = data;struct acpi_resource_gpio *agpio;union acpi_object *obj; -const char *err_msg;int ret;u8 type;
@@ -256,27 +255,31 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, ret =skl_int3472_map_gpio_to_sensor (int3472, agpio,"reset" ,GPIO_ACTIVE_LOW );if (ret) - err_msg ="Failed to map reset pin to sensor\n" ; +dev_err_probe (int3472->dev, ret, +"Failed to map reset pin to sensor\n" );break ;case INT3472_GPIO_TYPE_POWERDOWN : ret =skl_int3472_map_gpio_to_sensor (int3472, agpio,"powerdown" ,GPIO_ACTIVE_LOW );if (ret) - err_msg ="Failed to map powerdown pin to sensor\n" ; +dev_err_probe (int3472->dev, ret, +"Failed to map powerdown pin to sensor\n" );break ;case INT3472_GPIO_TYPE_CLK_ENABLE :case INT3472_GPIO_TYPE_PRIVACY_LED : ret =skl_int3472_map_gpio_to_clk (int3472, agpio, type);if (ret) - err_msg ="Failed to map GPIO to clock\n" ; +dev_err_probe (int3472->dev, ret, +"Failed to map GPIO to clock\n" );break ;case INT3472_GPIO_TYPE_POWER_ENABLE : ret =skl_int3472_register_regulator (int3472, agpio);if (ret) - err_msg ="Failed to map regulator to sensor\n" ; +dev_err_probe (int3472->dev, ret, +"Failed to map regulator to sensor\n" );break ;default :
@@ -290,9 +293,6 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, int3472->ngpios++;ACPI_FREE (obj); -if (ret <0 ) -return dev_err_probe (int3472->dev, ret, err_msg); -return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 997/2214 media: i2c: ov5647: fix power cleanup on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 6e81cfc38548109021ab761b94ecdd01f8753154 ]
ov5647_remove() disables runtime PM without powering off the sensor if it is still runtime active. pm_runtime_disable() does not invoke the runtime suspend callback, so the sensor can remain powered on.
If the device is not already runtime suspended, call ov5647_power_off() and mark the runtime PM state as suspended.
This issue was found by manual code inspection.
--- drivers/media/i2c/ov5647.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/i2c/ov5647.c +4 -0
@@ -1460,6 +1460,10 @@ static int ov5647_remove(struct i2c_client *client)v4l2_ctrl_handler_free (&sensor->ctrls);v4l2_device_unregister_subdev (sd);pm_runtime_disable (&client->dev); +if (!pm_runtime_status_suspended (&client->dev)) { +ov5647_power_off (&client->dev); +pm_runtime_set_suspended (&client->dev); + }mutex_destroy (&sensor->lock);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 998/2214 staging: media: av7110: fix sp8870 initialization failure state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Punnay Sharma <[email protected]>
[ Upstream commit 30684fa98394bc0eb4362282908612aab7d4dad9 ]
The SP8870 DVB frontend driver prematurely flags the device as initialized at the very beginning of the sp8870_init() routine, prior to requesting the firmware (dvb-fe-sp8870.fw) and executing the I2C upload sequence.
If request_firmware() times out or sp8870_firmware_upload() encounters an I2C bus error, the function aborts and returns -EIO. However, because state->initialised is already set to 1, all subsequent invocations of fe->ops.init() by the DVB core will immediately return 0 (success) without attempting to load the firmware again. This leaves the demodulator microcontroller halted and the frontend permanently dead until the module is forcibly reloaded.
Relocate the state->initialised = 1 assignment to the end of sp8870_init(), ensuring the flag is only set after the firmware is successfully uploaded and the system controller is actually restarted.
--- drivers/staging/media/av7110/sp8870.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/media/av7110/sp8870.c +2 -1
@@ -297,7 +297,6 @@ static int sp8870_init (struct dvb_frontend* fe)sp8870_wake_up (state);if (state->initialised)return 0 ; - state->initialised =1 ;dprintk ("%s\n" , __func__);
@@ -336,6 +335,8 @@ static int sp8870_init (struct dvb_frontend* fe)sp8870_writereg (state,0x0D00 ,0x010 );sp8870_writereg (state,0x0D01 ,0x000 ); + state->initialised =1 ; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 999/2214 KVM: x86/mmu: Bug the VM if KVM calcs a CPU role with EFER.LMA=1 && CR4.PAE=0
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 34dacbe7ae93f2d3c26cd0bf3e08200b1fa2c180 ]
Bug the VM if KVM attempts to construct a CPU role with the should-be- impossible combination of long mode being active without PAE paging being enabled. KVM's MMU construction assumes that EFER.LMA can be set if and only CR4.PAE is set, and will create a completely invalid MMU if that assumption fails. FNAME(walk_addr_generic) already has sanity checks to try and mitigate the fallout, but attempt to catch such bugs earlier, as this is (at least) the second time KVM has had bugs that escaped into FNAME(walk_addr_generic), and it's entirely possible the bad state could cause problems elsewhere.
--- arch/x86/kvm/mmu/mmu.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/mmu/mmu.c +3 -0
@@ -4854,6 +4854,9 @@ static union kvm_mmu_role kvm_calc_mmu_role_common(struct kvm_vcpu *vcpu, role.base.access =ACC_ALL ;if (____is_cr0_pg (regs)) { +if (KVM_BUG_ON (____is_efer_lma (regs) && !____is_cr4_pae (regs), vcpu->kvm)) + *(u64 *)®s->efer &= ~EFER_LMA ; + role.base.efer_nx =____is_efer_nx (regs); role.base.cr0_wp =____is_cr0_wp (regs); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1000/2214 af_unix: Clear oob_skb in scan_inflight()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
Embryo socket is not queued in gc_candidates, so we can't drop a reference held by its oob_skb.
Let's say we create listener and embryo sockets, send the listener's fd to the embryo as OOB data, and close() them without recv()ing the OOB data.
There is a self-reference cycle like
listener -> embryo.oob_skb -> listener
, so this must be cleaned up by GC. Otherwise, the listener's refcnt is not released and sockets are leaked:
# unshare -n # cat /proc/net/protocols | grep UNIX-STREAM UNIX-STREAM 1024 0 -1 NI 0 yes kernel ...
# python3
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
from array import array
from socket import *s =
socket(AF_UNIX, SOCK_STREAM)s.bind('\0test\0')s.listen()c =
socket(AF_UNIX, SOCK_STREAM)
c.connect(s.getsockname())c.sendmsg([b'x'], [(SOL_SOCKET, SCM_RIGHTS, array('i', [s.fileno()]))], MSG_OOB)
1
Quoted 1 line
Quoted 1 line
Quoted 1 line
quit()
# cat /proc/net/protocols | grep UNIX-STREAM
UNIX-STREAM 1024 3 -1 NI 0 yes kernel ...
^^^
3 sockets still in use after FDs are close()dLet's drop the embryo socket's oob_skb ref in scan_inflight().
This also fixes a racy access to oob_skb that commit 9841991a446c ("af_unix: Update unix_sk(sk)->oob_skb under sk_receive_queue lock.") fixed for the new Tarjan's algo-based GC.
--- net/unix/garbage.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
net/unix/garbage.c +10 -10
@@ -102,13 +102,14 @@ static void scan_inflight(struct sock *x, void (*func)(struct unix_sock *),/* Process the descriptors of this socket */ int nfd =UNIXCB (skb).fp->count;struct file **fp =UNIXCB (skb).fp->fp; +struct unix_sock *u;while (nfd--) {/* Get the socket the fd matches if it indeed does so */ struct sock *sk =unix_get_socket (*fp++);if (sk) { -struct unix_sock *u =unix_sk (sk); + u =unix_sk (sk);/* Ignore non-candidates, they could * have been added to the queues after
@@ -122,6 +123,13 @@ static void scan_inflight(struct sock *x, void (*func)(struct unix_sock *), } }if (hit && hitlist !=NULL ) { +#if IS_ENABLED (CONFIG_AF_UNIX_OOB ) + u =unix_sk (x); +if (u->oob_skb) { +WARN_ON_ONCE (skb_unref (u->oob_skb)); + u->oob_skb =NULL ; + } +#endif __skb_unlink (skb, &x->sk_receive_queue);__skb_queue_tail (hitlist, skb); }
@@ -299,17 +307,9 @@ void unix_gc(void)* which are creating the cycle(s). */ skb_queue_head_init (&hitlist); -list_for_each_entry (u, &gc_candidates, link) { +list_for_each_entry (u, &gc_candidates, link)scan_children (&u->sk, inc_inflight, &hitlist); -#if IS_ENABLED (CONFIG_AF_UNIX_OOB ) -if (u->oob_skb) { -kfree_skb (u->oob_skb); - u->oob_skb =NULL ; - } -#endif - } -/* not_cycle_list contains those sockets which do not make up a * cycle. Restore these to the inflight list. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1001/2214 Bluetooth: L2CAP: Reject signalling responses in invalid states
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siwei Zhang <[email protected]>
commit 6320736af7dcb90da6ee9fd651ecc11c564d45b7 upstream.
Adjusted context as stable does not have the lockdep_assert_held() calls, and l2cap_get_chan_by_scid() still returns the channel locked, so l2cap_config_rsp() does not lock it again.
A peer can send configuration messages while an incoming channel is in BT_CONNECT2, before the security or deferred accept gate has completed. A configuration response can then promote the channel to BT_CONNECTED. Configuration responses can also act on channels that are closing, and a late connection response can move a disconnecting channel back to BT_CONFIG.
Accept connection responses only while waiting inBT_CONNECT. Answer configuration requests inBT_CONNECT2, but defer our own request untilBT_CONFIG so configuration cannot complete before
the gate. Ignore configuration responses outsideBT_CONFIG and BT_CONNECTED, and only complete
configuration in BT_CONFIG.
--- net/bluetooth/l2cap_core.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +19 -1
@@ -4443,6 +4443,10 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,l2cap_chan_lock (chan); +/* Ignore a late response after the channel has left BT_CONNECT. */ +if (chan->state !=BT_CONNECT ) + goto done; +switch (result) {case L2CAP_CR_SUCCESS :if (__l2cap_get_chan_by_dcid (conn, dcid)) {
@@ -4472,6 +4476,7 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,break ; } +done:l2cap_chan_unlock (chan);l2cap_chan_put (chan);
@@ -4607,7 +4612,13 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, goto unlock; } -if (!test_and_set_bit (CONF_REQ_SENT , &chan->conf_state)) { +/* A channel in BT_CONNECT2 has not passed security or userspace +* accept yet. Answer the peer's request, but hold our own until +* the channel reaches BT_CONFIG: the CONNECT2 -> CONFIG sites send +* it. Connected channels may also need to reconfigure. +*/ +if ((chan->state ==BT_CONFIG || chan->state ==BT_CONNECTED ) && + !test_and_set_bit (CONF_REQ_SENT , &chan->conf_state)) {u8 buf[64 ];l2cap_send_cmd (conn,l2cap_get_ident (conn),L2CAP_CONF_REQ ,l2cap_build_conf_req (chan, buf,sizeof (buf)), buf);
@@ -4658,6 +4669,10 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,if (!chan)return 0 ; +/* Connected channels may also receive reconfiguration responses. */ +if (chan->state !=BT_CONFIG && chan->state !=BT_CONNECTED ) + goto done; +switch (result) {case L2CAP_CONF_SUCCESS :l2cap_conf_rfc_get (chan, rsp->data, len);
@@ -4733,6 +4748,9 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,if (test_bit (CONF_OUTPUT_DONE , &chan->conf_state)) {set_default_fcs (chan); +if (chan->state !=BT_CONFIG ) + goto done; +if (chan->mode ==L2CAP_MODE_ERTM || chan->mode ==L2CAP_MODE_STREAMING ) err =l2cap_ertm_init (chan);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1002/2214 Bluetooth: L2CAP: Only accept connection responses to outstanding requests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siwei Zhang <[email protected]>
commit a518b9a9ef6ee3b18ecdf6ba5360c608aaf969e9 upstream.
Adjusted context as stable does not have the lockdep_assert_held() call and the __must_hold() context analysis annotations, and l2cap_connect_create_rsp() still holds conn->chan_lock and returns through the unlock label when the channel lookup fails.
Stable still has AMP support, which upstream removed in commit e7b02296fb40 ("Bluetooth: Remove BT_HS"). The response to an L2CAP_CREATE_CHAN_REQ is also handled by l2cap_connect_create_rsp(), so set CONF_CONNECT_PEND in l2cap_send_create_chan_req() as l2cap_send_conn_req() does. Otherwise that response is dropped and an outgoing AMP channel hangs in BT_CONNECT. This also makes __l2cap_no_conn_pending() see the request as outstanding, so l2cap_do_start(), l2cap_conn_start() and l2cap_security_cfm() leave the channel alone until it is answered, as they already do for a pending connection request.
An outgoing channel waits in BT_CONNECT until security and the feature mask exchange complete, and only then sends its connection request. A peer can answer it before that with a connection response matching our source CID. The channel then moves to BT_CONFIG, completes configuration and becomes connected before security has completed. If security then fails, l2cap_security_cfm() leaves the connected channel alone, so it stays up on a link that did not reach the required security level.
A connection response with a zero source CID is matched by identifier. Another channel can hold the same identifier for a response it still has to send, so the lookup can pick the wrong channel.
Only accept a connection response while our request is outstanding, and only look at such channels when matching by identifier.
--- net/bluetooth/l2cap_core.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
net/bluetooth/l2cap_core.c +30 -3
@@ -185,6 +185,28 @@ static struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn,return c; } +/* Our connection request has been sent and is still outstanding */ +static bool l2cap_chan_connect_pending (struct l2cap_chan *chan) +{ +return chan->state ==BT_CONNECT && +test_bit (CONF_CONNECT_PEND , &chan->conf_state); +} + +/* Other channels may hold the same ident for a response they still have +* to send, so only look at channels waiting for a connection response. +*/ +static struct l2cap_chan *__l2cap_get_connect_chan_by_ident (struct l2cap_conn *conn, +u8 ident) +{ +struct l2cap_chan *c; + +list_for_each_entry (c, &conn->chan_l, list) { +if (c->ident == ident &&l2cap_chan_connect_pending (c)) +return c; + } +return NULL ; +} +static struct l2cap_chan *__l2cap_global_chan_by_addr (__le16 psm,bdaddr_t *src,u8 src_type) {
@@ -1329,6 +1351,8 @@ static void l2cap_send_create_chan_req(struct l2cap_chan *chan, u8 amp_id) chan->ident =l2cap_get_ident (chan->conn); +set_bit (CONF_CONNECT_PEND , &chan->conf_state); +l2cap_send_cmd (chan->conn, chan->ident,L2CAP_CREATE_CHAN_REQ ,sizeof (req), &req); }
@@ -4426,7 +4450,7 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn, goto unlock; } }else { - chan =__l2cap_get_chan_by_ident (conn, cmd->ident); + chan =__l2cap_get_connect_chan_by_ident (conn, cmd->ident);if (!chan) { err = -EBADSLT ; goto unlock;
@@ -4443,8 +4467,11 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,l2cap_chan_lock (chan); -/* Ignore a late response after the channel has left BT_CONNECT. */ -if (chan->state !=BT_CONNECT ) +/* Only accept a response to a connection request we sent and that +* is still outstanding. A channel waiting in BT_CONNECT for security +* or the feature mask has not sent one yet. +*/ +if (!l2cap_chan_connect_pending (chan)) goto done;switch (result) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1003/2214 Bluetooth: L2CAP: Ignore connection responses with wrong ident
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinwang Li <[email protected]>
commit a9f9eeb5344fc7dc625e5700ccf09891bc2603b5 upstream.
Adjusted context as stable does not have the lockdep_assert_held() call in l2cap_connect_create_rsp().
L2CAP/COS/CED/BI-28-C requires the IUT to ignore a Connection Response that carries an invalid Identifier.
l2cap_connect_create_rsp() only checks that a connection request is outstanding, not that the response answers it. Add an ident check against the pending request so that a mismatched response is dropped.
--- net/bluetooth/l2cap_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/bluetooth/l2cap_core.c +4 -4
@@ -4467,11 +4467,11 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,l2cap_chan_lock (chan); -/* Only accept a response to a connection request we sent and that -* is still outstanding. A channel waiting in BT_CONNECT for security -* or the feature mask has not sent one yet. +/* Only accept a response matching a connection request we sent and +* that is still outstanding. A channel waiting in BT_CONNECT for +* security or the feature mask has not sent one yet. */ -if (!l2cap_chan_connect_pending (chan)) +if (!l2cap_chan_connect_pending (chan) || chan->ident != cmd->ident) goto done;switch (result) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1004/2214 xen/gntdev: prevent private mappings from becoming writable
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdifatah Suruur <[email protected]>
[ Upstream commit 2176dea8d8c19cb43a9b3651bfa1cb21eab1b31a ]
gntdev_mmap() rejects writable private (non-shared) mappings of foreign grant pages, because a private writable mapping takes the COW path on pages that have no proper struct-page backing. However, VM_MAYWRITE is left set, so userspace can map the grant read-only and then upgrade the mapping to writable with mprotect(), hitting the same COW path the check was written to prevent.
Clear VM_MAYWRITE for private mappings, as i915 does for its read-only objects and as fixed in drm/vc4 (CVE-2026-68445) and drm/panthor (CVE-2024-53071) and ptp: vmclock (commit a5edadbae57e2298a56cf7a4e774a027905a331f).
Message-ID: <[email protected]>
--- drivers/xen/gntdev.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/xen/gntdev.c +7 -0
@@ -1074,6 +1074,13 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)if ((vma->vm_flags &VM_WRITE ) && !(vma->vm_flags &VM_SHARED ))return -EINVAL ; +/* +* Private mappings of foreign grant pages must never become +* writable: they would take the COW path on granted pages. +*/ +if (!(vma->vm_flags &VM_SHARED )) + vma->vm_flags &= ~VM_MAYWRITE ; +pr_debug ("map %d+%d at %lx (pgoff %lx)\n" , index, count, vma->vm_start, vma->vm_pgoff);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1005/2214 ext4: fix ABBA deadlock in ext4_rmdir()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Senozhatsky <[email protected]>
[ Upstream commit 19e16597f9baf1b5719a3a6c710486446f6808fd ]
We observe the following ABBA deadlock (casefolding enabled):
INFO: task jbd2/dm-13-8:447 blocked for more than 720 seconds. task:jbd2/dm-13-8 state:D stack:0 pid:447 tgid:447 ppid:2 Call Trace: <TASK> __schedule+0xc2c/0xe60 schedule+0x40/0xe0 jbd2_journal_wait_updates+0x8f/0xf0 jbd2_journal_commit_transaction+0x321/0x1850 kjournald2+0xa9/0x230 kthread+0x226/0x2a0 ret_from_fork+0x101/0x1e0 ret_from_fork_asm+0x1a/0x30 INFO: task Thread-10:4161 blocked for more than 720 seconds. task:Thread-10 state:D stack:0 pid:4161 tgid:3848 ppid:540 Call Trace: <TASK> __schedule+0xc2c/0xe60 schedule+0x40/0xe0 wait_transaction_locked+0x8c/0xd0 start_this_handle+0x252/0x870 jbd2__journal_start+0x120/0x280 __ext4_journal_start_sb+0x11a/0x250 ext4_evict_inode+0x208/0x760 iput+0x222/0x5c0 dput+0x293/0x690 ____fput+0x145/0x2b0 task_work_run+0x7a/0xb0 exit_to_user_mode_loop+0xc0/0xd0 do_syscall_64+0x14b/0xf10 entry_SYSCALL_64_after_hwframe+0x76/0x7e
NMI backtrace for cpu 0
CPU: 0 UID: 1010216 PID: 4160 Comm: Thread-7 RIP: 0010:d_walk+0x0/0x290 [..] Call Trace: <TASK> shrink_dcache_parent+0xb2/0x100 d_invalidate+0x50/0x110 ext4_rmdir+0x3a2/0x3d0 vfs_rmdir+0x9d/0x1d0 do_rmdir+0xf0/0x330 __x64_sys_unlinkat+0x34/0x50 do_syscall_64+0x61/0xf10
The problem is that ext4_rmdir() calls d_invalidate() before stopping the jbd2 transaction handle. Because d_invalidate() traverses child dentries it can encounter dying or in-use dentries. If a concurrent thread executing __dentry_kill() on a child dentry invokes ext4_evict_inode(), it requests a new transaction handle via ext4_journal_start(), which waits for all running handles to close. However, the thread executing ext4_rmdir() still holds its active transaction handle while looping in shrink_dcache_parent() waiting for the dying child dentry to complete eviction.
Stop transaction handle in ext4_rmdir() before calling d_invalidate().
--- fs/ext4/namei.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/namei.c +6 -5
@@ -3259,6 +3259,11 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)ext4_fc_track_unlink (handle, dentry); retval =ext4_mark_inode_dirty (handle, dir); +end_rmdir: +brelse (bh); +if (handle) +ext4_journal_stop (handle); +#ifdef CONFIG_UNICODE /* VFS negative dentries are incompatible with Encoding and * Case-insensitiveness. Eventually we'll want avoid
@@ -3266,14 +3271,10 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)* negative dentries at ext4_lookup(), when it is better * supported by the VFS for the CI case. */ -if (IS_CASEFOLDED (dir)) +if (!retval &&IS_CASEFOLDED (dir))d_invalidate (dentry);#endif -end_rmdir: -brelse (bh); -if (handle) -ext4_journal_stop (handle);return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1006/2214 crypto: ecc - Handle exceptional points in Shamir multiplication
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 6fd70bc8bc01a578c7728b7bd1cb5689c62cc5b7 ]
Shamir multiplication mishandles equal points, opposite points and the point at infinity. This rejects valid ECDSA signatures and can accept invalid digest/signature tuples when the public key is G or -G. The kernel incorrectly rejects 16 valid signatures from Wycheproof.
Handle doubling, cancellation and the point at infinity in precomputation and accumulation. Add regression tests for P-256 ECDSA and 256/512-bit EC-RDSA. The valid vectors are Wycheproof P1363 secp256r1/SHA-256 cases 60 and 210 converted to X9.62, two constructed ECDSA signatures for Q = +/-G with k = 2, and six constructed EC-RDSA signatures for Q = G, -G and -2G. Also add two invalid P-256 digest/signature tuples for Q = +/-G that must return -EKEYREJECTED.
--- crypto/ecc.c | 33 ++++- crypto/testmgr.c | 10 +- crypto/testmgr.h | 339 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 375 insertions(+), 7 deletions(-)
crypto/ecc.c +31 -2
@@ -1354,9 +1354,22 @@ static void ecc_point_add(const struct ecc_point *result,vli_set (result->x, q->x, ndigits);vli_set (result->y, q->y, ndigits);vli_mod_sub (z, result->x, p->x, curve->p, ndigits); +if (vli_is_zero (z, ndigits)) { +if (vli_cmp (p->y, q->y, ndigits)) { +/* P + (-P) is the point at infinity. */ +vli_clear (result->x, ndigits); +vli_clear (result->y, ndigits); +return ; + } +/* The co-Z addition formula does not handle P == Q. */ + z[0 ] =1 ; +ecc_point_double_jacobian (result->x, result->y, z, curve); + goto out; + }vli_set (px, p->x, ndigits);vli_set (py, p->y, ndigits);xycz_add (px, py, result->x, result->y, curve); +out:vli_mod_inv (z, z, curve->p, ndigits);apply_z (result->x, result->y, z, curve); }
@@ -1395,21 +1408,37 @@ void ecc_point_mult_shamir(const struct ecc_point *result,vli_set (rx, point->x, ndigits);vli_set (ry, point->y, ndigits);vli_clear (z +1 , ndigits -1 ); - z[0 ] =1 ; + z[0 ] = !ecc_point_is_zero (point);for (--i; i >=0 ; i--) {ecc_point_double_jacobian (rx, ry, z, curve); idx = (!!vli_test_bit (u1, i)) | ((!!vli_test_bit (u2, i)) <<1 ); point = points[idx]; -if (point) { +if (point && !ecc_point_is_zero (point)) {u64 tx[ECC_MAX_DIGITS ];u64 ty[ECC_MAX_DIGITS ];u64 tz[ECC_MAX_DIGITS ]; +if (vli_is_zero (z, ndigits)) { +/* Adding to infinity starts a new accumulator. */ +vli_set (rx, point->x, ndigits); +vli_set (ry, point->y, ndigits); + z[0 ] =1 ; +continue ; + }vli_set (tx, point->x, ndigits);vli_set (ty, point->y, ndigits);apply_z (tx, ty, z, curve);vli_mod_sub (tz, rx, tx, curve->p, ndigits); +if (vli_is_zero (tz, ndigits)) { +if (!vli_cmp (ry, ty, ndigits)) +ecc_point_double_jacobian (rx, ry, z, + curve); +else +/* Adding opposite points yields infinity. */ +vli_clear (z, ndigits); +continue ; + }xycz_add (tx, ty, rx, ry, curve);vli_mod_mult_fast (z, z, tz, curve); }
crypto/testmgr.c +6 -4
@@ -4008,8 +4008,10 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, crypto_akcipher_verify(req) :/* Run asymmetric encrypt */ crypto_akcipher_encrypt(req), &wait); -if (err) { -pr_err ("alg: akcipher: %s test failed. err %d\n" , op, err); +if (err != vecs->verify_error) { +pr_err ("alg: akcipher: %s test failed: expected %d, got %d\n" , + op, vecs->verify_error, err); + err = err ?: -EINVAL ; goto free_all; }if (!vecs->siggen_sigver_test && c) {
@@ -4031,9 +4033,9 @@ static int test_akcipher_one(struct crypto_akcipher *tfm,/* * Don't invoke (decrypt or sign) test which require a private key -* for vectors with only a public key. +* for vectors with only a public key or an invalid signature. */ -if (vecs->public_key_vec) { +if (vecs->public_key_vec || vecs->verify_error) { err =0 ; goto free_all; }
crypto/testmgr.h +338 -1
363 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1007/2214 usb: typec: ucsi: ccg: Validate altmode index in GET_CURRENT_CAM response
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seungjin Bae <[email protected]>
[ Upstream commit 02ee864e8d2142c5648998944c3306ea6a763c26 ]
When the PPM reports more than one DisplayPort alternate mode for a connector, ucsi_ccg_update_altmodes() merges them into a single entry in uc->updated[] and sets uc->has_multiple_dp. In that case, ucsi_ccg_update_get_current_cam_cmd() rewrites the response of the GET_CURRENT_CAM command. The response is a single byte holding the index of the currently active alternate mode, and it is provided by the PPM firmware.
The function uses this byte directly as an index into uc->orig[], and then uses the linked_idx read from that entry as the translated index into uc->updated[]. Both arrays have UCSI_MAX_ALTMODES entries, but neither index is checked against that size.
If a malicious or buggy PPM reports a value of UCSI_MAX_ALTMODES or larger, e.g. 0xFF, uc->orig[cam].linked_idx reads over the end of uc->orig[]. The byte read from there is then used as the index for writing cam into uc->updated[new_cam].active_idx, so the out-of-bounds read is followed by an out-of-bounds write. This happens without any userspace action, since the UCSI core issues GET_CURRENT_CAM on its own when handling connector changes.
Fix this by rejecting responses whose index is out of range, printing an error and returning -EPROTO, so that the caller cannot accept this. Also check linked_idx before using it as an index, so that the write into uc->updated[] is always within bounds.
The response is now only processed when the command completed without an error. ucsi_sync_control_common() only reads the response when the CCI reports command completion, so otherwise the buffer is not filled and must not be mistaken for an invalid index.
This bug was found with a Python script that traces where firmware input is used.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi_ccg.c +16 -2
@@ -351,14 +351,28 @@ static int ucsi_ccg_init(struct ucsi_ccg *uc)return -ETIMEDOUT ; } -static void ucsi_ccg_update_get_current_cam_cmd (struct ucsi_ccg *uc,u8 *data) +static int ucsi_ccg_update_get_current_cam_cmd (struct ucsi_ccg *uc,u8 *data) {u8 cam, new_cam; cam = data[0 ]; +if (cam >=UCSI_MAX_ALTMODES ) { +dev_err (uc->dev,"PPM returned invalid alternate mode index %u\n" , + cam); +return -EPROTO ; + } + new_cam = uc->orig[cam].linked_idx; +if (new_cam >=UCSI_MAX_ALTMODES ) { +dev_err (uc->dev,"invalid linked alternate mode index %u for %u\n" , + new_cam, cam); +return -EPROTO ; + } + uc->updated[new_cam].active_idx = cam; data[0 ] = new_cam; + +return 0 ; } static bool ucsi_ccg_update_altmodes(struct ucsi *ucsi,
@@ -541,7 +555,7 @@ static int ucsi_ccg_read(struct ucsi *ucsi, unsigned int offset,switch (UCSI_COMMAND (uc->last_cmd_sent)) {case UCSI_GET_CURRENT_CAM :if (uc->has_multiple_dp) -ucsi_ccg_update_get_current_cam_cmd (uc, (u8 *)val); + ret =ucsi_ccg_update_get_current_cam_cmd (uc, (u8 *)val);break ;case UCSI_GET_ALTERNATE_MODES : if (UCSI_ALTMODE_RECIPIENT(uc->last_cmd_sent) ==
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1008/2214 sctp: hold shkey across socket migration
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lee <[email protected]>
[ Upstream commit ad1320865b1826ffa2e81e37c49535751e81335c ]
sctp_sock_migrate() transfers queued DATA skbs from the old socket to the new one. skb_orphan() invokes sctp_wfree() during that transfer and drops the skb-owned shared-key reference.
If userspace has removed that key from the association, this can be the final reference. The following sctp_set_owner_w() then dereferences the freed chunk->shkey while trying to take the new owner reference.
Take a temporary shared-key reference before orphaning the skb and release it after the new owner has taken its reference. This preserves the selected authentication key throughout the ownership transfer.
Bug found and triaged by OpenAI Security Research and validated by Trail of Bits.
Stable-dep-of: 52ffeaa358d1 ("sctp: re-point retained control chunks on association migration")
--- net/sctp/socket.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
net/sctp/socket.c +11 -1
@@ -146,9 +146,19 @@ static inline void sctp_set_owner_w(struct sctp_chunk *chunk)static void sctp_clear_owner_w (struct sctp_chunk *chunk) { +/* Keep the shkey alive until the new owner takes its reference. */ +if (chunk->shkey) +sctp_auth_shkey_hold (chunk->shkey);skb_orphan (chunk->skb); } +static void sctp_set_owner_w_migrate (struct sctp_chunk *chunk) +{ +sctp_set_owner_w (chunk); +if (chunk->shkey) +sctp_auth_shkey_release (chunk->shkey); +} +#define traverse_and_process () \ do { \ msg = chunk->msg; \
@@ -9698,7 +9708,7 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,lock_sock_nested (newsk,SINGLE_DEPTH_NESTING );sctp_for_each_tx_datachunk (assoc, true, sctp_clear_owner_w);sctp_assoc_migrate (assoc, newsk); -sctp_for_each_tx_datachunk (assoc, false, sctp_set_owner_w); +sctp_for_each_tx_datachunk (assoc, false, sctp_set_owner_w_migrate);/* If the association on the newsk is already closed before accept() * is called, set RCV_SHUTDOWN flag.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1009/2214 sctp: re-point retained control chunks on association migration
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Yang <[email protected]>
[ Upstream commit 52ffeaa358d1f3d91aa87a26ad90d77769cff74b ]
sctp_sock_migrate() transfers DATA chunk ownership but leaves retained control chunks pointing at the old socket. A later retransmission can therefore access the socket after it has been freed.
Extend the migration walk to cover retained control chunks and use sctp_control_set_owner_w() to assign their new owner. Reuse the DATA ownership check so each chunk is processed once per pass, even when it is reachable through multiple lists or retained pointers.
Preserve a control chunk's existing authentication key across migration so its final release can still generate SCTP_AUTH_FREE_KEY when needed.
--- include/net/sctp/sm.h | 1 + net/sctp/sm_make_chunk.c | 5 ++-- net/sctp/socket.c | 53 ++++++++++++++++++++++++++++++---------- 3 files changed, 44 insertions(+), 15 deletions(-)
include/net/sctp/sm.h +1 -0
@@ -256,6 +256,7 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc, struct sctp_fwdtsn_skip *skiplist);struct sctp_chunk *sctp_make_auth (const struct sctp_association *asoc,__u16 key_id); +void sctp_control_set_owner_w (struct sctp_chunk *chunk);struct sctp_chunk *sctp_make_strreset_req (const struct sctp_association *asoc,__u16 stream_num,__be16 *stream_list,bool out,bool in);
net/sctp/sm_make_chunk.c +3 -2
@@ -95,7 +95,7 @@ static void sctp_control_release_owner(struct sk_buff *skb) } } -static void sctp_control_set_owner_w (struct sctp_chunk *chunk) +void sctp_control_set_owner_w (struct sctp_chunk *chunk) {struct sctp_association *asoc = chunk->asoc;struct sk_buff *skb = chunk->skb;
@@ -108,7 +108,8 @@ static void sctp_control_set_owner_w(struct sctp_chunk *chunk)* For now don't do anything for now. */ if (chunk->auth) { - chunk->shkey = asoc->shkey; +if (!chunk->shkey) + chunk->shkey = asoc->shkey;sctp_auth_shkey_hold (chunk->shkey); } skb->sk = asoc ? asoc->base.sk :NULL ;
net/sctp/socket.c +40 -13
81 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1010/2214 netfilter: nf_reject: initialize IPCB at inet ingress
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 73a73d442f9986353fe284bd1b504d0313d0f153 ]
The inet ingress hook runs before ip_rcv_core() and ip6_rcv_core(), so neither IPCB nor IP6CB has been initialized when nft_reject_inet passes a packet to nf_send_unreach() or nf_send_unreach6(). skb->cb can therefore retain metadata from an earlier protocol layer.
For IPv4, icmp_send() treats IPCB(skb)->opt as parsed IPv4 options. Stale option offsets can make __ip_options_echo() copy an attacker-controlled length into its 40-byte reply option buffer and overflow the stack. On an unpatched v7.2-rc5 kernel, the IPv4 reproducer produced:
BUG: KASAN: stack-out-of-bounds in __ip_options_echo() Write of size 255
For IPv6, icmpv6_send() consumes IP6CB(skb) as parsed IPv6 metadata. It always uses iif for source selection and, when MIP6 is enabled, uses dsthao as an extension-header offset. These fields must not be stale.
For NF_INET_INGRESS, clear the address-family-specific control block and restore its input interface before constructing the ICMP error. This matches similar initialization normally performed by ip_rcv_core() and ip6_rcv_core().
--- net/ipv4/netfilter/nf_reject_ipv4.c | 5 +++++ net/ipv6/netfilter/nf_reject_ipv6.c | 5 +++++ 2 files changed, 10 insertions(+)
net/ipv4/netfilter/nf_reject_ipv4.c +5 -0
@@ -346,6 +346,11 @@ void nf_send_unreach(struct sk_buff *skb_in, int code, int hook)if (!skb_valid_dst (skb_in) &&nf_reject_fill_skb_dst (skb_in) <0 )return ; +if (hook ==NF_INET_INGRESS ) { +memset (IPCB (skb_in),0 ,sizeof (*IPCB (skb_in))); +IPCB (skb_in)->iif = skb_in->skb_iif; + } +if (skb_csum_unnecessary (skb_in) || !nf_reject_verify_csum (proto)) {icmp_send (skb_in,ICMP_DEST_UNREACH , code,0 );return ;
net/ipv6/netfilter/nf_reject_ipv6.c +5 -0
@@ -428,6 +428,11 @@ void nf_send_unreach6(struct net *net, struct sk_buff *skb_in,if (hooknum ==NF_INET_LOCAL_OUT && skb_in->dev ==NULL ) skb_in->dev = net->loopback_dev; +if (hooknum ==NF_INET_INGRESS ) { +memset (IP6CB (skb_in),0 ,sizeof (*IP6CB (skb_in))); +IP6CB (skb_in)->iif = skb_in->skb_iif; + } +if (!skb_valid_dst (skb_in) &&nf_reject6_fill_skb_dst (skb_in) <0 )return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1011/2214 bnxt_en: dont leave an XDP program installed when the open fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vaibhav Nagare <[email protected]>
[ Upstream commit 78731b46967e3e7102b5cd5062bef185f3404b5c ]
bnxt_xdp_set() stores the new program and drops the reference on the old one before reopening the NIC. If bnxt_open_nic() then fails, ndo_bpf() returns an error with the new program still in bp->xdp_prog. The caller treats the error as "nothing was installed" and drops its own reference, so bp->xdp_prog is left pointing at a freed program and the next XDP update dereferences it:
BUG: unable to handle page fault for address: ff78ecc80ddd1038 RIP: 0010:__bpf_prog_put+0x5/0x80 Call Trace: bnxt_xdp_set+0xad/0x1b0 [bnxt_en] dev_xdp_propagate+0x36/0xa0 bond_xdp_set+0xeb/0x2d0 [bonding] dev_xdp_install+0x1b1/0x350 bpf_xdp_link_update+0xc5/0x1b0 link_update+0x104/0x1e0 __sys_bpf+0x662/0xcf0
Seen on a 6.12 based kernel after bnxt_alloc_mem() failed an order-4 allocation on a fragmented host:
bnxt_en 0000:a0:00.1 ens4f1np1: nic open fail (rc: fffffff4)
bond1: (slave ens4f1np1): Error -12 calling ndo_bpf
Bonding is not required to hit this; a plain XDP attach on a bnxt interface takes the same path.
Restore the previous program when an attach or a replace fails, and recompute the page-mode and XDP TX ring configuration from it. The configuration matters because bnxt_init_one_rx_ring() only assigns rxr->xdp_prog in page mode, and __bnxt_set_rx_skb_mode() derives dev->max_mtu from the installed program. Release the old program only once the change has been committed.
A detach is not undone. dev_xdp_detach_link() clears the core's record of the program even when the driver returns an error, so putting the program back would leave the driver running a program the core has already dropped. If the reopen fails during a detach, bnxt_xdp_set() therefore returns 0 with the device closed; bnxt_open_nic() has already logged the failure.
Found in a crash dump; the change was not tested on hardware.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +20 -5
@@ -269,6 +269,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)struct net_device *dev = bp->dev;int tx_xdp =0 , rc, tc;struct bpf_prog *old; +int old_tx_xdp;if (prog && bp->dev->mtu >BNXT_MAX_PAGE_MODE_MTU ) { netdev_warn(dev, "MTU %d larger than largest XDP supported MTU %d.\n",
@@ -294,11 +295,12 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)if (netif_running (dev))bnxt_close_nic (bp, true, false); + old_tx_xdp = bp->tx_nr_rings_xdp; old =xchg (&bp->xdp_prog, prog); -if (old) -bpf_prog_put (old); -if (prog) { +apply_cfg: + tc =netdev_get_num_tc (dev) ? :1 ; +if (bp->xdp_prog) {bnxt_set_rx_skb_mode (bp, true); }else {int rx, tx;
@@ -316,8 +318,21 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)bnxt_set_tpa_flags (bp);bnxt_set_ring_params (bp); -if (netif_running (dev)) -return bnxt_open_nic (bp, true, false); +if (rc) +return rc; + +if (netif_running (dev)) { + rc =bnxt_open_nic (bp, true, false); +/* a detach cannot be undone, only an attach */ +if (rc && prog) { +WRITE_ONCE (bp->xdp_prog, old); + tx_xdp = old_tx_xdp; + goto apply_cfg; + } + } + +if (old) +bpf_prog_put (old);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1012/2214 mm/madvise: atomically clear the young bit on THP MADV_COLD
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pedro Falcato <[email protected]>
[ Upstream commit 246c8cc33438a71c28f9b86baa492d9a0a130316 ]
As-is, madvise_cold_or_pageout_pte_range() discards the hardware young bit by invalidating the PMD, doing pmd_mkold() and subsequently writing to the pmd again. However, it does so in a racy manner, looking at a possibly-stale snapshot. It's entirely possible that a write elsewhere set the hardware D bit, which this logic now loses.
Fix it by using pmdp_test_and_clear_young(). This is an atomic modification of the PMD entry, and thus safe against any possible racing writes. As a (nice) side-effect, this elides one non-required TLB flush in pmdp_invalidate().
This bug can interact with the swapping system in complicated ways, leading to data loss. For instance, if a folio is marked lazyfree, but was later read from, and then MADV_COLD'd while racing a write to that same THP, dropping the dirty bit may lead to data loss as reclaim/MADV_PAGEOUT drops the "clean" anon folio:
T0 T1
================================================================MADV_FREE(thp) |
folio marked lazyfree |
read(thp) |
PMD marked young by hardware |
| MADV_COLD(thp)
write(thp) | if (pmd_young(pmd)) {
PMD marked dirty by hardware | set(pmdp, pmd_mkold(pmd));
MADV_PAGEOUT/reclaim |
dirty bit may or may not be |
set |
reclaim/pageout may drop |
the folio |
--- mm/madvise.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
mm/madvise.c +1 -4
@@ -363,10 +363,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, }if (pmd_young (orig_pmd)) { -pmdp_invalidate (vma, addr, pmd); - orig_pmd =pmd_mkold (orig_pmd); - -set_pmd_at (mm, addr, pmd, orig_pmd); +pmdp_test_and_clear_young (vma, addr, pmd);tlb_remove_pmd_tlb_entry (tlb, pmd, addr); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1013/2214 ceph: fix integer overflow in the snap trace bounds check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit b3bf89767e3ca9506f1c7167cac97c41ec254d42 ]
ceph_update_snap_trace() bounds the two encoded snapid arrays that follow a struct ceph_mds_snap_realm with sizeof(u64) * (num_snaps + num_prior_parent_snaps). Both counts come straight off the wire as __le32, so the addition is evaluated in unsigned int and wraps before sizeof(u64) promotes it to size_t: an MDS sending num_snaps = 1 and num_prior_parent_snaps = 0xffffffff makes the sum zero and the check degenerates to ceph_decode_need(&p, e, 0, bad), which always passes. dup_array() then reads num_snaps * 8 bytes past the end of the message front, which ceph_msg_new2() allocates at exactly front_len bytes. An unsolicited CEPH_MSG_CLIENT_SNAP reaches this from a malicious or compromised MDS with no client-side action, as do the snaptraces carried in an MDS reply and in a cap import.
Compute the length with size_add()/size_mul() so it saturates at SIZE_MAX instead of wrapping, in the style fs/ceph/mdsmap.c already uses for num_export_targets.
BUG: KASAN: slab-out-of-bounds in dup_array (include/linux/unaligned.h:28 fs/ceph/snap.c:500) Read of size 8 at addr ffff8880102a16c8 by task kworker/1:2/129 Workqueue: ceph-msgr ceph_con_workfn Call Trace: dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120) print_report (mm/kasan/report.c:378 mm/kasan/report.c:482) kasan_report (mm/kasan/report.c:595) dup_array (include/linux/unaligned.h:28 fs/ceph/snap.c:500) ceph_update_snap_trace (fs/ceph/snap.c:836) ceph_handle_snap (fs/ceph/snap.c:1155) mds_dispatch (fs/ceph/mds_client.c:7234) ceph_con_process_message (net/ceph/messenger.c:1424) ceph_con_v1_try_read (net/ceph/messenger_v1.c:1430) ceph_con_workfn (net/ceph/messenger.c:1576) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) ... The buggy address is located 0 bytes to the right of allocated 72-byte region [ffff8880102a1680, ffff8880102a16c8)
--- fs/ceph/snap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/ceph/snap.c +5 -2
@@ -710,6 +710,7 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,struct ceph_snap_realm *realm;struct ceph_snap_realm *first_realm =NULL ;struct ceph_snap_realm *realm_to_rebuild =NULL ; +size_t snaps_len;int rebuild_snapcs;int err = -ENOMEM ;LIST_HEAD (dirty_realms);
@@ -723,8 +724,10 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,ceph_decode_need (&p, e,sizeof (*ri), bad); ri = p; p +=sizeof (*ri); -ceph_decode_need (&p, e,sizeof (u64)*(le32_to_cpu (ri->num_snaps) + -le32_to_cpu (ri->num_prior_parent_snaps)), bad); + snaps_len =size_mul (size_add (le32_to_cpu (ri->num_snaps), +le32_to_cpu (ri->num_prior_parent_snaps)), +sizeof (u64)); +ceph_decode_need (&p, e, snaps_len, bad); snaps = p; p +=sizeof (u64) *le32_to_cpu (ri->num_snaps); prior_parent_snaps = p;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1014/2214 fs/ntfs3: validate the EA value length in ntfs_read_ea()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuejie Shi <[email protected]>
[ Upstream commit 351817226fbf0031c4c63d1f5d7f15c3172312eb ]
ntfs_read_ea() checks the $EA list for consistency, but it only recomputes the packed size of an entry when the entry's own size field is zero:
for (off = 0; off < size; off += ea_size) {
const struct EA_FULL *ef = Add2Ptr(ea_p, off);
u32 bytes = size - off;
...
if (ef->size) {
ea_size = le32_to_cpu(ef->size);
if (ea_size > bytes)
goto out1;
continue; /* <- elength never checked */
}
...
ea_size = ALIGN(struct_size(ef, name,
1 + ef->name_len +
le16_to_cpu(ef->elength)),
4);
if (ea_size > bytes)
goto out1;
}ef->size is non-zero for every entry except the last one, and it is what ntfs3 itself writes (ntfs_set_ea() stores exactly that aligned packed size), so in practice elength is not validated at all. find_ea() then uses unpacked_ea_size(), which also prefers ea->size when it is set, so it agrees and hands the entry back.
ntfs_get_ea() copies elength bytes with no further bound of its own:
len = le16_to_cpu(ea->elength);
...
if (len > size) { /* size is the *caller's* buffer */
err = -ERANGE;
...
}
memcpy(buffer, ea->name + ea->name_len + 1, len);so a caller that supplies a large enough buffer receives up to 64 KiB of whatever follows the small $EA allocation -- straight to userspace via getxattr(2).
Compute the packed size unconditionally and require it to fit in the entry. Hoist the "bytes < offsetof(struct EA_FULL, name)" test above the ef->size branch as well: name_len and elength were being read there without it, which is itself a small over-read of the kmalloc'd buffer when fewer than 8 bytes are left. The old "bytes < sizeof(ef->size)" test is subsumed by it.
# mkntfs image; create /mnt/ntfs/poc with user.ntfs6 set, then rewrite
# that EA_FULL's elength from 0xf to 0xff00 on the raw device
mount -t ntfs3 -o ro /dev/vda /mnt/ntfs
getxattr("/mnt/ntfs/poc", "user.ntfs6", buf, 128 * 1024);BUG: KASAN: slab-out-of-bounds in ntfs_get_ea+0x294/0x3e0 Read of size 65280 at addr ffff0000cca53acf by task xattr_probe/142 __asan_memcpy+0x3c/0xa0 ntfs_get_ea+0x294/0x3e0 ntfs_getxattr+0x284/0x318 __vfs_getxattr+0x104/0x160 vfs_getxattr+0x1b4/0x1e0 do_getxattr+0xcc/0x230 path_getxattrat+0x184/0x270 __arm64_sys_getxattr+0x64/0x80 Allocated by task 142: __kmalloc_noprof+0x294/0x668 ntfs_read_ea+0x1e4/0x420 ntfs_get_ea+0x2c8/0x3e0 The buggy address belongs to the object at ffff0000cca53a80 which belongs to the cache kmalloc-96 of size 96
The object being over-read is the one ntfs_read_ea() just allocated, and it is 96 bytes.
Entries written by ntfs3 and by Windows set size to the aligned packed size, so the new test does not reject anything a working filesystem produces.
--- fs/ntfs3/xattr.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
fs/ntfs3/xattr.c +14 -11
@@ -145,29 +145,32 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,for (off =0 ; off < size; off += ea_size) {const struct EA_FULL *ef =Add2Ptr (ea_p, off);u32 bytes = size - off; -size_t need; - -/* Check if we can use field ea->size. */ -if (bytes <sizeof (ef->size)) - goto out1; +u32 packed_size;/* Check if we can use fields ef->name_len and ef->elength. */ if (bytes < offsetof(struct EA_FULL , name)) goto out1; -/* Size needed to hold this record's name and value. */ - need =struct_size (ef, name, -1 + ef->name_len +le16_to_cpu (ef->elength)); +/* +* The name and the value have to fit in the entry whether or +* not ef->size is set, because ntfs_get_ea() copies elength +* bytes out of this buffer and checks them only against the +* caller supplied buffer size. +*/ + packed_size = +ALIGN (struct_size (ef, name, +1 + ef->name_len + +le16_to_cpu (ef->elength)), +4 );if (ef->size) { ea_size =le32_to_cpu (ef->size); -/* ef->size must fit the list and cover the record. */ -if (ea_size > bytes || ea_size < need) +if (ea_size > bytes || packed_size > ea_size) goto out1;continue ; } - ea_size =ALIGN (need,4 ); + ea_size = packed_size;if (ea_size > bytes) goto out1; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1015/2214 usb: xhci: Fix bounce buffer overflow
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Pecio <[email protected]>
[ Upstream commit 68c5cb7574c567e83ba95258cb146db95e069a87 ]
High-speed devices with out of spec 1024 byte bulk endpoints exist and are allowed by USB core, but xhci-hcd always sets packet size to 512. The exact nature of these devices isn't documented, commit fb5ee84ea72c ("USB: Accept bulk endpoints with 1024-byte maxpacket") only states that they "don't work with xHCI host controllers", whatever it means.
But somebody (or a malicious device) can try, and then the driver will allocate a 512 byte bounce buffer for this endpoint and may write up to 1024 bytes into it if particular scatter-gather URBs are used, because xhci_align_td() obtains packet size from the descriptor. Fix this.
As a side effect, TRBs will be aligned to the packet size chosen by the driver on all endpoints of all speeds. Alignment serves the xHC, not device, so this is fine. Only out of spec devices are affected anyway.
--- drivers/usb/host/xhci-ring.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/usb/host/xhci-ring.c +3 -6
@@ -3689,15 +3689,13 @@ static u32 xhci_td_remainder(struct xhci_hcd *xhci, int transferred,static int xhci_align_td (struct xhci_hcd *xhci,struct urb *urb,u32 enqd_len, -u32 *trb_buff_len,struct xhci_segment *seg) +u32 *trb_buff_len,struct xhci_segment *seg,u32 max_pkt) {struct device *dev =xhci_to_hcd (xhci)->self.sysdev;unsigned int unalign; -unsigned int max_pkt;u32 new_buff_len;size_t len; - max_pkt =usb_endpoint_maxp (&urb->ep->desc); unalign = (enqd_len + *trb_buff_len) % max_pkt;/* we got lucky, last normal TRB data on segment is packet aligned */
@@ -3842,9 +3840,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,if (enqd_len + trb_buff_len < full_len) { field |=TRB_CHAIN ;if (trb_is_link (ring->enqueue +1 )) { -if (xhci_align_td (xhci, urb, enqd_len, - &trb_buff_len, - ring->enq_seg)) { +if (xhci_align_td (xhci, urb, enqd_len, &trb_buff_len, + ring->enq_seg, ring->bounce_buf_len)) { send_addr = ring->enq_seg->bounce_dma;/* TD bounced at least, and last on this seg */ td->bounce_seg = ring->enq_seg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1016/2214 platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit 6dea092b261f04d632411c2be52d13190f5f67b1 ]
hp_wmi_perform_query() evaluates an ACPI WMI method and expects a struct bios_return header in the returned buffer. However, it only checks that the ACPI object type is ACPI_TYPE_BUFFER without verifying that obj->buffer.length is at least sizeof(*bios_return) (8 bytes).
If the firmware or ACPI method returns a buffer shorter than 8 bytes:
1. bios_return->return_code at offset 4 reads out of bounds from the allocated ACPI buffer slab.
2. If return_code evaluates to 0 and outsize is non-zero, (int)(obj->buffer.length - sizeof(*bios_return)) evaluates to a negative integer (e.g. -8 for a 0-length buffer). actual_outsize is set to this negative value and passed to memcpy(buffer, ..., actual_outsize), where the signed negative value is cast to size_t (e.g. 0xfffffffffffffff8), attempting to copy ~18 Exabytes and triggering an immediate kernel crash. Additionally, memset(buffer + actual_outsize, ...) performs an out-of-bounds write before buffer.
Fix this by ensuring obj->buffer.length is at least sizeof(*bios_return) before accessing the return code, and compute actual_outsize safely using min_t(u32, ...), which is sound specifically because the guard above already rules out obj->buffer.length being smaller than sizeof(*bios_return) by the time that subtraction runs.
--- drivers/platform/x86/hp/hp-wmi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +4 -2
@@ -261,7 +261,9 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,if (!obj)return -EINVAL ; -if (obj->type !=ACPI_TYPE_BUFFER ) { +if (obj->type !=ACPI_TYPE_BUFFER || + obj->buffer.length <sizeof (*bios_return)) { +pr_warn ("query 0x%x returned wrong type or too small buffer\n" , query); ret = -EINVAL ; goto out_free; }
@@ -280,7 +282,7 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,if (!outsize) goto out_free; - actual_outsize =min (outsize, (int )(obj->buffer.length -sizeof (*bios_return))); + actual_outsize =min_t (u32, outsize, obj->buffer.length -sizeof (*bios_return));memcpy (buffer, obj->buffer.pointer +sizeof (*bios_return), actual_outsize);memset (buffer + actual_outsize,0 , outsize - actual_outsize);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1017/2214 ALSA: usb-audio: Bound packet copies by the PCM buffer size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sinan Turunc <[email protected]>
[ Upstream commit 06be918062adc1a5a76dc346803b136b20bdb5ae ]
retire_capture_urb() and prepare_playback_urb() assume that one USB packet never carries more data than the whole ALSA ring buffer. Nothing enforces that: the packet size comes from the device (wMaxPacketSize, and curpacksize == maxpacksize when the class-specific endpoint descriptor sets MaxPacketsOnly), while the PCM hardware constraints only require 64-byte periods, two periods and a period time of one data interval. An 8 kHz mono U8 stream on a 128-byte buffer is legal, and a full-speed device can send 1023-byte packets into it.
On the first oversized packet hwptr_done is wrapped once and stays beyond buffer_bytes (895 for 1023 bytes into 128). On the next packet the wrap arithmetic in the copy path computes
bytes1 = subs->buffer_bytes - oldptr
with oldptr > buffer_bytes, so bytes1 wraps to about 4 GB and memcpy() runs off the end of the URB buffer and of the vmalloc'd DMA buffer:
BUG: KASAN: slab-out-of-bounds in retire_capture_urb+0x251/0x870 Read of size 4294966529 at addr ffff88800c1e2800 by task vhci_rx/82
and for playback, where copy_to_urb() has the same shape:
BUG: KASAN: vmalloc-out-of-bounds in copy_to_urb.isra.0+0x188/0x430 Read of size 4294966529 at addr ffffc9000004537f by task vhci_rx/79 prepare_playback_urb+0x98a/0x1fc0
Truncate an oversized capture packet to the buffer size, and stop filling a playback URB once it holds a whole buffer. With bytes <= buffer_bytes the single wrap of hwptr_done and the two-part memcpy() in both copy paths stay inside the buffer. A device whose packets do not fit the buffer at all was never going to play correctly anyway.
Reproduced on 7.3-rc7 with a USB/IP device (dummy_hcd cannot carry isochronous data) advertising a UAC1 endpoint with MaxPacketsOnly and wMaxPacketSize 1023, and a PCM client using period_size 64, periods 2.
--- sound/usb/pcm.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
sound/usb/pcm.c +20 -1
@@ -1228,6 +1228,18 @@ static void retire_capture_urb(struct snd_usb_substream *subs, bytes -= adj; subs->stream_offset_adj -= adj; } +/* +* A packet can be as large as the endpoint's maxpacksize, which +* the device chooses, while the ring buffer can be as small as +* two 64-byte periods. The hwptr_done wrap below handles one +* wrap only, so never take more than one buffer from a packet. +*/ +if (unlikely (bytes > subs->buffer_bytes)) { +dev_warn_ratelimited (&subs->dev->dev, +"%u-byte packet exceeds %u-byte buffer, truncating\n" , + bytes, subs->buffer_bytes); + bytes = subs->buffer_bytes; + } frames = bytes / stride;if (!subs->txfr_quirk) bytes = frames * stride;
@@ -1441,7 +1453,14 @@ static int prepare_playback_urb(struct snd_usb_substream *subs,for (i =0 ; i < ctx->packets; i++) { counts =snd_usb_endpoint_next_packet_size (ep, ctx, i, avail); -if (counts <0 ) +/* +* Bound by the ring buffer as well as by the URB: +* copy_to_urb() wraps hwptr_done once, so one URB must +* never carry more than the whole buffer. +*/ +if (counts <0 || + (frames + counts) * stride > ctx->buffer_size || + (frames + counts) * stride > subs->buffer_bytes)break ;/* set up descriptor */ urb->iso_frame_desc[i].offset = frames * stride;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1018/2214 mm/hugetlb: unmap the page where the other VMA maps it
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit ae99c503eb362b42cd5d24d80bc6cba669acc4c2 ]
If the owner of a MAP_PRIVATE hugetlb mapping fails to allocate a page for CoW, unmap_ref_private() unmaps the old page from all other private VMAs that have no reservation of their own. It finds them by the offset in the file, but then zaps each of them at the address of the faulting VMA. Nothing says that another VMA maps the offset at that address: a child can have moved its copy of the VMA with mremap(), and a second mapping of the file is wherever mmap() has put it.
So __unmap_hugepage_range() walks the page tables of the other mm at an address outside of iter_vma, where i_mmap_rwsem of this file protects nothing and where anything can be mapped, and the page stays mapped where it really is.
All of the following was seen on v7.3-rc6+ (g6c377d19d4a5) in KVM guests, as a user without any privilege. It takes a pool of 2 MiB pages with no free page that is not reserved, so that the allocation fails: the user can take or reserve what is free itself.
- The child moves its VMA away. The page is never unmapped, the mapcount stays 2, and the owner goes round retry_avoidcopy in hugetlb_wp() until the child is gone or a page becomes free. SIGKILL to the owner does not end it. 5 of 5 runs.
- The owner's mm has a second private mapping of the offset, made with MAP_NORESERVE. The owner zaps its own entry and reads zeroes where its data was. 5 of 5 runs.
- The child moves its VMA away and maps a 1 GiB hugetlb page at the old address, so this one takes a pool with a 1 GiB page as well. huge_pte_offset() for the 2 MiB size steps through the PUD leaf, so the "PMD table" is the 1 GiB page itself and its "page table lock" is folio->private of that page, which holds 2. Kernels with lock debugging oops in __unmap_hugepage_range(), 7 of 7 runs. Others spin on that word for ever with preemption disabled, 5 of 5 runs:
watchdog: BUG: soft lockup - CPU#0 stuck for 26s! [u_det3:130]
RIP: 0010:queued_spin_lock_slowpath+0x8a/0x290
RAX: 0000000000000002 RBX: ffffea0001000028
Call Trace:
__unmap_hugepage_range+0x154/0x6d0
unmap_hugepage_range+0xc1/0x140
hugetlb_wp+0x55c/0x700
hugetlb_fault+0x5f3/0x8f0RCU stalls follow, and killing all tasks of the user changes nothing. Four such owners, whose children share a single 1 GiB page, took down the whole guest with its four CPUs, 2 of 2 runs: one reported soft lockups on all four, the other gave no sign of life any more.
i_mmap_rwsem stays write locked. With a MAP_PRIVATE mapping of a hugetlbfs file that belongs to another user, and that the attacker can only read, the next mmap() of that file by its owner sleeps uninterruptibly in __mmap_region(), 4 of 4 runs.
Compute the address from the offset for each VMA. The tree walk returns only VMAs that cover pgoff, and vm_start, vm_end and vm_pgoff of a hugetlb VMA are aligned to the huge page size, as pgoff is, so the whole range lies inside iter_vma. Its page tables can not go away there, since the VMA is unlinked from the file under i_mmap_rwsem first.
With the right address the page is unmapped from all VMAs but the owner's, so the retry in hugetlb_wp() finds a mapcount of 1 and reuses the page.
A child that has moved its copy of the VMA now loses the page, and gets SIGBUS when it faults on a missing page of that VMA. That is what the comment above the function has always promised to those who do not own the reservation, and what already happens to a child that has left the VMA in place.
The address has been wrong from the start, and the second case needs only mmap() and fork(). mremap() of hugetlb VMAs, which the other cases use, came with commit 550a7d60bd5e ("mm, hugepages: add mremap() support for hugepage backed vma") in v5.16.
Original fix generated by an LLM and sent in private by Josef.
--- mm/hugetlb.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
mm/hugetlb.c +14 -3
@@ -4578,6 +4578,8 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,struct address_space *mapping;pgoff_t pgoff; +VM_WARN_ON_ONCE (!PageAnon (page)); +/* * vm_pgoff is in PAGE_SIZE units, hence the different calculation * from page cache lookup which is in HPAGE_SIZE units.
@@ -4613,9 +4615,18 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,* could insert a zeroed page instead of the data existing * from the time of fork. This would look like data corruption */ -if (!is_vma_resv_set (iter_vma,HPAGE_RESV_OWNER )) -unmap_hugepage_range (iter_vma, address, - address +huge_page_size (h), page); +if (is_vma_resv_set (iter_vma,HPAGE_RESV_OWNER )) +continue ; + +/* +* The address in other VMAs can differ. Even though our old +* page is anon, we always operate on the underlying hugetlb +* file. +*/ + address = iter_vma->vm_start + + ((pgoff - iter_vma->vm_pgoff) <<PAGE_SHIFT ); +unmap_hugepage_range (iter_vma, address, + address +huge_page_size (h), page); }i_mmap_unlock_write (mapping); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1019/2214 ipmr, ip6mr: validate packets injected into the register vif on xmit
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit aa1799e93f5ebb973252aec649d84d12d9c7fd1c ]
reg_vif_xmit() passes the packet to ipmr_cache_report() which copies its IP header into the IGMPMSG_WHOLEPKT report that is queued to the mroute socket. Nothing guarantees that the packet contains a full IP header, so when a short packet is injected on the register device (e.g., using AF_PACKET), the copy reads past the end of the packet and a recvmsg() on the mroute socket leaks the uninitialized bytes to user space [1].
IPv6 has the same problem [2]. Its reg_vif_xmit() does call pskb_inet_may_pull(), but the helper keys off skb->protocol and does not pull anything when the protocol is neither IPv4 nor IPv6.
Fix by dropping packets whose protocol does not match the address family of the register device or that do not contain a full network header.
[1]
BUG: KMSAN: kernel-infoleak in _copy_to_iter raw_recvmsg
Uninit was stored to memory at:
ipmr_cache_report
reg_vif_xmit
packet_sendmsg
Uninit was created at:
__alloc_skb
sock_alloc_send_pskb
packet_sendmsg
Bytes 1-3 of 21 are uninitialized
[2]
BUG: KMSAN: kernel-infoleak in _copy_to_iter rawv6_recvmsg
Uninit was stored to memory at:
ip6mr_cache_report
reg_vif_xmit
packet_sendmsg
Uninit was created at:
__alloc_skb
sock_alloc_send_pskb
packet_sendmsg
Bytes 8-23 of 41 are uninitialized
--- net/ipv4/ipmr.c | 6 ++++++ net/ipv6/ip6mr.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
net/ipv4/ipmr.c +6 -0
@@ -502,6 +502,12 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) };int err; +if (skb->protocol !=htons (ETH_P_IP ) || !pskb_inet_may_pull (skb)) { +DEV_STATS_INC (dev, tx_errors); +kfree_skb (skb); +return NETDEV_TX_OK ; + } + err =ipmr_fib_lookup (net, &fl4, &mrt);if (err <0 ) {kfree_skb (skb);
net/ipv6/ip6mr.c +1 -1
@@ -601,7 +601,7 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, .flowi6_mark = skb->mark, }; -if (!pskb_inet_may_pull (skb)) +if (skb->protocol !=htons (ETH_P_IPV6 ) || !pskb_inet_may_pull (skb)) goto tx_err;if (ip6mr_fib_lookup (net, &fl6, &mrt) <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1020/2214 loop: check for read-write open mode on LOOP_SET_STATUS in lo_compat_ioctl()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dominik Maier <[email protected]>
[ Upstream commit 87409eedc543d288cdd49c2174f7d61eca7b8db5 ]
lo_ioctl() checks for (mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN) before allowing LOOP_SET_STATUS or LOOP_SET_STATUS64, but not lo_compat_ioctl(), the handler used by 32-bit user space on 64-bit kernels.
As a result, on 64-bit kernels with CONFIG_COMPAT=y, a 32-bit unprivileged user-space process holding a read-only (O_RDONLY) file descriptor to an active /dev/loopN device can issue a compat LOOP_SET_STATUS ioctl to modify lo_offset, clear lo_sizelimit to 0 (exposing backing-file data past the configured limit), or alter lo_flags.
Enforce the same (mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN) check on LOOP_SET_STATUS in lo_compat_ioctl().
--- drivers/block/loop.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/block/loop.c +4 -2
@@ -2020,8 +2020,10 @@ static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode,switch (cmd) {case LOOP_SET_STATUS : - err =loop_set_status_compat (lo, - (const struct compat_loop_info __user *)arg); + err = -EPERM ; +if ((mode &FMODE_WRITE ) ||capable (CAP_SYS_ADMIN )) + err =loop_set_status_compat (lo, + (const struct compat_loop_info __user *)arg);break ;case LOOP_GET_STATUS : err = loop_get_status_compat(lo,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1021/2214 mm/page_vma_mapped: continue past nonmatching huge PMDs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 1a2993227e8a27fc4cdea305bbdae82d290bc885 ]
A PTE-mapped large folio can straddle PMD boundaries after an unaligned mremap(). If the first part is discarded and replaced with an unrelated huge PMD, page_vma_mapped_walk() stops instead of looking for the rest of the folio in subsequent PMDs.
This also affects migration entries. A walk that stops at an unrelated huge PMD can leave migration PTEs behind when migration or an anonymous folio split restores the mappings. Those entries do not hold mapping references and can outlive the source folio.
This issue can lead to memory corruption and I have a reproducer for it.
Skip the current PMD rather than ending the walk on a flag or PFN mismatch. Do the same if the PMD became nonpresent before the locked recheck. Release the PMD lock, clear the per-PMD state and advance with step_forward(), so the existing range limit controls termination. This covers present, migration and device-private huge PMDs while preserving the matching-PMD and split-to-PTE paths.
--- mm/page_vma_mapped.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
mm/page_vma_mapped.c +16 -6
@@ -223,9 +223,9 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) pmde = *pvmw->pmd;if (likely (pmd_trans_huge (pmde))) {if (pvmw->flags &PVMW_MIGRATION ) -return not_found (pvmw); + goto next_pmd;if (pmd_page (pmde) != page) -return not_found (pvmw); + goto next_pmd;return true; }if (!pmd_present (pmde)) {
@@ -233,11 +233,11 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)if (!thp_migration_supported () || !(pvmw->flags &PVMW_MIGRATION )) -return not_found (pvmw); + goto next_pmd; entry =pmd_to_swp_entry (pmde);if (!is_migration_entry (entry) ||pfn_swap_entry_to_page (entry) != page) -return not_found (pvmw); + goto next_pmd;return true; }/* THP pmd was split under us: handle on pte level */
@@ -255,8 +255,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_unlock (ptl); } -step_forward (pvmw,PMD_SIZE ); -continue ; + goto next_pmd; }if (!map_pte (pvmw)) goto next_pte;
@@ -290,6 +289,17 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_lock (pvmw->ptl); } goto this_pte; +next_pmd: +/* +* A large folio can be PTE-mapped across PMDs, so a +* nonmatching PMD does not end the walk. +*/ +if (pvmw->ptl) { +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ; + } + pvmw->pmd =NULL ; +step_forward (pvmw,PMD_SIZE ); }while (pvmw->address < end);return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1022/2214 splice: report related fsnotify events
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chung-Chiang Cheng <[email protected]>
[ Upstream commit 983652c691990b3257a07f67f4263eb847baa82d ]
The fsnotify ACCESS and MODIFY event are missing when manipulating a file with splice(2).
Message-Id: <[email protected]>
Stable-dep-of: 79b496ebe382 ("splice: avoid stale f_pos writeback on error")
--- fs/splice.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/splice.c +8 -0
@@ -30,6 +30,7 @@#include <linux/export.h> #include <linux/syscalls.h> #include <linux/uio.h> +#include <linux/fsnotify.h> #include <linux/security.h> #include <linux/gfp.h> #include <linux/socket.h>
@@ -1108,6 +1109,9 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =do_splice_from (ipipe, out, &offset, len, flags);file_end_write (out); +if (ret >0 ) +fsnotify_modify (out); +if (!off_out) out->f_pos = offset;else
@@ -1131,6 +1135,10 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, flags |=SPLICE_F_NONBLOCK ; ret =splice_file_to_pipe (in, opipe, &offset, len, flags); + +if (ret >0 ) +fsnotify_access (in); +if (!off_in) in->f_pos = offset;else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1023/2214 splice: always fsnotify_access(in), fsnotify_modify(out) on success
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahelenia Ziemiańska <[email protected]>
[ Upstream commit 12ee4b66af34f8e72f3b2fd93a946a955efe7c86 ]
The current behaviour caused an asymmetry where some write APIs (write, sendfile) would notify the written-to/read-from objects, but splice wouldn't.
This affected userspace which uses inotify, most notably coreutils tail -f, to monitor pipes.
If the pipe buffer had been filled by a splice-family function:
* tail wouldn't know and thus wouldn't service the pipe, and
* all writes to the pipe would block because it's full,
thus service was denied.
(For the particular case of tail -f this could be worked around
with ---disable-inotify.)
Message-Id: <604ec704d933e0e0121d9e107ce914512e045fad.1688393619.git.nabijaczleweli@nabijaczleweli.xyz>
Stable-dep-of: 79b496ebe382 ("splice: avoid stale f_pos writeback on error")
--- fs/splice.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
fs/splice.c +15 -17
@@ -1081,10 +1081,8 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out,if ((in->f_flags | out->f_flags) &O_NONBLOCK ) flags |=SPLICE_F_NONBLOCK ; -return splice_pipe_to_pipe (ipipe, opipe, len, flags); - } - -if (ipipe) { + ret =splice_pipe_to_pipe (ipipe, opipe, len, flags); + }else if (ipipe) {if (off_in)return -ESPIPE ;if (off_out) {
@@ -1109,18 +1107,11 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =do_splice_from (ipipe, out, &offset, len, flags);file_end_write (out); -if (ret >0 ) -fsnotify_modify (out); -if (!off_out) out->f_pos = offset;else *off_out = offset; - -return ret; - } - -if (opipe) { + }else if (opipe) {if (off_out)return -ESPIPE ;if (off_in) {
@@ -1136,18 +1127,25 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =splice_file_to_pipe (in, opipe, &offset, len, flags); -if (ret >0 ) -fsnotify_access (in); -if (!off_in) in->f_pos = offset;else *off_in = offset; + }else { + ret = -EINVAL ; + } -return ret; +if (ret >0 ) { +/* +* Generate modify out before access in: +* do_splice_from() may've already sent modify out, +* and this ensures the events get merged. +*/ +fsnotify_modify (out); +fsnotify_access (in); } -return -EINVAL ; +return ret; } static long __do_splice(struct file *in, loff_t __user *off_in,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1024/2214 splice: avoid stale f_pos writeback on error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
[ Upstream commit 79b496ebe382866e3a05090b7dc9ae95e85e65b2 ]
do_splice() snapshots an implicit file position before calling the splice helper. Since splice does not take f_pos_lock, another operation on the same open file description can update f_pos while the helper is blocked. If the helper then fails, the unconditional writeback restores the stale snapshot.
For a directory without ->splice_read, a file-to-pipe splice fails with -EINVAL. A concurrent directory mutation and getdents() call can advance f_pos and refresh the filesystem's revalidation cookie before that failure restores only the old position. The next ext2 readdir can then trust an offset inside a directory entry and copy data from the adjacent page to userspace.
Only update an implicit file position when splice returns a non-negative result, matching read and write. Keep explicit offset updates unchanged.
--- fs/splice.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/splice.c +6 -6
@@ -1107,10 +1107,10 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =do_splice_from (ipipe, out, &offset, len, flags);file_end_write (out); -if (!off_out) - out->f_pos = offset; -else +if (off_out) *off_out = offset; +else if (ret >=0 ) + out->f_pos = offset; }else if (opipe) {if (off_out)return -ESPIPE ;
@@ -1127,10 +1127,10 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =splice_file_to_pipe (in, opipe, &offset, len, flags); -if (!off_in) - in->f_pos = offset; -else +if (off_in) *off_in = offset; +else if (ret >=0 ) + in->f_pos = offset; }else { ret = -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1025/2214 ALSA: control: Fix UAF in snd_ctl_elem_add() on card disconnect
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit d4febca239be3c91498762dd0535a87d4af1eabc ]
A use-after-free can be triggered via SNDRV_CTL_IOCTL_ELEM_ADD when a USB audio card is disconnected while an ELEM_ADD ioctl is in flight.
The reproducer parks the ioctl thread inside copy_from_user() using userfaultfd, then tears down the USB device. Unlike every other ALSA control _user handler (ELEM_INFO, ELEM_READ, ELEM_WRITE, TLV_*), snd_ctl_elem_add_user() never calls snd_power_ref_and_wait(), so the parked thread holds no power reference. snd_card_disconnect() therefore cannot observe it via snd_power_sync_ref() and proceeds unimpeded:
1. card->shutdown is set to 1
2. device_del(&card->card_dev) drops the kobject reference on the
parent USB interface device (card->dev = &intf->dev)
3. The USB core drops its own reference and calls device_release(), freeing the struct usb_interface, including the embedded struct device that card->dev points to
When the userfaultfd is resolved and the thread resumes, snd_ctl_elem_add() acquires controls_rwsem without checking card->shutdown and calls __snd_ctl_add_replace(). Because the reproducer pre-registered the same control, the CTL_ADD_EXCLUSIVE path calls dev_err(card->dev, ...) on the freed USB interface:
KASAN: slab-use-after-free Read in __dev_printk
Add a card->shutdown guard immediately after acquiring controls_rwsem in snd_ctl_elem_add(). At that point card->shutdown is guaranteed to be stable: snd_card_disconnect() sets it before freeing the parent device, and it never transitions back to 0. A thread that acquired the lock before disconnect sees shutdown=0 and holds the write lock through the rest of the operation, preventing concurrent disconnect from proceeding past its own controls_rwsem-less shutdown=1 store (which happened earlier, outside the lock) from racing with dev_err().
--- sound/core/control.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/core/control.c +4 -0
@@ -1534,6 +1534,10 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, alloc_size =compute_user_elem_size (private_size, count);down_write (&card->controls_rwsem); +if (card->shutdown) { + err = -ENODEV ; + goto unlock; + }if (check_user_elem_overflow (card, alloc_size)) { err = -ENOMEM ; goto unlock;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1026/2214 mm/madvise: fix data loss from MADV_FREE on a KSM page
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 22d043c1da48d6c7274f9dd900714b6d58b7b9c6 ]
MADV_FREE can clear the dirty flag of a singly mapped KSM folio. The folio remains in the stable tree and can gain new mappings without being dirtied again. Once marked lazyfree, reclaim can discard data that those mappings still need.
KSM always marks a folio dirty when converting it to a KSM folio in try_to_merge_one_page(). Marking a folio lazyfree clears PG_swapbacked but leaves PG_dirty unchanged. Preserving PG_dirty makes reclaim restore PG_swapbacked instead of discarding the folio. This also protects folios that were already lazyfree when KSM converted them.
Skip KSM folios before clearing their dirty flag, checking under the folio lock to serialize with KSM conversion.
--- mm/madvise.c | 9 +++++++++ 1 file changed, 9 insertions(+)
mm/madvise.c +9 -0
@@ -651,6 +651,15 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,if (PageSwapCache (page) ||PageDirty (page)) {if (!trylock_page (page))continue ; +/* +* KSM pages can gain new mappings at any time, so we must +* not clear their dirty flag. +*/ +if (PageKsm (page)) { +unlock_page (page); +continue ; + } +/* * If page is shared with others, we couldn't clear * PG_dirty of the page.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1027/2214 ALSA: hwdep: Serialize DSP load requests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <[email protected]>
[ Upstream commit aee83c204f80d56b4d55f53acdb8594308ddcd4a ]
The check of the loaded DSP indices and the call of the driver's dsp_load callback in snd_hwdep_dsp_load() are not serialized. A hwdep file descriptor can be shared among threads, or inherited across fork, so two SNDRV_HWDEP_IOCTL_DSP_LOAD requests for the same index can both observe the index as unloaded and enter the driver's callback concurrently, even though the device itself is opened exclusively.
This breaks the assumption behind hw->dsp_loaded that a firmware index is loaded only once. For example, snd-usb-usx2y hits WARN_ON(usx2y->as04.buffer) in usx2y_async_seq04_init() and may allocate the US-428 sequence URBs twice.
Serialize the check, the callback invocation and the bookkeeping with a per-hwdep mutex, so that the second request returns -EBUSY.
5.10 and 5.15 still build with -std=gnu89, so guard() cannot be used after the early returns of this function. Take the mutex explicitly and release it on every exit path instead.
--- include/sound/hwdep.h | 1 + sound/core/hwdep.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-)
include/sound/hwdep.h +1 -0
@@ -57,6 +57,7 @@ struct snd_hwdep {struct mutex open_mutex;int used;/* reference counter */ +struct mutex dsp_mutex;/* serializes DSP load requests */ unsigned int dsp_loaded;/* bit fields of loaded dsp indices */ unsigned int exclusive:1; /* exclusive access mode */ };
sound/core/hwdep.c +10 -4
@@ -212,14 +212,19 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,return -ENXIO ;if (info->index >=32 )return -EINVAL ; +mutex_lock (&hw->dsp_mutex);/* check whether the dsp was already loaded */ -if (hw->dsp_loaded & (1u << info->index)) -return -EBUSY ; +if (hw->dsp_loaded & (1u << info->index)) { + err = -EBUSY ; + goto unlock; + } err = hw->ops.dsp_load (hw, info);if (err <0 ) -return err; + goto unlock; hw->dsp_loaded |= (1u << info->index); -return 0 ; +unlock: +mutex_unlock (&hw->dsp_mutex); +return err; } static int snd_hwdep_dsp_load_user(struct snd_hwdep *hw,
@@ -377,6 +382,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,init_waitqueue_head (&hwdep->open_wait);mutex_init (&hwdep->open_mutex); +mutex_init (&hwdep->dsp_mutex); hwdep->card = card; hwdep->device = device;if (id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1028/2214 drm/amd/display: skip pre-flip post_update on DCE
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Jiang <[email protected]>
The v5.15.119 backport of the dc_update_planes_and_stream series (commit 3c1aa91b37f9 "drm/amd/display: Add wrapper to call planes and stream update", upstream commit 81f743a08f3b) made update_planes_and_stream_adapter() call dc_post_update_surfaces_to_stream() before every UPDATE_TYPE_FAST flip.
In mainline that series was merged in the same cycle as commit 32953485c558 ("drm/amd/display: Do not update DRR while BW optimizations pending"), which restructured dc_post_update_surfaces_to_stream() so that disable_plane()/optimize_bandwidth() only run on DCN, retaining the legacy behaviour for DCE. That companion commit was never backported to 5.15.y, so on DCE every desktop flip now runs disable_plane() for each unused pipe - an ATOM enable_disp_power_gating VBIOS call each - plus optimize_bandwidth() immediately before the new surface address is programmed.
On Carrizo (DCE 11) this occasionally wedges the active pipe: the surface update stays GRPH_SURFACE_UPDATE_PENDING set forever and is never taken, GRPH_PFLIP never fires, drm_atomic_helper_wait_for_flip_done() times out and the desktop freezes. When it hits the first desktop commit after boot, the pipe scans out zero data, which shows as a green screen on YCbCr 4:4:4 HDMI outputs (black on RGB/DP). A VT switch recovers because the full modeset reprograms the front end. Wedging boots also show "atombios stuck in loop" in the EnableDispPowerGating table and smu8 message timeouts. Later modesets can deadlock in dce_mi_free_dmif().
This is the same class of regression that commit 62e5a7e2333a ("drm/amd/display: Fix surface optimization regression on Carrizo") fixed for the previous call site in dc_commit_updates_for_stream(), which the new adapter path bypasses. Mainline is not affected (DCE is guarded inside dc_post_update_surfaces_to_stream(), later cleaned up by commit 9571dbaf98c8); 6.1.y, 6.6.y and 6.12.y all carry the guard. Only 5.15.y is missing it.
Restrict the pre-update call to DCN, matching mainline behaviour. The full mainline rework does not backport cleanly; this is the minimal equivalent for 5.15.y.
Tested on LENOVO 90K7S04400/3141 (Carrizo, Wani [1002:9874], DCE 11, BIOS M25KT37A): without this patch the wedge reproduces within minutes of desktop use on 5.15.120 and later; with it (and on v5.15.110 which predates the series) it does not reproduce.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -376,7 +376,8 @@ static inline bool update_planes_and_stream_adapter(struct dc *dc,/* * Previous frame finished and HW is ready for optimization. */ -if (update_type ==UPDATE_TYPE_FAST ) +if (update_type ==UPDATE_TYPE_FAST && + dc->ctx->dce_version >=DCE_VERSION_MAX )dc_post_update_surfaces_to_stream (dc); return dc_update_planes_and_stream(dc,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1029/2214 mm/migrate: untag addresses when querying page nodes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hungyu Lin <[email protected]>
[ Upstream commit 7d8746d7dc9cc4003661011424e5880ea7ae364b ]
When move_pages() is used with nodes == NULL, do_pages_stat_array() uses each page address as-is for its VMA lookup. A valid tagged address therefore gets -EFAULT in its status entry instead of the NUMA node reported for the corresponding untagged address.
Strip the tag before the VMA lookup while holding the mmap read lock. Use untagged_addr(), the helper available in 5.15 and already used by the migration path.
--- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate.c +1 -1
@@ -1889,7 +1889,7 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages,mmap_read_lock (mm);for (i =0 ; i < nr_pages; i++) { -unsigned long addr = (unsigned long )(*pages); +unsigned long addr = (unsigned long )untagged_addr (*pages);struct vm_area_struct *vma;struct page *page;int err = -EFAULT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1030/2214 x86/init: Initialize wall clock in get_rtc_noop()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naman Jain <[email protected]>
[ Upstream commit 7d5af1f256fdecff6a7986bbc9146b69cb355bb5 ]
get_rtc_noop() is used when an RTC is unavailable, but leaves its output argument untouched. When CONFIG_INIT_STACK_ALL_ZERO is not enabled, timekeeping_init() may therefore receive a nonzero invalid persistent clock value and warn:
"Persistent clock returned invalid value"
Initialize the output to zero, the documented representation of an unsupported persistent clock.
--- arch/x86/kernel/x86_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/x86_init.c +1 -1
@@ -33,7 +33,7 @@ static void iommu_shutdown_noop(void) { }bool __init bool_x86_init_noop (void ) {return false; }void x86_op_int_noop (int cpu) { }static int set_rtc_noop (const struct timespec64 *now) {return -EINVAL ; } -static void get_rtc_noop (struct timespec64 *now) { } +static void get_rtc_noop (struct timespec64 *now) { *now = (struct timespec64 ){0 }; }static __initconst const struct of_device_id of_cmos_match[] = { { .compatible ="motorola,mc146818" },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1031/2214 drm/nouveau/pci: use config-space MSI rearm on MCP79/MCP7A (NVAC)
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Czernohous <[email protected]>
commit 354d47fb3f35461b7f942831c1b2a7105e92b57f upstream.
NVAC (MCP79/MCP7A) uses g94_pci_func, whose .msi_rearm is nv40_pci_msi_rearm(): a re-arm write through the MMIO mirror of PCI config space. On this IGP that path is unreliable; when a re-arm is missed the interrupt line stays dead, command submission times out and the GPU appears hung until reboot. On an Apple Mac mini (early 2009, MCP79, boot0 0x0ac080b1) this showed as sporadic fifo timeouts and GPU hangs under load unless MSI was disabled via config=NvMSI=0.
Give NVAC its own pci func that re-arms through real PCI config space (nv46_pci_msi_rearm) instead. This follows existing precedent: nv46.c documents the MMIO-mirror re-arm as broken on several related parts, and commit 5112abc6a433 ("drm/nouveau/pci/g92: Fix rearm") fixed g92 the same way while moving the remaining chipsets, NVAC included, into the newly added shared g94 table, where NVAC stayed on the MMIO path. This change completes that fix for NVAC. The sibling IGP NVAA (MCP77/MCP78) has MSI disabled entirely as "reported broken" in nvkm_pci_new_(); NVAC works correctly once the re-arm goes through config space, so disabling MSI is not necessary.
Only NVAC is switched: that is the hardware this has been validated on. The other users of g94_pci_func (G94/G96/G98/GT2xx and the MCP77/MCP89 IGPs) keep their current behavior; MCP77 and MCP89 plausibly want the same treatment but were not tested.
Tested on the Mac mini as a daily driver for two months with MSI enabled and zero fifo timeouts. Independently confirmed stable on an iMac9,1 (MCP79) running 6.12.90 with the v1 form of this change (the same one-line functional switch, applied to that kernel's g94 implementation).
[ Backport note: linux-5.15.y predates commit 2f89bb3264af
("drm/nouveau/pci: add PRI address of config space mirror to nvkm_pci_func"), so struct nvkm_pci_func has no .cfg member here. mcp79_pci_func uses the nv40 .rd32/.wr08/.wr32 accessors instead, exactly as g94_pci_func does in this tree, and still differs from g94_pci_func only in .msi_rearm. ]
--- .../gpu/drm/nouveau/include/nvkm/subdev/pci.h | 1 + .../gpu/drm/nouveau/nvkm/engine/device/base.c | 2 +- .../gpu/drm/nouveau/nvkm/subdev/pci/Kbuild | 1 + .../gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c | 36 +++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c
drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h +1 -0
@@ -46,6 +46,7 @@ int nv4c_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nint g84_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int g92_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int g94_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **); +int mcp79_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int gf100_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int gf106_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int gk104_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1 -1
@@ -1286,7 +1286,7 @@ nvac_chipset = { .mc = { 0x00000001, g98_mc_new }, .mmu = { 0x00000001, mcp77_mmu_new }, .mxm = { 0x00000001, nv50_mxm_new }, - .pci = { 0x00000001, g94_pci_new }, + .pci = { 0x00000001, mcp79_pci_new }, .therm = { 0x00000001, g84_therm_new }, .timer = { 0x00000001, nv41_timer_new }, .volt = { 0x00000001, nv40_volt_new },
drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild +1 -0
@@ -9,6 +9,7 @@ nvkm-y += nvkm/subdev/pci/nv4c.o nvkm-y += nvkm/subdev/pci/g84.o nvkm-y += nvkm/subdev/pci/g92.o nvkm-y += nvkm/subdev/pci/g94.o +nvkm-y += nvkm/subdev/pci/mcp79.o nvkm-y += nvkm/subdev/pci/gf100.o nvkm-y += nvkm/subdev/pci/gf106.o nvkm-y += nvkm/subdev/pci/gk104.o
drivers/gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c new file +36 -0
@@ -0,0 +1,36 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright 2026 Marek Czernohous +* +* MCP79/MCP7A (NVAC): like g94, but MSI re-arm goes through real PCI +* config space. The MMIO-mirror re-arm is unreliable on this IGP and a +* missed re-arm kills the interrupt line (see the nv46 comment; g92 +* already re-arms through config space for the same reason). +*/ +#include "priv.h" + +static const struct nvkm_pci_func +mcp79_pci_func = { + .init = g84_pci_init, + .rd32 = nv40_pci_rd32, + .wr08 = nv40_pci_wr08, + .wr32 = nv40_pci_wr32, + .msi_rearm = nv46_pci_msi_rearm, + + .pcie.init = g84_pcie_init, + .pcie.set_link = g84_pcie_set_link, + + .pcie.max_speed = g84_pcie_max_speed, + .pcie.cur_speed = g84_pcie_cur_speed, + + .pcie.set_version = g84_pcie_set_version, + .pcie.version = g84_pcie_version, + .pcie.version_supported = g92_pcie_version_supported, +}; + +int +mcp79_pci_new (struct nvkm_device *device,enum nvkm_subdev_type type,int inst, +struct nvkm_pci **ppci) +{ +return nvkm_pci_new_ (&mcp79_pci_func, device, type, inst, ppci); +}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1032/2214 udf: validate the device specification EA before using it
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yunpeng Tian <[email protected]>
[ Upstream commit 9a2390959685ac35a58c80c8016120849a2babf6 ]
udf_get_extendedattr() bounds an extended attribute only against struct genericFormat, which is 12 bytes. A type-12 device specification is struct deviceSpec, which is 24 bytes plus a flexible impUse array. Thus a corrupted filesystem can contain extended attribute that is accepted by udf_get_extendedattr() but udf_write_inode() or udf_read_inode() may access beyond the end of provided buffer.
Provide a udf_device_spec_valid() check to validate correctness of extended attribute that is a deviceSpec. While here, check the result of udf_add_extendedattr() before dereferencing it as it can return NULL in case of error.
[JK: Removed duplicated validity checks]
--- fs/udf/inode.c | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-)
fs/udf/inode.c +37 -5
@@ -1194,6 +1194,26 @@ int udf_setsize(struct inode *inode, loff_t newsize)return 0 ; } +/* +* Verify validity of struct deviceSpec on disk. udf_get_extendedattr() has +* already verified the generic header and made sure attribute fits in the +* inode so we just have to make sure attribute space is large enough for +* deviceSpec struct and required impUse information. +*/ +static bool udf_device_spec_valid (struct deviceSpec *dsea) +{ +u32 attr_length, imp_use_length; + + attr_length =le32_to_cpu (dsea->attrLength); + imp_use_length =le32_to_cpu (dsea->impUseLength); +if (attr_length <sizeof (struct deviceSpec ) || + imp_use_length <sizeof (struct regid ) || + imp_use_length > attr_length -sizeof (struct deviceSpec )) +return false; + +return true; +} +/* * Maximum length of linked list formed by ICB hierarchy. The chosen number is * arbitrary - just that we hopefully don't limit any real use of rewritten
@@ -1508,13 +1528,12 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode)) {struct deviceSpec *dsea = (struct deviceSpec *)udf_get_extendedattr (inode,12 ,1 ); -if (dsea) { -init_special_inode (inode, inode->i_mode, + +if (!dsea || !udf_device_spec_valid (dsea)) + goto out; +init_special_inode (inode, inode->i_mode,MKDEV (le32_to_cpu (dsea->majorDeviceIdent),le32_to_cpu (dsea->minorDeviceIdent))); -/* Developer ID ??? */ - }else - goto out; } ret =0 ; out:
@@ -1662,6 +1681,10 @@ static int udf_update_inode(struct inode *inode, int do_sync)udf_add_extendedattr (inode,sizeof (struct deviceSpec ) +sizeof (struct regid ),12 ,0x3 ); +if (!dsea) { + err = -ENOSPC ; + goto out_unlock; + } dsea->attrType =cpu_to_le32 (12 ); dsea->attrSubtype =1 ; dsea->attrLength = cpu_to_le32(
@@ -1669,6 +1692,10 @@ static int udf_update_inode(struct inode *inode, int do_sync) sizeof(struct regid)); dsea->impUseLength =cpu_to_le32 (sizeof (struct regid )); } +if (!udf_device_spec_valid (dsea)) { + err = -EFSCORRUPTED ; + goto out_unlock; + } eid = (struct regid *)dsea->impUse;memset (eid,0 ,sizeof (*eid));strcpy (eid->ident,UDF_ID_DEVELOPER );
@@ -1808,6 +1835,11 @@ static int udf_update_inode(struct inode *inode, int do_sync)brelse (bh);return err; + +out_unlock: +unlock_buffer (bh); +brelse (bh); +return err; } struct inode *__udf_iget(struct super_block *sb, struct kernel_lb_addr *ino,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1033/2214 hwmon: (tmp108) Fix jiffies wraparound in conversion-ready check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Verdonck <[email protected]>
[ Upstream commit 6b8b1d1d7bc7e579b53fc7c3293b787d68de702a ]
tmp108 records a one-shot deadline in ->ready_time at probe (and resume) and, on every temperature read, refuses the read with -EAGAIN while time_before(jiffies, ready_time) is true, in order to skip the initial conversion.
->ready_time is an unsigned long compared with time_before(), whose signed difference is only meaningful while the two values are within LONG_MAX jiffies of each other. Because ->ready_time is set once and never refreshed, jiffies keeps advancing away from it, and after 2^31 jiffies the difference flips sign. On a 32-bit HZ=100 kernel that happens ~248.5 days after boot: time_before() then permanently reports "not ready" and the driver returns -EAGAIN on every read, without ever touching the sensor, until the next reboot. The continuous-mode path, which sets ->ready_time to jiffies with no added conversion delay, wraps the same way.
Store the deadline as a 64-bit jiffies value and compare it with get_jiffies_64()/time_before64(), which does not wrap in any practical uptime.
--- drivers/hwmon/tmp108.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/tmp108.c +4 -4
@@ -73,7 +73,7 @@struct tmp108 {struct regmap *regmap;u16 orig_config; -unsigned long ready_time; +u64 ready_time; };/* convert 12-bit TMP108 register value to milliCelsius */
@@ -124,7 +124,7 @@ static int tmp108_read(struct device *dev, enum hwmon_sensor_types type,switch (attr) {case hwmon_temp_input:/* Is it too early to return a conversion ? */ -if (time_before (jiffies, tmp108->ready_time)) { +if (time_before64 (get_jiffies_64 (), tmp108->ready_time)) {dev_dbg (dev,"%s: Conversion not ready yet..\n" , __func__);return -EAGAIN ;
@@ -371,7 +371,7 @@ static int tmp108_probe(struct i2c_client *client)return err; } - tmp108->ready_time = jiffies; + tmp108->ready_time =get_jiffies_64 ();if ((tmp108->orig_config &TMP108_CONF_MODE_MASK ) ==TMP108_MODE_SHUTDOWN ) tmp108->ready_time +=
@@ -405,7 +405,7 @@ static int __maybe_unused tmp108_resume(struct device *dev) err =regmap_update_bits (tmp108->regmap,TMP108_REG_CONF ,TMP108_CONF_MODE_MASK ,TMP108_MODE_CONTINUOUS ); - tmp108->ready_time = jiffies + + tmp108->ready_time =get_jiffies_64 () +msecs_to_jiffies (TMP108_CONVERSION_TIME_MS );return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1034/2214 dmaengine: qcom: bam_dma: Defer IRQ trigger type to device tree
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Santhosh <[email protected]>
[ Upstream commit 3cee6f79553202d7d3954555560ac38d719344b8 ]
The driver hardcodes IRQF_TRIGGER_HIGH when registering the BAM interrupt, which overrides the trigger type specified in the device tree. On Qualcomm Shikra SoC, the A2 BAM signals an edge interrupt to the apps processor; registering it as level-high causes the interrupt to not fire, resulting in missed DMA completions.
Use IRQF_TRIGGER_NONE instead, which causes the kernel to use the trigger type already configured by platform_get_irq() when it parsed the device tree interrupts property. This makes the driver platform-agnostic.
Stable-dep-of: 82eed160cfa7 ("dmaengine: qcom: bam_dma: free interrupt before the clock in error path")
--- drivers/dma/qcom/bam_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/qcom/bam_dma.c +1 -1
@@ -1301,7 +1301,7 @@ static int bam_dma_probe(struct platform_device *pdev)bam_channel_init (bdev, &bdev->channels[i], i); ret =devm_request_irq (bdev->dev, bdev->irq, bam_dma_irq, -IRQF_TRIGGER_HIGH ,"bam_dma" , bdev); +IRQF_TRIGGER_NONE ,"bam_dma" , bdev);if (ret) goto err_bam_channel_exit;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1035/2214 dmaengine: qcom: bam_dma: free interrupt before the clock in error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
[ Upstream commit 82eed160cfa7a296ae4eb5acb8dd8f493323eea7 ]
The BAM interrupt is requested with a devres helper and so on error it's freed after probe() returns. We disable the clock before freeing or masking it so it may still fire and we may end up reading BAM registers with clock disabled.
Stop using devres for interrupts as we free it in remove() manually anyway. Add an appropriate label and free the interrupt before disabling the clock in error path and in remove().
--- drivers/dma/qcom/bam_dma.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/dma/qcom/bam_dma.c +7 -5
@@ -1300,8 +1300,8 @@ static int bam_dma_probe(struct platform_device *pdev)for (i =0 ; i < bdev->num_channels; i++)bam_channel_init (bdev, &bdev->channels[i], i); - ret =devm_request_irq (bdev->dev, bdev->irq, bam_dma_irq, -IRQF_TRIGGER_NONE ,"bam_dma" , bdev); + ret =request_irq (bdev->irq, bam_dma_irq,IRQF_TRIGGER_NONE , +"bam_dma" , bdev);if (ret) goto err_bam_channel_exit;
@@ -1310,7 +1310,7 @@ static int bam_dma_probe(struct platform_device *pdev) ret =dma_set_max_seg_size (bdev->common.dev,BAM_FIFO_SIZE );if (ret) {dev_err (bdev->dev,"cannot set maximum segment size\n" ); - goto err_bam_channel_exit; + goto err_free_irq; }platform_set_drvdata (pdev, bdev);
@@ -1338,7 +1338,7 @@ static int bam_dma_probe(struct platform_device *pdev) ret =dma_async_device_register (&bdev->common);if (ret) {dev_err (bdev->dev,"failed to register dma async device\n" ); - goto err_bam_channel_exit; + goto err_free_irq; } ret = of_dma_controller_register(pdev->dev.of_node, bam_dma_xlate,
@@ -1357,6 +1357,8 @@ static int bam_dma_probe(struct platform_device *pdev) err_unregister_dma:dma_async_device_unregister (&bdev->common); +err_free_irq: +free_irq (bdev->irq, bdev); err_bam_channel_exit:for (i =0 ; i < bdev->num_channels; i++)tasklet_kill (&bdev->channels[i].vc.task);
@@ -1382,7 +1384,7 @@ static int bam_dma_remove(struct platform_device *pdev)/* mask all interrupts for this execution environment */ writel_relaxed (0 ,bam_addr (bdev,0 ,BAM_IRQ_SRCS_MSK_EE )); -devm_free_irq (bdev->dev, bdev->irq, bdev); +free_irq (bdev->irq, bdev);for (i =0 ; i < bdev->num_channels; i++) {bam_dma_terminate_all (&bdev->channels[i].vc.chan);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1036/2214 nilfs2: correct return value kernel-doc descriptions for the rest
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 343d4a33f26d048fde4b02cfc3681f766b3f1b12 ]
Similar to the previous changes to fix return value descriptions, this fixes the format of the return value descriptions of functions for the rest.
Stable-dep-of: 7131aaa74bcc ("nilfs2: ignore non-fatal signals during synchronous log write wait")
--- fs/nilfs2/gcinode.c | 24 +++++++++------------- fs/nilfs2/inode.c | 12 +++-------- fs/nilfs2/recovery.c | 32 +++++++++++------------------ fs/nilfs2/segbuf.c | 12 ++--------- fs/nilfs2/segment.c | 48 ++++++++++++++++--------------------------- fs/nilfs2/the_nilfs.c | 12 +++++------ 6 files changed, 50 insertions(+), 90 deletions(-)
fs/nilfs2/gcinode.c +10 -14
@@ -46,14 +46,11 @@* specified by @pbn to the GC pagecache with the key @blkoff. * This function sets @vbn (@pbn if @vbn is zero) in b_blocknr of the buffer. * -* Return Value: On success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error. -* -* %-ENOMEM - Insufficient amount of memory available. -* -* %-ENOENT - The block specified with @pbn does not exist. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EIO - I/O error (including metadata corruption). +* * %-ENOENT - The block specified with @pbn does not exist. +* * %-ENOMEM - Insufficient memory available. */ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff, sector_t pbn, __u64 vbn,
@@ -114,12 +111,11 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff,* specified by @vbn to the GC pagecache. @pbn can be supplied by the * caller to avoid translation of the disk block address. * -* Return Value: On success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error. -* -* %-ENOMEM - Insufficient amount of memory available. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EIO - I/O error (including metadata corruption). +* * %-ENOENT - Invalid virtual block address. +* * %-ENOMEM - Insufficient memory available. */ int nilfs_gccache_submit_read_node (struct inode *inode,sector_t pbn,__u64 vbn,struct buffer_head **out_bh)
fs/nilfs2/inode.c +3 -9
@@ -676,10 +676,7 @@ struct inode *nilfs_iget_for_gc(struct super_block *sb, unsigned long ino,* or does nothing if the inode already has it. This function allocates * an additional inode to maintain page cache of B-tree nodes one-on-one. * -* Return Value: On success, 0 is returned. On errors, one of the following -* negative error code is returned. -* -* %-ENOMEM - Insufficient memory available. +* Return: 0 on success, or %-ENOMEM if memory is insufficient. */ int nilfs_attach_btree_node_cache (struct inode *inode) {
@@ -740,11 +737,8 @@ void nilfs_detach_btree_node_cache(struct inode *inode)* in one inode and the one for b-tree node pages is set up in the * other inode, which is attached to the former inode. * -* Return Value: On success, a pointer to the inode for data pages is -* returned. On errors, one of the following negative error code is returned -* in a pointer type. -* -* %-ENOMEM - Insufficient memory available. +* Return: a pointer to the inode for data pages on success, or %-ENOMEM +* if memory is insufficient. */ struct inode *nilfs_iget_for_shadow (struct inode *inode) {
fs/nilfs2/recovery.c +12 -20
@@ -741,18 +741,13 @@ static void nilfs_abort_roll_forward(struct the_nilfs *nilfs)* @sb: super block instance * @ri: pointer to a nilfs_recovery_info struct to store search results. * -* Return Value: On success, 0 is returned. On error, one of the following -* negative error code is returned. -* -* %-EINVAL - Inconsistent filesystem state. -* -* %-EIO - I/O error -* -* %-ENOSPC - No space left on device (only in a panic state). -* -* %-ERESTARTSYS - Interrupted. -* -* %-ENOMEM - Insufficient memory available. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EINVAL - Inconsistent filesystem state. +* * %-EIO - I/O error. +* * %-ENOMEM - Insufficient memory available. +* * %-ENOSPC - No space left on device (only in a panic state). +* * %-ERESTARTSYS - Interrupted. */ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, struct super_block *sb,
@@ -817,14 +812,11 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,* segment pointed by the superblock. It sets up struct the_nilfs through * this search. It fills nilfs_recovery_info (ri) required for recovery. * -* Return Value: On success, 0 is returned. On error, one of the following -* negative error code is returned. -* -* %-EINVAL - No valid segment found -* -* %-EIO - I/O error -* -* %-ENOMEM - Insufficient memory available. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EINVAL - No valid segment found. +* * %-EIO - I/O error. +* * %-ENOMEM - Insufficient memory available. */ int nilfs_search_super_root (struct the_nilfs *nilfs,struct nilfs_recovery_info *ri)
fs/nilfs2/segbuf.c +2 -10
@@ -444,12 +444,7 @@ static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,* @segbuf: buffer storing a log to be written * @nilfs: nilfs object * -* Return Value: On Success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error -* -* %-ENOMEM - Insufficient memory available. +* Return: Always 0. */ static int nilfs_segbuf_write (struct nilfs_segment_buffer *segbuf,struct the_nilfs *nilfs)
@@ -490,10 +485,7 @@ static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf,* nilfs_segbuf_wait - wait for completion of requested BIOs * @segbuf: segment buffer * -* Return Value: On Success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error +* Return: 0 on success, or %-EIO if I/O error is detected. */ static int nilfs_segbuf_wait (struct nilfs_segment_buffer *segbuf) {
fs/nilfs2/segment.c +18 -30
66 lines not on this page · raw message
fs/nilfs2/the_nilfs.c +5 -7
@@ -50,8 +50,8 @@ void nilfs_set_last_segment(struct the_nilfs *nilfs,* alloc_nilfs - allocate a nilfs object * @sb: super block instance * -* Return Value: On success, pointer to the_nilfs is returned. -* On error, NULL is returned. +* Return: a pointer to the allocated nilfs object on success, or NULL on +* failure. */ struct the_nilfs *alloc_nilfs (struct super_block *sb) {
@@ -202,8 +202,7 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs,* exponent information written in @sbp and stores it in @blocksize, * or aborts with an error message if it's too large. * -* Return Value: On success, 0 is returned. If the block size is too -* large, -EINVAL is returned. +* Return: 0 on success, or %-EINVAL if the block size is too large. */ static int nilfs_get_blocksize (struct super_block *sb,struct nilfs_super_block *sbp,int *blocksize)
@@ -547,7 +546,7 @@ static int nilfs_valid_sb(struct nilfs_super_block *sbp)* area, or if the parameters themselves are not normal, it is * determined to be invalid. * -* Return Value: true if invalid, false if valid. +* Return: true if invalid, false if valid. */ static bool nilfs_sb2_bad_offset (struct nilfs_super_block *sbp,u64 offset) {
@@ -678,8 +677,7 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs,* reading the super block, getting disk layout information, initializing * shared fields in the_nilfs). * -* Return Value: On success, 0 is returned. On error, a negative error -* code is returned. +* Return: 0 on success, or a negative error code on failure. */ int init_nilfs (struct the_nilfs *nilfs,struct super_block *sb,char *data) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1037/2214 nilfs2: ignore non-fatal signals during synchronous log write wait
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 7131aaa74bcc7c9da1f1d1c8724da75c775557a0 ]
Based on a syzbot report, Wang Jianjian pointed out that following a successful directory operation in nilfs_rename(), a synchronous write requested within nilfs_transaction_commit(), triggered by a sync flag set by nilfs_commit_chunk(), could be interrupted by a user signal. This interruption leaves in-memory metadata updates intact while returning an error, causing inconsistency with the VFS dentry cache and ultimately triggering a kernel warning.
According to "signal(7)", local disks are not classified as "slow devices" (such as terminals, FIFOs, or pipes) and their I/O operations on disk devices are not interrupted by signals. In kernel space, waiting for such disk I/O should therefore not be aborted by ordinary (non-fatal) signals.
Suppress this issue by modifying nilfs_segctor_sync(), which waits for the log writer thread to complete synchronous writes, to catch only fatal signals via fatal_signal_pending() and return -EINTR rather than -ERESTARTSYS. To complement this change and prevent the wait loop from busy-looping when schedule() returns immediately due to a pending non-fatal signal, switch the wait state from TASK_INTERRUPTIBLE to TASK_KILLABLE.
This serves as an effective interim stabilization measure without structural changes until a comprehensive fix for metadata consistency is implemented.
--- fs/nilfs2/ioctl.c | 2 +- fs/nilfs2/recovery.c | 2 +- fs/nilfs2/segment.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-)
fs/nilfs2/ioctl.c +1 -1
@@ -960,10 +960,10 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,* Return: 0 on success, or one of the following negative error codes on * failure: * * %-EFAULT - Failure during execution of requested operation. +* * %-EINTR - Interrupted. * * %-EIO - I/O error. * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
fs/nilfs2/recovery.c +1 -1
@@ -743,11 +743,11 @@ static void nilfs_abort_roll_forward(struct the_nilfs *nilfs)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EINVAL - Inconsistent filesystem state. * * %-EIO - I/O error. * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. */ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, struct super_block *sb,
fs/nilfs2/segment.c +5 -5
@@ -2234,7 +2234,7 @@ static int nilfs_segctor_sync(struct nilfs_sc_info *sci)wake_up (&sci->sc_wait_daemon);for (;;) { -set_current_state (TASK_INTERRUPTIBLE ); +set_current_state (TASK_KILLABLE );/* * Synchronize only while the log writer thread is alive.
@@ -2248,11 +2248,11 @@ static int nilfs_segctor_sync(struct nilfs_sc_info *sci) err = wait_req.err;break ; } -if (!signal_pending (current)) { +if (!fatal_signal_pending (current)) {schedule ();continue ; } - err = -ERESTARTSYS ; + err = -EINTR ;break ; }finish_wait (&sci->sc_wait_request, &wait_req.wq);
@@ -2286,10 +2286,10 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info *sci, int err, bool force)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EIO - I/O error (including metadata corruption). * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ int nilfs_construct_segment (struct super_block *sb)
@@ -2318,10 +2318,10 @@ int nilfs_construct_segment(struct super_block *sb)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EIO - I/O error (including metadata corruption). * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1038/2214 ASoC: stm32: i2s: remove irqf_oneshot flag
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olivier Moysan <[email protected]>
[ Upstream commit 7c0f8f1462c9edeaa202a2cbea1bde0960434b09 ]
The IRQF_ONESHOT flag allows to ensure that the interrupt is not unmasked after the hard interrupt context handler has been executed and the thread has been woken. The interrupt line is unmasked after the thread handler function has been executed.
The STM32 I2S driver does not implement a threaded IRQ handler. So, the IRQF_ONESHOT flag is not useful in I2S driver. Remove this flag to allow the interrupt routine to be managed as a thread in RT mode.
Stable-dep-of: 1b207c85551f ("ASoC: stm: stm32_i2s: request IRQ after regmap initialization")
--- sound/soc/stm/stm32_i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/stm/stm32_i2s.c +1 -1
@@ -1075,7 +1075,7 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,if (irq <0 )return irq; - ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,IRQF_ONESHOT , + ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 ,dev_name (&pdev->dev), i2s);if (ret) {dev_err (&pdev->dev,"irq request returned %d\n" , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1039/2214 ASoC: stm: stm32_i2s: Drop redundant error messages
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit a6cdfb6230944082e7be64f9166eed64656b1162 ]
Both devm_request_irq() and snd_dmaengine_pcm_register() already log failures internally. Drop the redundant error messages and return the original errors directly.
Stable-dep-of: 1b207c85551f ("ASoC: stm: stm32_i2s: request IRQ after regmap initialization")
--- sound/soc/stm/stm32_i2s.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/stm/stm32_i2s.c +2 -4
@@ -1077,10 +1077,8 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev, ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 ,dev_name (&pdev->dev), i2s); -if (ret) { -dev_err (&pdev->dev,"irq request returned %d\n" , ret); +if (ret)return ret; - }/* Reset */ rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL );
@@ -1135,7 +1133,7 @@ static int stm32_i2s_probe(struct platform_device *pdev) ret =snd_dmaengine_pcm_register (&pdev->dev, &stm32_i2s_pcm_config,0 );if (ret) -return dev_err_probe (&pdev->dev, ret,"PCM DMA register error\n" ); +return ret; ret =snd_soc_register_component (&pdev->dev, &stm32_i2s_component, i2s->dai_drv,1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1040/2214 ASoC: stm: stm32_i2s: request IRQ after regmap initialization
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 1b207c85551fd74854d632116849295b2305245f ]
The ISR accesses the managed regmap, but probe requests the IRQ before creating it. An early interrupt can reach an uninitialized regmap. Reverse-order cleanup can free the regmap while the IRQ remains active.
Request the IRQ after regmap initialization so probe unwind and removal free and synchronize it before releasing the regmap.
The teardown ordering issue was found by static analysis.
--- sound/soc/stm/stm32_i2s.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
sound/soc/stm/stm32_i2s.c +11 -12
@@ -1025,7 +1025,7 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,const struct of_device_id *of_id;struct reset_control *rst;struct resource *res; -int irq, ret; +int ret;if (!np)return -ENODEV ;
@@ -1070,16 +1070,6 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,return ret; } -/* Get irqs */ - irq =platform_get_irq (pdev,0 ); -if (irq <0 ) -return irq; - - ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 , -dev_name (&pdev->dev), i2s); -if (ret) -return ret; -/* Reset */ rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL );if (IS_ERR (rst))
@@ -1105,7 +1095,7 @@ static int stm32_i2s_probe(struct platform_device *pdev) {struct stm32_i2s_data *i2s;u32 val; -int ret; +int irq, ret; i2s =devm_kzalloc (&pdev->dev,sizeof (*i2s),GFP_KERNEL );if (!i2s)
@@ -1131,6 +1121,15 @@ static int stm32_i2s_probe(struct platform_device *pdev)return dev_err_probe (&pdev->dev,PTR_ERR (i2s->regmap),"Regmap init error\n" ); + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) +return irq; + + ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 , +dev_name (&pdev->dev), i2s); +if (ret) +return ret; + ret =snd_dmaengine_pcm_register (&pdev->dev, &stm32_i2s_pcm_config,0 );if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1041/2214 media: vpif_capture: Fix i2c adapter reference leak in vpif_probe()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit b00fbdad64d4ea7d594bc67988c1722fe5b3be50 ]
vpif_probe() takes a reference to the i2c adapter with i2c_get_adapter() and passes it to v4l2_i2c_new_subdev_board(), which does not consume it, but the reference is never released, so it is leaked both when the probe succeeds and when it fails after the adapter has been acquired.
Release the reference with i2c_put_adapter() on the success path and in the probe_subdev_out cleanup, and initialise i2c_adap so that the cleanup is a no-op when the adapter was never acquired.
--- drivers/media/platform/davinci/vpif_capture.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/davinci/vpif_capture.c +4 -1
@@ -1617,7 +1617,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)static int vpif_probe (struct platform_device *pdev) {struct vpif_subdev_info *subdevdata; -struct i2c_adapter *i2c_adap; +struct i2c_adapter *i2c_adap =NULL ;struct resource *res;int subdev_count;int res_idx =0 ;
@@ -1701,9 +1701,12 @@ static int vpif_probe(struct platform_device *pdev) } } +i2c_put_adapter (i2c_adap); +return 0 ; probe_subdev_out: +i2c_put_adapter (i2c_adap);/* free sub devices memory */ kfree (vpif_obj.sd); vpif_unregister:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1042/2214 ata: sata_inic162x: remove dangerous broken driver
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ethan Nelson-Moore <[email protected]>
[ Upstream commit 96fdeb7e3fd8d937f8351ed90824c9d904e590a1 ]
The sata_inic162x driver was labeled as "very experimental" in commit bb9696192826 ("libata: make it clear that sata_inic162x is experimental") due to data corruption issues, but not marked as broken. Since then, no changes have been made to it that could fix these issues. Since the driver was not marked as broken, and the message about potential data corruption is only visible in the code and dmesg, it is possible that someone could enable the driver without realizing its potential for data corruption. Remove the driver to protect users' data.
--- drivers/ata/Kconfig | 7 - drivers/ata/Makefile | 1 - drivers/ata/sata_inic162x.c | 906 ------------------------------------ 3 files changed, 914 deletions(-) delete mode 100644 drivers/ata/sata_inic162x.c
drivers/ata/Kconfig +0 -7
@@ -318,13 +318,6 @@ config SATA_AHCI_SEATTLE If unsure, say N -config SATA_INIC162X - tristate "Initio 162x SATA support (Very Experimental)" - depends on PCI - select SATA_HOST - help - This option enables support for Initio 162x Serial ATA. - config SATA_ACARD_AHCI tristate "ACard AHCI variant (ATP 8620)" depends on PCI
drivers/ata/Makefile +0 -1
@@ -9,7 +9,6 @@ obj-$(CONFIG_SATA_AHCI_SEATTLE) += ahci_seattle.o libahci.o libahci_platform.o obj-$(CONFIG_SATA_AHCI_PLATFORM) += ahci_platform.o libahci.o libahci_platform.o obj-$(CONFIG_SATA_FSL) += sata_fsl.o obj-$(CONFIG_SATA_GEMINI) += sata_gemini.o -obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o obj-$(CONFIG_SATA_SIL24) += sata_sil24.o obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o
drivers/ata/sata_inic162x.c deleted +0 -906
906 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1043/2214 mm/madvise: use folio_trylock() in the cold/pageout PMD split
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price <[email protected]>
[ Upstream commit 5a6c9cf117fca3c38a98fb2a2d5549795c8b0b73 ]
MADV_COLD or MADV_PAGEOUT over part of a PMD splits the THP in madvise_cold_or_pageout_pte_range(). Two threads doing that to the same THP create spurious failures.
CPU0 CPU1
---- ----
folio_get()
spin_unlock(ptl)
folio_lock()
folio_get() spin_unlock(ptl) folio_lock() <- blocks, keeps its ref
split_folio()
folio_expected_ref_count(folio) != folio_ref_count(folio) - 1
-EAGAINCPU1 cannot drop its reference until it gets the lock CPU0 holds, so CPU0's split always fails. folio_trylock() makes CPU1 leave without ever taking a reference. The PTE branch of this same function already does this, as do madvise_free_pte_range() and madvise_free_huge_pmd().
Reproducer: 400 rounds of eight threads calling MADV_COLD on half of each of eight THPs, re-formed with MADV_COLLAPSE between rounds. From /proc/vmstat:
thp_split_page thp_split_page_failed
before 3186 860
after 3200 0
The short before count is rounds where every thread failed and the advice was dropped for that THP entirely.
On failure the walker returns 0 and nothing retries. The PMD path becomes best effort when the folio lock is held elsewhere - same as the PTE path.
--- mm/madvise.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/madvise.c +2 -1
@@ -351,9 +351,10 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,if (next - addr !=HPAGE_PMD_SIZE ) {int err; +if (!trylock_page (page)) + goto huge_unlock;get_page (page);spin_unlock (ptl); -lock_page (page); err =split_huge_page (page);unlock_page (page);put_page (page);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1044/2214 ALSA: line6: Handle period elapsed calls outside the locks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 443ed4edc2678cc51c5a01e7dffc4c890be40051 ]
LINE6 driver may call snd_pcm_period_elapsed() for both playback and capture substreams at processing the playback substream, and this may lead to a ABBA deadlock.
Move the actual calls of snd_pcm_period_elapsed() outside the locks for avoiding it. The capture period notification at submitting the initial playback URBs (only with the impulse mode) is simply skipped, as it's done in the lock context; it'll be caught up at the next period.
--- sound/usb/line6/capture.c | 17 +++++++++-------- sound/usb/line6/capture.h | 2 +- sound/usb/line6/playback.c | 31 +++++++++++++++++++++---------- 3 files changed, 31 insertions(+), 19 deletions(-)
sound/usb/line6/capture.c +9 -8
@@ -137,18 +137,15 @@ void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize) line6pcm->in.pos_done -= runtime->buffer_size; } -void line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length) +/* update the capture position and check whether we need period_elapsed call */ +bool line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length) { -struct snd_pcm_substream *substream = -get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE ); - line6pcm->in.bytes += length;if (line6pcm->in.bytes >= line6pcm->in.period) { line6pcm->in.bytes %= line6pcm->in.period; -spin_unlock (&line6pcm->in.lock); -snd_pcm_period_elapsed (substream); -spin_lock (&line6pcm->in.lock); +return true; } +return false; }/*
@@ -158,6 +155,7 @@ static void audio_in_callback(struct urb *urb) {int i, index, length =0 , shutdown =0 ;unsigned long flags; +bool capture_period_elapsed = false;struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context;
@@ -221,10 +219,13 @@ static void audio_in_callback(struct urb *urb)if (!test_bit (LINE6_STREAM_IMPULSE , &line6pcm->in.running) &&test_bit (LINE6_STREAM_PCM , &line6pcm->in.running)) -line6_capture_check_period (line6pcm, length); + capture_period_elapsed =line6_capture_check_period (line6pcm, length); }spin_unlock_irqrestore (&line6pcm->in.lock, flags); + +if (capture_period_elapsed) +snd_pcm_period_elapsed (get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE )); }/* open capture callback */
sound/usb/line6/capture.h +1 -1
@@ -17,7 +17,7 @@ extern const struct snd_pcm_ops snd_line6_capture_ops;extern void line6_capture_copy (struct snd_line6_pcm *line6pcm,char *fbuf,int fsize); -extern void line6_capture_check_period (struct snd_line6_pcm *line6pcm, +extern bool line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length);extern int line6_create_audio_in_urbs (struct snd_line6_pcm *line6pcm);extern int line6_submit_audio_in_all_urbs (struct snd_line6_pcm *line6pcm);
sound/usb/line6/playback.c +21 -10
@@ -136,6 +136,8 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal,/* Find a free URB, prepare audio data, and submit URB. must be called in line6pcm->out.lock context +Returns 1 if snd_pcm_period_elapsed() needs to be called for the +capture stream after releasing the lock, 0 if not, or a negative error */ static int submit_audio_out_urb (struct snd_line6_pcm *line6pcm) {
@@ -151,6 +153,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) line6pcm->properties->rates.rats[0 ].den * (line6pcm->line6->intervals_per_second /LINE6_ISO_INTERVAL );struct urb *urb_out; +bool capture_period_elapsed = false; index =find_first_zero_bit (&line6pcm->out.active_urbs, line6pcm->line6->iso_buffers);
@@ -260,8 +263,9 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) urb_out->transfer_buffer, urb_out-> transfer_buffer_length); -line6_capture_check_period (line6pcm, - urb_out->transfer_buffer_length); + capture_period_elapsed = +line6_capture_check_period (line6pcm, + urb_out->transfer_buffer_length); } }else { if (!(line6pcm->line6->properties->capabilities & LINE6_CAP_HWMON)
@@ -283,24 +287,26 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)dev_err (line6pcm->line6->ifcdev,"URB out #%d submission failed (%d)\n" , index, ret); -return 0 ; +return capture_period_elapsed; }/* Submit all currently available playback URBs. must be called in line6pcm->out.lock context +The capture period notification is skipped here since we can't call +snd_pcm_period_elapsed() in the lock; it'll be caught up at the next one. */ int line6_submit_audio_out_all_urbs (struct snd_line6_pcm *line6pcm) { -int ret =0 , i; +int ret, i;for (i =0 ; i < line6pcm->line6->iso_buffers; ++i) { ret =submit_audio_out_urb (line6pcm);if (ret <0 ) -break ; +return ret; } -return ret; +return 0 ; }/*
@@ -316,6 +322,8 @@ static void audio_out_callback(struct urb *urb)const int bytes_per_frame = line6pcm->properties->bytes_per_channel * line6pcm->properties->playback_hw.channels_max; +bool capture_period_elapsed = false; +bool playback_period_elapsed = false;#if USE_CLEAR_BUFFER_WORKAROUND memset (urb->transfer_buffer,0 , urb->transfer_buffer_length);
@@ -358,19 +366,22 @@ static void audio_out_callback(struct urb *urb) shutdown =1 ;if (!shutdown) { -submit_audio_out_urb (line6pcm); + capture_period_elapsed =submit_audio_out_urb (line6pcm) >0 ;if (test_bit (LINE6_STREAM_PCM , &line6pcm->out.running)) { line6pcm->out.bytes += length;if (line6pcm->out.bytes >= line6pcm->out.period) { line6pcm->out.bytes %= line6pcm->out.period; -spin_unlock (&line6pcm->out.lock); -snd_pcm_period_elapsed (substream); -spin_lock (&line6pcm->out.lock); + playback_period_elapsed = true; } } }spin_unlock_irqrestore (&line6pcm->out.lock, flags); + +if (capture_period_elapsed) +snd_pcm_period_elapsed (get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE )); +if (playback_period_elapsed) +snd_pcm_period_elapsed (substream); }/* open playback callback */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1045/2214 PCI: rockchip-host: Do not attempt 5.0 GT/s retraining
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geraldo Nascimento <[email protected]>
[ Upstream commit 2a1e6c382fb7567679c07bd6a7060fefc7a5edc9 ]
Drop the 5.0 GT/s Link Speed retraining from Rockchip PCIe Root Complex Mode Operation, so-called host driver.
The reason is that Shawn Lin from Rockchip has reiterated that there may be danger of "catastrophic failure" in using their PCIe with 5.0GT/s speeds.
While Rockchip has done so informally without issuing a proper errata, and the particulars are thus unknown, this may cause data loss or worse.
This change is corroborated by RK3399 official datasheet [1], which states maximum link speed for this platform is 2.5 GT/s.
[1] https://opensource.rock-chips.com/images/d/d7/Rockchip_RK3399_Datasheet_V2.1-20200323.pdf
--- drivers/pci/controller/pcie-rockchip-host.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/pci/controller/pcie-rockchip-host.c +0 -16
@@ -338,22 +338,6 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip) goto err_power_off_phy; } -if (rockchip->link_gen ==2 ) { -/* -* Enable retrain for gen2. This should be configured only after -* gen1 finished. -*/ - status =rockchip_pcie_read (rockchip,PCIE_RC_CONFIG_LCS ); - status |=PCI_EXP_LNKCTL_RL ; -rockchip_pcie_write (rockchip, status,PCIE_RC_CONFIG_LCS ); - - err =readl_poll_timeout (rockchip->apb_base +PCIE_CORE_CTRL , - status,PCIE_LINK_IS_GEN2 (status),20 , -500 *USEC_PER_MSEC ); -if (err) -dev_dbg (dev,"PCIe link training gen2 timeout, fall back to gen1!\n" ); - } -/* Check the final link width from negotiated lane counter from MGMT */ status =rockchip_pcie_read (rockchip,PCIE_CORE_CTRL ); status = 0x1 << ((status & PCIE_CORE_PL_CONF_LANE_MASK) >>
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1046/2214 f2fs: return -EIO for a lost inode block after cp_error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 53b12b63304b34a3850a901c4de3cc6ad08e0aee ]
After cp_error, dirty node caches are dropped without being written. If such an inode was never written, its NAT entry is still NEW_ADDR, and reading its inode block returns -ENOENT.
f2fs_get_dnode_of_data() passes that -ENOENT up, and callers take it as a hole. Since the inode block is missing, the next offset can only advance one block, so fiemap walks block by block up to maxbytes, about 2^30 blocks, while holding the inode lock. It took hours in a power-off recovery test after shutdown and blocked unlink and umount on the file.
Return -EIO instead of -ENOENT when the inode block itself is missing after cp_error or shutdown. A missing direct or indirect node is still reported as -ENOENT.
--- fs/f2fs/node.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
fs/f2fs/node.c +14 -2
@@ -777,8 +777,20 @@ int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)if (!npage[0 ]) { npage[0 ] =f2fs_get_node_page (sbi, nids[0 ]); -if (IS_ERR (npage[0 ])) -return PTR_ERR (npage[0 ]); +if (IS_ERR (npage[0 ])) { + err =PTR_ERR (npage[0 ]); +/* +* cp_error drops dirty node caches, so the inode block +* of an inode that was never written reads as NEW_ADDR +* and returns -ENOENT. It is not a hole; the inode is +* gone. Callers treat -ENOENT as a hole and keep +* looking block by block (e.g. fiemap up to maxbytes). +*/ +if (err == -ENOENT && (f2fs_cp_error (sbi) || +is_sbi_flag_set (sbi,SBI_IS_SHUTDOWN ))) + err = -EIO ; +return err; + } }/* if inline_data is set, should not report any block indices */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1047/2214 KVM: arm64: vgic-v3: Roll back assignments from the new region
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit a32c01324eb494dda811912eb847b0e907cd7270 ]
A failed REDIST_REGION write unregisters the redistributor iodevs of every vCPU processed before the failure. This includes vCPUs assigned to older regions. Their assignments remain cached, so a retry does not register the iodevs again.
The vCPU whose registration fails has no assignment to roll back. For vCPUs processed earlier, limit rollback to those assigned to the new region. The region is removed on failure, so its free_index does not need restoring.
Resetting assignments from older regions is unsafe because a vCPU can own one before kvm_for_each_vcpu() can see it. Rollback could then move free_index behind that live assignment.
kvm_vgic_addr() holds slots_lock across the REDIST_REGION write. vCPU creation takes the same lock before assigning a redistributor. A concurrent vCPU cannot acquire an assignment from the new region before rollback completes. The lock also keeps rdreg valid across the config_lock drop required by MMIO-bus registration.
--- arch/arm64/kvm/vgic/vgic-mmio-v3.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
arch/arm64/kvm/vgic/vgic-mmio-v3.c +12 -5
@@ -763,7 +763,8 @@ void vgic_unregister_redist_iodev(struct kvm_vcpu *vcpu)kvm_io_bus_unregister_dev (vcpu->kvm,KVM_MMIO_BUS , &rd_dev->dev); } -static int vgic_register_all_redist_iodevs (struct kvm *kvm) +static int vgic_register_all_redist_iodevs (struct kvm *kvm, +struct vgic_redist_region *rdreg) {struct kvm_vcpu *vcpu;int c, ret =0 ;
@@ -779,7 +780,13 @@ static int vgic_register_all_redist_iodevs(struct kvm *kvm)mutex_lock (&kvm->slots_lock);for (c--; c >=0 ; c--) { vcpu =kvm_get_vcpu (kvm, c); +if (vcpu->arch.vgic_cpu.rdreg != rdreg) +continue ; +vgic_unregister_redist_iodev (vcpu); + + vcpu->arch.vgic_cpu.rdreg =NULL ; + vcpu->arch.vgic_cpu.rd_iodev.base_addr =VGIC_ADDR_UNDEF ; }mutex_unlock (&kvm->slots_lock); }
@@ -876,21 +883,21 @@ void vgic_v3_free_redist_region(struct vgic_redist_region *rdreg)int vgic_v3_set_redist_base (struct kvm *kvm,u32 index,u64 addr,u32 count) { +struct vgic_redist_region *rdreg;int ret; ret =vgic_v3_alloc_redist_region (kvm, index, addr, count);if (ret)return ret; + rdreg =vgic_v3_rdist_region_from_index (kvm, index); +/* * Register iodevs for each existing VCPU. Adding more VCPUs * afterwards will register the iodevs when needed. */ - ret =vgic_register_all_redist_iodevs (kvm); + ret =vgic_register_all_redist_iodevs (kvm, rdreg);if (ret) { -struct vgic_redist_region *rdreg; - - rdreg =vgic_v3_rdist_region_from_index (kvm, index);vgic_v3_free_redist_region (rdreg);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1048/2214 mfd: twl: Remove platform data support
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 4a346a03a63cb45f7766d9d6559cf3fee783e926 ]
There is no in-tree machine that provides a struct twl4030_platform_data since commit e92fc4f04a34 ("ARM: OMAP2+: Drop legacy board file for LDP"). So assume dev_get_platdata() returns NULL in twl_probe() and simplify accordingly.
Stable-dep-of: 3c5c55d979dd ("mfd: twl-core: Unregister the auxiliary platform device on unbind")
--- drivers/mfd/twl-core.c | 323 +--------------------------------------- include/linux/mfd/twl.h | 55 ------- 2 files changed, 5 insertions(+), 373 deletions(-)
drivers/mfd/twl-core.c +5 -318
@@ -656,309 +656,6 @@ static inline struct device *add_child(unsigned mod_no, const char *name, can_wakeup, irq0, irq1); } -static struct device * -add_regulator_linked (int num,struct regulator_init_data *pdata, -struct regulator_consumer_supply *consumers, -unsigned num_consumers,unsigned long features) -{ -struct twl_regulator_driver_data drv_data; - -/* regulator framework demands init_data ... */ -if (!pdata) -return NULL ; - -if (consumers) { - pdata->consumer_supplies = consumers; - pdata->num_consumer_supplies = num_consumers; - } - -if (pdata->driver_data) { -/* If we have existing drv_data, just add the flags */ -struct twl_regulator_driver_data *tmp; - tmp = pdata->driver_data; - tmp->features |= features; - }else { -/* add new driver data struct, used only during init */ - drv_data.features = features; - drv_data.set_voltage =NULL ; - drv_data.get_voltage =NULL ; - drv_data.data =NULL ; - pdata->driver_data = &drv_data; - } - -/* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */ -return add_numbered_child (TWL_MODULE_PM_MASTER ,"twl_reg" , num, - pdata,sizeof (*pdata), false,0 ,0 ); -} - -static struct device * -add_regulator (int num,struct regulator_init_data *pdata, -unsigned long features) -{ -return add_regulator_linked (num, pdata,NULL ,0 , features); -} - -/* -* NOTE: We know the first 8 IRQs after pdata->base_irq are -* for the PIH, and the next are for the PWR_INT SIH, since -* that's how twl_init_irq() sets things up. -*/ - -static int -add_children (struct twl4030_platform_data *pdata,unsigned irq_base, -unsigned long features) -{ -struct device *child; - -if (IS_ENABLED (CONFIG_GPIO_TWL4030 ) && pdata->gpio) { - child =add_child (TWL4030_MODULE_GPIO ,"twl4030_gpio" , - pdata->gpio,sizeof (*pdata->gpio), - false, irq_base +GPIO_INTR_OFFSET ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_KEYBOARD_TWL4030 ) && pdata->keypad) { - child =add_child (TWL4030_MODULE_KEYPAD ,"twl4030_keypad" , - pdata->keypad,sizeof (*pdata->keypad), - true, irq_base +KEYPAD_INTR_OFFSET ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_TWL4030_MADC ) && pdata->madc && -twl_class_is_4030 ()) { - child =add_child (TWL4030_MODULE_MADC ,"twl4030_madc" , - pdata->madc,sizeof (*pdata->madc), - true, irq_base +MADC_INTR_OFFSET ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_RTC_DRV_TWL4030 )) { -/* -* REVISIT platform_data here currently might expose the -* "msecure" line ... but for now we just expect board -* setup to tell the chip "it's always ok to SET_TIME". -* Eventually, Linux might become more aware of such -* HW security concerns, and "least privilege". -*/ - child =add_child (TWL_MODULE_RTC ,"twl_rtc" ,NULL ,0 , - true, irq_base +RTC_INTR_OFFSET ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_PWM_TWL )) { - child =add_child (TWL_MODULE_PWM ,"twl-pwm" ,NULL ,0 , - false,0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_PWM_TWL_LED )) { - child =add_child (TWL_MODULE_LED ,"twl-pwmled" ,NULL ,0 , - false,0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_TWL4030_USB ) && pdata->usb && -twl_class_is_4030 ()) { - -static struct regulator_consumer_supply usb1v5 = { - .supply ="usb1v5" , - }; -static struct regulator_consumer_supply usb1v8 = { - .supply ="usb1v8" , - }; -static struct regulator_consumer_supply usb3v1 = { - .supply ="usb3v1" , - }; - -/* First add the regulators so that they can be used by transceiver */ -if (IS_ENABLED (CONFIG_REGULATOR_TWL4030 )) { -/* this is a template that gets copied */ -struct regulator_init_data usb_fixed = { - .constraints.valid_modes_mask = -REGULATOR_MODE_NORMAL - |REGULATOR_MODE_STANDBY , - .constraints.valid_ops_mask = -REGULATOR_CHANGE_MODE - |REGULATOR_CHANGE_STATUS , - }; - - child =add_regulator_linked (TWL4030_REG_VUSB1V5 , - &usb_fixed, &usb1v5,1 , - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator_linked (TWL4030_REG_VUSB1V8 , - &usb_fixed, &usb1v8,1 , - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator_linked (TWL4030_REG_VUSB3V1 , - &usb_fixed, &usb3v1,1 , - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - } - - child =add_child (TWL_MODULE_USB ,"twl4030_usb" , - pdata->usb,sizeof (*pdata->usb), true, -/* irq0 = USB_PRES, irq1 = USB */ - irq_base +USB_PRES_INTR_OFFSET , - irq_base +USB_INTR_OFFSET ); - -if (IS_ERR (child)) -return PTR_ERR (child); - -/* we need to connect regulators to this transceiver */ -if (IS_ENABLED (CONFIG_REGULATOR_TWL4030 ) && child) { - usb1v5.dev_name =dev_name (child); - usb1v8.dev_name =dev_name (child); - usb3v1.dev_name =dev_name (child); - } - } - -if (IS_ENABLED (CONFIG_TWL4030_WATCHDOG ) &&twl_class_is_4030 ()) { - child =add_child (TWL_MODULE_PM_RECEIVER ,"twl4030_wdt" ,NULL , -0 , false,0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_INPUT_TWL4030_PWRBUTTON ) &&twl_class_is_4030 ()) { - child =add_child (TWL_MODULE_PM_MASTER ,"twl4030_pwrbutton" , -NULL ,0 , true, irq_base +8 +0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_MFD_TWL4030_AUDIO ) && pdata->audio && -twl_class_is_4030 ()) { - child =add_child (TWL4030_MODULE_AUDIO_VOICE ,"twl4030-audio" , - pdata->audio,sizeof (*pdata->audio), - false,0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -/* twl4030 regulators */ -if (IS_ENABLED (CONFIG_REGULATOR_TWL4030 ) &&twl_class_is_4030 ()) { - child =add_regulator (TWL4030_REG_VPLL1 , pdata->vpll1, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VIO , pdata->vio, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VDD1 , pdata->vdd1, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VDD2 , pdata->vdd2, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VMMC1 , pdata->vmmc1, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VDAC , pdata->vdac, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator ((features &TWL4030_VAUX2 ) - ?TWL4030_REG_VAUX2_4030 - :TWL4030_REG_VAUX2 , - pdata->vaux2, features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VINTANA1 , pdata->vintana1, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VINTANA2 , pdata->vintana2, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VINTDIG , pdata->vintdig, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -/* maybe add LDOs that are omitted on cost-reduced parts */ -if (IS_ENABLED (CONFIG_REGULATOR_TWL4030 ) && !(features &TPS_SUBSET ) - &&twl_class_is_4030 ()) { - child =add_regulator (TWL4030_REG_VPLL2 , pdata->vpll2, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VMMC2 , pdata->vmmc2, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VSIM , pdata->vsim, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VAUX1 , pdata->vaux1, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VAUX3 , pdata->vaux3, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VAUX4 , pdata->vaux4, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_CHARGER_TWL4030 ) && pdata->bci && - !(features & (TPS_SUBSET |TWL5031 ))) { - child =add_child (TWL_MODULE_MAIN_CHARGE ,"twl4030_bci" , - pdata->bci,sizeof (*pdata->bci), false, -/* irq0 = CHG_PRES, irq1 = BCI */ - irq_base +BCI_PRES_INTR_OFFSET , - irq_base +BCI_INTR_OFFSET ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_TWL4030_POWER ) && pdata->power) { - child =add_child (TWL_MODULE_PM_MASTER ,"twl4030_power" , - pdata->power,sizeof (*pdata->power), false, -0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -return 0 ; -} -/*----------------------------------------------------------------------*/ /*
@@ -987,8 +684,7 @@ static inline int unprotect_pm_master(void)return e; } -static void clocks_init (struct device *dev, -struct twl4030_clock_init_data *clock) +static void clocks_init (struct device *dev) {int e =0 ;struct clk *osc;
@@ -1018,8 +714,6 @@ static void clocks_init(struct device *dev, } ctrl |=HIGH_PERF_SQ ; -if (clock && clock->ck32k_lowpwr_enable) - ctrl |=CK32K_LOWPWR_EN ; e |=unprotect_pm_master ();/* effect->MADC+USB ck en */
@@ -1067,7 +761,6 @@ static struct of_dev_auxdata twl_auxdata_lookup[] = {static int twl_probe (struct i2c_client *client,const struct i2c_device_id *id) { -struct twl4030_platform_data *pdata =dev_get_platdata (&client->dev);struct device_node *node = client->dev.of_node;struct platform_device *pdev;const struct regmap_config *twl_regmap_config;
@@ -1075,7 +768,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)int status;unsigned i, num_slaves; -if (!node && !pdata) { +if (!node) {dev_err (&client->dev,"no platform data\n" );return -EINVAL ; }
@@ -1165,7 +858,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) twl_priv->ready = true;/* setup clock framework */ -clocks_init (&client->dev, pdata ? pdata->clock :NULL ); +clocks_init (&client->dev);/* read TWL IDCODE Register */ if (twl_class_is_4030 ()) {
@@ -1213,14 +906,8 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) TWL4030_DCDC_GLOBAL_CFG); } -if (node) { -if (pdata) - twl_auxdata_lookup[0 ].platform_data = pdata->gpio; - status =of_platform_populate (node,NULL , twl_auxdata_lookup, - &client->dev); - }else { - status =add_children (pdata, irq_base, id->driver_data); - } + status =of_platform_populate (node,NULL , twl_auxdata_lookup, + &client->dev); fail:if (status <0 )
include/linux/mfd/twl.h +0 -55
61 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1049/2214 mfd: twl-core: Use i2c_check_functionality as boolean value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 7ee4fa2674e51a0d100b9240cd8a50355141362f ]
i2c_check_functionality() returns a boolean status rather than an error code - directly use it as a boolean value.
Stable-dep-of: 3c5c55d979dd ("mfd: twl-core: Unregister the auxiliary platform device on unbind")
--- drivers/mfd/twl-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/twl-core.c +1 -1
@@ -791,7 +791,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)return status; } -if (i2c_check_functionality (client->adapter,I2C_FUNC_I2C ) ==0 ) { +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_dbg (&client->dev,"can't talk I2C?\n" ); status = -EIO ; goto free;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1050/2214 mfd: twl-core: Unregister the auxiliary platform device on unbind
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 3c5c55d979ddcb0765ce531bc7ba173c87c8712a ]
twl_probe() registers a standalone platform device named "twl", but keeps its pointer only in a local variable. Probe errors unregister the device, while successful probe leaves no way for twl_remove() to release it. The platform device therefore remains registered after the I2C driver unbinds.
Register a managed action on the I2C device immediately after adding the platform device. This unregisters it on probe failure and driver unbind, and also handles failure to register the action itself. Remove the manual error-path unregister to avoid releasing the device twice.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/mfd/twl-core.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/mfd/twl-core.c +14 -7
@@ -757,6 +757,11 @@ static struct of_dev_auxdata twl_auxdata_lookup[] = { { /* sentinel */ }, }; +static void twl_unregister_device (void *data) +{ +platform_device_unregister (data); +} +/* NOTE: This driver only handles a single twl4030/tps659x0 chip */ static int twl_probe (struct i2c_client *client,const struct i2c_device_id *id)
@@ -791,17 +796,22 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)return status; } + status =devm_add_action_or_reset (&client->dev, twl_unregister_device, + pdev); +if (status) +return status; +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_dbg (&client->dev,"can't talk I2C?\n" ); status = -EIO ; - goto free; + goto out; } twl_priv =devm_kzalloc (&client->dev,sizeof (struct twl_private ),GFP_KERNEL );if (!twl_priv) { status = -ENOMEM ; - goto free; + goto out; }if ((id->driver_data) &TWL6030_CLASS ) {
@@ -825,7 +835,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) GFP_KERNEL);if (!twl_priv->twl_modules) { status = -ENOMEM ; - goto free; + goto out; }for (i =0 ; i < num_slaves; i++) {
@@ -912,10 +922,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) fail:if (status <0 )twl_remove (client); -free: -if (status <0 ) -platform_device_unregister (pdev); - +out:return status; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1051/2214 ALSA: hda/hdmi: clamp sad_count in ELD proc write handler
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
[ Upstream commit b3e7ddd694f8429217ba509b55b910a0e4361dfb ]
snd_hdmi_write_eld_info() parses a "sad_count N" line from the root-writable ELD proc interface and assigns N directly to e->sad_count with no upper bound, unlike the per-index "sadN_*" lines a few lines below which are already bounded to ELD_MAX_SAD.
snd_hdmi_eld_update_pcm_info() later iterates
"for (i = 0; i < e->sad_count; i++)" over the fixed e->sad[ELD_MAX_SAD] array, so an oversized sad_count read from the proc file causes it to walk past the array.
Reject sad_count values above ELD_MAX_SAD, matching the existing per-index guard.
--- sound/pci/hda/hda_eld.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/pci/hda/hda_eld.c +4 -2
@@ -521,9 +521,11 @@ void snd_hdmi_write_eld_info(struct hdmi_eld *eld, e->aud_synch_delay = val; else if (!strcmp(name, "speakers")) e->spk_alloc = val; - else if (!strcmp(name, "sad_count")) + else if (!strcmp(name, "sad_count")) { +if (val >ELD_MAX_SAD ) +continue ; e->sad_count = val; - else if (!strncmp(name, "sad", 3)) { + } else if (!strncmp(name, "sad", 3)) { sname = name +4 ; n = name[3 ] -'0' ;if (name[4 ] >='0' && name[4 ] <='9' ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1052/2214 Bluetooth: hci_core: Move all debugfs handling to hci_debugfs.c
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 8331dc487fc55963e853b6858af716907717e181 ]
This moves hci_debugfs_create_basic to hci_debugfs.c which is where all the others debugfs entries are handled.
Stable-dep-of: 2a3e2287877b ("Bluetooth: hci_debugfs: Pin module for debugfs file operations")
--- net/bluetooth/hci_core.c | 124 ------------------------------------ net/bluetooth/hci_debugfs.c | 123 +++++++++++++++++++++++++++++++++++ net/bluetooth/hci_debugfs.h | 5 ++ 3 files changed, 128 insertions(+), 124 deletions(-)
net/bluetooth/hci_core.c +0 -124
@@ -61,130 +61,6 @@ DEFINE_MUTEX(hci_cb_list_lock);/* HCI ID Numbering */ static DEFINE_IDA (hci_index_ida); -/* ---- HCI debugfs entries ---- */ - -static ssize_t dut_mode_read (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct hci_dev *hdev = file->private_data; -char buf[3 ]; - - buf[0 ] =hci_dev_test_flag (hdev,HCI_DUT_MODE ) ?'Y' :'N' ; - buf[1 ] ='\n' ; - buf[2 ] ='\0' ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); -} - -static ssize_t dut_mode_write (struct file *file,const char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct hci_dev *hdev = file->private_data; -struct sk_buff *skb; -bool enable; -int err; - -if (!test_bit (HCI_UP , &hdev->flags)) -return -ENETDOWN ; - - err =kstrtobool_from_user (user_buf, count, &enable); -if (err) -return err; - -if (enable ==hci_dev_test_flag (hdev,HCI_DUT_MODE )) -return -EALREADY ; - -hci_req_sync_lock (hdev); -if (enable) - skb =__hci_cmd_sync (hdev,HCI_OP_ENABLE_DUT_MODE ,0 ,NULL , -HCI_CMD_TIMEOUT ); -else - skb =__hci_cmd_sync (hdev,HCI_OP_RESET ,0 ,NULL , -HCI_CMD_TIMEOUT ); -hci_req_sync_unlock (hdev); - -if (IS_ERR (skb)) -return PTR_ERR (skb); - -kfree_skb (skb); - -hci_dev_change_flag (hdev,HCI_DUT_MODE ); - -return count; -} - -static const struct file_operations dut_mode_fops = { - .open = simple_open, - .read = dut_mode_read, - .write = dut_mode_write, - .llseek = default_llseek, -}; - -static ssize_t vendor_diag_read (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct hci_dev *hdev = file->private_data; -char buf[3 ]; - - buf[0 ] =hci_dev_test_flag (hdev,HCI_VENDOR_DIAG ) ?'Y' :'N' ; - buf[1 ] ='\n' ; - buf[2 ] ='\0' ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); -} - -static ssize_t vendor_diag_write (struct file *file,const char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct hci_dev *hdev = file->private_data; -bool enable; -int err; - - err =kstrtobool_from_user (user_buf, count, &enable); -if (err) -return err; - -/* When the diagnostic flags are not persistent and the transport -* is not active or in user channel operation, then there is no need -* for the vendor callback. Instead just store the desired value and -* the setting will be programmed when the controller gets powered on. -*/ -if (test_bit (HCI_QUIRK_NON_PERSISTENT_DIAG , &hdev->quirks) && - (!test_bit (HCI_RUNNING , &hdev->flags) || -hci_dev_test_flag (hdev,HCI_USER_CHANNEL ))) - goto done; - -hci_req_sync_lock (hdev); - err = hdev->set_diag (hdev, enable); -hci_req_sync_unlock (hdev); - -if (err <0 ) -return err; - -done: -if (enable) -hci_dev_set_flag (hdev,HCI_VENDOR_DIAG ); -else -hci_dev_clear_flag (hdev,HCI_VENDOR_DIAG ); - -return count; -} - -static const struct file_operations vendor_diag_fops = { - .open = simple_open, - .read = vendor_diag_read, - .write = vendor_diag_write, - .llseek = default_llseek, -}; - -static void hci_debugfs_create_basic (struct hci_dev *hdev) -{ -debugfs_create_file ("dut_mode" ,0644 , hdev->debugfs, hdev, - &dut_mode_fops); - -if (hdev->set_diag) -debugfs_create_file ("vendor_diag" ,0644 , hdev->debugfs, hdev, - &vendor_diag_fops); -} -static int hci_reset_req (struct hci_request *req,unsigned long opt) {BT_DBG ("%s %ld" , req->hdev->name, opt);
net/bluetooth/hci_debugfs.c +123 -0
132 lines not on this page · raw message
net/bluetooth/hci_debugfs.h +5 -0
@@ -26,6 +26,7 @@ void hci_debugfs_create_common(struct hci_dev *hdev);void hci_debugfs_create_bredr (struct hci_dev *hdev);void hci_debugfs_create_le (struct hci_dev *hdev);void hci_debugfs_create_conn (struct hci_conn *conn); +void hci_debugfs_create_basic (struct hci_dev *hdev);#else
@@ -45,4 +46,8 @@ static inline void hci_debugfs_create_conn(struct hci_conn *conn) { } +static inline void hci_debugfs_create_basic (struct hci_dev *hdev) +{ +} +#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1053/2214 Bluetooth: hci_debugfs: Pin module for debugfs file operations
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bui Viet Dung <[email protected]>
[ Upstream commit 2a3e2287877b1ee40ffb80b7d769b633866533f3 ]
An open debugfs file retains its file_operations pointer in the debugfs proxy state. However, the file_operations defined in hci_debugfs.c (use_debug_keys_fops, sc_only_mode_fops, ssp_debug_mode_fops, force_bredr_smp_fops, force_static_address_fops, force_no_mitm_fops, dut_mode_fops, vendor_diag_fops, and the DEFINE_QUIRK_ATTRIBUTE macro) have no .owner set to THIS_MODULE.
As a result, full_proxy_open_regular() calls fops_get() which succeeds without taking a reference to the bluetooth module. When a userspace process opens any of these debugfs files, a subsequent controller removal and module unload (rmmod bluetooth) can succeed while the file descriptor remains open.
When the userspace process subsequently closes the descriptor, full_proxy_release() accesses the already unmapped file_operations structure, triggering a kernel oops in full_proxy_release():
BUG: unable to handle page fault for address: fffffbfff8056f03 #PF: supervisor read access in kernel mode Oops: 0000 [#1] SMP KASAN NOPTI RIP: 0010:full_proxy_release+0x8e/0x140 Call Trace: <TASK> __fput+0x39f/0xa60 fput_close_sync+0xff/0x200 __x64_sys_close+0x8c/0xf0 do_syscall_64+0x115/0x6a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
The issue was discovered via manual code audit of net/bluetooth/hci_debugfs.c and verified on a Linux 7.3-rc6 test VM with CONFIG_BT=m.
Set .owner = THIS_MODULE on all debugfs file_operations tables in hci_debugfs.c so that debugfs keeps the module loaded until close has finished.
--- net/bluetooth/hci_debugfs.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/bluetooth/hci_debugfs.c +9 -0
@@ -68,6 +68,7 @@ static ssize_t __name ## _write(struct file *file, \ } \ \ static const struct file_operations __name ## _fops = { \ + .owner =THIS_MODULE , \ .open = simple_open, \ .read = __name ## _read, \ .write = __name ## _write, \
@@ -286,6 +287,7 @@ static ssize_t use_debug_keys_read(struct file *file, char __user *user_buf, }static const struct file_operations use_debug_keys_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = use_debug_keys_read, .llseek = default_llseek,
@@ -304,6 +306,7 @@ static ssize_t sc_only_mode_read(struct file *file, char __user *user_buf, }static const struct file_operations sc_only_mode_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = sc_only_mode_read, .llseek = default_llseek,
@@ -440,6 +443,7 @@ static ssize_t ssp_debug_mode_read(struct file *file, char __user *user_buf, }static const struct file_operations ssp_debug_mode_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = ssp_debug_mode_read, .llseek = default_llseek,
@@ -532,6 +536,7 @@ static ssize_t force_bredr_smp_write(struct file *file, }static const struct file_operations force_bredr_smp_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = force_bredr_smp_read, .write = force_bredr_smp_write,
@@ -781,6 +786,7 @@ static ssize_t force_static_address_write(struct file *file, }static const struct file_operations force_static_address_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = force_static_address_read, .write = force_static_address_write,
@@ -1184,6 +1190,7 @@ static ssize_t force_no_mitm_write(struct file *file, }static const struct file_operations force_no_mitm_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = force_no_mitm_read, .write = force_no_mitm_write,
@@ -1322,6 +1329,7 @@ static ssize_t dut_mode_write(struct file *file, const char __user *user_buf, }static const struct file_operations dut_mode_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = dut_mode_read, .write = dut_mode_write,
@@ -1378,6 +1386,7 @@ static ssize_t vendor_diag_write(struct file *file, const char __user *user_buf, }static const struct file_operations vendor_diag_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = vendor_diag_read, .write = vendor_diag_write,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1054/2214 iommu/dma: Catch scatterlist length overflows
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Karas <[email protected]>
[ Upstream commit 1c8f6308e557f32412e9d4678b3f029f47f6d9aa ]
It is possible, when a very large mapping uses only one scatterlist, that padding overflows scatterlist's length field. This results in:
1) silently wrapping the value
2) smaller than desired mappings produced by iommu_map_sg
3) leaving mapped bytes in memory (no iommu_unmap)
Address this issue by adding overflow detection for scatterlist length field.
--- drivers/iommu/dma-iommu.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/iommu/dma-iommu.c +19 -1
@@ -1023,6 +1023,11 @@ static int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg,sg_dma_len (s) = s_length; s->offset -= s_iova_off; s_length =iova_align (iovad, s_length + s_iova_off); +if (s_length >UINT_MAX ) { + ret = -EOVERFLOW ; + + goto out_restore_sg; + } s->length = s_length;/*
@@ -1039,7 +1044,20 @@ static int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg,* time through here (i.e. before it has a meaningful value). */ if (pad_len && pad_len < s_length -1 ) { - prev->length += pad_len; +unsigned int new_prev_len; + +/* +* For large mappings spanning multiple GBs we +* may not be able to fit all needed padding into +* sg->length. +*/ +if (check_add_overflow (prev->length, pad_len, &new_prev_len)) { + ret = -EOVERFLOW ; + + goto out_restore_sg; + } + + prev->length = new_prev_len; iova_len += pad_len; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1055/2214 mailbox: altera: shut down RX polling timer on channel teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 0cf10e65639cba32d05994f85e6a8f08dd0ffe08 ]
The RX polling callback unconditionally rearms the timer after it processes mailbox data. altera_mbox_shutdown() uses timer_delete_sync(), which waits for a running callback but does not prevent that callback from rearming the timer after the deletion.
Use timer_shutdown_sync() for the final polling teardown so the timer cannot be queued again while the mailbox channel is being released. The timer is reinitialized with timer_setup() on a later channel startup, so polling mode remains reusable.
--- drivers/mailbox/mailbox-altera.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/mailbox-altera.c +1 -1
@@ -270,7 +270,7 @@ static void altera_mbox_shutdown(struct mbox_chan *chan)writel_relaxed (~0 , mbox->mbox_base +MAILBOX_INTMASK_REG );free_irq (mbox->irq, chan); }else if (!mbox->is_sender) { -del_timer_sync (&mbox->rxpoll_timer); +timer_shutdown_sync (&mbox->rxpoll_timer); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1056/2214 platform/x86: asus-wmi: Serialize WMI method evaluations with a mutex
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Scardovi <[email protected]>
[ Upstream commit b9428edaf4109e86a97254228d831767d0acc1f8 ]
Concurrent evaluations of ASUS WMI management methods (from ACPI notify, HID, userspace daemons, and debugfs) enter the BIOS ACPI/SMM interface simultaneously, triggering re-entrant SMIs or EC mailbox buffer corruption.
Fix this at the root by introducing a centralized evaluation helper (asus_wmi_evaluate_method_locked()) protected by a global mutex (asus_wmi_eval_lock) using guard(mutex). Route all evaluations of ASUS_WMI_MGMT_GUID (method3, method5, method_buf, and show_call) through this helper.
A static mutex is required because asus_wmi_evaluate_method() is an exported symbol used by external modules (such as hid-asus and asus-armoury) that lack access to struct asus_wmi drvdata, and the underlying ASUS ACPI/EC management method is a single physical platform resource.
The mutex is non-recursive: nested ACPI/WMI notify handlers must not call back into evaluate on the same task (defer via workqueue, as asus_rfkill_notify already does).
The sysfs-versus-notify race predates the later export of asus_wmi_evaluate_method(), so Fixes points at the original shared evaluate helper rather than that export.
--- drivers/platform/x86/asus-wmi.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/platform/x86/asus-wmi.c +11 -0
@@ -15,6 +15,7 @@#include <linux/kernel.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/init.h> #include <linux/types.h> #include <linux/slab.h>
@@ -249,6 +250,12 @@ struct asus_wmi {/* WMI ************************************************************************/ +/* +* Concurrent evaluations of ASUS WMI methods can re-enter firmware +* SMI/EC mailbox handling and corrupt the mailbox. +*/ +static DEFINE_MUTEX (asus_wmi_eval_lock); +static int asus_wmi_evaluate_method3 (u32 method_id,u32 arg0,u32 arg1,u32 arg2,u32 *retval) {
@@ -263,8 +270,10 @@ static int asus_wmi_evaluate_method3(u32 method_id,union acpi_object *obj;u32 tmp =0 ; +mutex_lock (&asus_wmi_eval_lock); status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , method_id, &input, &output); +mutex_unlock (&asus_wmi_eval_lock);if (ACPI_FAILURE (status))return -EIO ;
@@ -2906,9 +2915,11 @@ static int show_call(struct seq_file *m, void *data)union acpi_object *obj;acpi_status status; +mutex_lock (&asus_wmi_eval_lock); status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , asus->debug.method_id, &input, &output); +mutex_unlock (&asus_wmi_eval_lock);if (ACPI_FAILURE (status))return -EIO ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1057/2214 mm: disallow ioremaping ordinary RAM in generic_access_phys()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 4590752e20aa393cc0d4fe538c0747d14a98c97a ]
generic_access_phys() can end up getting called on CoW PFNMAP mappings, resulting in it trying to ioremap anonymous folios, which especially the x86 code doesn't enjoy, and which is in general just odd/wrong.
E.g., with a CoW mapping of a PCI BAR:
ioremap on RAM at 0x0000000045623000 - 0x0000000045623fff
WARNING: arch/x86/mm/ioremap.c:216 at __ioremap_caller.isra.0+0x4c2/0x5f0 Call Trace: generic_access_phys+0x130/0x4d0 mm/memory.c:7178 kernfs_vma_access+0x1ce/0x280 fs/kernfs/file.c:437 __access_remote_vm+0x58f/0x890 mm/memory.c:7256 mem_rw+0x2a1/0x670 fs/proc/base.c:912
But more generically, we should disallow access to anything that looks like ordinary RAM in the system: including allocating memory (e.g., alloc_pages) and mapping them in a VM_PFNMAP.
For pages with an online memmap, allow only pages marked as reserved (PageReserved). This also includes memblock allocations, however, distinguishing them from other MMIO is tricky, and nobody should really be mapping them in a PFNMAP (except someone abusing /dev/mem, which we do not care about).
So only allow access if there is no online memmap, or if the pages are marked reserved. Reject other pages with -EINVAL.
Note that, just like other pfn_to_online_page() users, we won't care about concurrent memory offlining; mapping memory that can concurrently get offlined is highly dubious.
--- mm/memory.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
mm/memory.c +14 -0
@@ -5150,6 +5150,7 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,resource_size_t phys_addr;unsigned long prot =0 ;void __iomem *maddr; +struct page *page;pte_t *ptep, pte;spinlock_t *ptl;int offset =offset_in_page (addr);
@@ -5162,6 +5163,19 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,if (follow_pte (vma->vm_mm, addr, &ptep, &ptl))return -EINVAL ; pte = *ptep; + +/* +* Reject anything that looks like ordinary RAM, including anonymous +* folios in CoW mappings or allocated kernel memory. Note that we +* cannot distinguish memblock allocations from non-RAM reliably, so +* we cannot easily reject them here. +*/ + page =pfn_to_online_page (pte_pfn (pte)); +if (page && !PageReserved (page)) { +pte_unmap_unlock (ptep, ptl); +return -EINVAL ; + } +pte_unmap_unlock (ptep, ptl); prot =pgprot_val (pte_pgprot (pte));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1058/2214 cxl/acpi: Check ACPI companion before use
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 371c2ad1624283b6c7a62a28199f5161d388a738 ]
Platform drivers can be forced to match devices outside their ID tables through driver_override. cxl_acpi_probe() assumes that every bound device has an ACPI companion and dereferences adev->dev.bus without checking the result of ACPI_COMPANION(). Force-binding cxl_acpi to a platform device without a companion therefore causes a NULL pointer dereference.
This was reproduced by setting the driver override for the pcspkr platform device to cxl_acpi and binding it through sysfs:
BUG: kernel NULL pointer dereference, address: 0000000000000280 #PF: supervisor read access in kernel mode RIP: cxl_acpi_probe+0xf4/0x220 Call Trace: platform_probe+0x4d/0x80 really_probe+0x106/0x370 device_driver_attach+0x4c/0xa0 bind_store+0xd0/0x100
Commit 2b3a5dabe89e ("platform/surface: acpi-notify: Check ACPI companion before use") fixed the same force-binding issue in another platform driver. Check the companion before setting up the CXL root and return -ENODEV when it is absent.
--- drivers/cxl/acpi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/cxl/acpi.c +6 -2
@@ -377,11 +377,15 @@ static int add_root_nvdimm_bridge(struct device *match, void *data)static int cxl_acpi_probe (struct platform_device *pdev) { -int rc;acpi_status status; +struct acpi_device *adev;struct cxl_port *root_port;struct device *host = &pdev->dev; -struct acpi_device *adev =ACPI_COMPANION (host); +int rc; + + adev =ACPI_COMPANION (host); +if (!adev) +return -ENODEV ; root_port =devm_cxl_add_port (host, host,CXL_RESOURCE_NONE ,NULL );if (IS_ERR (root_port))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1059/2214 KVM: arm64: Move IN_GUEST_MODE ahead of state being loaded
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
[ Upstream commit 22b6557ad05bf05c73246f62c19af3e04017270e ]
IN_GUEST_MODE is advertised too late, when state has already been moved onto CPU registers and cannot be observed by another CPU anymore.
Move the IN_GUEST_MODE publication ahead of the state being loaded, and immediately check for pending request. This ensures that there is no window of opportunity for another CPU to observe OUTSIDE_GUEST_MODE and yet for state to be loaded.
This also simplifies the "state rollback", which solely amounts to synchronising the timer when no irqchip is present.
--- arch/arm64/kvm/arm.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
arch/arm64/kvm/arm.c +8 -5
@@ -836,28 +836,31 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)local_irq_disable (); -kvm_vgic_flush_hwstate (vcpu); -/* * Ensure we set mode to IN_GUEST_MODE after we disable * interrupts and before the final VCPU requests check. * See the comment in kvm_vcpu_exiting_guest_mode() and * Documentation/virt/kvm/vcpu-requests.rst +* +* Requests to self must be posted before this point, or +* won't be taken into account until the next exit. No state +* loading other than what happens at vcpu_load() time can +* be done before we have checked for pending requests. */ smp_store_mb (vcpu->mode,IN_GUEST_MODE );if (ret <=0 ||kvm_vcpu_exit_request (vcpu, &ret)) { -isb ();/* Ensure work in x_flush_hwstate is committed */ -kvm_pmu_sync_hwstate (vcpu);if (static_branch_unlikely (&userspace_irqchip_in_use))kvm_timer_sync_user (vcpu); -kvm_vgic_sync_hwstate (vcpu);smp_store_release (&vcpu->mode,OUTSIDE_GUEST_MODE );local_irq_enable ();preempt_enable ();continue ; } +/* From here onwards, we are commited to entering the guest */ +kvm_vgic_flush_hwstate (vcpu); +kvm_arm_setup_debug (vcpu);/**************************************************************
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1060/2214 media: rockchip: rga: fix clock cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit 254f3337ce2575bf94f1fb40cc40fdbc70371116 ]
Fix this smatch warning:
drivers/media/platform/rockchip/rga/rga.c:734 rga_enable_clocks() warn: 'rga->sclk' from clk_prepare_enable() not released on lines: 734.
The reason is that aclk should be disabled/unprepared before sclk, instead of the other way around.
Stable-dep-of: a875c43dd95e ("media: rockchip: rga: quiesce IRQ before releasing m2m state")
--- drivers/media/platform/rockchip/rga/rga.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/rockchip/rga/rga.c +2 -2
@@ -717,10 +717,10 @@ static int rga_enable_clocks(struct rockchip_rga *rga)return 0 ; -err_disable_sclk: -clk_disable_unprepare (rga->sclk); err_disable_aclk:clk_disable_unprepare (rga->aclk); +err_disable_sclk: +clk_disable_unprepare (rga->sclk);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1061/2214 media: rockchip: rga: use clk_bulk api
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Püschel <[email protected]>
[ Upstream commit a2a4f69fd2e333bacd17d1788eb5211cb6f373cc ]
Use the clk_bulk API to avoid code duplication for each of the three clocks.
Stable-dep-of: a875c43dd95e ("media: rockchip: rga: quiesce IRQ before releasing m2m state")
--- drivers/media/platform/rockchip/rga/rga.c | 65 +++-------------------- drivers/media/platform/rockchip/rga/rga.h | 6 +-- 2 files changed, 11 insertions(+), 60 deletions(-)
drivers/media/platform/rockchip/rga/rga.c +8 -57
@@ -693,48 +693,10 @@ static const struct video_device rga_videodev = { .device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING, }; -static int rga_enable_clocks (struct rockchip_rga *rga) -{ -int ret; - - ret =clk_prepare_enable (rga->sclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga sclk: %d\n" , ret); -return ret; - } - - ret =clk_prepare_enable (rga->aclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga aclk: %d\n" , ret); - goto err_disable_sclk; - } - - ret =clk_prepare_enable (rga->hclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga hclk: %d\n" , ret); - goto err_disable_aclk; - } - -return 0 ; - -err_disable_aclk: -clk_disable_unprepare (rga->aclk); -err_disable_sclk: -clk_disable_unprepare (rga->sclk); - -return ret; -} - -static void rga_disable_clocks (struct rockchip_rga *rga) -{ -clk_disable_unprepare (rga->sclk); -clk_disable_unprepare (rga->hclk); -clk_disable_unprepare (rga->aclk); -} -static int rga_parse_dt (struct rockchip_rga *rga) {struct reset_control *core_rst, *axi_rst, *ahb_rst; +int ret; core_rst =devm_reset_control_get (rga->dev,"core" );if (IS_ERR (core_rst)) {
@@ -766,23 +728,12 @@ static int rga_parse_dt(struct rockchip_rga *rga)udelay (1 );reset_control_deassert (ahb_rst); - rga->sclk =devm_clk_get (rga->dev,"sclk" ); -if (IS_ERR (rga->sclk)) { -dev_err (rga->dev,"failed to get sclk clock\n" ); -return PTR_ERR (rga->sclk); - } - - rga->aclk =devm_clk_get (rga->dev,"aclk" ); -if (IS_ERR (rga->aclk)) { -dev_err (rga->dev,"failed to get aclk clock\n" ); -return PTR_ERR (rga->aclk); - } - - rga->hclk =devm_clk_get (rga->dev,"hclk" ); -if (IS_ERR (rga->hclk)) { -dev_err (rga->dev,"failed to get hclk clock\n" ); -return PTR_ERR (rga->hclk); + ret =devm_clk_bulk_get_all (rga->dev, &rga->clks); +if (ret <0 ) { +dev_err (rga->dev,"failed to get clocks\n" ); +return ret; } + rga->num_clks = ret;return 0 ; }
@@ -949,7 +900,7 @@ static int __maybe_unused rga_runtime_suspend(struct device *dev) {struct rockchip_rga *rga =dev_get_drvdata (dev); -rga_disable_clocks (rga); +clk_bulk_disable_unprepare (rga->num_clks, rga->clks);return 0 ; }
@@ -958,7 +909,7 @@ static int __maybe_unused rga_runtime_resume(struct device *dev) {struct rockchip_rga *rga =dev_get_drvdata (dev); -return rga_enable_clocks (rga); +return clk_bulk_prepare_enable (rga->num_clks, rga->clks); }static const struct dev_pm_ops rga_pm = {
drivers/media/platform/rockchip/rga/rga.h +3 -3
@@ -6,6 +6,7 @@#ifndef __RGA_H__#define __RGA_H__ +#include <linux/clk.h> #include <linux/platform_device.h> #include <media/videobuf2-v4l2.h> #include <media/v4l2-ctrls.h>
@@ -68,9 +69,8 @@ struct rockchip_rga {struct device *dev;struct regmap *grf;void __iomem *regs; -struct clk *sclk; -struct clk *aclk; -struct clk *hclk; +struct clk_bulk_data *clks; +int num_clks;struct rockchip_rga_version version;/* vfd lock */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1062/2214 media: rockchip: rga: quiesce IRQ before releasing m2m state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit a875c43dd95ee4f9c4e3e5ae1cb8362cc6d7817d ]
rga_remove() releases the m2m state before the IRQ is freed. The IRQ is devm-managed and is only released once rga_remove() returns, so rga_isr() can still run while the m2m device state is being torn down.
Store the IRQ number in struct rockchip_rga, unregister the video device first, and free the IRQ before releasing the m2m state so the handler cannot run against the freed state.
--- drivers/media/platform/rockchip/rga/rga.c | 4 +++- drivers/media/platform/rockchip/rga/rga.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/rockchip/rga/rga.c +3 -1
@@ -776,6 +776,7 @@ static int rga_probe(struct platform_device *pdev) ret = irq; goto err_put_clk; } + rga->irq = irq; ret =devm_request_irq (rga->dev, irq, rga_isr,0 ,dev_name (rga->dev), rga);
@@ -887,8 +888,9 @@ static int rga_remove(struct platform_device *pdev)v4l2_info (&rga->v4l2_dev,"Removing\n" ); -v4l2_m2m_release (rga->m2m_dev);video_unregister_device (rga->vfd); +devm_free_irq (rga->dev, rga->irq, rga); +v4l2_m2m_release (rga->m2m_dev);v4l2_device_unregister (&rga->v4l2_dev);pm_runtime_disable (rga->dev);
drivers/media/platform/rockchip/rga/rga.h +1 -0
@@ -69,6 +69,7 @@ struct rockchip_rga {struct device *dev;struct regmap *grf;void __iomem *regs; +int irq;struct clk_bulk_data *clks;int num_clks;struct rockchip_rga_version version;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1063/2214 fbdev: core: Initialize modelist in framebuffer_alloc()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Misiurov <[email protected]>
[ Upstream commit 0c9cb9321cb3863b52bdea4b8ae5a27705762c9e ]
framebuffer_alloc() returns zeroed memory, so info->modelist starts out with NULL next and prev pointers. The list head is initialized only later, by fb_videomode_to_modelist() or by do_register_framebuffer().
The "fix potential memory leak" commits listed below added fb_destroy_modelist(&info->modelist) to the probe error paths of s3fb, tdfxfb, tridentfb, i740fb and carminefb. These paths can run before the list head is initialized:
- s3fb, tdfxfb, tridentfb and i740fb call fb_videomode_to_modelist() only after a successful EDID read, and tridentfb can also hit the error path on an ioremap() or kmalloc() failure before that;
- carminefb jumps to the error path when fb_find_mode() fails, before its fb_videomode_to_modelist() call.
fb_destroy_modelist() then dereferences the NULL head. Reproduced on Debian 12 (6.1.180) by binding s3fb to a VGA device without EDID and forcing fb_alloc_cmap() to fail:
s3fb 0000:00:03.0: cannot allocate colormap
BUG: kernel NULL pointer dereference, address: 0000000000000000 RIP: 0010:fb_destroy_modelist+0x10/0x80 Call Trace: s3_pci_probe.cold+0x12b/0x2bf [s3fb] local_pci_probe+0x41/0x80 pci_device_probe+0xc3/0x240 really_probe+0xde/0x380 __driver_probe_device+0x84/0x150 driver_probe_device+0x1f/0x90 __driver_attach+0xce/0x1c0 bus_for_each_dev+0x87/0xd0 bus_add_driver+0x1ae/0x200 driver_register+0x89/0xe0 do_one_initcall+0x59/0x220 do_init_module+0x4a/0x1f0
Initialize the list head in framebuffer_alloc(), so info->modelist is always a valid, possibly empty, list and fb_destroy_modelist() is safe on every error path. Keep the lazy initialization in do_register_framebuffer(), as drivers that embed struct fb_info rather than calling framebuffer_alloc() still depend on it.
--- drivers/video/fbdev/core/fbsysfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/core/fbsysfs.c +1 -0
@@ -56,6 +56,7 @@ struct fb_info *framebuffer_alloc(size_t size, struct device *dev) info->device = dev; info->fbcon_rotate_hint =-1 ; +INIT_LIST_HEAD (&info->modelist);#if IS_ENABLED (CONFIG_FB_BACKLIGHT )mutex_init (&info->bl_curve_mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1064/2214 s390/pci: Add error cleanup in zpci_directed_irq_init()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Schumacher <[email protected]>
[ Upstream commit 769f66f595c11185c66913ea5d96420504bfebc3 ]
If per-CPU airq_iv allocation fails in the loop, previously allocated vectors and arrays leak. Add proper error path to release all resources on failure.
The error path frees zpci_sbv, but SIC_IRQ_MODE_DIRECT has already programmed its address into the hardware. Set the directed interrupt mode only after all allocations have succeeded, so a failed init leaves no freed memory registered with the hardware.
--- arch/s390/pci/pci_irq.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
arch/s390/pci/pci_irq.c +19 -7
@@ -411,15 +411,10 @@ static int __init zpci_directed_irq_init(void)if (!zpci_sbv)return -ENOMEM ; - iib.diib.isc =PCI_ISC ; - iib.diib.nr_cpus =num_possible_cpus (); - iib.diib.disb_addr = (u64 ) zpci_sbv->vector; -__zpci_set_irq_ctrl (SIC_IRQ_MODE_DIRECT ,0 , &iib); - zpci_ibv =kcalloc (num_possible_cpus (),sizeof (*zpci_ibv),GFP_KERNEL );if (!zpci_ibv) -return -ENOMEM ; + goto out_free_sbv;for_each_possible_cpu (cpu) {/*
@@ -431,13 +426,30 @@ static int __init zpci_directed_irq_init(void)AIRQ_IV_CACHELINE | (!cpu ? AIRQ_IV_ALLOC : 0));if (!zpci_ibv[cpu]) -return -ENOMEM ; + goto out_free_ibv; } + + iib.diib.isc =PCI_ISC ; + iib.diib.nr_cpus =num_possible_cpus (); + iib.diib.disb_addr = (u64 ) zpci_sbv->vector; +__zpci_set_irq_ctrl (SIC_IRQ_MODE_DIRECT ,0 , &iib);on_each_cpu (cpu_enable_directed_irq,NULL ,1 ); zpci_irq_chip.irq_set_affinity = zpci_set_irq_affinity;return 0 ; + +out_free_ibv: +for_each_possible_cpu (cpu) { +if (zpci_ibv[cpu]) +airq_iv_release (zpci_ibv[cpu]); + } +kfree (zpci_ibv); + zpci_ibv =NULL ; +out_free_sbv: +airq_iv_release (zpci_sbv); + zpci_sbv =NULL ; +return -ENOMEM ; }static int __init zpci_floating_irq_init (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1065/2214 ALSA: mpu401: shut down timer before freeing MPU
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9332af5220d42341bb1446a62c545c0518e990ef ]
When an MPU401 interface has no usable IRQ, the driver polls raw-MIDI input and output with a timer. During raw-MIDI teardown, the timer callback can already be running when snd_mpu401_uart_remove_timer() clears the last mode bit and calls timer_delete(). That API neither waits for a running callback nor prevents it from rearming the timer, and free_irq() does not synchronize timer callbacks. snd_mpu401_uart_free() can therefore release mpu while the timer callback still uses it.
Initialize the timer once when the MPU object is created and only rearm it while a timer mode is active. Shut it down synchronously after freeing the IRQ so an in-flight callback completes before mpu and its resources are released.
--- sound/drivers/mpu401/mpu401_uart.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/drivers/mpu401/mpu401_uart.c +5 -3
@@ -161,14 +161,15 @@ static void snd_mpu401_uart_timer(struct timer_list *t)spin_lock_irqsave (&mpu->timer_lock, flags);/*mpu->mode |= MPU401_MODE_TIMER;*/ -mod_timer (&mpu->timer,1 + jiffies); +if (mpu->timer_invoked) +mod_timer (&mpu->timer,1 + jiffies);spin_unlock_irqrestore (&mpu->timer_lock, flags);if (mpu->rmidi)_snd_mpu401_uart_interrupt (mpu); }/* -* initialize the timer callback if not programmed yet +* arm the timer if it is not already active */ static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu,int input) {
@@ -176,7 +177,6 @@ static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu, int input)spin_lock_irqsave (&mpu->timer_lock, flags);if (mpu->timer_invoked ==0 ) { -timer_setup (&mpu->timer, snd_mpu401_uart_timer,0 );mod_timer (&mpu->timer,1 + jiffies); } mpu->timer_invoked |= input ? MPU401_MODE_INPUT_TIMER :
@@ -490,6 +490,7 @@ static void snd_mpu401_uart_free(struct snd_rawmidi *rmidi)struct snd_mpu401 *mpu = rmidi->private_data;if (mpu->irq >=0 )free_irq (mpu->irq, (void *) mpu); +timer_shutdown_sync (&mpu->timer);release_and_free_resource (mpu->res);kfree (mpu); }
@@ -544,6 +545,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,spin_lock_init (&mpu->input_lock);spin_lock_init (&mpu->output_lock);spin_lock_init (&mpu->timer_lock); +timer_setup (&mpu->timer, snd_mpu401_uart_timer,0 ); mpu->hardware = hardware; mpu->irq =-1 ;if (! (info_flags &MPU401_INFO_INTEGRATED )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1066/2214 net: skbuff: dont BUG() on a bad csum_start in skb_copy_and_csum_dev()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 56453199d28f0072a8196fba14b2d702632e2219 ]
skb_copy_and_csum_dev() copies everything up to the checksum start out of the linear area, and BUG()s if the checksum start is past the end of the linear area. It misses the other direction: a CHECKSUM_PARTIAL skb that has been pulled past its csum_start gives a negative offset, which gets past the check and becomes a ~4GB copy. It also trusts csum_offset when it stores the folded checksum. So far skb_copy_and_csum_bits() BUG()ing on a short skb has covered for that, but once it returns instead, a bad csum_offset would write past the end of the caller's buffer.
The function returns void and its callers are drivers copying a frame into a bounce buffer just before handing it to the hardware. There's nothing for them to back out of, so check both ends of csum_start and that the checksum field fits in the frame, and if not, copy the whole frame with skb_copy_bits() without filling in the checksum, with a DEBUG_NET_WARN_ON_ONCE() for debug kernels. The frame
goes out with a bad checksum and is dropped by the receiver. If even that copy fails, zero the buffer so the driver doesn't send stale bytes.
--- net/core/skbuff.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
net/core/skbuff.c +12 -1
@@ -3257,7 +3257,18 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)else csstart =skb_headlen (skb); -BUG_ON (csstart >skb_headlen (skb)); +if (unlikely (csstart <0 || csstart >skb_headlen (skb) || + (skb->ip_summed ==CHECKSUM_PARTIAL && + csstart + skb->csum_offset +sizeof (__sum16) > + skb->len))) { +WARN_ON_ONCE (IS_ENABLED (CONFIG_DEBUG_NET )); +/* Send the frame without the checksum filled in, or send +* zeroes if we can't even copy it. +*/ +if (skb_copy_bits (skb,0 , to, skb->len)) +memset (to,0 , skb->len); +return ; + }skb_copy_from_linear_data (skb, to, csstart);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1067/2214 f2fs: remove mappedtodisk flag usage in mmap write path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nanzhe Zhao <[email protected]>
[ Upstream commit b3c9843589257631bac18f30655e82d88970688a ]
PG_mappedtodisk was inherited from the nobh/buffer-head era. However, f2fs has no buffer heads and the flag is no longer meaningful. The only user of the flag is the "no holes" shortcut in f2fs_vm_page_mkwrite(), which makes mmap write faults skip marking the folio dirty. Moreover, it causes the following race condition with filesystem freezing:
CPU0 (write fault) CPU1 (freeze_super)
---- ----
f2fs_vm_page_mkwrite()
sb_start_pagefault()
/* shortcut: no dirty */
sb_end_pagefault()
sb_wait_write(SB_FREEZE_PAGEFAULT)
/* no waiter, passes */
sync_filesystem()
/* folio not dirty, skipped */ finish_fault()
/* PTE writable */
fault_dirty_shared_page()
folio_mark_dirty()
/* dirty folio on a frozen fs */
It will also skip APP_MAPPED_IO iostat/REQ_TIME updates and post-EOF folio zeroing.
Remove this shortcut in f2fs_vm_page_mkwrite() and stop setting it in f2fs_read_single_page().
--- fs/f2fs/data.c | 1 - fs/f2fs/file.c | 6 ------ 2 files changed, 7 deletions(-)
fs/f2fs/data.c +0 -1
@@ -2163,7 +2163,6 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, got_it:if ((map->m_flags &F2FS_MAP_MAPPED )) { block_nr = map->m_pblk + block_in_file - map->m_lblk; -SetPageMappedToDisk (page);if (!PageUptodate (page) && (!PageSwapCache (page) && !cleancache_get_page (page))) {
fs/f2fs/file.c +0 -6
@@ -135,12 +135,6 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)/* wait for GCed page writeback via META_MAPPING */ f2fs_wait_on_block_writeback (inode, dn.data_blkaddr); -/* -* check to see if the page is mapped already (no holes) -*/ -if (PageMappedToDisk (page)) - goto out_sem; -/* page is wholly or partially inside EOF */ if (((loff_t)(page->index +1 ) <<PAGE_SHIFT ) >i_size_read (inode)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1068/2214 serial: sc16is7xx: declare MCR and IER as volatile registers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 1c41d09dcd07ee9648e20aa8238e404c2e6a12fb ]
MCR register has the same address as XON1 register. IER register has the same address as DLH register.
Which register is accessed depends on bits configuration in some other registers.
To prevent potential access errors, declare MCR and IER as volatile registers.
--- drivers/tty/serial/sc16is7xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/sc16is7xx.c +2 -0
@@ -467,7 +467,9 @@ static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg) {switch (reg >>SC16IS7XX_REG_SHIFT ) {case SC16IS7XX_RHR_REG : +case SC16IS7XX_IER_REG :/* Shared address space with DLH */ case SC16IS7XX_IIR_REG : +case SC16IS7XX_MCR_REG :/* Shared address space with XON1 */ case SC16IS7XX_LSR_REG :case SC16IS7XX_MSR_REG :case SC16IS7XX_TXLVL_REG :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1069/2214 virtiofs: add FUSE protocol validation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuto Ohnuki <[email protected]>
[ Upstream commit 68b69fa0edb241a946cd4c850110990f30705164 ]
Add virtio_fs_verify_response() to validate that the server properly follows the FUSE protocol by checking:
- Response length is at least sizeof(struct fuse_out_header).
- oh.len matches the actual response length.
- oh.unique matches the request's unique identifier.
On validation failure, set error to -EIO and normalize oh.len to prevent underflow in copy_args_from_argbuf().
Addresses the TODO comment in virtio_fs_request_complete().
Stable-dep-of: 5364d081125a ("virtiofs: validate fixed-output response length")
--- fs/fuse/virtio_fs.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
fs/fuse/virtio_fs.c +25 -4
@@ -551,6 +551,27 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req) req->argbuf =NULL ; } +/* Verify that the server properly follows the FUSE protocol */ +static bool virtio_fs_verify_response (struct fuse_req *req,unsigned int len) +{ +struct fuse_out_header *oh = &req->out.h; + +if (len <sizeof (*oh)) { +pr_warn ("virtio-fs: response too short (%u)\n" , len); +return false; + } +if (oh->len != len) { +pr_warn ("virtio-fs: oh.len mismatch (%u != %u)\n" , oh->len, len); +return false; + } +if (oh->unique != req->in.h.unique) { +pr_warn ("virtio-fs: oh.unique mismatch (%llu != %llu)\n" , + oh->unique, req->in.h.unique); +return false; + } +return true; +} +/* Work function for request completion */ static void virtio_fs_request_complete (struct fuse_req *req,struct virtio_fs_vq *fsvq)
@@ -561,10 +582,6 @@ static void virtio_fs_request_complete(struct fuse_req *req,unsigned int len, i, thislen;struct page *page; -/* -* TODO verify that server properly follows FUSE protocol -* (oh.uniq, oh.len) -*/ args = req->args;copy_args_from_argbuf (args, req);
@@ -620,6 +637,10 @@ static void virtio_fs_requests_done_work(struct work_struct *work)virtqueue_disable_cb (vq);while ((req =virtqueue_get_buf (vq, &len)) !=NULL ) { +if (!virtio_fs_verify_response (req, len)) { + req->out.h.error = -EIO ; + req->out.h.len =sizeof (struct fuse_out_header ); + }spin_lock (&fpq->lock);list_move_tail (&req->list, &reqs);spin_unlock (&fpq->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1070/2214 virtiofs: validate fixed-output response length
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Byeongchan <[email protected]>
[ Upstream commit 5364d081125a34e90851fbb46ecc93f79339ce78 ]
A short successful virtiofs response can leave the fixed-output portion of the request argument buffer unwritten. The completion path nevertheless copies the full declared output to the request destination, allowing stale allocator contents to reach callers such as fuse_statfs().
Require successful fixed-output responses to contain their complete declared output. Continue to permit a shorter final argument only for out_argvar requests. Reject positive and internal restart error values and require valid error replies to be header-only. The error already stored in the FUSE output header is returned by fuse_request_end(), so do not copy output arguments from an error reply.
This was found by source review with AI assistance. A header-only successful FUSE_STATFS reply returned stale fields in nine of nine calls across three boots. The fixed kernel rejected the short response and preserved complete replies, valid negative-error replies, and variable-output replies.
--- fs/fuse/virtio_fs.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
fs/fuse/virtio_fs.c +30 -0
@@ -522,6 +522,10 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)unsigned int num_out;unsigned int i; +/* fuse_request_end() returns this error; there are no args to copy. */ +if (req->out.h.error) + goto out; + remaining = req->out.h.len -sizeof (req->out.h); num_in = args->in_numargs - args->in_pages; num_out = args->out_numargs - args->out_pages;
@@ -547,6 +551,7 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)if (args->out_argvar) args->out_args[args->out_numargs -1 ].size = remaining; +out:kfree (req->argbuf); req->argbuf =NULL ; }
@@ -554,7 +559,9 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)/* Verify that the server properly follows the FUSE protocol */ static bool virtio_fs_verify_response (struct fuse_req *req,unsigned int len) { +struct fuse_args *args = req->args;struct fuse_out_header *oh = &req->out.h; +unsigned int expected;if (len <sizeof (*oh)) {pr_warn ("virtio-fs: response too short (%u)\n" , len);
@@ -569,6 +576,29 @@ static bool virtio_fs_verify_response(struct fuse_req *req, unsigned int len) oh->unique, req->in.h.unique);return false; } +if (oh->error <= -ERESTARTSYS || oh->error >0 ) { +pr_warn ("virtio-fs: invalid error value (%d)\n" , oh->error); +return false; + } + +if (oh->error) { +if (len !=sizeof (*oh)) { +pr_warn ("virtio-fs: error response too long (%u)\n" , len); +return false; + } +return true; + } + + expected =sizeof (*oh) + +fuse_len_args (args->out_numargs, args->out_args); +if (len > expected || + (len < expected && + (!args->out_argvar || + expected - len > args->out_args[args->out_numargs -1 ].size))) { +pr_warn ("virtio-fs: invalid response length (%u, expected %u)\n" , + len, expected); +return false; + }return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1071/2214 mm/memory: constrain generic_access_phys() to page boundary
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luxiao Xu <[email protected]>
[ Upstream commit ae0298a5fbeff32951c0d31398ccec97ec6aa0ea ]
This patch addresses an issue in generic_access_phys() where accessing memory across page boundaries in PFNMAP VMAs assumes physical pages are contiguous, which can lead to accessing unintended physical memory or exceeding VMA boundaries.
generic_access_phys() improperly validates the memory access range: it only validates the start address using follow_pfnmap_start() and passes PAGE_ALIGN(len + offset) to ioremap_prot().
This poses two problems:
1. In PFNMAP VMAs, consecutive virtual pages are not guaranteed to be physically contiguous, and individual PTEs may have different access permissions or writability.
2. The mapping may cross VMA boundaries if len extends beyond vma->vm_end.
Constrain the access in generic_access_phys() to at most the current page boundary (PAGE_SIZE - offset) and map only a single PAGE_SIZE via ioremap_prot(). Since the caller __access_remote_vm() already loops over the requested length and handles partial transfers, it will naturally iterate over the remaining pages.
Also add a missing (resource_size_t) cast during PFN re-validation to avoid truncation on 32-bit PAE systems.
--- mm/memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
mm/memory.c +7 -1
@@ -5159,6 +5159,12 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,if (!(vma->vm_flags & (VM_IO |VM_PFNMAP )))return -EINVAL ; +/* +* Limit access to one page at a time, as that's what follow_pte() +* guarantees; expect the caller to retry to read larger ranges. +*/ + len =min_t (int, len,PAGE_SIZE - offset); + retry:if (follow_pte (vma->vm_mm, addr, &ptep, &ptl))return -EINVAL ;
@@ -5184,7 +5190,7 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,if ((write &FOLL_WRITE ) && !pte_write (pte))return -EINVAL ; - maddr =ioremap_prot (phys_addr,PAGE_ALIGN (len + offset), prot); + maddr =ioremap_prot (phys_addr,PAGE_SIZE , prot);if (!maddr)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1072/2214 mptcp: fix MP_CAPABLE token migration when cloning reqsk
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruide Cao <[email protected]>
[ Upstream commit 2093bc7fa50056fef8620d2b82bcb2e9a0a5575d ]
TCP request migration clones pending request sockets with inet_reqsk_clone(). For MPTCP MP_CAPABLE requests this byte-copies the token_node hlist state into the clone even though the token table still names the original request, and the following warning can be seen:
WARNING: net/mptcp/token.c:364 at mptcp_token_destroy_request+0x2b0/0x330, CPU#2: swapper/2/0 CPU: 2 UID: 0 PID: 0 Comm: swapper/2 Not tainted 7.2.0-rc5-00353-gc27e36054537 #10 PREEMPT(full) RIP: 0010:mptcp_token_destroy_request (net/mptcp/token.c:364 (discriminator 1)) Call Trace: <IRQ> subflow_v4_req_destructor (net/mptcp/subflow.c:694) __reqsk_free (net/ipv4/inet_connection_sock.c:906) reqsk_timer_handler (include/net/request_sock.h:137 net/ipv4/inet_connection_sock.c:1147) call_timer_fn (kernel/time/timer.c:1748)
Move token request ownership from the original request to the clone under the token bucket lock. Make mptcp_token_accept() and mptcp_token_destroy_request() re-check token_node under the same lock and treat an already moved or removed request as a normal race instead of warning. This also keeps token bucket chain_len accounting balanced.
If a passive MP_CAPABLE socket cannot claim the token, destroy the provisional MPTCP socket and let the subflow fall back rather than installing a socket with mismatched token ownership. Mark that path as a passive handshake fallback so MPCapableFallbackACK records the downgrade.
If the speculative clone later loses the inet_ehash_insert() ownership arbitration, the original request may find that its token was already moved and fall back to plain TCP. The clone destructor then releases the token reservation and keeps chain_len balanced. This trades an exceptionally rare fallback for eliminating the warning and persistent accounting drift.
--- net/mptcp/protocol.h | 4 ++- net/mptcp/subflow.c | 10 ++++++- net/mptcp/token.c | 65 ++++++++++++++++++++++++++++++++++++++---- net/mptcp/token_test.c | 4 +-- 4 files changed, 73 insertions(+), 10 deletions(-)
net/mptcp/protocol.h +3 -1
@@ -712,9 +712,11 @@ static inline void mptcp_token_init_request(struct request_sock *req) }int mptcp_token_new_request (struct request_sock *req); +void mptcp_token_move_request (struct request_sock *req, +struct request_sock *new_req);void mptcp_token_destroy_request (struct request_sock *req);int mptcp_token_new_connect (struct sock *sk); -void mptcp_token_accept (struct mptcp_subflow_request_sock *r, +bool mptcp_token_accept (struct mptcp_subflow_request_sock *r,struct mptcp_sock *msk);bool mptcp_token_exists (u32 token);struct mptcp_sock *mptcp_token_get_sock (struct net *net,u32 token);
net/mptcp/subflow.c +9 -1
@@ -81,6 +81,8 @@ void mptcp_subflow_reqsk_clone(struct request_sock *req, } new_subflow_req->msk = msk; + +mptcp_token_move_request (req, new_req); } static void subflow_generate_hmac(u64 key1, u64 key2, u32 nonce1, u32 nonce2,
@@ -779,6 +781,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, goto dispose_child; } +fallback:if (fallback)SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK );
@@ -803,13 +806,18 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,if (mp_opt.deny_join_id0)WRITE_ONCE (mptcp_sk (new_msk)->pm.remote_deny_join_id0, true); +if (!mptcp_token_accept (subflow_req,mptcp_sk (new_msk))) { +WRITE_ONCE (mptcp_sk (new_msk)->first,NULL ); + fallback = true; + goto fallback; + } +/* new mpc subflow takes ownership of the newly * created mptcp socket */ new_msk->sk_destruct = mptcp_sock_destruct;mptcp_sk (new_msk)->setsockopt_seq = ctx->setsockopt_seq;mptcp_pm_new_connection (mptcp_sk (new_msk), child,1 ); -mptcp_token_accept (subflow_req,mptcp_sk (new_msk)); ctx->conn = new_msk; new_msk =NULL ;
net/mptcp/token.c +59 -6
103 lines not on this page · raw message
net/mptcp/token_test.c +2 -2
@@ -91,7 +91,7 @@ static void mptcp_token_test_accept(struct kunit *test)KUNIT_ASSERT_EQ (test,0 ,mptcp_token_new_request ((struct request_sock *)req)); msk->token = req->token; -mptcp_token_accept (req, msk); +KUNIT_EXPECT_TRUE (test,mptcp_token_accept (req, msk));KUNIT_EXPECT_PTR_EQ (test, msk,mptcp_token_get_sock (&init_net, msk->token));/* this is now a no-op */
@@ -114,7 +114,7 @@ static void mptcp_token_test_destroyed(struct kunit *test)KUNIT_ASSERT_EQ (test,0 ,mptcp_token_new_request ((struct request_sock *)req)); msk->token = req->token; -mptcp_token_accept (req, msk); +KUNIT_EXPECT_TRUE (test,mptcp_token_accept (req, msk));/* simulate race on removal */ refcount_set (&sk->sk_refcnt,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1073/2214 irqchip/imx-intmux: Convert to platform_driver::remove_new() callback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 984e5c7b8d7bac9efd3818e06dcf1f7aab7701b2 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: b167c1a30e9e ("irqchip/imx-intmux: Fix runtime PM teardown on remove")
--- drivers/irqchip/irq-imx-intmux.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/irqchip/irq-imx-intmux.c +6 -8
@@ -283,7 +283,7 @@ static int imx_intmux_probe(struct platform_device *pdev)return ret; } -static int imx_intmux_remove (struct platform_device *pdev) +static void imx_intmux_remove (struct platform_device *pdev) {struct intmux_data *data =platform_get_drvdata (pdev);int i;
@@ -299,8 +299,6 @@ static int imx_intmux_remove(struct platform_device *pdev) }pm_runtime_disable (&pdev->dev); - -return 0 ; }#ifdef CONFIG_PM
@@ -355,11 +353,11 @@ static const struct of_device_id imx_intmux_id[] = {static struct platform_driver imx_intmux_driver = { .driver = { - .name ="imx-intmux" , - .of_match_table = imx_intmux_id, - .pm = &imx_intmux_pm_ops, + .name ="imx-intmux" , + .of_match_table = imx_intmux_id, + .pm = &imx_intmux_pm_ops, }, - .probe = imx_intmux_probe, - .remove = imx_intmux_remove, + .probe = imx_intmux_probe, + .remove_new = imx_intmux_remove, };builtin_platform_driver (imx_intmux_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1074/2214 irqchip/imx-intmux: Fix runtime PM teardown on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit b167c1a30e9e020e4c5e102c7a555943742c024b ]
imx_intmux_probe() enables the IPG clock and then drops its runtime PM reference with pm_runtime_put(). With CONFIG_PM enabled, the runtime suspend callback disables the IPG clock. With CONFIG_PM disabled, the clock remains enabled after probe.
imx_intmux_remove() accesses the CHANIER registers without first making sure that the device is runtime active. The device may therefore be runtime suspended with the IPG clock disabled when these registers are accessed. In addition, the remove path only calls pm_runtime_disable() and does not balance the clock enable when CONFIG_PM is disabled.
Resume the device and acquire a runtime PM reference before accessing the registers. If resume fails, skip the register accesses but still tear down the chained handlers and IRQ domains. Disable runtime PM afterwards, drop the acquired reference without triggering another runtime suspend, and explicitly disable the IPG clock.
This keeps the clock enabled while the hardware registers are accessed and balances the clk_prepare_enable() performed during probe for both CONFIG_PM configurations.
This issue was found by manual code inspection.
--- drivers/irqchip/irq-imx-intmux.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/irqchip/irq-imx-intmux.c +12 -3
@@ -286,12 +286,16 @@ static int imx_intmux_probe(struct platform_device *pdev)static void imx_intmux_remove (struct platform_device *pdev) {struct intmux_data *data =platform_get_drvdata (pdev); -int i; +int i, ret; + + ret =pm_runtime_resume_and_get (&pdev->dev); +if (ret <0 ) +dev_warn (&pdev->dev,"failed to resume device: %d\n" , ret);for (i =0 ; i < data->channum; i++) {/* disable all interrupt sources of this channel */ -writel_relaxed (0 , data->regs +CHANIER (i)); - +if (ret >=0 ) +writel_relaxed (0 , data->regs +CHANIER (i));irq_set_chained_handler_and_data (data->irqchip_data[i].irq,NULL ,NULL );
@@ -299,6 +303,11 @@ static void imx_intmux_remove(struct platform_device *pdev) }pm_runtime_disable (&pdev->dev); +if (ret >=0 ) { +pm_runtime_put_noidle (&pdev->dev); +clk_disable_unprepare (data->ipg_clk); +pm_runtime_set_suspended (&pdev->dev); + } }#ifdef CONFIG_PM
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1075/2214 xen/pcifront: Drop pcifront_common_process() tests of pcidev, pdrv
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 34ab316d7287692bad41ce4a431b43d60a8bd20f ]
pcifront_common_process() exits early if pcidev or pcidev->driver are NULL, so simplify it by not checking them again.
Stable-dep-of: 3b4854b69ee7 ("xen/pcifront: check that an AER callback exists before calling it")
--- drivers/pci/xen-pcifront.c | 52 +++++++++++++------------------------- 1 file changed, 17 insertions(+), 35 deletions(-)
drivers/pci/xen-pcifront.c +17 -35
@@ -588,61 +588,43 @@ static pci_ers_result_t pcifront_common_process(int cmd, struct pcifront_device *pdev, pci_channel_state_t state) { -pci_ers_result_t result;struct pci_driver *pdrv;int bus = pdev->sh_info->aer_op.bus;int devfn = pdev->sh_info->aer_op.devfn;int domain = pdev->sh_info->aer_op.domain;struct pci_dev *pcidev; -int flag =0 ;dev_dbg (&pdev->xdev->dev,"pcifront AER process: cmd %x (bus:%x, devfn%x)" , cmd, bus, devfn); - result =PCI_ERS_RESULT_NONE ; pcidev =pci_get_domain_bus_and_slot (domain, bus, devfn);if (!pcidev || !pcidev->driver) {dev_err (&pdev->xdev->dev,"device or AER driver is NULL\n" );pci_dev_put (pcidev); -return result; +return PCI_ERS_RESULT_NONE ; } pdrv = pcidev->driver; -if (pdrv) { -if (pdrv->err_handler && pdrv->err_handler->error_detected) { -pci_dbg (pcidev,"trying to call AER service\n" ); -if (pcidev) { - flag =1 ; -switch (cmd) { -case XEN_PCI_OP_aer_detected: - result = pdrv->err_handler-> -error_detected (pcidev, state); -break ; -case XEN_PCI_OP_aer_mmio: - result = pdrv->err_handler-> -mmio_enabled (pcidev); -break ; -case XEN_PCI_OP_aer_slotreset: - result = pdrv->err_handler-> -slot_reset (pcidev); -break ; -case XEN_PCI_OP_aer_resume: - pdrv->err_handler->resume (pcidev); -break ; -default : -dev_err (&pdev->xdev->dev, -"bad request in aer recovery " -"operation!\n" ); - - } - } +if (pdrv->err_handler && pdrv->err_handler->error_detected) { +pci_dbg (pcidev,"trying to call AER service\n" ); +switch (cmd) { +case XEN_PCI_OP_aer_detected: +return pdrv->err_handler->error_detected (pcidev, state); +case XEN_PCI_OP_aer_mmio: +return pdrv->err_handler->mmio_enabled (pcidev); +case XEN_PCI_OP_aer_slotreset: +return pdrv->err_handler->slot_reset (pcidev); +case XEN_PCI_OP_aer_resume: + pdrv->err_handler->resume (pcidev); +return PCI_ERS_RESULT_NONE ; +default : +dev_err (&pdev->xdev->dev, +"bad request in aer recovery operation!\n" ); } } -if (!flag) - result =PCI_ERS_RESULT_NONE ; -return result; +return PCI_ERS_RESULT_NONE ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1076/2214 xen/pcifront: check that an AER callback exists before calling it
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit 3b4854b69ee70fffb2fa7acac09e715a7efcbae1 ]
pcifront_common_process() handles an AER request from the backend by dispatching on aer_op.cmd to the bound driver's PCI error handler. It only checks that err_handler and err_handler->error_detected are present, then for the mmio_enabled, slot_reset and resume commands it calls the corresponding callback unconditionally. Those three callbacks are optional -- the PCI core NULL-checks each of them individually before use -- and many drivers (for example igb, igc, ice and ixgbevf) install error_detected without all of them.
aer_op.cmd comes from the shared ring, so a malicious or buggy backend can send XEN_PCI_OP_aer_mmio (or _slotreset/_resume) for a device whose driver leaves that callback NULL and make the frontend call through a NULL pointer, crashing the guest.
Check each callback before calling it. When mmio_enabled or slot_reset is absent, return PCI_ERS_RESULT_RECOVERED so recovery proceeds, as the PCI core does for a missing callback; returning PCI_ERS_RESULT_NONE would instead make xen-pciback tear the guest domain down.
Message-ID: <[email protected]>
--- drivers/pci/xen-pcifront.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/pci/xen-pcifront.c +8 -3
@@ -612,11 +612,16 @@ static pci_ers_result_t pcifront_common_process(int cmd,case XEN_PCI_OP_aer_detected:return pdrv->err_handler->error_detected (pcidev, state);case XEN_PCI_OP_aer_mmio: -return pdrv->err_handler->mmio_enabled (pcidev); +if (pdrv->err_handler->mmio_enabled) +return pdrv->err_handler->mmio_enabled (pcidev); +return PCI_ERS_RESULT_RECOVERED ;case XEN_PCI_OP_aer_slotreset: -return pdrv->err_handler->slot_reset (pcidev); +if (pdrv->err_handler->slot_reset) +return pdrv->err_handler->slot_reset (pcidev); +return PCI_ERS_RESULT_RECOVERED ;case XEN_PCI_OP_aer_resume: - pdrv->err_handler->resume (pcidev); +if (pdrv->err_handler->resume) + pdrv->err_handler->resume (pcidev);return PCI_ERS_RESULT_NONE ;default : dev_err(&pdev->xdev->dev,
Signature · 1 line
2.53.0