Skip to content
  1. Dec 29, 2021
    • Federico Motta's avatar
      block, bfq: improve asymmetric scenarios detection · e4cd53c6
      Federico Motta authored
      commit 2d29c9f8
      
       upstream.
      
      bfq defines as asymmetric a scenario where an active entity, say E
      (representing either a single bfq_queue or a group of other entities),
      has a higher weight than some other entities.  If the entity E does sync
      I/O in such a scenario, then bfq plugs the dispatch of the I/O of the
      other entities in the following situation: E is in service but
      temporarily has no pending I/O request.  In fact, without this plugging,
      all the times that E stops being temporarily idle, it may find the
      internal queues of the storage device already filled with an
      out-of-control number of extra requests, from other entities. So E may
      have to wait for the service of these extra requests, before finally
      having its own requests served. This may easily break service
      guarantees, with E getting less than its fair share of the device
      throughput.  Usually, the end result is that E gets the same fraction of
      the throughput as the other entities, instead of getting more, according
      to its higher weight.
      
      Yet there are two other more subtle cases where E, even if its weight is
      actually equal to or even lower than the weight of any other active
      entities, may get less than its fair share of the throughput in case the
      above I/O plugging is not performed:
      1. other entities issue larger requests than E;
      2. other entities contain more active child entities than E (or in
         general tend to have more backlog than E).
      
      In the first case, other entities may get more service than E because
      they get larger requests, than those of E, served during the temporary
      idle periods of E.  In the second case, other entities get more service
      because, by having many child entities, they have many requests ready
      for dispatching while E is temporarily idle.
      
      This commit addresses this issue by extending the definition of
      asymmetric scenario: a scenario is asymmetric when
      - active entities representing bfq_queues have differentiated weights,
        as in the original definition
      or (inclusive)
      - one or more entities representing groups of entities are active.
      
      This broader definition makes sure that I/O plugging will be performed
      in all the above cases, provided that there is at least one active
      group.  Of course, this definition is very coarse, so it will trigger
      I/O plugging also in cases where it is not needed, such as, e.g.,
      multiple active entities with just one child each, and all with the same
      I/O-request size.  The reason for this coarse definition is just that a
      finer-grained definition would be rather heavy to compute.
      
      On the opposite end, even this new definition does not trigger I/O
      plugging in all cases where there is no active group, and all bfq_queues
      have the same weight.  So, in these cases some unfairness may occur if
      there are asymmetries in I/O-request sizes.  We made this choice because
      I/O plugging may lower throughput, and probably a user that has not
      created any group cares more about throughput than about perfect
      fairness.  At any rate, as for possible applications that may care about
      service guarantees, bfq already guarantees a high responsiveness and a
      low latency to soft real-time applications automatically.
      
      Signed-off-by: default avatarFederico Motta <federico@willer.it>
      Signed-off-by: default avatarPaolo Valente <paolo.valente@linaro.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e4cd53c6
    • Greg Jesionowski's avatar
      net: usb: lan78xx: add Allied Telesis AT29M2-AF · 7a4cd349
      Greg Jesionowski authored
      commit ef8a0f6e
      
       upstream.
      
      This adds the vendor and product IDs for the AT29M2-AF which is a
      lan7801-based device.
      
      Signed-off-by: default avatarGreg Jesionowski <jesionowskigreg@gmail.com>
      Link: https://lore.kernel.org/r/20211214221027.305784-1-jesionowskigreg@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7a4cd349
  2. Dec 22, 2021
    • Greg Kroah-Hartman's avatar
      Linux 4.19.222 · 508a321e
      Greg Kroah-Hartman authored
      
      
      Link: https://lore.kernel.org/r/20211220143023.451982183@linuxfoundation.org
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Tested-by: default avatarPavel Machek (CIP) <pavel@denx.de>
      Tested-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Tested-by: default avatarSudip Mukherjee <sudip.mukherjee@codethink.co.uk>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Tested-by: default avatarHulk Robot <hulkrobot@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v4.19.222
      508a321e
    • Juergen Gross's avatar
      xen/netback: don't queue unlimited number of packages · c9f17e92
      Juergen Gross authored
      commit be81992f upstream.
      
      In case a guest isn't consuming incoming network traffic as fast as it
      is coming in, xen-netback is buffering network packages in unlimited
      numbers today. This can result in host OOM situations.
      
      Commit f48da8b1 ("xen-netback: fix unlimited guest Rx internal
      queue and carrier flapping") meant to introduce a mechanism to limit
      the amount of buffered data by stopping the Tx queue when reaching the
      data limit, but this doesn't work for cases like UDP.
      
      When hitting the limit don't queue further SKBs, but drop them instead.
      In order to be able to tell Rx packages have been dropped increment the
      rx_dropped statistics counter in this case.
      
      It should be noted that the old solution to continue queueing SKBs had
      the additional problem of an overflow of the 32-bit rx_queue_len value
      would result in intermittent Tx queue enabling.
      
      This is part of XSA-392
      
      Fixes: f48da8b1
      
       ("xen-netback: fix unlimited guest Rx internal queue and carrier flapping")
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c9f17e92
    • Juergen Gross's avatar
      xen/netback: fix rx queue stall detection · 1de7644e
      Juergen Gross authored
      commit 6032046e upstream.
      
      Commit 1d5d4852 ("xen-netback: require fewer guest Rx slots when
      not using GSO") introduced a security problem in netback, as an
      interface would only be regarded to be stalled if no slot is available
      in the rx queue ring page. In case the SKB at the head of the queued
      requests will need more than one rx slot and only one slot is free the
      stall detection logic will never trigger, as the test for that is only
      looking for at least one slot to be free.
      
      Fix that by testing for the needed number of slots instead of only one
      slot being available.
      
      In order to not have to take the rx queue lock that often, store the
      number of needed slots in the queue data. As all SKB dequeue operations
      happen in the rx queue kernel thread this is safe, as long as the
      number of needed slots is accessed via READ/WRITE_ONCE() only and
      updates are always done with the rx queue lock held.
      
      Add a small helper for obtaining the number of free slots.
      
      This is part of XSA-392
      
      Fixes: 1d5d4852
      
       ("xen-netback: require fewer guest Rx slots when not using GSO")
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1de7644e
    • Juergen Gross's avatar
      xen/console: harden hvc_xen against event channel storms · 57e46acb
      Juergen Gross authored
      This is commit fe415186
      
       upstream.
      
      The Xen console driver is still vulnerable for an attack via excessive
      number of events sent by the backend. Fix that by using a lateeoi event
      channel.
      
      For the normal domU initial console this requires the introduction of
      bind_evtchn_to_irq_lateeoi() as there is no xenbus device available
      at the time the event channel is bound to the irq.
      
      As the decision whether an interrupt was spurious or not requires to
      test for bytes having been read from the backend, move sending the
      event into the if statement, as sending an event without having found
      any bytes to be read is making no sense at all.
      
      This is part of XSA-391
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57e46acb
    • Juergen Gross's avatar
      xen/netfront: harden netfront against event channel storms · 3559ca59
      Juergen Gross authored
      commit b27d4795
      
       upstream.
      
      The Xen netfront driver is still vulnerable for an attack via excessive
      number of events sent by the backend. Fix that by using lateeoi event
      channels.
      
      For being able to detect the case of no rx responses being added while
      the carrier is down a new lock is needed in order to update and test
      rsp_cons and the number of seen unconsumed responses atomically.
      
      This is part of XSA-391
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3559ca59
    • Juergen Gross's avatar
      xen/blkfront: harden blkfront against event channel storms · 269d7124
      Juergen Gross authored
      commit 0fd08a34
      
       upstream.
      
      The Xen blkfront driver is still vulnerable for an attack via excessive
      number of events sent by the backend. Fix that by using lateeoi event
      channels.
      
      This is part of XSA-391
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      269d7124
    • George Kennedy's avatar
      scsi: scsi_debug: Sanity check block descriptor length in resp_mode_select() · 04181973
      George Kennedy authored
      commit e0a2c28d
      
       upstream.
      
      In resp_mode_select() sanity check the block descriptor len to avoid UAF.
      
      BUG: KASAN: use-after-free in resp_mode_select+0xa4c/0xb40 drivers/scsi/scsi_debug.c:2509
      Read of size 1 at addr ffff888026670f50 by task scsicmd/15032
      
      CPU: 1 PID: 15032 Comm: scsicmd Not tainted 5.15.0-01d0625 #15
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      Call Trace:
       <TASK>
       dump_stack_lvl+0x89/0xb5 lib/dump_stack.c:107
       print_address_description.constprop.9+0x28/0x160 mm/kasan/report.c:257
       kasan_report.cold.14+0x7d/0x117 mm/kasan/report.c:443
       __asan_report_load1_noabort+0x14/0x20 mm/kasan/report_generic.c:306
       resp_mode_select+0xa4c/0xb40 drivers/scsi/scsi_debug.c:2509
       schedule_resp+0x4af/0x1a10 drivers/scsi/scsi_debug.c:5483
       scsi_debug_queuecommand+0x8c9/0x1e70 drivers/scsi/scsi_debug.c:7537
       scsi_queue_rq+0x16b4/0x2d10 drivers/scsi/scsi_lib.c:1521
       blk_mq_dispatch_rq_list+0xb9b/0x2700 block/blk-mq.c:1640
       __blk_mq_sched_dispatch_requests+0x28f/0x590 block/blk-mq-sched.c:325
       blk_mq_sched_dispatch_requests+0x105/0x190 block/blk-mq-sched.c:358
       __blk_mq_run_hw_queue+0xe5/0x150 block/blk-mq.c:1762
       __blk_mq_delay_run_hw_queue+0x4f8/0x5c0 block/blk-mq.c:1839
       blk_mq_run_hw_queue+0x18d/0x350 block/blk-mq.c:1891
       blk_mq_sched_insert_request+0x3db/0x4e0 block/blk-mq-sched.c:474
       blk_execute_rq_nowait+0x16b/0x1c0 block/blk-exec.c:63
       sg_common_write.isra.18+0xeb3/0x2000 drivers/scsi/sg.c:837
       sg_new_write.isra.19+0x570/0x8c0 drivers/scsi/sg.c:775
       sg_ioctl_common+0x14d6/0x2710 drivers/scsi/sg.c:941
       sg_ioctl+0xa2/0x180 drivers/scsi/sg.c:1166
       __x64_sys_ioctl+0x19d/0x220 fs/ioctl.c:52
       do_syscall_64+0x3a/0x80 arch/x86/entry/common.c:50
       entry_SYSCALL_64_after_hwframe+0x44/0xae arch/x86/entry/entry_64.S:113
      
      Link: https://lore.kernel.org/r/1637262208-28850-1-git-send-email-george.kennedy@oracle.com
      Reported-by: default avatarsyzkaller <syzkaller@googlegroups.com>
      Acked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: default avatarGeorge Kennedy <george.kennedy@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      04181973
    • Miklos Szeredi's avatar
      ovl: fix warning in ovl_create_real() · 445d2dc6
      Miklos Szeredi authored
      commit 1f5573cf
      
       upstream.
      
      Syzbot triggered the following warning in ovl_workdir_create() ->
      ovl_create_real():
      
      	if (!err && WARN_ON(!newdentry->d_inode)) {
      
      The reason is that the cgroup2 filesystem returns from mkdir without
      instantiating the new dentry.
      
      Weird filesystems such as this will be rejected by overlayfs at a later
      stage during setup, but to prevent such a warning, call ovl_mkdir_real()
      directly from ovl_workdir_create() and reject this case early.
      
      Reported-and-tested-by: default avatar <syzbot+75eab84fd0af9e8bf66b@syzkaller.appspotmail.com>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      445d2dc6
    • Miklos Szeredi's avatar
      fuse: annotate lock in fuse_reverse_inval_entry() · 55e0c283
      Miklos Szeredi authored
      commit bda9a719
      
       upstream.
      
      Add missing inode lock annotatation; found by syzbot.
      
      Reported-and-tested-by: default avatar <syzbot+9f747458f5990eaa8d43@syzkaller.appspotmail.com>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55e0c283
    • Pavel Skripkin's avatar
      media: mxl111sf: change mutex_init() location · 4b2d9600
      Pavel Skripkin authored
      commit 44870a9e
      
       upstream.
      
      Syzbot reported, that mxl111sf_ctrl_msg() uses uninitialized
      mutex. The problem was in wrong mutex_init() location.
      
      Previous mutex_init(&state->msg_lock) call was in ->init() function, but
      dvb_usbv2_init() has this order of calls:
      
      	dvb_usbv2_init()
      	  dvb_usbv2_adapter_init()
      	    dvb_usbv2_adapter_frontend_init()
      	      props->frontend_attach()
      
      	  props->init()
      
      Since mxl111sf_* devices call mxl111sf_ctrl_msg() in ->frontend_attach()
      internally we need to initialize state->msg_lock before
      frontend_attach(). To achieve it, ->probe() call added to all mxl111sf_*
      devices, which will simply initiaize mutex.
      
      Reported-and-tested-by: default avatar <syzbot+5ca0bf339f13c4243001@syzkaller.appspotmail.com>
      
      Fixes: 85722118
      
       ("[media] mxl111sf: convert to new DVB USB")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b2d9600
    • Fabio Estevam's avatar
      ARM: dts: imx6ull-pinfunc: Fix CSI_DATA07__ESAI_TX0 pad name · cc2d4087
      Fabio Estevam authored
      commit 737e65c7 upstream.
      
      According to the i.MX6ULL Reference Manual, pad CSI_DATA07 may
      have the ESAI_TX0 functionality, not ESAI_T0.
      
      Also, NXP's i.MX Config Tools 10.0 generates dtsi with the
      MX6ULL_PAD_CSI_DATA07__ESAI_TX0 naming, so fix it accordingly.
      
      There are no devicetree users in mainline that use the old name,
      so just remove the old entry.
      
      Fixes: c201369d
      
       ("ARM: dts: imx6ull: add imx6ull support")
      Reported-by: default avatarGeorge Makarov <georgemakarov1@gmail.com>
      Signed-off-by: default avatarFabio Estevam <festevam@gmail.com>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cc2d4087
    • Sudeep Holla's avatar
      firmware: arm_scpi: Fix string overflow in SCPI genpd driver · 7e8645ca
      Sudeep Holla authored
      commit 865ed67a upstream.
      
      Without the bound checks for scpi_pd->name, it could result in the buffer
      overflow when copying the SCPI device name from the corresponding device
      tree node as the name string is set at maximum size of 30.
      
      Let us fix it by using devm_kasprintf so that the string buffer is
      allocated dynamically.
      
      Fixes: 8bec4337
      
       ("firmware: scpi: add device power domain support using genpd")
      Reported-by: default avatarPedro Batista <pedbap.g@gmail.com>
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Cc: stable@vger.kernel.org
      Cc: Cristian Marussi <cristian.marussi@arm.com>
      Link: https://lore.kernel.org/r/20211209120456.696879-1-sudeep.holla@arm.com'
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e8645ca
    • Nathan Chancellor's avatar
      Input: touchscreen - avoid bitwise vs logical OR warning · 9723ebad
      Nathan Chancellor authored
      commit a02dcde5
      
       upstream.
      
      A new warning in clang points out a few places in this driver where a
      bitwise OR is being used with boolean types:
      
      drivers/input/touchscreen.c:81:17: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]
              data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x",
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      This use of a bitwise OR is intentional, as bitwise operations do not
      short circuit, which allows all the calls to touchscreen_get_prop_u32()
      to happen so that the last parameter is initialized while coalescing the
      results of the calls to make a decision after they are all evaluated.
      
      To make this clearer to the compiler, use the '|=' operator to assign
      the result of each touchscreen_get_prop_u32() call to data_present,
      which keeps the meaning of the code the same but makes it obvious that
      every one of these calls is expected to happen.
      
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reported-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lore.kernel.org/r/20211014205757.3474635-1-nathan@kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9723ebad
    • Stefan Agner's avatar
      ARM: 8800/1: use choice for kernel unwinders · b182bc71
      Stefan Agner authored
      commit f9b58e8c
      
       upstream.
      
      While in theory multiple unwinders could be compiled in, it does
      not make sense in practise. Use a choice to make the unwinder
      selection mutually exclusive and mandatory.
      
      Already before this commit it has not been possible to deselect
      FRAME_POINTER. Remove the obsolete comment.
      
      Furthermore, to produce a meaningful backtrace with FRAME_POINTER
      enabled the kernel needs a specific function prologue:
          mov    ip, sp
          stmfd    sp!, {fp, ip, lr, pc}
          sub    fp, ip, #4
      
      To get to the required prologue gcc uses apcs and no-sched-prolog.
      This compiler options are not available on clang, and clang is not
      able to generate the required prologue. Make the FRAME_POINTER
      config symbol depending on !clang.
      
      Suggested-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarStefan Agner <stefan@agner.ch>
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b182bc71
    • Nathan Chancellor's avatar
      mwifiex: Remove unnecessary braces from HostCmd_SET_SEQ_NO_BSS_INFO · 3bdac6e1
      Nathan Chancellor authored
      commit 6a953dc4 upstream.
      
      A new warning in clang points out when macro expansion might result in a
      GNU C statement expression. There is an instance of this in the mwifiex
      driver:
      
      drivers/net/wireless/marvell/mwifiex/cmdevt.c:217:34: warning: '}' and
      ')' tokens terminating statement expression appear in different macro
      expansion contexts [-Wcompound-token-split-by-macro]
              host_cmd->seq_num = cpu_to_le16(HostCmd_SET_SEQ_NO_BSS_INFO
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/net/wireless/marvell/mwifiex/fw.h:519:46: note: expanded from
      macro 'HostCmd_SET_SEQ_NO_BSS_INFO'
              (((type) & 0x000f) << 12);                  }
                                                          ^
      
      This does not appear to be a real issue. Removing the braces and
      replacing them with parentheses will fix the warning and not change the
      meaning of the code.
      
      Fixes: 5e6e3a92
      
       ("wireless: mwifiex: initial commit for Marvell mwifiex driver")
      Link: https://github.com/ClangBuiltLinux/linux/issues/1146
      Reported-by: default avatarAndy Lavr <andy.lavr@gmail.com>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200901070834.1015754-1-natechancellor@gmail.com
      Signed-off-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3bdac6e1
    • Nicolas Pitre's avatar
      ARM: 8805/2: remove unneeded naked function usage · b753ea6a
      Nicolas Pitre authored
      commit b99afae1 upstream.
      
      The naked attribute is known to confuse some old gcc versions when
      function arguments aren't explicitly listed as inline assembly operands
      despite the gcc documentation. That resulted in commit 9a40ac86
      
      
      ("ARM: 6164/1: Add kto and kfrom to input operands list.").
      
      Yet that commit has problems of its own by having assembly operand
      constraints completely wrong. If the generated code has been OK since
      then, it is due to luck rather than correctness. So this patch also
      provides proper assembly operand constraints, and removes two instances
      of redundant register usages in the implementation while at it.
      
      Inspection of the generated code with this patch doesn't show any
      obvious quality degradation either, so not relying on __naked at all
      will make the code less fragile, and avoid some issues with clang.
      
      The only remaining __naked instances (excluding the kprobes test cases)
      are exynos_pm_power_up_setup(), tc2_pm_power_up_setup() and
      
      cci_enable_port_for_self(. But in the first two cases, only the function
      address is used by the compiler with no chance of inlining it by
      mistake, and the third case is called from assembly code only. And the
      fact that no stack is available when the corresponding code is executed
      does warrant the __naked usage in those cases.
      
      Signed-off-by: default avatarNicolas Pitre <nico@linaro.org>
      Reviewed-by: default avatarStefan Agner <stefan@agner.ch>
      Tested-by: default avatarStefan Agner <stefan@agner.ch>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b753ea6a
    • Nathan Chancellor's avatar
      net: lan78xx: Avoid unnecessary self assignment · 77c91834
      Nathan Chancellor authored
      commit 94e7c844
      
       upstream.
      
      Clang warns when a variable is assigned to itself.
      
      drivers/net/usb/lan78xx.c:940:11: warning: explicitly assigning value of
      variable of type 'u32' (aka 'unsigned int') to itself [-Wself-assign]
                              offset = offset;
                              ~~~~~~ ^ ~~~~~~
      1 warning generated.
      
      Reorder the if statement to acheive the same result and avoid a self
      assignment warning.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/129
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      77c91834
    • Johannes Berg's avatar
      mac80211: validate extended element ID is present · 03029bb0
      Johannes Berg authored
      commit 768c0b19 upstream.
      
      Before attempting to parse an extended element, verify that
      the extended element ID is present.
      
      Fixes: 41cbb0f5
      
       ("mac80211: add support for HE")
      Reported-by: default avatar <syzbot+59bdff68edce82e393b6@syzkaller.appspotmail.com>
      Link: https://lore.kernel.org/r/20211211201023.f30a1b128c07.I5cacc176da94ba316877c6e10fe3ceec8b4dbd7d@changeid
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      03029bb0
    • Florian Fainelli's avatar
      net: systemport: Add global locking for descriptor lifecycle · 595a684f
      Florian Fainelli authored
      commit 8b8e6e78 upstream.
      
      The descriptor list is a shared resource across all of the transmit queues, and
      the locking mechanism used today only protects concurrency across a given
      transmit queue between the transmit and reclaiming. This creates an opportunity
      for the SYSTEMPORT hardware to work on corrupted descriptors if we have
      multiple producers at once which is the case when using multiple transmit
      queues.
      
      This was particularly noticeable when using multiple flows/transmit queues and
      it showed up in interesting ways in that UDP packets would get a correct UDP
      header checksum being calculated over an incorrect packet length. Similarly TCP
      packets would get an equally correct checksum computed by the hardware over an
      incorrect packet length.
      
      The SYSTEMPORT hardware maintains an internal descriptor list that it re-arranges
      when the driver produces a new descriptor anytime it writes to the
      WRITE_PORT_{HI,LO} registers, there is however some delay in the hardware to
      re-organize its descriptors and it is possible that concurrent TX queues
      eventually break this internal allocation scheme to the point where the
      length/status part of the descriptor gets used for an incorrect data buffer.
      
      The fix is to impose a global serialization for all TX queues in the short
      section where we are writing to the WRITE_PORT_{HI,LO} registers which solves
      the corruption even with multiple concurrent TX queues being used.
      
      Fixes: 80105bef
      
       ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20211215202450.4086240-1-f.fainelli@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      595a684f
    • Le Ma's avatar
      drm/amdgpu: correct register access for RLC_JUMP_TABLE_RESTORE · 6ca6342e
      Le Ma authored
      commit f3a8076e
      
       upstream.
      
      should count on GC IP base address
      
      Signed-off-by: default avatarLe Ma <le.ma@amd.com>
      Signed-off-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
      Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ca6342e
    • George Kennedy's avatar
      libata: if T_LENGTH is zero, dma direction should be DMA_NONE · 61295b8c
      George Kennedy authored
      commit 5da5231b
      
       upstream.
      
      Avoid data corruption by rejecting pass-through commands where
      T_LENGTH is zero (No data is transferred) and the dma direction
      is not DMA_NONE.
      
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatar <syzkaller&lt;syzkaller@googlegroups.com>
      Signed-off-by: default avatarGeorge <Kennedy&lt;george.kennedy@oracle.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      61295b8c
    • Yu Liao's avatar
      timekeeping: Really make sure wall_to_monotonic isn't positive · 8938a447
      Yu Liao authored
      commit 4e8c11b6 upstream.
      
      Even after commit e1d7ba87 ("time: Always make sure wall_to_monotonic
      isn't positive") it is still possible to make wall_to_monotonic positive
      by running the following code:
      
          int main(void)
          {
              struct timespec time;
      
              clock_gettime(CLOCK_MONOTONIC, &time);
              time.tv_nsec = 0;
              clock_settime(CLOCK_REALTIME, &time);
              return 0;
          }
      
      The reason is that the second parameter of timespec64_compare(), ts_delta,
      may be unnormalized because the delta is calculated with an open coded
      substraction which causes the comparison of tv_sec to yield the wrong
      result:
      
        wall_to_monotonic = { .tv_sec = -10, .tv_nsec =  900000000 }
        ts_delta 	    = { .tv_sec =  -9, .tv_nsec = -900000000 }
      
      That makes timespec64_compare() claim that wall_to_monotonic < ts_delta,
      but actually the result should be wall_to_monotonic > ts_delta.
      
      After normalization, the result of timespec64_compare() is correct because
      the tv_sec comparison is not longer misleading:
      
        wall_to_monotonic = { .tv_sec = -10, .tv_nsec =  900000000 }
        ts_delta 	    = { .tv_sec = -10, .tv_nsec =  100000000 }
      
      Use timespec64_sub() to ensure that ts_delta is normalized, which fixes the
      issue.
      
      Fixes: e1d7ba87
      
       ("time: Always make sure wall_to_monotonic isn't positive")
      Signed-off-by: default avatarYu Liao <liaoyu15@huawei.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20211213135727.1656662-1-liaoyu15@huawei.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8938a447
    • Daniele Palmas's avatar
      USB: serial: option: add Telit FN990 compositions · d902474a
      Daniele Palmas authored
      commit 2b503c85
      
       upstream.
      
      Add the following Telit FN990 compositions:
      
      0x1070: tty, adb, rmnet, tty, tty, tty, tty
      0x1071: tty, adb, mbim, tty, tty, tty, tty
      0x1072: rndis, tty, adb, tty, tty, tty, tty
      0x1073: tty, adb, ecm, tty, tty, tty, tty
      
      Signed-off-by: default avatarDaniele Palmas <dnlplm@gmail.com>
      Link: https://lore.kernel.org/r/20211210100714.22587-1-dnlplm@gmail.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>
      d902474a
    • Johan Hovold's avatar
      USB: serial: cp210x: fix CP2105 GPIO registration · c9c61034
      Johan Hovold authored
      commit 83b67041
      
       upstream.
      
      When generalising GPIO support and adding support for CP2102N, the GPIO
      registration for some CP2105 devices accidentally broke. Specifically,
      when all the pins of a port are in "modem" mode, and thus unavailable
      for GPIO use, the GPIO chip would now be registered without having
      initialised the number of GPIO lines. This would in turn be rejected by
      gpiolib and some errors messages would be printed (but importantly probe
      would still succeed).
      
      Fix this by initialising the number of GPIO lines before registering the
      GPIO chip.
      
      Note that as for the other device types, and as when all CP2105 pins are
      muxed for LED function, the GPIO chip is registered also when no pins
      are available for GPIO use.
      
      Reported-by: default avatarMaarten Brock <m.brock@vanmierlo.com>
      Link: https://lore.kernel.org/r/5eb560c81d2ea1a2b4602a92d9f48a89@vanmierlo.com
      Fixes: c8acfe0a
      
       ("USB: serial: cp210x: implement GPIO support for CP2102N")
      Cc: stable@vger.kernel.org      # 4.19
      Cc: Karoly Pados <pados@pados.hu>
      Link: https://lore.kernel.org/r/20211126094348.31698-1-johan@kernel.org
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Tested-by: default avatarMaarten Brock <m.brock@vanmierlo.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c9c61034
    • Stefan Roese's avatar
      PCI/MSI: Mask MSI-X vectors only on success · 12ae8cd1
      Stefan Roese authored
      commit 83dbf898 upstream.
      
      Masking all unused MSI-X entries is done to ensure that a crash kernel
      starts from a clean slate, which correponds to the reset state of the
      device as defined in the PCI-E specificion 3.0 and later:
      
       Vector Control for MSI-X Table Entries
       --------------------------------------
      
       "00: Mask bit:  When this bit is set, the function is prohibited from
                       sending a message using this MSI-X Table entry.
                       ...
                       This bit’s state after reset is 1 (entry is masked)."
      
      A Marvell NVME device fails to deliver MSI interrupts after trying to
      enable MSI-X interrupts due to that masking. It seems to take the MSI-X
      mask bits into account even when MSI-X is disabled.
      
      While not specification compliant, this can be cured by moving the masking
      into the success path, so that the MSI-X table entries stay in device reset
      state when the MSI-X setup fails.
      
      [ tglx: Move it into the success path, add comment and amend changelog ]
      
      Fixes: aa8092c1
      
       ("PCI/MSI: Mask all unused MSI-X entries")
      Signed-off-by: default avatarStefan Roese <sr@denx.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: linux-pci@vger.kernel.org
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Michal Simek <michal.simek@xilinx.com>
      Cc: Marek Vasut <marex@denx.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20211210161025.3287927-1-sr@denx.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      12ae8cd1
    • Thomas Gleixner's avatar
      PCI/MSI: Clear PCI_MSIX_FLAGS_MASKALL on error · 107883a5
      Thomas Gleixner authored
      commit 94185adb upstream.
      
      PCI_MSIX_FLAGS_MASKALL is set in the MSI-X control register at MSI-X
      interrupt setup time. It's cleared on success, but the error handling path
      only clears the PCI_MSIX_FLAGS_ENABLE bit.
      
      That's incorrect as the reset state of the PCI_MSIX_FLAGS_MASKALL bit is
      zero. That can be observed via lspci:
      
              Capabilities: [b0] MSI-X: Enable- Count=67 Masked+
      
      Clear the bit in the error path to restore the reset state.
      
      Fixes: 43855395
      
       ("PCI/MSI: Enable and mask MSI-X early")
      Reported-by: default avatarStefan Roese <sr@denx.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarStefan Roese <sr@denx.de>
      Cc: linux-pci@vger.kernel.org
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Michal Simek <michal.simek@xilinx.com>
      Cc: Marek Vasut <marex@denx.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/87tufevoqx.ffs@tglx
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      107883a5
    • Jimmy Wang's avatar
      USB: NO_LPM quirk Lenovo USB-C to Ethernet Adapher(RTL8153-04) · bb43b3c3
      Jimmy Wang authored
      commit 0ad3bd56
      
       upstream.
      
      This device doesn't work well with LPM, losing connectivity intermittently.
      Disable LPM to resolve the issue.
      
      Reviewed-by: default avatar <markpearson@lenovo.com>
      Signed-off-by: default avatarJimmy Wang <wangjm221@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20211214012652.4898-1-wangjm221@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb43b3c3
    • Greg Kroah-Hartman's avatar
      USB: gadget: bRequestType is a bitfield, not a enum · 05da4194
      Greg Kroah-Hartman authored
      [ Upstream commit f08adf5a ]
      
      Szymon rightly pointed out that the previous check for the endpoint
      direction in bRequestType was not looking at only the bit involved, but
      rather the whole value.  Normally this is ok, but for some request
      types, bits other than bit 8 could be set and the check for the endpoint
      length could not stall correctly.
      
      Fix that up by only checking the single bit.
      
      Fixes: 153a2d7e
      
       ("USB: gadget: detect too-big endpoint 0 requests")
      Cc: Felipe Balbi <balbi@kernel.org>
      Reported-by: default avatarSzymon Heidrich <szymon.heidrich@gmail.com>
      Link: https://lore.kernel.org/r/20211214184621.385828-1-gregkh@linuxfoundation.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      05da4194
    • Eric Dumazet's avatar
      sit: do not call ipip6_dev_free() from sit_init_net() · e56b65c1
      Eric Dumazet authored
      [ Upstream commit e28587cc ]
      
      ipip6_dev_free is sit dev->priv_destructor, already called
      by register_netdevice() if something goes wrong.
      
      Alternative would be to make ipip6_dev_free() robust against
      multiple invocations, but other drivers do not implement this
      strategy.
      
      syzbot reported:
      
      dst_release underflow
      WARNING: CPU: 0 PID: 5059 at net/core/dst.c:173 dst_release+0xd8/0xe0 net/core/dst.c:173
      Modules linked in:
      CPU: 1 PID: 5059 Comm: syz-executor.4 Not tainted 5.16.0-rc5-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:dst_release+0xd8/0xe0 net/core/dst.c:173
      Code: 4c 89 f2 89 d9 31 c0 5b 41 5e 5d e9 da d5 44 f9 e8 1d 90 5f f9 c6 05 87 48 c6 05 01 48 c7 c7 80 44 99 8b 31 c0 e8 e8 67 29 f9 <0f> 0b eb 85 0f 1f 40 00 53 48 89 fb e8 f7 8f 5f f9 48 83 c3 a8 48
      RSP: 0018:ffffc9000aa5faa0 EFLAGS: 00010246
      RAX: d6894a925dd15a00 RBX: 00000000ffffffff RCX: 0000000000040000
      RDX: ffffc90005e19000 RSI: 000000000003ffff RDI: 0000000000040000
      RBP: 0000000000000000 R08: ffffffff816a1f42 R09: ffffed1017344f2c
      R10: ffffed1017344f2c R11: 0000000000000000 R12: 0000607f462b1358
      R13: 1ffffffff1bfd305 R14: ffffe8ffffcb1358 R15: dffffc0000000000
      FS:  00007f66c71a2700(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f88aaed5058 CR3: 0000000023e0f000 CR4: 00000000003506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
       dst_cache_destroy+0x107/0x1e0 net/core/dst_cache.c:160
       ipip6_dev_free net/ipv6/sit.c:1414 [inline]
       sit_init_net+0x229/0x550 net/ipv6/sit.c:1936
       ops_init+0x313/0x430 net/core/net_namespace.c:140
       setup_net+0x35b/0x9d0 net/core/net_namespace.c:326
       copy_net_ns+0x359/0x5c0 net/core/net_namespace.c:470
       create_new_namespaces+0x4ce/0xa00 kernel/nsproxy.c:110
       unshare_nsproxy_namespaces+0x11e/0x180 kernel/nsproxy.c:226
       ksys_unshare+0x57d/0xb50 kernel/fork.c:3075
       __do_sys_unshare kernel/fork.c:3146 [inline]
       __se_sys_unshare kernel/fork.c:3144 [inline]
       __x64_sys_unshare+0x34/0x40 kernel/fork.c:3144
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x7f66c882ce99
      Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007f66c71a2168 EFLAGS: 00000246 ORIG_RAX: 0000000000000110
      RAX: ffffffffffffffda RBX: 00007f66c893ff60 RCX: 00007f66c882ce99
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000048040200
      RBP: 00007f66c8886ff1 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      R13: 00007fff6634832f R14: 00007f66c71a2300 R15: 0000000000022000
       </TASK>
      
      Fixes: cf124db5
      
       ("net: Fix inconsistent teardown and release of private netdev state.")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Link: https://lore.kernel.org/r/20211216111741.1387540-1-eric.dumazet@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e56b65c1
    • Willem de Bruijn's avatar
      net/packet: rx_owner_map depends on pg_vec · 18c73170
      Willem de Bruijn authored
      [ Upstream commit ec6af094 ]
      
      Packet sockets may switch ring versions. Avoid misinterpreting state
      between versions, whose fields share a union. rx_owner_map is only
      allocated with a packet ring (pg_vec) and both are swapped together.
      If pg_vec is NULL, meaning no packet ring was allocated, then neither
      was rx_owner_map. And the field may be old state from a tpacket_v3.
      
      Fixes: 61fad681
      
       ("net/packet: tpacket_rcv: avoid a producer race condition")
      Reported-by: default avatarSyzbot <syzbot+1ac0994a0a0c55151121@syzkaller.appspotmail.com>
      Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Link: https://lore.kernel.org/r/20211215143937.106178-1-willemdebruijn.kernel@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18c73170
    • Haimin Zhang's avatar
      netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc · d861443c
      Haimin Zhang authored
      [ Upstream commit 48122177 ]
      
      Zero-initialize memory for new map's value in function nsim_bpf_map_alloc
      since it may cause a potential kernel information leak issue, as follows:
      1. nsim_bpf_map_alloc calls nsim_map_alloc_elem to allocate elements for
      a new map.
      2. nsim_map_alloc_elem uses kmalloc to allocate map's value, but doesn't
      zero it.
      3. A user application can use IOCTL BPF_MAP_LOOKUP_ELEM to get specific
      element's information in the map.
      4. The kernel function map_lookup_elem will call bpf_map_copy_value to get
      the information allocated at step-2, then use copy_to_user to copy to the
      user buffer.
      This can only leak information for an array map.
      
      Fixes: 395cacb5
      
       ("netdevsim: bpf: support fake map offload")
      Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
      Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarHaimin Zhang <tcs.kernel@gmail.com>
      Link: https://lore.kernel.org/r/20211215111530.72103-1-tcs.kernel@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d861443c
    • Cyril Novikov's avatar
      ixgbe: set X550 MDIO speed before talking to PHY · 3ac69148
      Cyril Novikov authored
      [ Upstream commit bf0a3750 ]
      
      The MDIO bus speed must be initialized before talking to the PHY the first
      time in order to avoid talking to it using a speed that the PHY doesn't
      support.
      
      This fixes HW initialization error -17 (IXGBE_ERR_PHY_ADDR_INVALID) on
      Denverton CPUs (a.k.a. the Atom C3000 family) on ports with a 10Gb network
      plugged in. On those devices, HLREG0[MDCSPD] resets to 1, which combined
      with the 10Gb network results in a 24MHz MDIO speed, which is apparently
      too fast for the connected PHY. PHY register reads over MDIO bus return
      garbage, leading to initialization failure.
      
      Reproduced with Linux kernel 4.19 and 5.15-rc7. Can be reproduced using
      the following setup:
      
      * Use an Atom C3000 family system with at least one X552 LAN on the SoC
      * Disable PXE or other BIOS network initialization if possible
        (the interface must not be initialized before Linux boots)
      * Connect a live 10Gb Ethernet cable to an X550 port
      * Power cycle (not reset, doesn't always work) the system and boot Linux
      * Observe: ixgbe interfaces w/ 10GbE cables plugged in fail with error -17
      
      Fixes: e84db727
      
       ("ixgbe: Introduce function to control MDIO speed")
      Signed-off-by: default avatarCyril Novikov <cnovikov@lynx.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3ac69148
    • Letu Ren's avatar
      igbvf: fix double free in `igbvf_probe` · cc9b655b
      Letu Ren authored
      [ Upstream commit b6d335a6 ]
      
      In `igbvf_probe`, if register_netdev() fails, the program will go to
      label err_hw_init, and then to label err_ioremap. In free_netdev() which
      is just below label err_ioremap, there is `list_for_each_entry_safe` and
      `netif_napi_del` which aims to delete all entries in `dev->napi_list`.
      The program has added an entry `adapter->rx_ring->napi` which is added by
      `netif_napi_add` in igbvf_alloc_queues(). However, adapter->rx_ring has
      been freed below label err_hw_init. So this a UAF.
      
      In terms of how to patch the problem, we can refer to igbvf_remove() and
      delete the entry before `adapter->rx_ring`.
      
      The KASAN logs are as follows:
      
      [   35.126075] BUG: KASAN: use-after-free in free_netdev+0x1fd/0x450
      [   35.127170] Read of size 8 at addr ffff88810126d990 by task modprobe/366
      [   35.128360]
      [   35.128643] CPU: 1 PID: 366 Comm: modprobe Not tainted 5.15.0-rc2+ #14
      [   35.129789] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
      [   35.131749] Call Trace:
      [   35.132199]  dump_stack_lvl+0x59/0x7b
      [   35.132865]  print_address_description+0x7c/0x3b0
      [   35.133707]  ? free_netdev+0x1fd/0x450
      [   35.134378]  __kasan_report+0x160/0x1c0
      [   35.135063]  ? free_netdev+0x1fd/0x450
      [   35.135738]  kasan_report+0x4b/0x70
      [   35.136367]  free_netdev+0x1fd/0x450
      [   35.137006]  igbvf_probe+0x121d/0x1a10 [igbvf]
      [   35.137808]  ? igbvf_vlan_rx_add_vid+0x100/0x100 [igbvf]
      [   35.138751]  local_pci_probe+0x13c/0x1f0
      [   35.139461]  pci_device_probe+0x37e/0x6c0
      [   35.165526]
      [   35.165806] Allocated by task 366:
      [   35.166414]  ____kasan_kmalloc+0xc4/0xf0
      [   35.167117]  foo_kmem_cache_alloc_trace+0x3c/0x50 [igbvf]
      [   35.168078]  igbvf_probe+0x9c5/0x1a10 [igbvf]
      [   35.168866]  local_pci_probe+0x13c/0x1f0
      [   35.169565]  pci_device_probe+0x37e/0x6c0
      [   35.179713]
      [   35.179993] Freed by task 366:
      [   35.180539]  kasan_set_track+0x4c/0x80
      [   35.181211]  kasan_set_free_info+0x1f/0x40
      [   35.181942]  ____kasan_slab_free+0x103/0x140
      [   35.182703]  kfree+0xe3/0x250
      [   35.183239]  igbvf_probe+0x1173/0x1a10 [igbvf]
      [   35.184040]  local_pci_probe+0x13c/0x1f0
      
      Fixes: d4e0fe01
      
       (igbvf: add new driver to support 82576 virtual functions)
      Reported-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      Signed-off-by: default avatarLetu Ren <fantasquex@gmail.com>
      Tested-by: default avatarKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cc9b655b
    • Karen Sornek's avatar
      igb: Fix removal of unicast MAC filters of VFs · c615597e
      Karen Sornek authored
      [ Upstream commit 584af821 ]
      
      Move checking condition of VF MAC filter before clearing
      or adding MAC filter to VF to prevent potential blackout caused
      by removal of necessary and working VF's MAC filter.
      
      Fixes: 1b8b062a
      
       ("igb: add VF trust infrastructure")
      Signed-off-by: default avatarKaren Sornek <karen.sornek@intel.com>
      Tested-by: default avatarKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c615597e
    • Nathan Chancellor's avatar
      soc/tegra: fuse: Fix bitwise vs. logical OR warning · 214082bd
      Nathan Chancellor authored
      [ Upstream commit a7083763 ]
      
      A new warning in clang points out two instances where boolean
      expressions are being used with a bitwise OR instead of logical OR:
      
      drivers/soc/tegra/fuse/speedo-tegra20.c:72:9: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]
                      reg = tegra_fuse_read_spare(i) |
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
                                                     ||
      drivers/soc/tegra/fuse/speedo-tegra20.c:72:9: note: cast one or both operands to int to silence this warning
      drivers/soc/tegra/fuse/speedo-tegra20.c:87:9: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]
                      reg = tegra_fuse_read_spare(i) |
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
                                                     ||
      drivers/soc/tegra/fuse/speedo-tegra20.c:87:9: note: cast one or both operands to int to silence this warning
      2 warnings generated.
      
      The motivation for the warning is that logical operations short circuit
      while bitwise operations do not.
      
      In this instance, tegra_fuse_read_spare() is not semantically returning
      a boolean, it is returning a bit value. Use u32 for its return type so
      that it can be used with either bitwise or boolean operators without any
      warnings.
      
      Fixes: 25cd5a39
      
       ("ARM: tegra: Add speedo-based process identification")
      Link: https://github.com/ClangBuiltLinux/linux/issues/1488
      Suggested-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      214082bd
    • Hangyu Hua's avatar
      rds: memory leak in __rds_conn_create() · 1ed17372
      Hangyu Hua authored
      [ Upstream commit 5f9562eb ]
      
      __rds_conn_create() did not release conn->c_path when loop_trans != 0 and
      trans->t_prefer_loopback != 0 and is_outgoing == 0.
      
      Fixes: aced3ce5
      
       ("RDS tcp loopback connection can hang")
      Signed-off-by: default avatarHangyu Hua <hbh25y@gmail.com>
      Reviewed-by: default avatarSharath Srinivasan <sharath.srinivasan@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1ed17372
    • Alyssa Ross's avatar
      dmaengine: st_fdma: fix MODULE_ALIAS · 109627a6
      Alyssa Ross authored
      [ Upstream commit 822c9f2b ]
      
      modprobe can't handle spaces in aliases.
      
      Fixes: 6b4cd727
      
       ("dmaengine: st_fdma: Add STMicroelectronics FDMA engine driver support")
      Signed-off-by: default avatarAlyssa Ross <hi@alyssa.is>
      Link: https://lore.kernel.org/r/20211125154441.2626214-1-hi@alyssa.is
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      109627a6
    • Eric Dumazet's avatar
      sch_cake: do not call cake_destroy() from cake_init() · 4e388232
      Eric Dumazet authored
      [ Upstream commit ab443c53 ]
      
      qdiscs are not supposed to call their own destroy() method
      from init(), because core stack already does that.
      
      syzbot was able to trigger use after free:
      
      DEBUG_LOCKS_WARN_ON(lock->magic != lock)
      WARNING: CPU: 0 PID: 21902 at kernel/locking/mutex.c:586 __mutex_lock_common kernel/locking/mutex.c:586 [inline]
      WARNING: CPU: 0 PID: 21902 at kernel/locking/mutex.c:586 __mutex_lock+0x9ec/0x12f0 kernel/locking/mutex.c:740
      Modules linked in:
      CPU: 0 PID: 21902 Comm: syz-executor189 Not tainted 5.16.0-rc4-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:__mutex_lock_common kernel/locking/mutex.c:586 [inline]
      RIP: 0010:__mutex_lock+0x9ec/0x12f0 kernel/locking/mutex.c:740
      Code: 08 84 d2 0f 85 19 08 00 00 8b 05 97 38 4b 04 85 c0 0f 85 27 f7 ff ff 48 c7 c6 20 00 ac 89 48 c7 c7 a0 fe ab 89 e8 bf 76 ba ff <0f> 0b e9 0d f7 ff ff 48 8b 44 24 40 48 8d b8 c8 08 00 00 48 89 f8
      RSP: 0018:ffffc9000627f290 EFLAGS: 00010282
      RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
      RDX: ffff88802315d700 RSI: ffffffff815f1db8 RDI: fffff52000c4fe44
      RBP: ffff88818f28e000 R08: 0000000000000000 R09: 0000000000000000
      R10: ffffffff815ebb5e R11: 0000000000000000 R12: 0000000000000000
      R13: dffffc0000000000 R14: ffffc9000627f458 R15: 0000000093c30000
      FS:  0000555556abc400(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007fda689c3303 CR3: 000000001cfbb000 CR4: 0000000000350ef0
      Call Trace:
       <TASK>
       tcf_chain0_head_change_cb_del+0x2e/0x3d0 net/sched/cls_api.c:810
       tcf_block_put_ext net/sched/cls_api.c:1381 [inline]
       tcf_block_put_ext net/sched/cls_api.c:1376 [inline]
       tcf_block_put+0xbc/0x130 net/sched/cls_api.c:1394
       cake_destroy+0x3f/0x80 net/sched/sch_cake.c:2695
       qdisc_create.constprop.0+0x9da/0x10f0 net/sched/sch_api.c:1293
       tc_modify_qdisc+0x4c5/0x1980 net/sched/sch_api.c:1660
       rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5571
       netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2496
       netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
       netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1345
       netlink_sendmsg+0x904/0xdf0 net/netlink/af_netlink.c:1921
       sock_sendmsg_nosec net/socket.c:704 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:724
       ____sys_sendmsg+0x6e8/0x810 net/socket.c:2409
       ___sys_sendmsg+0xf3/0x170 net/socket.c:2463
       __sys_sendmsg+0xe5/0x1b0 net/socket.c:2492
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x7f1bb06badb9
      Code: Unable to access opcode bytes at RIP 0x7f1bb06bad8f.
      RSP: 002b:00007fff3012a658 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f1bb06badb9
      RDX: 0000000000000000 RSI: 00000000200007c0 RDI: 0000000000000003
      RBP: 0000000000000000 R08: 0000000000000003 R09: 0000000000000003
      R10: 0000000000000003 R11: 0000000000000246 R12: 00007fff3012a688
      R13: 00007fff3012a6a0 R14: 00007fff3012a6e0 R15: 00000000000013c2
       </TASK>
      
      Fixes: 046f6fd5
      
       ("sched: Add Common Applications Kept Enhanced (cake) qdisc")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Acked-by: default avatarToke Høiland-Jørgensen <toke@toke.dk>
      Link: https://lore.kernel.org/r/20211210142046.698336-1-eric.dumazet@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4e388232