Skip to content
  1. Sep 03, 2021
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Fix dwc3_calc_trbs_left() · 24749050
      Thinh Nguyen authored
      commit 51f1954a upstream.
      
      We can't depend on the TRB's HWO bit to determine if the TRB ring is
      "full". A TRB is only available when the driver had processed it, not
      when the controller consumed and relinquished the TRB's ownership to the
      driver. Otherwise, the driver may overwrite unprocessed TRBs. This can
      happen when many transfer events accumulate and the system is slow to
      process them and/or when there are too many small requests.
      
      If a request is in the started_list, that means there is one or more
      unprocessed TRBs remained. Check this instead of the TRB's HWO bit
      whether the TRB ring is full.
      
      Fixes: c4233573
      
       ("usb: dwc3: gadget: prepare TRBs on update transfers too")
      Cc: <stable@vger.kernel.org>
      Acked-by: default avatarFelipe Balbi <balbi@kernel.org>
      Signed-off-by: default avatarThinh Nguyen <Thinh.Nguyen@synopsys.com>
      Link: https://lore.kernel.org/r/e91e975affb0d0d02770686afc3a5b9eb84409f6.1629335416.git.Thinh.Nguyen@synopsys.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      24749050
    • Zhengjun Zhang's avatar
      USB: serial: option: add new VID/PID to support Fibocom FG150 · 13078d2d
      Zhengjun Zhang authored
      commit 2829a4e3
      
       upstream.
      
      Fibocom FG150 is a 5G module based on Qualcomm SDX55 platform,
      support Sub-6G band.
      
      Here are the outputs of lsusb -v and usb-devices:
      
      > T:  Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=5000 MxCh= 0
      > D:  Ver= 3.20 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
      > P:  Vendor=2cb7 ProdID=010b Rev=04.14
      > S:  Manufacturer=Fibocom
      > S:  Product=Fibocom Modem_SN:XXXXXXXX
      > S:  SerialNumber=XXXXXXXX
      > C:  #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=896mA
      > I:  If#=0x0 Alt= 0 #EPs= 1 Cls=ef(misc ) Sub=04 Prot=01 Driver=rndis_host
      > I:  If#=0x1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=rndis_host
      > I:  If#=0x2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
      > I:  If#=0x3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=(none)
      > I:  If#=0x4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none)
      
      > Bus 002 Device 002: ID 2cb7:010b Fibocom Fibocom Modem_SN:XXXXXXXX
      > Device Descriptor:
      >   bLength                18
      >   bDescriptorType         1
      >   bcdUSB               3.20
      >   bDeviceClass            0
      >   bDeviceSubClass         0
      >   bDeviceProtocol         0
      >   bMaxPacketSize0         9
      >   idVendor           0x2cb7 Fibocom
      >   idProduct          0x010b
      >   bcdDevice            4.14
      >   iManufacturer           1 Fibocom
      >   iProduct                2 Fibocom Modem_SN:XXXXXXXX
      >   iSerial                 3 XXXXXXXX
      >   bNumConfigurations      1
      >   Configuration Descriptor:
      >     bLength                 9
      >     bDescriptorType         2
      >     wTotalLength       0x00e6
      >     bNumInterfaces          5
      >     bConfigurationValue     1
      >     iConfiguration          4 RNDIS_DUN_DIAG_ADB
      >     bmAttributes         0xa0
      >       (Bus Powered)
      >       Remote Wakeup
      >     MaxPower              896mA
      >     Interface Association:
      >       bLength                 8
      >       bDescriptorType        11
      >       bFirstInterface         0
      >       bInterfaceCount         2
      >       bFunctionClass        239 Miscellaneous Device
      >       bFunctionSubClass       4
      >       bFunctionProtocol       1
      >       iFunction               7 RNDIS
      >     Interface Descriptor:
      >       bLength                 9
      >       bDescriptorType         4
      >       bInterfaceNumber        0
      >       bAlternateSetting       0
      >       bNumEndpoints           1
      >       bInterfaceClass       239 Miscellaneous Device
      >       bInterfaceSubClass      4
      >       bInterfaceProtocol      1
      >       iInterface              0
      >       ** UNRECOGNIZED:  05 24 00 10 01
      >       ** UNRECOGNIZED:  05 24 01 00 01
      >       ** UNRECOGNIZED:  04 24 02 00
      >       ** UNRECOGNIZED:  05 24 06 00 01
      >       Endpoint Descriptor:
      >         bLength                 7
      >         bDescriptorType         5
      >         bEndpointAddress     0x81  EP 1 IN
      >         bmAttributes            3
      >           Transfer Type            Interrupt
      >           Synch Type               None
      >           Usage Type               Data
      >         wMaxPacketSize     0x0008  1x 8 bytes
      >         bInterval               9
      >         bMaxBurst               0
      >     Interface Descriptor:
      >       bLength                 9
      >       bDescriptorType         4
      >       bInterfaceNumber        1
      >       bAlternateSetting       0
      >       bNumEndpoints           2
      >       bInterfaceClass        10 CDC Data
      >       bInterfaceSubClass      0
      >       bInterfaceProtocol      0
      >       iInterface              0
      >       Endpoint Descriptor:
      >         bLength                 7
      >         bDescriptorType         5
      >         bEndpointAddress     0x8e  EP 14 IN
      >         bmAttributes            2
      >           Transfer Type            Bulk
      >           Synch Type               None
      >           Usage Type               Data
      >         wMaxPacketSize     0x0400  1x 1024 bytes
      >         bInterval               0
      >         bMaxBurst               6
      >       Endpoint Descriptor:
      >         bLength                 7
      >         bDescriptorType         5
      >         bEndpointAddress     0x0f  EP 15 OUT
      >         bmAttributes            2
      >           Transfer Type            Bulk
      >           Synch Type               None
      >           Usage Type               Data
      >         wMaxPacketSize     0x0400  1x 1024 bytes
      >         bInterval               0
      >         bMaxBurst               6
      >     Interface Descriptor:
      >       bLength                 9
      >       bDescriptorType         4
      >       bInterfaceNumber        2
      >       bAlternateSetting       0
      >       bNumEndpoints           3
      >       bInterfaceClass       255 Vendor Specific Class
      >       bInterfaceSubClass      0
      >       bInterfaceProtocol      0
      >       iInterface              0
      >       ** UNRECOGNIZED:  05 24 00 10 01
      >       ** UNRECOGNIZED:  05 24 01 00 00
      >       ** UNRECOGNIZED:  04 24 02 02
      >       ** UNRECOGNIZED:  05 24 06 00 00
      >       Endpoint Descriptor:
      >         bLength                 7
      >         bDescriptorType         5
      >         bEndpointAddress     0x83  EP 3 IN
      >         bmAttributes            3
      >           Transfer Type            Interrupt
      >           Synch Type               None
      >           Usage Type               Data
      >         wMaxPacketSize     0x000a  1x 10 bytes
      >         bInterval               9
      >         bMaxBurst               0
      >       Endpoint Descriptor:
      >         bLength                 7
      >         bDescriptorType         5
      >         bEndpointAddress     0x82  EP 2 IN
      >         bmAttributes            2
      >           Transfer Type            Bulk
      >           Synch Type               None
      >           Usage Type               Data
      >         wMaxPacketSize     0x0400  1x 1024 bytes
      >         bInterval               0
      >         bMaxBurst               0
      >       Endpoint Descriptor:
      >         bLength                 7
      >         bDescriptorType         5
      >         bEndpointAddress     0x01  EP 1 OUT
      >         bmAttributes            2
      >           Transfer Type            Bulk
      >           Synch Type               None
      >           Usage Type               Data
      >         wMaxPacketSize     0x0400  1x 1024 bytes
      >         bInterval               0
      >         bMaxBurst               0
      >     Interface Descriptor:
      >       bLength                 9
      >       bDescriptorType         4
      >       bInterfaceNumber        3
      >       bAlternateSetting       0
      >       bNumEndpoints           2
      >       bInterfaceClass       255 Vendor Specific Class
      >       bInterfaceSubClass    255 Vendor Specific Subclass
      >       bInterfaceProtocol     48
      >       iInterface              0
      >       Endpoint Descriptor:
      >         bLength                 7
      >         bDescriptorType         5
      >         bEndpointAddress     0x84  EP 4 IN
      >         bmAttributes            2
      >           Transfer Type            Bulk
      >           Synch Type               None
      >           Usage Type               Data
      >         wMaxPacketSize     0x0400  1x 1024 bytes
      >         bInterval               0
      >         bMaxBurst               0
      >       Endpoint Descriptor:
      >         bLength                 7
      >         bDescriptorType         5
      >         bEndpointAddress     0x02  EP 2 OUT
      >         bmAttributes            2
      >           Transfer Type            Bulk
      >           Synch Type               None
      >           Usage Type               Data
      >         wMaxPacketSize     0x0400  1x 1024 bytes
      >         bInterval               0
      >         bMaxBurst               0
      >     Interface Descriptor:
      >       bLength                 9
      >       bDescriptorType         4
      >       bInterfaceNumber        4
      >       bAlternateSetting       0
      >       bNumEndpoints           2
      >       bInterfaceClass       255 Vendor Specific Class
      >       bInterfaceSubClass     66
      >       bInterfaceProtocol      1
      >       iInterface              0
      >       Endpoint Descriptor:
      >         bLength                 7
      >         bDescriptorType         5
      >         bEndpointAddress     0x03  EP 3 OUT
      >         bmAttributes            2
      >           Transfer Type            Bulk
      >           Synch Type               None
      >           Usage Type               Data
      >         wMaxPacketSize     0x0400  1x 1024 bytes
      >         bInterval               0
      >         bMaxBurst               0
      >       Endpoint Descriptor:
      >         bLength                 7
      >         bDescriptorType         5
      >         bEndpointAddress     0x85  EP 5 IN
      >         bmAttributes            2
      >           Transfer Type            Bulk
      >           Synch Type               None
      >           Usage Type               Data
      >         wMaxPacketSize     0x0400  1x 1024 bytes
      >         bInterval               0
      >         bMaxBurst               0
      > Binary Object Store Descriptor:
      >   bLength                 5
      >   bDescriptorType        15
      >   wTotalLength       0x0016
      >   bNumDeviceCaps          2
      >   USB 2.0 Extension Device Capability:
      >     bLength                 7
      >     bDescriptorType        16
      >     bDevCapabilityType      2
      >     bmAttributes   0x00000006
      >       BESL Link Power Management (LPM) Supported
      >   SuperSpeed USB Device Capability:
      >     bLength                10
      >     bDescriptorType        16
      >     bDevCapabilityType      3
      >     bmAttributes         0x00
      >     wSpeedsSupported   0x000f
      >       Device can operate at Low Speed (1Mbps)
      >       Device can operate at Full Speed (12Mbps)
      >       Device can operate at High Speed (480Mbps)
      >       Device can operate at SuperSpeed (5Gbps)
      >     bFunctionalitySupport   1
      >       Lowest fully-functional device speed is Full Speed (12Mbps)
      >     bU1DevExitLat           1 micro seconds
      >     bU2DevExitLat         500 micro seconds
      > Device Status:     0x0000
      >   (Bus Powered)
      
      Signed-off-by: default avatarZhengjun Zhang <zhangzhengjun@aicrobo.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      13078d2d
    • Johan Hovold's avatar
      Revert "USB: serial: ch341: fix character loss at high transfer rates" · 86363c32
      Johan Hovold authored
      commit df7b16d1 upstream.
      
      This reverts commit 3c18e9ba
      
      .
      
      These devices do not appear to send a zero-length packet when the
      transfer size is a multiple of the bulk-endpoint max-packet size. This
      means that incoming data may not be processed by the driver until a
      short packet is received or the receive buffer is full.
      
      Revert back to using endpoint-sized receive buffers to avoid stalled
      reads.
      
      Reported-by: default avatarPaul Größel <pb.g@gmx.de>
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=214131
      Fixes: 3c18e9ba
      
       ("USB: serial: ch341: fix character loss at high transfer rates")
      Cc: stable@vger.kernel.org
      Cc: Willy Tarreau <w@1wt.eu>
      Link: https://lore.kernel.org/r/20210824121926.19311-1-johan@kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86363c32
    • Stefan Mätje's avatar
      can: usb: esd_usb2: esd_usb2_rx_event(): fix the interchange of the CAN RX and TX error counters · 251b1f1e
      Stefan Mätje authored
      commit 044012b5 upstream.
      
      This patch fixes the interchanged fetch of the CAN RX and TX error
      counters from the ESD_EV_CAN_ERROR_EXT message. The RX error counter
      is really in struct rx_msg::data[2] and the TX error counter is in
      struct rx_msg::data[3].
      
      Fixes: 96d8e903
      
       ("can: Add driver for esd CAN-USB/2 device")
      Link: https://lore.kernel.org/r/20210825215227.4947-2-stefan.maetje@esd.eu
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarStefan Mätje <stefan.maetje@esd.eu>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      251b1f1e
    • Guenter Roeck's avatar
      ARC: Fix CONFIG_STACKDEPOT · c1635eff
      Guenter Roeck authored
      [ Upstream commit bf79167f
      
       ]
      
      Enabling CONFIG_STACKDEPOT results in the following build error.
      
      arc-elf-ld: lib/stackdepot.o: in function `filter_irq_stacks':
      stackdepot.c:(.text+0x456): undefined reference to `__irqentry_text_start'
      arc-elf-ld: stackdepot.c:(.text+0x456): undefined reference to `__irqentry_text_start'
      arc-elf-ld: stackdepot.c:(.text+0x476): undefined reference to `__irqentry_text_end'
      arc-elf-ld: stackdepot.c:(.text+0x476): undefined reference to `__irqentry_text_end'
      arc-elf-ld: stackdepot.c:(.text+0x484): undefined reference to `__softirqentry_text_start'
      arc-elf-ld: stackdepot.c:(.text+0x484): undefined reference to `__softirqentry_text_start'
      arc-elf-ld: stackdepot.c:(.text+0x48c): undefined reference to `__softirqentry_text_end'
      arc-elf-ld: stackdepot.c:(.text+0x48c): undefined reference to `__softirqentry_text_end'
      
      Other architectures address this problem by adding IRQENTRY_TEXT and
      SOFTIRQENTRY_TEXT to the text segment, so do the same here.
      
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c1635eff
  2. Aug 26, 2021
    • Sasha Levin's avatar
    • Sergey Marinkevich's avatar
      netfilter: nft_exthdr: fix endianness of tcp option cast · 41e34d65
      Sergey Marinkevich authored
      [ Upstream commit 2e34328b
      
       ]
      
      I got a problem on MIPS with Big-Endian is turned on: every time when
      NF trying to change TCP MSS it returns because of new.v16 was greater
      than old.v16. But real MSS was 1460 and my rule was like this:
      
      	add rule table chain tcp option maxseg size set 1400
      
      And 1400 is lesser that 1460, not greater.
      
      Later I founded that main causer is cast from u32 to __be16.
      
      Debugging:
      
      In example MSS = 1400(HEX: 0x578). Here is representation of each byte
      like it is in memory by addresses from left to right(e.g. [0x0 0x1 0x2
      0x3]). LE — Little-Endian system, BE — Big-Endian, left column is type.
      
      	     LE               BE
      	u32: [78 05 00 00]    [00 00 05 78]
      
      As you can see, u32 representation will be casted to u16 from different
      half of 4-byte address range. But actually nf_tables uses registers and
      store data of various size. Actually TCP MSS stored in 2 bytes. But
      registers are still u32 in definition:
      
      	struct nft_regs {
      		union {
      			u32			data[20];
      			struct nft_verdict	verdict;
      		};
      	};
      
      So, access like regs->data[priv->sreg] exactly u32. So, according to
      table presents above, per-byte representation of stored TCP MSS in
      register will be:
      
      	                     LE               BE
      	(u32)regs->data[]:   [78 05 00 00]    [05 78 00 00]
      	                                       ^^ ^^
      
      We see that register uses just half of u32 and other 2 bytes may be
      used for some another data. But in nft_exthdr_tcp_set_eval() it casted
      just like u32 -> __be16:
      
      	new.v16 = src
      
      But u32 overfill __be16, so it get 2 low bytes. For clarity draw
      one more table(<xx xx> means that bytes will be used for cast).
      
      	                     LE                 BE
      	u32:                 [<78 05> 00 00]    [00 00 <05 78>]
      	(u32)regs->data[]:   [<78 05> 00 00]    [05 78 <00 00>]
      
      As you can see, for Little-Endian nothing changes, but for Big-endian we
      take the wrong half. In my case there is some other data instead of
      zeros, so new MSS was wrongly greater.
      
      For shooting this bug I used solution for ports ranges. Applying of this
      patch does not affect Little-Endian systems.
      
      Signed-off-by: default avatarSergey Marinkevich <sergey.marinkevich@eltex-co.ru>
      Acked-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      41e34d65
    • Jeff Layton's avatar
      fs: warn about impending deprecation of mandatory locks · 74ea7ece
      Jeff Layton authored
      [ Upstream commit fdd92b64
      
       ]
      
      We've had CONFIG_MANDATORY_FILE_LOCKING since 2015 and a lot of distros
      have disabled it. Warn the stragglers that still use "-o mand" that
      we'll be dropping support for that mount option.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      74ea7ece
    • Jeff Layton's avatar
      locks: print a warning when mount fails due to lack of "mand" support · 65c8fef2
      Jeff Layton authored
      [ Upstream commit df2474a2 ]
      
      Since 9e8925b6
      
       ("locks: Allow disabling mandatory locking at compile
      time"), attempts to mount filesystems with "-o mand" will fail.
      Unfortunately, there is no other indiciation of the reason for the
      failure.
      
      Change how the function is defined for better readability. When
      CONFIG_MANDATORY_FILE_LOCKING is disabled, printk a warning when
      someone attempts to mount with -o mand.
      
      Also, add a blurb to the mandatory-locking.txt file to explain about
      the "mand" option, and the behavior one should expect when it is
      disabled.
      
      Reported-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      65c8fef2
    • Takashi Iwai's avatar
      ASoC: intel: atom: Fix breakage for PCM buffer address setup · 846b0dc7
      Takashi Iwai authored
      [ Upstream commit 65ca89c2 ]
      
      The commit 2e6b8363 ("ASoC: intel: atom: Fix reference to PCM
      buffer address") changed the reference of PCM buffer address to
      substream->runtime->dma_addr as the buffer address may change
      dynamically.  However, I forgot that the dma_addr field is still not
      set up for the CONTINUOUS buffer type (that this driver uses) yet in
      5.14 and earlier kernels, and it resulted in garbage I/O.  The problem
      will be fixed in 5.15, but we need to address it quickly for now.
      
      The fix is to deduce the address again from the DMA pointer with
      virt_to_phys(), but from the right one, substream->runtime->dma_area.
      
      Fixes: 2e6b8363
      
       ("ASoC: intel: atom: Fix reference to PCM buffer address")
      Reported-and-tested-by: default avatarHans de Goede <hdegoede@redhat.com>
      Cc: <stable@vger.kernel.org>
      Acked-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/2048c6aa-2187-46bd-6772-36a4fb3c5aeb@redhat.com
      Link: https://lore.kernel.org/r/20210819152945.8510-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      846b0dc7
    • NeilBrown's avatar
      btrfs: prevent rename2 from exchanging a subvol with a directory from different parents · 585015c1
      NeilBrown authored
      [ Upstream commit 3f79f6f6 ]
      
      Cross-rename lacks a check when that would prevent exchanging a
      directory and subvolume from different parent subvolume. This causes
      data inconsistencies and is caught before commit by tree-checker,
      turning the filesystem to read-only.
      
      Calling the renameat2 with RENAME_EXCHANGE flags like
      
        renameat2(AT_FDCWD, namesrc, AT_FDCWD, namedest, (1 << 1))
      
      on two paths:
      
        namesrc = dir1/subvol1/dir2
       namedest = subvol2/subvol3
      
      will cause key order problem with following write time tree-checker
      report:
      
        [1194842.307890] BTRFS critical (device loop1): corrupt leaf: root=5 block=27574272 slot=10 ino=258, invalid previous key objectid, have 257 expect 258
        [1194842.322221] BTRFS info (device loop1): leaf 27574272 gen 8 total ptrs 11 free space 15444 owner 5
        [1194842.331562] BTRFS info (device loop1): refs 2 lock_owner 0 current 26561
        [1194842.338772]        item 0 key (256 1 0) itemoff 16123 itemsize 160
        [1194842.338793]                inode generation 3 size 16 mode 40755
        [1194842.338801]        item 1 key (256 12 256) itemoff 16111 itemsize 12
        [1194842.338809]        item 2 key (256 84 2248503653) itemoff 16077 itemsize 34
        [1194842.338817]                dir oid 258 type 2
        [1194842.338823]        item 3 key (256 84 2363071922) itemoff 16043 itemsize 34
        [1194842.338830]                dir oid 257 type 2
        [1194842.338836]        item 4 key (256 96 2) itemoff 16009 itemsize 34
        [1194842.338843]        item 5 key (256 96 3) itemoff 15975 itemsize 34
        [1194842.338852]        item 6 key (257 1 0) itemoff 15815 itemsize 160
        [1194842.338863]                inode generation 6 size 8 mode 40755
        [1194842.338869]        item 7 key (257 12 256) itemoff 15801 itemsize 14
        [1194842.338876]        item 8 key (257 84 2505409169) itemoff 15767 itemsize 34
        [1194842.338883]                dir oid 256 type 2
        [1194842.338888]        item 9 key (257 96 2) itemoff 15733 itemsize 34
        [1194842.338895]        item 10 key (258 12 256) itemoff 15719 itemsize 14
        [1194842.339163] BTRFS error (device loop1): block=27574272 write time tree block corruption detected
        [1194842.339245] ------------[ cut here ]------------
        [1194842.443422] WARNING: CPU: 6 PID: 26561 at fs/btrfs/disk-io.c:449 csum_one_extent_buffer+0xed/0x100 [btrfs]
        [1194842.511863] CPU: 6 PID: 26561 Comm: kworker/u17:2 Not tainted 5.14.0-rc3-git+ #793
        [1194842.511870] Hardware name: empty empty/S3993, BIOS PAQEX0-3 02/24/2008
        [1194842.511876] Workqueue: btrfs-worker-high btrfs_work_helper [btrfs]
        [1194842.511976] RIP: 0010:csum_one_extent_buffer+0xed/0x100 [btrfs]
        [1194842.512068] RSP: 0018:ffffa2c284d77da0 EFLAGS: 00010282
        [1194842.512074] RAX: 0000000000000000 RBX: 0000000000001000 RCX: ffff928867bd9978
        [1194842.512078] RDX: 0000000000000000 RSI: 0000000000000027 RDI: ffff928867bd9970
        [1194842.512081] RBP: ffff92876b958000 R08: 0000000000000001 R09: 00000000000c0003
        [1194842.512085] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000
        [1194842.512088] R13: ffff92875f989f98 R14: 0000000000000000 R15: 0000000000000000
        [1194842.512092] FS:  0000000000000000(0000) GS:ffff928867a00000(0000) knlGS:0000000000000000
        [1194842.512095] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        [1194842.512099] CR2: 000055f5384da1f0 CR3: 0000000102fe4000 CR4: 00000000000006e0
        [1194842.512103] Call Trace:
        [1194842.512128]  ? run_one_async_free+0x10/0x10 [btrfs]
        [1194842.631729]  btree_csum_one_bio+0x1ac/0x1d0 [btrfs]
        [1194842.631837]  run_one_async_start+0x18/0x30 [btrfs]
        [1194842.631938]  btrfs_work_helper+0xd5/0x1d0 [btrfs]
        [1194842.647482]  process_one_work+0x262/0x5e0
        [1194842.647520]  worker_thread+0x4c/0x320
        [1194842.655935]  ? process_one_work+0x5e0/0x5e0
        [1194842.655946]  kthread+0x135/0x160
        [1194842.655953]  ? set_kthread_struct+0x40/0x40
        [1194842.655965]  ret_from_fork+0x1f/0x30
        [1194842.672465] irq event stamp: 1729
        [1194842.672469] hardirqs last  enabled at (1735): [<ffffffffbd1104f5>] console_trylock_spinning+0x185/0x1a0
        [1194842.672477] hardirqs last disabled at (1740): [<ffffffffbd1104cc>] console_trylock_spinning+0x15c/0x1a0
        [1194842.672482] softirqs last  enabled at (1666): [<ffffffffbdc002e1>] __do_softirq+0x2e1/0x50a
        [1194842.672491] softirqs last disabled at (1651): [<ffffffffbd08aab7>] __irq_exit_rcu+0xa7/0xd0
      
      The corrupted data will not be written, and filesystem can be unmounted
      and mounted again (all changes since the last commit will be lost).
      
      Add the missing check for new_ino so that all non-subvolumes must reside
      under the same parent subvolume. There's an exception allowing to
      exchange two subvolumes from any parents as the directory representing a
      subvolume is only a logical link and does not have any other structures
      related to the parent subvolume, unlike files, directories etc, that
      are always in the inode namespace of the parent subvolume.
      
      Fixes: cdd1fedf
      
       ("btrfs: add support for RENAME_EXCHANGE and RENAME_WHITEOUT")
      CC: stable@vger.kernel.org # 4.7+
      Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      585015c1
    • Dongliang Mu's avatar
      ipack: tpci200: fix many double free issues in tpci200_pci_probe · b06ed72c
      Dongliang Mu authored
      [ Upstream commit 57a16810 ]
      
      The function tpci200_register called by tpci200_install and
      tpci200_unregister called by tpci200_uninstall are in pair. However,
      tpci200_unregister has some cleanup operations not in the
      tpci200_register. So the error handling code of tpci200_pci_probe has
      many different double free issues.
      
      Fix this problem by moving those cleanup operations out of
      tpci200_unregister, into tpci200_pci_remove and reverting
      the previous commit 9272e5d0 ("ipack/carriers/tpci200:
      Fix a double free in tpci200_pci_probe").
      
      Fixes: 9272e5d0
      
       ("ipack/carriers/tpci200: Fix a double free in tpci200_pci_probe")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
      Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
      Link: https://lore.kernel.org/r/20210810100323.3938492-1-mudongliangabcd@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b06ed72c
    • Jaroslav Kysela's avatar
      ALSA: hda - fix the 'Capture Switch' value change notifications · ae870337
      Jaroslav Kysela authored
      [ Upstream commit a2befe93 ]
      
      The original code in the cap_put_caller() function does not
      handle correctly the positive values returned from the passed
      function for multiple iterations. It means that the change
      notifications may be lost.
      
      Fixes: 352f7f91
      
       ("ALSA: hda - Merge Realtek parser code to generic parser")
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=213851
      Cc: <stable@kernel.org>
      Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
      Link: https://lore.kernel.org/r/20210811161441.1325250-1-perex@perex.cz
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ae870337
    • Vincent Whitchurch's avatar
      mmc: dw_mmc: Fix hang on data CRC error · 1d89eecc
      Vincent Whitchurch authored
      [ Upstream commit 25f8203b
      
       ]
      
      When a Data CRC interrupt is received, the driver disables the DMA, then
      sends the stop/abort command and then waits for Data Transfer Over.
      
      However, sometimes, when a data CRC error is received in the middle of a
      multi-block write transfer, the Data Transfer Over interrupt is never
      received, and the driver hangs and never completes the request.
      
      The driver sets the BMOD.SWR bit (SDMMC_IDMAC_SWRESET) when stopping the
      DMA, but according to the manual CMD.STOP_ABORT_CMD should be programmed
      "before assertion of SWR".  Do these operations in the recommended
      order.  With this change the Data Transfer Over is always received
      correctly in my tests.
      
      Signed-off-by: default avatarVincent Whitchurch <vincent.whitchurch@axis.com>
      Reviewed-by: default avatarJaehoon Chung <jh80.chung@samsung.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210630102232.16011-1-vincent.whitchurch@axis.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1d89eecc
    • Saravana Kannan's avatar
      net: mdio-mux: Handle -EPROBE_DEFER correctly · 22c589d0
      Saravana Kannan authored
      [ Upstream commit 7bd0cef5 ]
      
      When registering mdiobus children, if we get an -EPROBE_DEFER, we shouldn't
      ignore it and continue registering the rest of the mdiobus children. This
      would permanently prevent the deferring child mdiobus from working instead
      of reattempting it in the future. So, if a child mdiobus needs to be
      reattempted in the future, defer the entire mdio-mux initialization.
      
      This fixes the issue where PHYs sitting under the mdio-mux aren't
      initialized correctly if the PHY's interrupt controller is not yet ready
      when the mdio-mux is being probed. Additional context in the link below.
      
      Fixes: 0ca2997d
      
       ("netdev/of/phy: Add MDIO bus multiplexer support.")
      Link: https://lore.kernel.org/lkml/CAGETcx95kHrv8wA-O+-JtfH7H9biJEGJtijuPVN0V5dUKUAB3A@mail.gmail.com/#t
      Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Acked-by: default avatarMarc Zyngier <maz@kernel.org>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Acked-by: default avatarKevin Hilman <khilman@baylibre.com>
      Tested-by: default avatarKevin Hilman <khilman@baylibre.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      22c589d0
    • Saravana Kannan's avatar
      net: mdio-mux: Don't ignore memory allocation errors · 1757014d
      Saravana Kannan authored
      [ Upstream commit 99d81e94 ]
      
      If we are seeing memory allocation errors, don't try to continue
      registering child mdiobus devices. It's unlikely they'll succeed.
      
      Fixes: 342fa196
      
       ("mdio: mux: make child bus walking more permissive and errors more verbose")
      Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Acked-by: default avatarMarc Zyngier <maz@kernel.org>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Acked-by: default avatarKevin Hilman <khilman@baylibre.com>
      Tested-by: default avatarKevin Hilman <khilman@baylibre.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1757014d
    • Dinghao Liu's avatar
      net: qlcnic: add missed unlock in qlcnic_83xx_flash_read32 · 3e5f9833
      Dinghao Liu authored
      [ Upstream commit 0a298d13 ]
      
      qlcnic_83xx_unlock_flash() is called on all paths after we call
      qlcnic_83xx_lock_flash(), except for one error path on failure
      of QLCRD32(), which may cause a deadlock. This bug is suggested
      by a static analysis tool, please advise.
      
      Fixes: 81d0aeb0
      
       ("qlcnic: flash template based firmware reset recovery")
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Link: https://lore.kernel.org/r/20210816131405.24024-1-dinghao.liu@zju.edu.cn
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3e5f9833
    • Andy Shevchenko's avatar
      ptp_pch: Restore dependency on PCI · c075da32
      Andy Shevchenko authored
      [ Upstream commit 55c8fca1 ]
      
      During the swap dependency on PCH_GBE to selection PTP_1588_CLOCK_PCH
      incidentally dropped the implicit dependency on the PCI. Restore it.
      
      Fixes: 18d359ce
      
       ("pch_gbe, ptp_pch: Fix the dependency direction between these drivers")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c075da32
    • Pavel Skripkin's avatar
      net: 6pack: fix slab-out-of-bounds in decode_data · 5e0e7828
      Pavel Skripkin authored
      [ Upstream commit 19d1532a
      
       ]
      
      Syzbot reported slab-out-of bounds write in decode_data().
      The problem was in missing validation checks.
      
      Syzbot's reproducer generated malicious input, which caused
      decode_data() to be called a lot in sixpack_decode(). Since
      rx_count_cooked is only 400 bytes and noone reported before,
      that 400 bytes is not enough, let's just check if input is malicious
      and complain about buffer overrun.
      
      Fail log:
      ==================================================================
      BUG: KASAN: slab-out-of-bounds in drivers/net/hamradio/6pack.c:843
      Write of size 1 at addr ffff888087c5544e by task kworker/u4:0/7
      
      CPU: 0 PID: 7 Comm: kworker/u4:0 Not tainted 5.6.0-rc3-syzkaller #0
      ...
      Workqueue: events_unbound flush_to_ldisc
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x197/0x210 lib/dump_stack.c:118
       print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
       __kasan_report.cold+0x1b/0x32 mm/kasan/report.c:506
       kasan_report+0x12/0x20 mm/kasan/common.c:641
       __asan_report_store1_noabort+0x17/0x20 mm/kasan/generic_report.c:137
       decode_data.part.0+0x23b/0x270 drivers/net/hamradio/6pack.c:843
       decode_data drivers/net/hamradio/6pack.c:965 [inline]
       sixpack_decode drivers/net/hamradio/6pack.c:968 [inline]
      
      Reported-and-tested-by: default avatar <syzbot+fc8cd9a673d4577fb2e4@syzkaller.appspotmail.com>
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5e0e7828
    • Jakub Kicinski's avatar
      bnxt: don't lock the tx queue from napi poll · bffcedb5
      Jakub Kicinski authored
      [ Upstream commit 3c603136 ]
      
      We can't take the tx lock from the napi poll routine, because
      netpoll can poll napi at any moment, including with the tx lock
      already held.
      
      The tx lock is protecting against two paths - the disable
      path, and (as Michael points out) the NETDEV_TX_BUSY case
      which may occur if NAPI completions race with start_xmit
      and both decide to re-enable the queue.
      
      For the disable/ifdown path use synchronize_net() to make sure
      closing the device does not race we restarting the queues.
      Annotate accesses to dev_state against data races.
      
      For the NAPI cleanup vs start_xmit path - appropriate barriers
      are already in place in the main spot where Tx queue is stopped
      but we need to do the same careful dance in the TX_BUSY case.
      
      Fixes: c0c050c5
      
       ("bnxt_en: New Broadcom ethernet driver.")
      Reviewed-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Reviewed-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bffcedb5
    • Xie Yongji's avatar
      vhost: Fix the calculation in vhost_overflow() · 152962a7
      Xie Yongji authored
      [ Upstream commit f7ad318e ]
      
      This fixes the incorrect calculation for integer overflow
      when the last address of iova range is 0xffffffff.
      
      Fixes: ec33d031
      
       ("vhost: detect 32 bit integer wrap around")
      Reported-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarXie Yongji <xieyongji@bytedance.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Link: https://lore.kernel.org/r/20210728130756.97-2-xieyongji@bytedance.com
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      152962a7
    • Randy Dunlap's avatar
      dccp: add do-while-0 stubs for dccp_pr_debug macros · 91cc40b9
      Randy Dunlap authored
      [ Upstream commit 86aab09a ]
      
      GCC complains about empty macros in an 'if' statement, so convert
      them to 'do {} while (0)' macros.
      
      Fixes these build warnings:
      
      net/dccp/output.c: In function 'dccp_xmit_packet':
      ../net/dccp/output.c:283:71: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
        283 |                 dccp_pr_debug("transmit_skb() returned err=%d\n", err);
      net/dccp/ackvec.c: In function 'dccp_ackvec_update_old':
      ../net/dccp/ackvec.c:163:80: warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
        163 |                                               (unsigned long long)seqno, state);
      
      Fixes: dc841e30 ("dccp: Extend CCID packet dequeueing interface")
      Fixes: 38024086
      
       ("dccp ccid-2: Update code for the Ack Vector input/registration routine")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: dccp@vger.kernel.org
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Gerrit Renker <gerrit@erg.abdn.ac.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      91cc40b9
    • Ole Bjørn Midtbø's avatar
      Bluetooth: hidp: use correct wait queue when removing ctrl_wait · 49146a68
      Ole Bjørn Midtbø authored
      [ Upstream commit cca342d9
      
       ]
      
      A different wait queue was used when removing ctrl_wait than when adding
      it. This effectively made the remove operation without locking compared
      to other operations on the wait queue ctrl_wait was part of. This caused
      issues like below where dead000000000100 is LIST_POISON1 and
      dead000000000200 is LIST_POISON2.
      
       list_add corruption. next->prev should be prev (ffffffc1b0a33a08), \
      	but was dead000000000200. (next=ffffffc03ac77de0).
       ------------[ cut here ]------------
       CPU: 3 PID: 2138 Comm: bluetoothd Tainted: G           O    4.4.238+ #9
       ...
       ---[ end trace 0adc2158f0646eac ]---
       Call trace:
       [<ffffffc000443f78>] __list_add+0x38/0xb0
       [<ffffffc0000f0d04>] add_wait_queue+0x4c/0x68
       [<ffffffc00020eecc>] __pollwait+0xec/0x100
       [<ffffffc000d1556c>] bt_sock_poll+0x74/0x200
       [<ffffffc000bdb8a8>] sock_poll+0x110/0x128
       [<ffffffc000210378>] do_sys_poll+0x220/0x480
       [<ffffffc0002106f0>] SyS_poll+0x80/0x138
       [<ffffffc00008510c>] __sys_trace_return+0x0/0x4
      
       Unable to handle kernel paging request at virtual address dead000000000100
       ...
       CPU: 4 PID: 5387 Comm: kworker/u15:3 Tainted: G        W  O    4.4.238+ #9
       ...
       Call trace:
        [<ffffffc0000f079c>] __wake_up_common+0x7c/0xa8
        [<ffffffc0000f0818>] __wake_up+0x50/0x70
        [<ffffffc000be11b0>] sock_def_wakeup+0x58/0x60
        [<ffffffc000de5e10>] l2cap_sock_teardown_cb+0x200/0x224
        [<ffffffc000d3f2ac>] l2cap_chan_del+0xa4/0x298
        [<ffffffc000d45ea0>] l2cap_conn_del+0x118/0x198
        [<ffffffc000d45f8c>] l2cap_disconn_cfm+0x6c/0x78
        [<ffffffc000d29934>] hci_event_packet+0x564/0x2e30
        [<ffffffc000d19b0c>] hci_rx_work+0x10c/0x360
        [<ffffffc0000c2218>] process_one_work+0x268/0x460
        [<ffffffc0000c2678>] worker_thread+0x268/0x480
        [<ffffffc0000c94e0>] kthread+0x118/0x128
        [<ffffffc000085070>] ret_from_fork+0x10/0x20
        ---[ end trace 0adc2158f0646ead ]---
      
      Signed-off-by: default avatarOle Bjørn Midtbø <omidtbo@cisco.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      49146a68
    • Ivan T. Ivanov's avatar
      net: usb: lan78xx: don't modify phy_device state concurrently · d15995a9
      Ivan T. Ivanov authored
      [ Upstream commit 6b67d4d6
      
       ]
      
      Currently phy_device state could be left in inconsistent state shown
      by following alert message[1]. This is because phy_read_status could
      be called concurrently from lan78xx_delayedwork, phy_state_machine and
      __ethtool_get_link. Fix this by making sure that phy_device state is
      updated atomically.
      
      [1] lan78xx 1-1.1.1:1.0 eth0: No phy led trigger registered for speed(-1)
      
      Signed-off-by: default avatarIvan T. Ivanov <iivanov@suse.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d15995a9
    • Sudeep Holla's avatar
      ARM: dts: nomadik: Fix up interrupt controller node names · f7d86403
      Sudeep Holla authored
      [ Upstream commit 47091f47
      
       ]
      
      Once the new schema interrupt-controller/arm,vic.yaml is added, we get
      the below warnings:
      
      	arch/arm/boot/dts/ste-nomadik-nhk15.dt.yaml:
      	intc@10140000: $nodename:0: 'intc@10140000' does not match
      	'^interrupt-controller(@[0-9a-f,]+)*$'
      
      Fix the node names for the interrupt controller to conform
      to the standard node name interrupt-controller@..
      
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Link: https://lore.kernel.org/r/20210617210825.3064367-2-sudeep.holla@arm.com
      Link: https://lore.kernel.org/r/20210626000103.830184-1-linus.walleij@linaro.org'
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f7d86403
    • Sreekanth Reddy's avatar
      scsi: core: Avoid printing an error if target_alloc() returns -ENXIO · 53fb1ce7
      Sreekanth Reddy authored
      [ Upstream commit 70edd2e6
      
       ]
      
      Avoid printing a 'target allocation failed' error if the driver
      target_alloc() callback function returns -ENXIO. This return value
      indicates that the corresponding H:C:T:L entry is empty.
      
      Removing this error reduces the scan time if the user issues SCAN_WILD_CARD
      scan operation through sysfs parameter on a host with a lot of empty
      H:C:T:L entries.
      
      Avoiding the printk on -ENXIO matches the behavior of the other callback
      functions during scanning.
      
      Link: https://lore.kernel.org/r/20210726115402.1936-1-sreekanth.reddy@broadcom.com
      Signed-off-by: default avatarSreekanth Reddy <sreekanth.reddy@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      53fb1ce7
    • Ye Bin's avatar
      scsi: scsi_dh_rdac: Avoid crash during rdac_bus_attach() · 19cbfd31
      Ye Bin authored
      [ Upstream commit bc546c0c
      
       ]
      
      The following BUG_ON() was observed during RDAC scan:
      
      [595952.944297] kernel BUG at drivers/scsi/device_handler/scsi_dh_rdac.c:427!
      [595952.951143] Internal error: Oops - BUG: 0 [#1] SMP
      ......
      [595953.251065] Call trace:
      [595953.259054]  check_ownership+0xb0/0x118
      [595953.269794]  rdac_bus_attach+0x1f0/0x4b0
      [595953.273787]  scsi_dh_handler_attach+0x3c/0xe8
      [595953.278211]  scsi_dh_add_device+0xc4/0xe8
      [595953.282291]  scsi_sysfs_add_sdev+0x8c/0x2a8
      [595953.286544]  scsi_probe_and_add_lun+0x9fc/0xd00
      [595953.291142]  __scsi_scan_target+0x598/0x630
      [595953.295395]  scsi_scan_target+0x120/0x130
      [595953.299481]  fc_user_scan+0x1a0/0x1c0 [scsi_transport_fc]
      [595953.304944]  store_scan+0xb0/0x108
      [595953.308420]  dev_attr_store+0x44/0x60
      [595953.312160]  sysfs_kf_write+0x58/0x80
      [595953.315893]  kernfs_fop_write+0xe8/0x1f0
      [595953.319888]  __vfs_write+0x60/0x190
      [595953.323448]  vfs_write+0xac/0x1c0
      [595953.326836]  ksys_write+0x74/0xf0
      [595953.330221]  __arm64_sys_write+0x24/0x30
      
      Code is in check_ownership:
      
      	list_for_each_entry_rcu(tmp, &h->ctlr->dh_list, node) {
      		/* h->sdev should always be valid */
      		BUG_ON(!tmp->sdev);
      		tmp->sdev->access_state = access_state;
      	}
      
      	rdac_bus_attach
      		initialize_controller
      			list_add_rcu(&h->node, &h->ctlr->dh_list);
      			h->sdev = sdev;
      
      	rdac_bus_detach
      		list_del_rcu(&h->node);
      		h->sdev = NULL;
      
      Fix the race between rdac_bus_attach() and rdac_bus_detach() where h->sdev
      is NULL when processing the RDAC attach.
      
      Link: https://lore.kernel.org/r/20210113063103.2698953-1-yebin10@huawei.com
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      19cbfd31
    • Harshvardhan Jha's avatar
      scsi: megaraid_mm: Fix end of loop tests for list_for_each_entry() · 3b90de19
      Harshvardhan Jha authored
      [ Upstream commit 77541f78
      
       ]
      
      The list_for_each_entry() iterator, "adapter" in this code, can never be
      NULL.  If we exit the loop without finding the correct adapter then
      "adapter" points invalid memory that is an offset from the list head.  This
      will eventually lead to memory corruption and presumably a kernel crash.
      
      Link: https://lore.kernel.org/r/20210708074642.23599-1-harshvardhan.jha@oracle.com
      Acked-by: default avatarSumit Saxena <sumit.saxena@broadcom.com>
      Signed-off-by: default avatarHarshvardhan Jha <harshvardhan.jha@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3b90de19
    • Peter Ujfalusi's avatar
      dmaengine: of-dma: router_xlate to return -EPROBE_DEFER if controller is not yet available · 8175f082
      Peter Ujfalusi authored
      [ Upstream commit eda97cb0
      
       ]
      
      If the router_xlate can not find the controller in the available DMA
      devices then it should return with -EPORBE_DEFER in a same way as the
      of_dma_request_slave_channel() does.
      
      The issue can be reproduced if the event router is registered before the
      DMA controller itself and a driver would request for a channel before the
      controller is registered.
      In of_dma_request_slave_channel():
      1. of_dma_find_controller() would find the dma_router
      2. ofdma->of_dma_xlate() would fail and returned NULL
      3. -ENODEV is returned as error code
      
      with this patch we would return in this case the correct -EPROBE_DEFER and
      the client can try to request the channel later.
      
      Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@gmail.com>
      Link: https://lore.kernel.org/r/20210717190021.21897-1-peter.ujfalusi@gmail.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8175f082
    • Dave Gerlach's avatar
      ARM: dts: am43x-epos-evm: Reduce i2c0 bus speed for tps65218 · b5df9e60
      Dave Gerlach authored
      [ Upstream commit 20a6b3fd
      
       ]
      
      Based on the latest timing specifications for the TPS65218 from the data
      sheet, http://www.ti.com/lit/ds/symlink/tps65218.pdf, document SLDS206
      from November 2014, we must change the i2c bus speed to better fit within
      the minimum high SCL time required for proper i2c transfer.
      
      When running at 400khz, measurements show that SCL spends
      0.8125 uS/1.666 uS high/low which violates the requirement for minimum
      high period of SCL provided in datasheet Table 7.6 which is 1 uS.
      Switching to 100khz gives us 5 uS/5 uS high/low which both fall above
      the minimum given values for 100 khz, 4.0 uS/4.7 uS high/low.
      
      Without this patch occasionally a voltage set operation from the kernel
      will appear to have worked but the actual voltage reflected on the PMIC
      will not have updated, causing problems especially with cpufreq that may
      update to a higher OPP without actually raising the voltage on DCDC2,
      leading to a hang.
      
      Signed-off-by: default avatarDave Gerlach <d-gerlach@ti.com>
      Signed-off-by: default avatarKevin Hilman <khilman@baylibre.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b5df9e60
    • Yu Kuai's avatar
      dmaengine: usb-dmac: Fix PM reference leak in usb_dmac_probe() · 9a24b6a1
      Yu Kuai authored
      [ Upstream commit 1da569fa
      
       ]
      
      pm_runtime_get_sync will increment pm usage counter even it failed.
      Forgetting to putting operation will result in reference leak here.
      Fix it by moving the error_pm label above the pm_runtime_put() in
      the error path.
      
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
      Link: https://lore.kernel.org/r/20210706124521.1371901-1-yukuai3@huawei.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9a24b6a1
    • Jouni Malinen's avatar
      ath9k: Postpone key cache entry deletion for TXQ frames reference it · 61b014a8
      Jouni Malinen authored
      commit ca284802
      
       upstream.
      
      Do not delete a key cache entry that is still being referenced by
      pending frames in TXQs. This avoids reuse of the key cache entry while a
      frame might still be transmitted using it.
      
      To avoid having to do any additional operations during the main TX path
      operations, track pending key cache entries in a new bitmap and check
      whether any pending entries can be deleted before every new key
      add/remove operation. Also clear any remaining entries when stopping the
      interface.
      
      Signed-off-by: default avatarJouni Malinen <jouni@codeaurora.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20201214172118.18100-6-jouni@codeaurora.org
      Cc: Pali Rohár <pali@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      61b014a8
    • Jouni Malinen's avatar
      ath: Modify ath_key_delete() to not need full key entry · f4d4f447
      Jouni Malinen authored
      commit 144cd24d
      
       upstream.
      
      tkip_keymap can be used internally to avoid the reference to key->cipher
      and with this, only the key index value itself is needed. This allows
      ath_key_delete() call to be postponed to be handled after the upper
      layer STA and key entry have already been removed. This is needed to
      make ath9k key cache management safer.
      
      Signed-off-by: default avatarJouni Malinen <jouni@codeaurora.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20201214172118.18100-5-jouni@codeaurora.org
      Cc: Pali Rohár <pali@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f4d4f447
    • Jouni Malinen's avatar
      ath: Export ath_hw_keysetmac() · 995586a5
      Jouni Malinen authored
      commit d2d3e364
      
       upstream.
      
      ath9k is going to use this for safer management of key cache entries.
      
      Signed-off-by: default avatarJouni Malinen <jouni@codeaurora.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20201214172118.18100-4-jouni@codeaurora.org
      Cc: Pali Rohár <pali@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      995586a5
    • Jouni Malinen's avatar
      ath9k: Clear key cache explicitly on disabling hardware · 20e7de09
      Jouni Malinen authored
      commit 73488cb2
      
       upstream.
      
      Now that ath/key.c may not be explicitly clearing keys from the key
      cache, clear all key cache entries when disabling hardware to make sure
      no keys are left behind beyond this point.
      
      Signed-off-by: default avatarJouni Malinen <jouni@codeaurora.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20201214172118.18100-3-jouni@codeaurora.org
      Cc: Pali Rohár <pali@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      20e7de09
    • Jouni Malinen's avatar
      ath: Use safer key clearing with key cache entries · 2cbb22fd
      Jouni Malinen authored
      commit 56c5485c
      
       upstream.
      
      It is possible for there to be pending frames in TXQs with a reference
      to the key cache entry that is being deleted. If such a key cache entry
      is cleared, those pending frame in TXQ might get transmitted without
      proper encryption. It is safer to leave the previously used key into the
      key cache in such cases. Instead, only clear the MAC address to prevent
      RX processing from using this key cache entry.
      
      This is needed in particularly in AP mode where the TXQs cannot be
      flushed on station disconnection. This change alone may not be able to
      address all cases where the key cache entry might get reused for other
      purposes immediately (the key cache entry should be released for reuse
      only once the TXQs do not have any remaining references to them), but
      this makes it less likely to get unprotected frames and the more
      complete changes may end up being significantly more complex.
      
      Signed-off-by: default avatarJouni Malinen <jouni@codeaurora.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20201214172118.18100-2-jouni@codeaurora.org
      Cc: Pali Rohár <pali@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2cbb22fd
    • Thomas Gleixner's avatar
      x86/fpu: Make init_fpstate correct with optimized XSAVE · af3da506
      Thomas Gleixner authored
      commit f9dfb5e3 upstream.
      
      The XSAVE init code initializes all enabled and supported components with
      XRSTOR(S) to init state. Then it XSAVEs the state of the components back
      into init_fpstate which is used in several places to fill in the init state
      of components.
      
      This works correctly with XSAVE, but not with XSAVEOPT and XSAVES because
      those use the init optimization and skip writing state of components which
      are in init state. So init_fpstate.xsave still contains all zeroes after
      this operation.
      
      There are two ways to solve that:
      
         1) Use XSAVE unconditionally, but that requires to reshuffle the buffer when
            XSAVES is enabled because XSAVES uses compacted format.
      
         2) Save the components which are known to have a non-zero init state by other
            means.
      
      Looking deeper, #2 is the right thing to do because all components the
      kernel supports have all-zeroes init state except the legacy features (FP,
      SSE). Those cannot be hard coded because the states are not identical on all
      CPUs, but they can be saved with FXSAVE which avoids all conditionals.
      
      Use FXSAVE to save the legacy FP/SSE components in init_fpstate along with
      a BUILD_BUG_ON() which reminds developers to validate that a newly added
      component has all zeroes init state. As a bonus remove the now unused
      copy_xregs_to_kernel_booting() crutch.
      
      The XSAVE and reshuffle method can still be implemented in the unlikely
      case that components are added which have a non-zero init state and no
      other means to save them. For now, FXSAVE is just simple and good enough.
      
        [ bp: Fix a typo or two in the text. ]
      
      Fixes: 6bad06b7
      
       ("x86, xsave: Use xsaveopt in context-switch path when supported")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20210618143444.587311343@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af3da506
    • Maxim Levitsky's avatar
      KVM: nSVM: avoid picking up unsupported bits from L2 in int_ctl (CVE-2021-3653) · 26af47bd
      Maxim Levitsky authored
      [ upstream commit 0f923e07 ]
      
      * Invert the mask of bits that we pick from L2 in
        nested_vmcb02_prepare_control
      
      * Invert and explicitly use VIRQ related bits bitmask in svm_clear_vintr
      
      This fixes a security issue that allowed a malicious L1 to run L2 with
      AVIC enabled, which allowed the L2 to exploit the uninitialized and enabled
      AVIC to read/write the host physical memory at some offsets.
      
      Fixes: 3d6368ef
      
       ("KVM: SVM: Add VMRUN handler")
      Signed-off-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      26af47bd
    • Maxim Levitsky's avatar
      KVM: nSVM: always intercept VMLOAD/VMSAVE when nested (CVE-2021-3656) · 6ed19838
      Maxim Levitsky authored
      [ upstream commit c7dfa400 ]
      
      If L1 disables VMLOAD/VMSAVE intercepts, and doesn't enable
      Virtual VMLOAD/VMSAVE (currently not supported for the nested hypervisor),
      then VMLOAD/VMSAVE must operate on the L1 physical memory, which is only
      possible by making L0 intercept these instructions.
      
      Failure to do so allowed the nested guest to run VMLOAD/VMSAVE unintercepted,
      and thus read/write portions of the host physical memory.
      
      Fixes: 89c8a498
      
       ("KVM: SVM: Enable Virtual VMLOAD VMSAVE feature")
      
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ed19838
    • Johannes Berg's avatar
      mac80211: drop data frames without key on encrypted links · 60986d10
      Johannes Berg authored
      commit a0761a30
      
       upstream.
      
      If we know that we have an encrypted link (based on having had
      a key configured for TX in the past) then drop all data frames
      in the key selection handler if there's no key anymore.
      
      This fixes an issue with mac80211 internal TXQs - there we can
      buffer frames for an encrypted link, but then if the key is no
      longer there when they're dequeued, the frames are sent without
      encryption. This happens if a station is disconnected while the
      frames are still on the TXQ.
      
      Detecting that a link should be encrypted based on a first key
      having been configured for TX is fine as there are no use cases
      for a connection going from with encryption to no encryption.
      With extended key IDs, however, there is a case of having a key
      configured for only decryption, so we can't just trigger this
      behaviour on a key being configured.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarJouni Malinen <j@w1.fi>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Link: https://lore.kernel.org/r/iwlwifi.20200326150855.6865c7f28a14.I9fb1d911b064262d33e33dfba730cdeef83926ca@changeid
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      [pali: Backported to 4.19 and older versions]
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      60986d10