Skip to content
  1. Sep 03, 2021
    • Yufeng Mo's avatar
      net: hns3: clear hardware resource when loading driver · 951805c2
      Yufeng Mo authored
      
      
      [ Upstream commit 1a6d2819 ]
      
      If a PF is bonded to a virtual machine and the virtual machine exits
      unexpectedly, some hardware resource cannot be cleared. In this case,
      loading driver may cause exceptions. Therefore, the hardware resource
      needs to be cleared when the driver is loaded.
      
      Fixes: 46a3df9f ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
      Signed-off-by: default avatarYufeng Mo <moyufeng@huawei.com>
      Signed-off-by: default avatarSalil Mehta <salil.mehta@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      951805c2
    • Andrey Ignatov's avatar
      rtnetlink: Return correct error on changing device netns · 08162f65
      Andrey Ignatov authored
      
      
      [ Upstream commit 96a6b93b ]
      
      Currently when device is moved between network namespaces using
      RTM_NEWLINK message type and one of netns attributes (FLA_NET_NS_PID,
      IFLA_NET_NS_FD, IFLA_TARGET_NETNSID) but w/o specifying IFLA_IFNAME, and
      target namespace already has device with same name, userspace will get
      EINVAL what is confusing and makes debugging harder.
      
      Fix it so that userspace gets more appropriate EEXIST instead what makes
      debugging much easier.
      
      Before:
      
        # ./ifname.sh
        + ip netns add ns0
        + ip netns exec ns0 ip link add l0 type dummy
        + ip netns exec ns0 ip link show l0
        8: l0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
            link/ether 66:90:b5:d5:78:69 brd ff:ff:ff:ff:ff:ff
        + ip link add l0 type dummy
        + ip link show l0
        10: l0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
            link/ether 6e:c6:1f:15:20:8d brd ff:ff:ff:ff:ff:ff
        + ip link set l0 netns ns0
        RTNETLINK answers: Invalid argument
      
      After:
      
        # ./ifname.sh
        + ip netns add ns0
        + ip netns exec ns0 ip link add l0 type dummy
        + ip netns exec ns0 ip link show l0
        8: l0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
            link/ether 1e:4a:72:e3:e3:8f brd ff:ff:ff:ff:ff:ff
        + ip link add l0 type dummy
        + ip link show l0
        10: l0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
            link/ether f2:fc:fe:2b:7d:a6 brd ff:ff:ff:ff:ff:ff
        + ip link set l0 netns ns0
        RTNETLINK answers: File exists
      
      The problem is that do_setlink() passes its `char *ifname` argument,
      that it gets from a caller, to __dev_change_net_namespace() as is (as
      `const char *pat`), but semantics of ifname and pat can be different.
      
      For example, __rtnl_newlink() does this:
      
      net/core/rtnetlink.c
          3270	char ifname[IFNAMSIZ];
           ...
          3286	if (tb[IFLA_IFNAME])
          3287		nla_strscpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ);
          3288	else
          3289		ifname[0] = '\0';
           ...
          3364	if (dev) {
           ...
          3394		return do_setlink(skb, dev, ifm, extack, tb, ifname, status);
          3395	}
      
      , i.e. do_setlink() gets ifname pointer that is always valid no matter
      if user specified IFLA_IFNAME or not and then do_setlink() passes this
      ifname pointer as is to __dev_change_net_namespace() as pat argument.
      
      But the pat (pattern) in __dev_change_net_namespace() is used as:
      
      net/core/dev.c
         11198	err = -EEXIST;
         11199	if (__dev_get_by_name(net, dev->name)) {
         11200		/* We get here if we can't use the current device name */
         11201		if (!pat)
         11202			goto out;
         11203		err = dev_get_valid_name(net, dev, pat);
         11204		if (err < 0)
         11205			goto out;
         11206	}
      
      As the result the `goto out` path on line 11202 is neven taken and
      instead of returning EEXIST defined on line 11198,
      __dev_change_net_namespace() returns an error from dev_get_valid_name()
      and this, in turn, will be EINVAL for ifname[0] = '\0' set earlier.
      
      Fixes: d8a5ec67 ("[NET]: netlink support for moving devices between network namespaces.")
      Signed-off-by: default avatarAndrey Ignatov <rdna@fb.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      08162f65
    • Maxim Kiselev's avatar
      net: marvell: fix MVNETA_TX_IN_PRGRS bit number · f58e42d1
      Maxim Kiselev authored
      
      
      [ Upstream commit 359f4cdd ]
      
      According to Armada XP datasheet bit at 0 position is corresponding for
      TxInProg indication.
      
      Fixes: c5aff182 ("net: mvneta: driver for Marvell Armada 370/XP network unit")
      Signed-off-by: default avatarMaxim Kiselev <bigunclemax@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f58e42d1
    • Christophe JAILLET's avatar
      xgene-v2: Fix a resource leak in the error handling path of 'xge_probe()' · 45454400
      Christophe JAILLET authored
      
      
      [ Upstream commit 5ed74b03 ]
      
      A successful 'xge_mdio_config()' call should be balanced by a corresponding
      'xge_mdio_remove()' call in the error handling path of the probe, as
      already done in the remove function.
      
      Update the error handling path accordingly.
      
      Fixes: ea8ab16a ("drivers: net: xgene-v2: Add MDIO support")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      45454400
    • Shreyansh Chouhan's avatar
      ip_gre: add validation for csum_start · 53b480e6
      Shreyansh Chouhan authored
      
      
      [ Upstream commit 1d011c48 ]
      
      Validate csum_start in gre_handle_offloads before we call _gre_xmit so
      that we do not crash later when the csum_start value is used in the
      lco_csum function call.
      
      This patch deals with ipv4 code.
      
      Fixes: c5441932 ("GRE: Refactor GRE tunneling code.")
      Reported-by: default avatar <syzbot+ff8e1b9f2f36481e2efc@syzkaller.appspotmail.com>
      Signed-off-by: default avatarShreyansh Chouhan <chouhan.shreyansh630@gmail.com>
      Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      53b480e6
    • Gal Pressman's avatar
      RDMA/efa: Free IRQ vectors on error flow · bb8ca7e2
      Gal Pressman authored
      [ Upstream commit dbe986bd ]
      
      Make sure to free the IRQ vectors in case the allocation doesn't return
      the expected number of IRQs.
      
      Fixes: b7f5e880 ("RDMA/efa: Add the efa module")
      Link: https://lore.kernel.org/r/20210811151131.39138-2-galpress@amazon.com
      
      
      Reviewed-by: default avatarFiras JahJah <firasj@amazon.com>
      Reviewed-by: default avatarYossi Leybovich <sleybo@amazon.com>
      Signed-off-by: default avatarGal Pressman <galpress@amazon.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bb8ca7e2
    • Sasha Neftin's avatar
      e1000e: Fix the max snoop/no-snoop latency for 10M · e29565b4
      Sasha Neftin authored
      
      
      [ Upstream commit 44a13a5d ]
      
      We should decode the latency and the max_latency before directly compare.
      The latency should be presented as lat_enc = scale x value:
      lat_enc_d = (lat_enc & 0x0x3ff) x (1U << (5*((max_ltr_enc & 0x1c00)
      >> 10)))
      
      Fixes: cf8fb73c ("e1000e: add support for LTR on I217/I218")
      Suggested-by: default avatarYee Li <seven.yi.lee@gmail.com>
      Signed-off-by: default avatarSasha Neftin <sasha.neftin@intel.com>
      Tested-by: default avatarDvora Fuxbrumer <dvorax.fuxbrumer@linux.intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e29565b4
    • Tuo Li's avatar
      IB/hfi1: Fix possible null-pointer dereference in _extend_sdma_tx_descs() · 8a21e843
      Tuo Li authored
      [ Upstream commit cbe71c61 ]
      
      kmalloc_array() is called to allocate memory for tx->descp. If it fails,
      the function __sdma_txclean() is called:
        __sdma_txclean(dd, tx);
      
      However, in the function __sdma_txclean(), tx-descp is dereferenced if
      tx->num_desc is not zero:
        sdma_unmap_desc(dd, &tx->descp[0]);
      
      To fix this possible null-pointer dereference, assign the return value of
      kmalloc_array() to a local variable descp, and then assign it to tx->descp
      if it is not NULL. Otherwise, go to enomem.
      
      Fixes: 77241056 ("IB/hfi1: add driver files")
      Link: https://lore.kernel.org/r/20210806133029.194964-1-islituo@gmail.com
      
      
      Reported-by: default avatarTOTE Robot <oslab@tsinghua.edu.cn>
      Signed-off-by: default avatarTuo Li <islituo@gmail.com>
      Tested-by: default avatarMike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
      Acked-by: default avatarMike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8a21e843
    • Naresh Kumar PBS's avatar
      RDMA/bnxt_re: Add missing spin lock initialization · 944a50f5
      Naresh Kumar PBS authored
      [ Upstream commit 17f2569d ]
      
      Add the missing initialization of srq lock.
      
      Fixes: 37cb11ac ("RDMA/bnxt_re: Add SRQ support for Broadcom adapters")
      Link: https://lore.kernel.org/r/1629343553-5843-3-git-send-email-selvin.xavier@broadcom.com
      
      
      Signed-off-by: default avatarNaresh Kumar PBS <nareshkumar.pbs@broadcom.com>
      Signed-off-by: default avatarSelvin Xavier <selvin.xavier@broadcom.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      944a50f5
    • Li Jinlin's avatar
      scsi: core: Fix hang of freezing queue between blocking and running device · 28b18954
      Li Jinlin authored
      commit 02c6dcd5 upstream.
      
      We found a hang, the steps to reproduce  are as follows:
      
        1. blocking device via scsi_device_set_state()
      
        2. dd if=/dev/sda of=/mnt/t.log bs=1M count=10
      
        3. echo none > /sys/block/sda/queue/scheduler
      
        4. echo "running" >/sys/block/sda/device/state
      
      Step 3 and 4 should complete after step 4, but they hang.
      
        CPU#0               CPU#1                CPU#2
        ---------------     ----------------     ----------------
                                                 Step 1: blocking device
      
                                                 Step 2: dd xxxx
                                                        ^^^^^^ get request
                                                               q_usage_counter++
      
                            Step 3: switching scheculer
                            elv_iosched_store
                              elevator_switch
                                blk_mq_freeze_queue
                                  blk_freeze_queue
                                    > blk_freeze_queue_start
                                      ^^^^^^ mq_freeze_depth++
      
                                    > blk_mq_run_hw_queues
                                      ^^^^^^ can't run queue when dev blocked
      
                                    > blk_mq_freeze_queue_wait
                                      ^^^^^^ Hang here!!!
                                             wait q_usage_counter==0
      
        Step 4: running device
        store_state_field
          scsi_rescan_device
            scsi_attach_vpd
              scsi_vpd_inquiry
                __scsi_execute
                  blk_get_request
                    blk_mq_alloc_request
                      blk_queue_enter
                      ^^^^^^ Hang here!!!
                             wait mq_freeze_depth==0
      
          blk_mq_run_hw_queues
          ^^^^^^ dispatch IO, q_usage_counter will reduce to zero
      
                                  blk_mq_unfreeze_queue
                                  ^^^^^ mq_freeze_depth--
      
      To fix this, we need to run queue before rescanning device when the device
      state changes to SDEV_RUNNING.
      
      Link: https://lore.kernel.org/r/20210824025921.3277629-1-lijinlin3@huawei.com
      
      
      Fixes: f0f82e24 ("scsi: core: Fix capacity set to zero after offlinining device")
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarLi Jinlin <lijinlin3@huawei.com>
      Signed-off-by: default avatarQiu Laibin <qiulaibin@huawei.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28b18954
    • Wesley Cheng's avatar
      usb: dwc3: gadget: Stop EP0 transfers during pullup disable · 628c5828
      Wesley Cheng authored
      
      
      commit 4a1e25c0 upstream.
      
      During a USB cable disconnect, or soft disconnect scenario, a pending
      SETUP transaction may not be completed, leading to the following
      error:
      
          dwc3 a600000.dwc3: timed out waiting for SETUP phase
      
      If this occurs, then the entire pullup disable routine is skipped and
      proper cleanup and halting of the controller does not complete.
      
      Instead of returning an error (which is ignored from the UDC
      perspective), allow the pullup disable routine to continue, which
      will also handle disabling of EP0/1.  This will end any active
      transfers as well.  Ensure to clear any delayed_status also, as the
      timeout could happen within the STATUS stage.
      
      Fixes: bb014736 ("usb: dwc3: gadget: don't clear RUN/STOP when it's invalid to do so")
      Cc: <stable@vger.kernel.org>
      Reviewed-by: default avatarThinh Nguyen <Thinh.Nguyen@synopsys.com>
      Acked-by: default avatarFelipe Balbi <balbi@kernel.org>
      Signed-off-by: default avatarWesley Cheng <wcheng@codeaurora.org>
      Link: https://lore.kernel.org/r/20210825042855.7977-1-wcheng@codeaurora.org
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      628c5828
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Fix dwc3_calc_trbs_left() · d9da281c
      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>
      d9da281c
    • Zhengjun Zhang's avatar
      USB: serial: option: add new VID/PID to support Fibocom FG150 · 21880abf
      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>
      21880abf
    • Johan Hovold's avatar
      Revert "USB: serial: ch341: fix character loss at high transfer rates" · 2e098e91
      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>
      2e098e91
    • Stefan Mätje's avatar
      can: usb: esd_usb2: esd_usb2_rx_event(): fix the interchange of the CAN RX and TX error counters · 16b281a7
      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>
      16b281a7
    • Yafang Shao's avatar
      mm, oom: make the calculation of oom badness more accurate · 765437d1
      Yafang Shao authored
      [ Upstream commit 9066e5cf ]
      
      Recently we found an issue on our production environment that when memcg
      oom is triggered the oom killer doesn't chose the process with largest
      resident memory but chose the first scanned process.  Note that all
      processes in this memcg have the same oom_score_adj, so the oom killer
      should chose the process with largest resident memory.
      
      Bellow is part of the oom info, which is enough to analyze this issue.
      [7516987.983223] memory: usage 16777216kB, limit 16777216kB, failcnt 52843037
      [7516987.983224] memory+swap: usage 16777216kB, limit 9007199254740988kB, failcnt 0
      [7516987.983225] kmem: usage 301464kB, limit 9007199254740988kB, failcnt 0
      [...]
      [7516987.983293] [ pid ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
      [7516987.983510] [ 5740]     0  5740      257        1    32768        0          -998 pause
      [7516987.983574] [58804]     0 58804     4594      771    81920        0          -998 entry_point.bas
      [7516987.983577] [58908]     0 58908     7089      689    98304        0          -998 cron
      [7516987.983580] [58910]     0 58910    16235     5576   163840        0          -998 supervisord
      [7516987.983590] [59620]     0 59620    18074     1395   188416        0          -998 sshd
      [7516987.983594] [59622]     0 59622    18680     6679   188416        0          -998 python
      [7516987.983598] [59624]     0 59624  1859266     5161   548864        0          -998 odin-agent
      [7516987.983600] [59625]     0 59625   707223     9248   983040        0          -998 filebeat
      [7516987.983604] [59627]     0 59627   416433    64239   774144        0          -998 odin-log-agent
      [7516987.983607] [59631]     0 59631   180671    15012   385024        0          -998 python3
      [7516987.983612] [61396]     0 61396   791287     3189   352256        0          -998 client
      [7516987.983615] [61641]     0 61641  1844642    29089   946176        0          -998 client
      [7516987.983765] [ 9236]     0  9236     2642      467    53248        0          -998 php_scanner
      [7516987.983911] [42898]     0 42898    15543      838   167936        0          -998 su
      [7516987.983915] [42900]  1000 42900     3673      867    77824        0          -998 exec_script_vr2
      [7516987.983918] [42925]  1000 42925    36475    19033   335872        0          -998 python
      [7516987.983921] [57146]  1000 57146     3673      848    73728        0          -998 exec_script_J2p
      [7516987.983925] [57195]  1000 57195   186359    22958   491520        0          -998 python2
      [7516987.983928] [58376]  1000 58376   275764    14402   290816        0          -998 rosmaster
      [7516987.983931] [58395]  1000 58395   155166     4449   245760        0          -998 rosout
      [7516987.983935] [58406]  1000 58406 18285584  3967322 37101568        0          -998 data_sim
      [7516987.984221] oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=3aa16c9482ae3a6f6b78bda68a55d32c87c99b985e0f11331cddf05af6c4d753,mems_allowed=0-1,oom_memcg=/kubepods/podf1c273d3-9b36-11ea-b3df-246e9693c184,task_memcg=/kubepods/podf1c273d3-9b36-11ea-b3df-246e9693c184/1f246a3eeea8f70bf91141eeaf1805346a666e225f823906485ea0b6c37dfc3d,task=pause,pid=5740,uid=0
      [7516987.984254] Memory cgroup out of memory: Killed process 5740 (pause) total-vm:1028kB, anon-rss:4kB, file-rss:0kB, shmem-rss:0kB
      [7516988.092344] oom_reaper: reaped process 5740 (pause), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
      
      We can find that the first scanned process 5740 (pause) was killed, but
      its rss is only one page.  That is because, when we calculate the oom
      badness in oom_badness(), we always ignore the negtive point and convert
      all of these negtive points to 1.  Now as oom_score_adj of all the
      processes in this targeted memcg have the same value -998, the points of
      these processes are all negtive value.  As a result, the first scanned
      process will be killed.
      
      The oom_socre_adj (-998) in this memcg is set by kubelet, because it is a
      a Guaranteed pod, which has higher priority to prevent from being killed
      by system oom.
      
      To fix this issue, we should make the calculation of oom point more
      accurate.  We can achieve it by convert the chosen_point from 'unsigned
      long' to 'long'.
      
      [cai@lca.pw: reported a issue in the previous version]
      [mhocko@suse.com: fixed the issue reported by Cai]
      [mhocko@suse.com: add the comment in proc_oom_score()]
      [laoar.shao@gmail.com: v3]
        Link: http://lkml.kernel.org/r/1594396651-9931-1-git-send-email-laoar.shao@gmail.com
      
      
      
      Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Tested-by: default avatarNaresh Kamboju <naresh.kamboju@linaro.org>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Qian Cai <cai@lca.pw>
      Link: http://lkml.kernel.org/r/1594309987-9919-1-git-send-email-laoar.shao@gmail.com
      
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      765437d1
    • Shaik Sajida Bhanu's avatar
      mmc: sdhci-msm: Update the software timeout value for sdhc · 1cccf5c0
      Shaik Sajida Bhanu authored
      
      
      [ Upstream commit 67b13f3e ]
      
      Whenever SDHC run at clock rate 50MHZ or below, the hardware data
      timeout value will be 21.47secs, which is approx. 22secs and we have
      a current software timeout value as 10secs. We have to set software
      timeout value more than the hardware data timeout value to avioid seeing
      the below register dumps.
      
      [  332.953670] mmc2: Timeout waiting for hardware interrupt.
      [  332.959608] mmc2: sdhci: ============ SDHCI REGISTER DUMP ===========
      [  332.966450] mmc2: sdhci: Sys addr:  0x00000000 | Version:  0x00007202
      [  332.973256] mmc2: sdhci: Blk size:  0x00000200 | Blk cnt:  0x00000001
      [  332.980054] mmc2: sdhci: Argument:  0x00000000 | Trn mode: 0x00000027
      [  332.986864] mmc2: sdhci: Present:   0x01f801f6 | Host ctl: 0x0000001f
      [  332.993671] mmc2: sdhci: Power:     0x00000001 | Blk gap:  0x00000000
      [  333.000583] mmc2: sdhci: Wake-up:   0x00000000 | Clock:    0x00000007
      [  333.007386] mmc2: sdhci: Timeout:   0x0000000e | Int stat: 0x00000000
      [  333.014182] mmc2: sdhci: Int enab:  0x03ff100b | Sig enab: 0x03ff100b
      [  333.020976] mmc2: sdhci: ACmd stat: 0x00000000 | Slot int: 0x00000000
      [  333.027771] mmc2: sdhci: Caps:      0x322dc8b2 | Caps_1:   0x0000808f
      [  333.034561] mmc2: sdhci: Cmd:       0x0000183a | Max curr: 0x00000000
      [  333.041359] mmc2: sdhci: Resp[0]:   0x00000900 | Resp[1]:  0x00000000
      [  333.048157] mmc2: sdhci: Resp[2]:   0x00000000 | Resp[3]:  0x00000000
      [  333.054945] mmc2: sdhci: Host ctl2: 0x00000000
      [  333.059657] mmc2: sdhci: ADMA Err:  0x00000000 | ADMA Ptr:
      0x0000000ffffff218
      [  333.067178] mmc2: sdhci_msm: ----------- VENDOR REGISTER DUMP
      -----------
      [  333.074343] mmc2: sdhci_msm: DLL sts: 0x00000000 | DLL cfg:
      0x6000642c | DLL cfg2: 0x0020a000
      [  333.083417] mmc2: sdhci_msm: DLL cfg3: 0x00000000 | DLL usr ctl:
      0x00000000 | DDR cfg: 0x80040873
      [  333.092850] mmc2: sdhci_msm: Vndr func: 0x00008a9c | Vndr func2 :
      0xf88218a8 Vndr func3: 0x02626040
      [  333.102371] mmc2: sdhci: ============================================
      
      So, set software timeout value more than hardware timeout value.
      
      Signed-off-by: default avatarShaik Sajida Bhanu <sbhanu@codeaurora.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/1626435974-14462-1-git-send-email-sbhanu@codeaurora.org
      
      
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1cccf5c0
    • Miklos Szeredi's avatar
      ovl: fix uninitialized pointer read in ovl_lookup_real_one() · aec1e470
      Miklos Szeredi authored
      
      
      [ Upstream commit 580c6104 ]
      
      One error path can result in release_dentry_name_snapshot() being called
      before "name" was initialized by take_dentry_name_snapshot().
      
      Fix by moving the release_dentry_name_snapshot() to immediately after the
      only use.
      
      Reported-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aec1e470
    • Kefeng Wang's avatar
      once: Fix panic when module unload · 57bd5b59
      Kefeng Wang authored
      [ Upstream commit 1027b96e ]
      
      DO_ONCE
      DEFINE_STATIC_KEY_TRUE(___once_key);
      __do_once_done
        once_disable_jump(once_key);
          INIT_WORK(&w->work, once_deferred);
          struct once_work *w;
          w->key = key;
          schedule_work(&w->work);                     module unload
                                                         //*the key is
      destroy*
      process_one_work
        once_deferred
          BUG_ON(!static_key_enabled(work->key));
             static_key_count((struct static_key *)x)    //*access key, crash*
      
      When module uses DO_ONCE mechanism, it could crash due to the above
      concurrency problem, we could reproduce it with link[1].
      
      Fix it by add/put module refcount in the once work process.
      
      [1] https://lore.kernel.org/netdev/eaa6c371-465e-57eb-6be9-f4b16b9d7cbf@huawei.com/
      
      
      
      Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Eric Dumazet <edumazet@google.com>
      Reported-by: default avatarMinmin chen <chenmingmin@huawei.com>
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Acked-by: default avatarHannes Frederic Sowa <hannes@stressinduktion.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      57bd5b59
    • Florian Westphal's avatar
      netfilter: conntrack: collect all entries in one cycle · 5892f910
      Florian Westphal authored
      
      
      [ Upstream commit 4608fdfc ]
      
      Michal Kubecek reports that conntrack gc is responsible for frequent
      wakeups (every 125ms) on idle systems.
      
      On busy systems, timed out entries are evicted during lookup.
      The gc worker is only needed to remove entries after system becomes idle
      after a busy period.
      
      To resolve this, always scan the entire table.
      If the scan is taking too long, reschedule so other work_structs can run
      and resume from next bucket.
      
      After a completed scan, wait for 2 minutes before the next cycle.
      Heuristics for faster re-schedule are removed.
      
      GC_SCAN_INTERVAL could be exposed as a sysctl in the future to allow
      tuning this as-needed or even turn the gc worker off.
      
      Reported-by: default avatarMichal Kubecek <mkubecek@suse.cz>
      Signed-off-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>
      5892f910
    • Guenter Roeck's avatar
      ARC: Fix CONFIG_STACKDEPOT · 7c95c89b
      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>
      7c95c89b
    • Xiaolong Huang's avatar
      net: qrtr: fix another OOB Read in qrtr_endpoint_post · a6b049ae
      Xiaolong Huang authored
      
      
      commit 7e78c597 upstream.
      
      This check was incomplete, did not consider size is 0:
      
      	if (len != ALIGN(size, 4) + hdrlen)
                          goto err;
      
      if size from qrtr_hdr is 0, the result of ALIGN(size, 4)
      will be 0, In case of len == hdrlen and size == 0
      in header this check won't fail and
      
      	if (cb->type == QRTR_TYPE_NEW_SERVER) {
                      /* Remote node endpoint can bridge other distant nodes */
                      const struct qrtr_ctrl_pkt *pkt = data + hdrlen;
      
                      qrtr_node_assign(node, le32_to_cpu(pkt->server.node));
              }
      
      will also read out of bound from data, which is hdrlen allocated block.
      
      Fixes: 194ccc88 ("net: qrtr: Support decoding incoming v2 packets")
      Fixes: ad9d24c9 ("net: qrtr: fix OOB Read in qrtr_endpoint_post")
      Signed-off-by: default avatarXiaolong Huang <butterflyhuangxx@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a6b049ae
  2. Aug 26, 2021