Skip to content
  1. Sep 03, 2021
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Fix dwc3_calc_trbs_left() · 9b660089
      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>
      9b660089
    • Zhengjun Zhang's avatar
      USB: serial: option: add new VID/PID to support Fibocom FG150 · 015936d1
      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>
      015936d1
    • Johan Hovold's avatar
      Revert "USB: serial: ch341: fix character loss at high transfer rates" · 12b7e85f
      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>
      12b7e85f
    • Stefan Mätje's avatar
      can: usb: esd_usb2: esd_usb2_rx_event(): fix the interchange of the CAN RX and TX error counters · 1f1a5e78
      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>
      1f1a5e78
    • Guenter Roeck's avatar
      ARC: Fix CONFIG_STACKDEPOT · 2f1a4696
      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>
      2f1a4696
  2. Aug 26, 2021
    • Sasha Levin's avatar
    • Jeff Layton's avatar
      fs: warn about impending deprecation of mandatory locks · 0febcf95
      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>
      0febcf95
    • Jeff Layton's avatar
      locks: print a warning when mount fails due to lack of "mand" support · c5e63107
      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>
      c5e63107
    • Takashi Iwai's avatar
      ASoC: intel: atom: Fix breakage for PCM buffer address setup · 158a1a8c
      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>
      158a1a8c
    • NeilBrown's avatar
      btrfs: prevent rename2 from exchanging a subvol with a directory from different parents · 1cc3418d
      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>
      1cc3418d
    • Dongliang Mu's avatar
      ipack: tpci200: fix many double free issues in tpci200_pci_probe · d2d92bc2
      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>
      d2d92bc2
    • Jaroslav Kysela's avatar
      ALSA: hda - fix the 'Capture Switch' value change notifications · ff60622b
      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>
      ff60622b
    • Vincent Whitchurch's avatar
      mmc: dw_mmc: Fix hang on data CRC error · 460e3534
      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>
      460e3534
    • Jaehoon Chung's avatar
      mmc: dw_mmc: call the dw_mci_prep_stop_abort() by default · 14ec14b6
      Jaehoon Chung authored
      [ Upstream commit e13c3c08
      
       ]
      
      stop_cmdr should be set to values relevant to stop command.
      It migth be assigned to values whatever there is mrq->stop or not.
      Then it doesn't need to use dw_mci_prepare_command().
      It's enough to use the prep_stop_abort for preparing stop command.
      
      Signed-off-by: default avatarJaehoon Chung <jh80.chung@samsung.com>
      Tested-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Reviewed-by: default avatarShawn Lin <shawn.lin@rock-chips.com>
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      14ec14b6
    • Dinghao Liu's avatar
      net: qlcnic: add missed unlock in qlcnic_83xx_flash_read32 · afe3fbc1
      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>
      afe3fbc1
    • Pavel Skripkin's avatar
      net: 6pack: fix slab-out-of-bounds in decode_data · de9171c1
      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>
      de9171c1
    • Xie Yongji's avatar
      vhost: Fix the calculation in vhost_overflow() · cd66049e
      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>
      cd66049e
    • Randy Dunlap's avatar
      dccp: add do-while-0 stubs for dccp_pr_debug macros · adc3308f
      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>
      adc3308f
    • Ole Bjørn Midtbø's avatar
      Bluetooth: hidp: use correct wait queue when removing ctrl_wait · b8c000ef
      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>
      b8c000ef
    • Sudeep Holla's avatar
      ARM: dts: nomadik: Fix up interrupt controller node names · a080bad7
      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>
      a080bad7
    • Sreekanth Reddy's avatar
      scsi: core: Avoid printing an error if target_alloc() returns -ENXIO · 869d9b41
      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>
      869d9b41
    • Ye Bin's avatar
      scsi: scsi_dh_rdac: Avoid crash during rdac_bus_attach() · 110fde2f
      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>
      110fde2f
    • Harshvardhan Jha's avatar
      scsi: megaraid_mm: Fix end of loop tests for list_for_each_entry() · 881dff36
      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>
      881dff36
    • Peter Ujfalusi's avatar
      dmaengine: of-dma: router_xlate to return -EPROBE_DEFER if controller is not yet available · b116976b
      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>
      b116976b
    • Dave Gerlach's avatar
      ARM: dts: am43x-epos-evm: Reduce i2c0 bus speed for tps65218 · a617330f
      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>
      a617330f
    • Yu Kuai's avatar
      dmaengine: usb-dmac: Fix PM reference leak in usb_dmac_probe() · 072cc0ba
      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>
      072cc0ba
    • Thomas Gleixner's avatar
      x86/fpu: Make init_fpstate correct with optimized XSAVE · c4a1a09a
      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>
      c4a1a09a
    • Maxim Levitsky's avatar
      KVM: nSVM: avoid picking up unsupported bits from L2 in int_ctl (CVE-2021-3653) · 29c4f674
      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>
      29c4f674
    • Johannes Berg's avatar
      mac80211: drop data frames without key on encrypted links · ca37ab96
      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>
      ca37ab96
    • Nathan Chancellor's avatar
      vmlinux.lds.h: Handle clang's module.{c,d}tor sections · 2c20065d
      Nathan Chancellor authored
      commit 84837881
      
       upstream.
      
      A recent change in LLVM causes module_{c,d}tor sections to appear when
      CONFIG_K{A,C}SAN are enabled, which results in orphan section warnings
      because these are not handled anywhere:
      
      ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.asan.module_ctor) is being placed in '.text.asan.module_ctor'
      ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.asan.module_dtor) is being placed in '.text.asan.module_dtor'
      ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.tsan.module_ctor) is being placed in '.text.tsan.module_ctor'
      
      Fangrui explains: "the function asan.module_ctor has the SHF_GNU_RETAIN
      flag, so it is in a separate section even with -fno-function-sections
      (default)".
      
      Place them in the TEXT_TEXT section so that these technologies continue
      to work with the newer compiler versions. All of the KASAN and KCSAN
      KUnit tests continue to pass after this change.
      
      Cc: stable@vger.kernel.org
      Link: https://github.com/ClangBuiltLinux/linux/issues/1432
      Link: https://github.com/llvm/llvm-project/commit/7b789562244ee941b7bf2cefeb3fc08a59a01865
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: default avatarFangrui Song <maskray@google.com>
      Acked-by: default avatarMarco Elver <elver@google.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20210731023107.1932981-1-nathan@kernel.org
      [nc: Fix conflicts due to lack of cf68fffb and 266ff2a8
      
      ]
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c20065d
    • Thomas Gleixner's avatar
      PCI/MSI: Enforce MSI[X] entry updates to be visible · 97987e14
      Thomas Gleixner authored
      commit b9255a7c
      
       upstream.
      
      Nothing enforces the posted writes to be visible when the function
      returns. Flush them even if the flush might be redundant when the entry is
      masked already as the unmask will flush as well. This is either setup or a
      rare affinity change event so the extra flush is not the end of the world.
      
      While this is more a theoretical issue especially the logic in the X86
      specific msi_set_affinity() function relies on the assumption that the
      update has reached the hardware when the function returns.
      
      Again, as this never has been enforced the Fixes tag refers to a commit in:
         git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
      
      Fixes: f036d4ea5fa7 ("[PATCH] ia32 Message Signalled Interrupt support")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210729222542.515188147@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      97987e14
    • Thomas Gleixner's avatar
      PCI/MSI: Enforce that MSI-X table entry is masked for update · 6a91749e
      Thomas Gleixner authored
      commit da181dc9
      
       upstream.
      
      The specification (PCIe r5.0, sec 6.1.4.5) states:
      
          For MSI-X, a function is permitted to cache Address and Data values
          from unmasked MSI-X Table entries. However, anytime software unmasks a
          currently masked MSI-X Table entry either by clearing its Mask bit or
          by clearing the Function Mask bit, the function must update any Address
          or Data values that it cached from that entry. If software changes the
          Address or Data value of an entry while the entry is unmasked, the
          result is undefined.
      
      The Linux kernel's MSI-X support never enforced that the entry is masked
      before the entry is modified hence the Fixes tag refers to a commit in:
            git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
      
      Enforce the entry to be masked across the update.
      
      There is no point in enforcing this to be handled at all possible call
      sites as this is just pointless code duplication and the common update
      function is the obvious place to enforce this.
      
      Fixes: f036d4ea5fa7 ("[PATCH] ia32 Message Signalled Interrupt support")
      Reported-by: default avatarKevin Tian <kevin.tian@intel.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210729222542.462096385@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a91749e
    • Thomas Gleixner's avatar
      PCI/MSI: Mask all unused MSI-X entries · 3590d16b
      Thomas Gleixner authored
      commit 7d5ec3d3
      
       upstream.
      
      When MSI-X is enabled the ordering of calls is:
      
        msix_map_region();
        msix_setup_entries();
        pci_msi_setup_msi_irqs();
        msix_program_entries();
      
      This has a few interesting issues:
      
       1) msix_setup_entries() allocates the MSI descriptors and initializes them
          except for the msi_desc:masked member which is left zero initialized.
      
       2) pci_msi_setup_msi_irqs() allocates the interrupt descriptors and sets
          up the MSI interrupts which ends up in pci_write_msi_msg() unless the
          interrupt chip provides its own irq_write_msi_msg() function.
      
       3) msix_program_entries() does not do what the name suggests. It solely
          updates the entries array (if not NULL) and initializes the masked
          member for each MSI descriptor by reading the hardware state and then
          masks the entry.
      
      Obviously this has some issues:
      
       1) The uninitialized masked member of msi_desc prevents the enforcement
          of masking the entry in pci_write_msi_msg() depending on the cached
          masked bit. Aside of that half initialized data is a NONO in general
      
       2) msix_program_entries() only ensures that the actually allocated entries
          are masked. This is wrong as experimentation with crash testing and
          crash kernel kexec has shown.
      
          This limited testing unearthed that when the production kernel had more
          entries in use and unmasked when it crashed and the crash kernel
          allocated a smaller amount of entries, then a full scan of all entries
          found unmasked entries which were in use in the production kernel.
      
          This is obviously a device or emulation issue as the device reset
          should mask all MSI-X table entries, but obviously that's just part
          of the paper specification.
      
      Cure this by:
      
       1) Masking all table entries in hardware
       2) Initializing msi_desc::masked in msix_setup_entries()
       3) Removing the mask dance in msix_program_entries()
       4) Renaming msix_program_entries() to msix_update_entries() to
          reflect the purpose of that function.
      
      As the masking of unused entries has never been done the Fixes tag refers
      to a commit in:
         git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
      
      Fixes: f036d4ea5fa7 ("[PATCH] ia32 Message Signalled Interrupt support")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210729222542.403833459@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3590d16b
    • Thomas Gleixner's avatar
      PCI/MSI: Protect msi_desc::masked for multi-MSI · cb93b6c5
      Thomas Gleixner authored
      commit 77e89afc upstream.
      
      Multi-MSI uses a single MSI descriptor and there is a single mask register
      when the device supports per vector masking. To avoid reading back the mask
      register the value is cached in the MSI descriptor and updates are done by
      clearing and setting bits in the cache and writing it to the device.
      
      But nothing protects msi_desc::masked and the mask register from being
      modified concurrently on two different CPUs for two different Linux
      interrupts which belong to the same multi-MSI descriptor.
      
      Add a lock to struct device and protect any operation on the mask and the
      mask register with it.
      
      This makes the update of msi_desc::masked unconditional, but there is no
      place which requires a modification of the hardware register without
      updating the masked cache.
      
      msi_mask_irq() is now an empty wrapper which will be cleaned up in follow
      up changes.
      
      The problem goes way back to the initial support of multi-MSI, but picking
      the commit which introduced the mask cache is a valid cut off point
      (2.6.30).
      
      Fixes: f2440d9a
      
       ("PCI MSI: Refactor interrupt masking code")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210729222542.726833414@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb93b6c5
    • Thomas Gleixner's avatar
      PCI/MSI: Use msi_mask_irq() in pci_msi_shutdown() · 9c2266da
      Thomas Gleixner authored
      commit d28d4ad2
      
       upstream.
      
      No point in using the raw write function from shutdown. Preparatory change
      to introduce proper serialization for the msi_desc::masked cache.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210729222542.674391354@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9c2266da
    • Thomas Gleixner's avatar
      PCI/MSI: Correct misleading comments · 73a00b00
      Thomas Gleixner authored
      commit 689e6b53
      
       upstream.
      
      The comments about preserving the cached state in pci_msi[x]_shutdown() are
      misleading as the MSI descriptors are freed right after those functions
      return. So there is nothing to restore. Preparatory change.
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210729222542.621609423@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73a00b00
    • Thomas Gleixner's avatar
      PCI/MSI: Do not set invalid bits in MSI mask · 4e1ec390
      Thomas Gleixner authored
      commit 361fd373 upstream.
      
      msi_mask_irq() takes a mask and a flags argument. The mask argument is used
      to mask out bits from the cached mask and the flags argument to set bits.
      
      Some places invoke it with a flags argument which sets bits which are not
      used by the device, i.e. when the device supports up to 8 vectors a full
      unmask in some places sets the mask to 0xFFFFFF00. While devices probably
      do not care, it's still bad practice.
      
      Fixes: 7ba1930d
      
       ("PCI MSI: Unmask MSI if setup failed")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210729222542.568173099@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e1ec390
    • Thomas Gleixner's avatar
      PCI/MSI: Enable and mask MSI-X early · 130b04af
      Thomas Gleixner authored
      commit 43855395 upstream.
      
      The ordering of MSI-X enable in hardware is dysfunctional:
      
       1) MSI-X is disabled in the control register
       2) Various setup functions
       3) pci_msi_setup_msi_irqs() is invoked which ends up accessing
          the MSI-X table entries
       4) MSI-X is enabled and masked in the control register with the
          comment that enabling is required for some hardware to access
          the MSI-X table
      
      Step #4 obviously contradicts #3. The history of this is an issue with the
      NIU hardware. When #4 was introduced the table access actually happened in
      msix_program_entries() which was invoked after enabling and masking MSI-X.
      
      This was changed in commit d71d6432 ("PCI/MSI: Kill redundant call of
      irq_set_msi_desc() for MSI-X interrupts") which removed the table write
      from msix_program_entries().
      
      Interestingly enough nobody noticed and either NIU still works or it did
      not get any testing with a kernel 3.19 or later.
      
      Nevertheless this is inconsistent and there is no reason why MSI-X can't be
      enabled and masked in the control register early on, i.e. move step #4
      above to step #1. This preserves the NIU workaround and has no side effects
      on other hardware.
      
      Fixes: d71d6432
      
       ("PCI/MSI: Kill redundant call of irq_set_msi_desc() for MSI-X interrupts")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarAshok Raj <ashok.raj@intel.com>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210729222542.344136412@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      130b04af
    • Randy Dunlap's avatar
      x86/tools: Fix objdump version check again · 5fe8555c
      Randy Dunlap authored
      [ Upstream commit 839ad22f ]
      
      Skip (omit) any version string info that is parenthesized.
      
      Warning: objdump version 15) is older than 2.19
      Warning: Skipping posttest.
      
      where 'objdump -v' says:
      GNU objdump (GNU Binutils; SUSE Linux Enterprise 15) 2.35.1.20201123-7.18
      
      Fixes: 8bee738b
      
       ("x86: Fix objdump version check in chkobjdump.awk for different formats.")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Link: https://lore.kernel.org/r/20210731000146.2720-1-rdunlap@infradead.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5fe8555c
    • Maximilian Heyne's avatar
      xen/events: Fix race in set_evtchn_to_irq · e746e331
      Maximilian Heyne authored
      [ Upstream commit 88ca2521
      
       ]
      
      There is a TOCTOU issue in set_evtchn_to_irq. Rows in the evtchn_to_irq
      mapping are lazily allocated in this function. The check whether the row
      is already present and the row initialization is not synchronized. Two
      threads can at the same time allocate a new row for evtchn_to_irq and
      add the irq mapping to the their newly allocated row. One thread will
      overwrite what the other has set for evtchn_to_irq[row] and therefore
      the irq mapping is lost. This will trigger a BUG_ON later in
      bind_evtchn_to_cpu:
      
        INFO: pci 0000:1a:15.4: [1d0f:8061] type 00 class 0x010802
        INFO: nvme 0000:1a:12.1: enabling device (0000 -> 0002)
        INFO: nvme nvme77: 1/0/0 default/read/poll queues
        CRIT: kernel BUG at drivers/xen/events/events_base.c:427!
        WARN: invalid opcode: 0000 [#1] SMP NOPTI
        WARN: Workqueue: nvme-reset-wq nvme_reset_work [nvme]
        WARN: RIP: e030:bind_evtchn_to_cpu+0xc2/0xd0
        WARN: Call Trace:
        WARN:  set_affinity_irq+0x121/0x150
        WARN:  irq_do_set_affinity+0x37/0xe0
        WARN:  irq_setup_affinity+0xf6/0x170
        WARN:  irq_startup+0x64/0xe0
        WARN:  __setup_irq+0x69e/0x740
        WARN:  ? request_threaded_irq+0xad/0x160
        WARN:  request_threaded_irq+0xf5/0x160
        WARN:  ? nvme_timeout+0x2f0/0x2f0 [nvme]
        WARN:  pci_request_irq+0xa9/0xf0
        WARN:  ? pci_alloc_irq_vectors_affinity+0xbb/0x130
        WARN:  queue_request_irq+0x4c/0x70 [nvme]
        WARN:  nvme_reset_work+0x82d/0x1550 [nvme]
        WARN:  ? check_preempt_wakeup+0x14f/0x230
        WARN:  ? check_preempt_curr+0x29/0x80
        WARN:  ? nvme_irq_check+0x30/0x30 [nvme]
        WARN:  process_one_work+0x18e/0x3c0
        WARN:  worker_thread+0x30/0x3a0
        WARN:  ? process_one_work+0x3c0/0x3c0
        WARN:  kthread+0x113/0x130
        WARN:  ? kthread_park+0x90/0x90
        WARN:  ret_from_fork+0x3a/0x50
      
      This patch sets evtchn_to_irq rows via a cmpxchg operation so that they
      will be set only once. The row is now cleared before writing it to
      evtchn_to_irq in order to not create a race once the row is visible for
      other threads.
      
      While at it, do not require the page to be zeroed, because it will be
      overwritten with -1's in clear_evtchn_to_irq_row anyway.
      
      Signed-off-by: default avatarMaximilian Heyne <mheyne@amazon.de>
      Fixes: d0b075ff
      
       ("xen/events: Refactor evtchn_to_irq array to be dynamically allocated")
      Link: https://lore.kernel.org/r/20210812130930.127134-1-mheyne@amazon.de
      Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e746e331