Skip to content
  1. Jul 22, 2022
    • Ryusuke Konishi's avatar
      nilfs2: fix incorrect masking of permission flags for symlinks · d85d19f3
      Ryusuke Konishi authored
      commit 5924e6ec
      
       upstream.
      
      The permission flags of newly created symlinks are wrongly dropped on
      nilfs2 with the current umask value even though symlinks should have 777
      (rwxrwxrwx) permissions:
      
       $ umask
       0022
       $ touch file && ln -s file symlink; ls -l file symlink
       -rw-r--r--. 1 root root 0 Jun 23 16:29 file
       lrwxr-xr-x. 1 root root 4 Jun 23 16:29 symlink -> file
      
      This fixes the bug by inserting a missing check that excludes
      symlinks.
      
      Link: https://lkml.kernel.org/r/1655974441-5612-1-git-send-email-konishi.ryusuke@gmail.com
      Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Reported-by: default avatarTommy Pettersson <ptp@lysator.liu.se>
      Reported-by: default avatarCiprian Craciun <ciprian.craciun@gmail.com>
      Tested-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d85d19f3
    • Dmitry Osipenko's avatar
      drm/panfrost: Fix shrinker list corruption by madvise IOCTL · 393594aa
      Dmitry Osipenko authored
      commit 9fc33eaa upstream.
      
      Calling madvise IOCTL twice on BO causes memory shrinker list corruption
      and crashes kernel because BO is already on the list and it's added to
      the list again, while BO should be removed from the list before it's
      re-added. Fix it.
      
      Cc: stable@vger.kernel.org
      Fixes: 013b6510
      
       ("drm/panfrost: Add madvise and shrinker support")
      Acked-by: default avatarAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
      Reviewed-by: default avatarSteven Price <steven.price@arm.com>
      Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
      Signed-off-by: default avatarSteven Price <steven.price@arm.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220630200601.1884120-3-dmitry.osipenko@collabora.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      393594aa
    • Tejun Heo's avatar
      cgroup: Use separate src/dst nodes when preloading css_sets for migration · ad44e05f
      Tejun Heo authored
      commit 07fd5b6c
      
       upstream.
      
      Each cset (css_set) is pinned by its tasks. When we're moving tasks around
      across csets for a migration, we need to hold the source and destination
      csets to ensure that they don't go away while we're moving tasks about. This
      is done by linking cset->mg_preload_node on either the
      mgctx->preloaded_src_csets or mgctx->preloaded_dst_csets list. Using the
      same cset->mg_preload_node for both the src and dst lists was deemed okay as
      a cset can't be both the source and destination at the same time.
      
      Unfortunately, this overloading becomes problematic when multiple tasks are
      involved in a migration and some of them are identity noop migrations while
      others are actually moving across cgroups. For example, this can happen with
      the following sequence on cgroup1:
      
       #1> mkdir -p /sys/fs/cgroup/misc/a/b
       #2> echo $$ > /sys/fs/cgroup/misc/a/cgroup.procs
       #3> RUN_A_COMMAND_WHICH_CREATES_MULTIPLE_THREADS &
       #4> PID=$!
       #5> echo $PID > /sys/fs/cgroup/misc/a/b/tasks
       #6> echo $PID > /sys/fs/cgroup/misc/a/cgroup.procs
      
      the process including the group leader back into a. In this final migration,
      non-leader threads would be doing identity migration while the group leader
      is doing an actual one.
      
      After #3, let's say the whole process was in cset A, and that after #4, the
      leader moves to cset B. Then, during #6, the following happens:
      
       1. cgroup_migrate_add_src() is called on B for the leader.
      
       2. cgroup_migrate_add_src() is called on A for the other threads.
      
       3. cgroup_migrate_prepare_dst() is called. It scans the src list.
      
       4. It notices that B wants to migrate to A, so it tries to A to the dst
          list but realizes that its ->mg_preload_node is already busy.
      
       5. and then it notices A wants to migrate to A as it's an identity
          migration, it culls it by list_del_init()'ing its ->mg_preload_node and
          putting references accordingly.
      
       6. The rest of migration takes place with B on the src list but nothing on
          the dst list.
      
      This means that A isn't held while migration is in progress. If all tasks
      leave A before the migration finishes and the incoming task pins it, the
      cset will be destroyed leading to use-after-free.
      
      This is caused by overloading cset->mg_preload_node for both src and dst
      preload lists. We wanted to exclude the cset from the src list but ended up
      inadvertently excluding it from the dst list too.
      
      This patch fixes the issue by separating out cset->mg_preload_node into
      ->mg_src_preload_node and ->mg_dst_preload_node, so that the src and dst
      preloadings don't interfere with each other.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatarMukesh Ojha <quic_mojha@quicinc.com>
      Reported-by: default avatarshisiyuan <shisiyuan19870131@gmail.com>
      Link: http://lkml.kernel.org/r/1654187688-27411-1-git-send-email-shisiyuan@xiaomi.com
      Link: https://www.spinics.net/lists/cgroups/msg33313.html
      Fixes: f817de98
      
       ("cgroup: prepare migration path for unified hierarchy")
      Cc: stable@vger.kernel.org # v3.16+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ad44e05f
    • Felix Fietkau's avatar
      wifi: mac80211: fix queue selection for mesh/OCB interfaces · 444be5a0
      Felix Fietkau authored
      commit 50e2ab39
      
       upstream.
      
      When using iTXQ, the code assumes that there is only one vif queue for
      broadcast packets, using the BE queue. Allowing non-BE queue marking
      violates that assumption and txq->ac == skb_queue_mapping is no longer
      guaranteed. This can cause issues with queue handling in the driver and
      also causes issues with the recent ATF change, resulting in an AQL
      underflow warning.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
      Link: https://lore.kernel.org/r/20220702145227.39356-1-nbd@nbd.name
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      444be5a0
    • Ard Biesheuvel's avatar
      ARM: 9214/1: alignment: advance IT state after emulating Thumb instruction · dba54847
      Ard Biesheuvel authored
      commit e5c46fde
      
       upstream.
      
      After emulating a misaligned load or store issued in Thumb mode, we have
      to advance the IT state by hand, or it will get out of sync with the
      actual instruction stream, which means we'll end up applying the wrong
      condition code to subsequent instructions. This might corrupt the
      program state rather catastrophically.
      
      So borrow the it_advance() helper from the probing code, and use it on
      CPSR if the emulated instruction is Thumb.
      
      Cc: <stable@vger.kernel.org>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dba54847
    • Dmitry Osipenko's avatar
      ARM: 9213/1: Print message about disabled Spectre workarounds only once · b4d99aa5
      Dmitry Osipenko authored
      commit e4ced82d
      
       upstream.
      
      Print the message about disabled Spectre workarounds only once. The
      message is printed each time CPU goes out from idling state on NVIDIA
      Tegra boards, causing storm in KMSG that makes system unusable.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b4d99aa5
    • Nicolas Dichtel's avatar
      ip: fix dflt addr selection for connected nexthop · 2c1cc40f
      Nicolas Dichtel authored
      commit 747c1430 upstream.
      
      When a nexthop is added, without a gw address, the default scope was set
      to 'host'. Thus, when a source address is selected, 127.0.0.1 may be chosen
      but rejected when the route is used.
      
      When using a route without a nexthop id, the scope can be configured in the
      route, thus the problem doesn't exist.
      
      To explain more deeply: when a user creates a nexthop, it cannot specify
      the scope. To create it, the function nh_create_ipv4() calls fib_check_nh()
      with scope set to 0. fib_check_nh() calls fib_check_nh_nongw() wich was
      setting scope to 'host'. Then, nh_create_ipv4() calls
      fib_info_update_nhc_saddr() with scope set to 'host'. The src addr is
      chosen before the route is inserted.
      
      When a 'standard' route (ie without a reference to a nexthop) is added,
      fib_create_info() calls fib_info_update_nhc_saddr() with the scope set by
      the user. iproute2 set the scope to 'link' by default.
      
      Here is a way to reproduce the problem:
      ip netns add foo
      ip -n foo link set lo up
      ip netns add bar
      ip -n bar link set lo up
      sleep 1
      
      ip -n foo link add name eth0 type dummy
      ip -n foo link set eth0 up
      ip -n foo address add 192.168.0.1/24 dev eth0
      
      ip -n foo link add name veth0 type veth peer name veth1 netns bar
      ip -n foo link set veth0 up
      ip -n bar link set veth1 up
      
      ip -n bar address add 192.168.1.1/32 dev veth1
      ip -n bar route add default dev veth1
      
      ip -n foo nexthop add id 1 dev veth0
      ip -n foo route add 192.168.1.1 nhid 1
      
      Try to get/use the route:
      > $ ip -n foo route get 192.168.1.1
      > RTNETLINK answers: Invalid argument
      > $ ip netns exec foo ping -c1 192.168.1.1
      > ping: connect: Invalid argument
      
      Try without nexthop group (iproute2 sets scope to 'link' by dflt):
      ip -n foo route del 192.168.1.1
      ip -n foo route add 192.168.1.1 dev veth0
      
      Try to get/use the route:
      > $ ip -n foo route get 192.168.1.1
      > 192.168.1.1 dev veth0 src 192.168.0.1 uid 0
      >     cache
      > $ ip netns exec foo ping -c1 192.168.1.1
      > PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
      > 64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.039 ms
      >
      > --- 192.168.1.1 ping statistics ---
      > 1 packets transmitted, 1 received, 0% packet loss, time 0ms
      > rtt min/avg/max/mdev = 0.039/0.039/0.039/0.000 ms
      
      CC: stable@vger.kernel.org
      Fixes: 597cfe4f
      
       ("nexthop: Add support for IPv4 nexthops")
      Reported-by: default avatarEdwin Brossette <edwin.brossette@6wind.com>
      Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Link: https://lore.kernel.org/r/20220713114853.29406-1-nicolas.dichtel@6wind.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c1cc40f
    • Steven Rostedt (Google)'s avatar
      net: sock: tracing: Fix sock_exceed_buf_limit not to dereference stale pointer · fb5a7f15
      Steven Rostedt (Google) authored
      commit 820b8963 upstream.
      
      The trace event sock_exceed_buf_limit saves the prot->sysctl_mem pointer
      and then dereferences it in the TP_printk() portion. This is unsafe as the
      TP_printk() portion is executed at the time the buffer is read. That is,
      it can be seconds, minutes, days, months, even years later. If the proto
      is freed, then this dereference will can also lead to a kernel crash.
      
      Instead, save the sysctl_mem array into the ring buffer and have the
      TP_printk() reference that instead. This is the proper and safe way to
      read pointers in trace events.
      
      Link: https://lore.kernel.org/all/20220706052130.16368-12-kuniyu@amazon.com/
      
      Cc: stable@vger.kernel.org
      Fixes: 3847ce32
      
       ("core: add tracepoints for queueing skb to rcvbuf")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Acked-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fb5a7f15
    • Zheng Yejian's avatar
      tracing/histograms: Fix memory leak problem · ecc6dec1
      Zheng Yejian authored
      commit 7edc3945 upstream.
      
      This reverts commit 46bbe5c6.
      
      As commit 46bbe5c6 ("tracing: fix double free") said, the
      "double free" problem reported by clang static analyzer is:
        > In parse_var_defs() if there is a problem allocating
        > var_defs.expr, the earlier var_defs.name is freed.
        > This free is duplicated by free_var_defs() which frees
        > the rest of the list.
      
      However, if there is a problem allocating N-th var_defs.expr:
        + in parse_var_defs(), the freed 'earlier var_defs.name' is
          actually the N-th var_defs.name;
        + then in free_var_defs(), the names from 0th to (N-1)-th are freed;
      
                              IF ALLOCATING PROBLEM HAPPENED HERE!!! -+
                                                                       \
                                                                        |
                0th           1th                 (N-1)-th      N-th    V
                +-------------+-------------+-----+-------------+-----------
      var_defs: | name | expr | name | expr | ... | name | expr | name | ///
                +-------------+-------------+-----+-------------+-----------
      
      These two frees don't act on same name, so there was no "double free"
      problem before. Conversely, after that commit, we get a "memory leak"
      problem because the above "N-th var_defs.name" is not freed.
      
      If enable CONFIG_DEBUG_KMEMLEAK and inject a fault at where the N-th
      var_defs.expr allocated, then execute on shell like:
        $ echo 'hist:key=call_site:val=$v1,$v2:v1=bytes_req,v2=bytes_alloc' > \
      /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger
      
      Then kmemleak reports:
        unreferenced object 0xffff8fb100ef3518 (size 8):
          comm "bash", pid 196, jiffies 4295681690 (age 28.538s)
          hex dump (first 8 bytes):
            76 31 00 00 b1 8f ff ff                          v1......
          backtrace:
            [<0000000038fe4895>] kstrdup+0x2d/0x60
            [<00000000c99c049a>] event_hist_trigger_parse+0x206f/0x20e0
            [<00000000ae70d2cc>] trigger_process_regex+0xc0/0x110
            [<0000000066737a4c>] event_trigger_write+0x75/0xd0
            [<000000007341e40c>] vfs_write+0xbb/0x2a0
            [<0000000087fde4c2>] ksys_write+0x59/0xd0
            [<00000000581e9cdf>] do_syscall_64+0x3a/0x80
            [<00000000cf3b065c>] entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      Link: https://lkml.kernel.org/r/20220711014731.69520-1-zhengyejian1@huawei.com
      
      Cc: stable@vger.kernel.org
      Fixes: 46bbe5c6
      
       ("tracing: fix double free")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Suggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Reviewed-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
      Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ecc6dec1
    • Juergen Gross's avatar
      xen/netback: avoid entering xenvif_rx_next_skb() with an empty rx queue · 7425479d
      Juergen Gross authored
      commit 94e81006 upstream.
      
      xenvif_rx_next_skb() is expecting the rx queue not being empty, but
      in case the loop in xenvif_rx_action() is doing multiple iterations,
      the availability of another skb in the rx queue is not being checked.
      
      This can lead to crashes:
      
      [40072.537261] BUG: unable to handle kernel NULL pointer dereference at 0000000000000080
      [40072.537407] IP: xenvif_rx_skb+0x23/0x590 [xen_netback]
      [40072.537534] PGD 0 P4D 0
      [40072.537644] Oops: 0000 [#1] SMP NOPTI
      [40072.537749] CPU: 0 PID: 12505 Comm: v1-c40247-q2-gu Not tainted 4.12.14-122.121-default #1 SLE12-SP5
      [40072.537867] Hardware name: HP ProLiant DL580 Gen9/ProLiant DL580 Gen9, BIOS U17 11/23/2021
      [40072.537999] task: ffff880433b38100 task.stack: ffffc90043d40000
      [40072.538112] RIP: e030:xenvif_rx_skb+0x23/0x590 [xen_netback]
      [40072.538217] RSP: e02b:ffffc90043d43de0 EFLAGS: 00010246
      [40072.538319] RAX: 0000000000000000 RBX: ffffc90043cd7cd0 RCX: 00000000000000f7
      [40072.538430] RDX: 0000000000000000 RSI: 0000000000000006 RDI: ffffc90043d43df8
      [40072.538531] RBP: 000000000000003f R08: 000077ff80000000 R09: 0000000000000008
      [40072.538644] R10: 0000000000007ff0 R11: 00000000000008f6 R12: ffffc90043ce2708
      [40072.538745] R13: 0000000000000000 R14: ffffc90043d43ed0 R15: ffff88043ea748c0
      [40072.538861] FS: 0000000000000000(0000) GS:ffff880484600000(0000) knlGS:0000000000000000
      [40072.538988] CS: e033 DS: 0000 ES: 0000 CR0: 0000000080050033
      [40072.539088] CR2: 0000000000000080 CR3: 0000000407ac8000 CR4: 0000000000040660
      [40072.539211] Call Trace:
      [40072.539319] xenvif_rx_action+0x71/0x90 [xen_netback]
      [40072.539429] xenvif_kthread_guest_rx+0x14a/0x29c [xen_netback]
      
      Fix that by stopping the loop in case the rx queue becomes empty.
      
      Cc: stable@vger.kernel.org
      Fixes: 98f6d57c
      
       ("xen-netback: process guest rx packets in batches")
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      Reviewed-by: default avatarPaul Durrant <paul@xen.org>
      Link: https://lore.kernel.org/r/20220713135322.19616-1-jgross@suse.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7425479d
    • Meng Tang's avatar
      ALSA: hda/realtek - Enable the headset-mic on a Xiaomi's laptop · 9026b280
      Meng Tang authored
      commit 9b043a8f
      
       upstream.
      
      The headset on this machine is not defined, after applying the quirk
      ALC256_FIXUP_ASUS_HEADSET_MIC, the headset-mic works well
      
      Signed-off-by: default avatarMeng Tang <tangmeng@uniontech.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220713094133.9894-1-tangmeng@uniontech.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9026b280
    • Meng Tang's avatar
      ALSA: hda/realtek - Fix headset mic problem for a HP machine with alc221 · bbb82d4d
      Meng Tang authored
      commit 4ba5c853
      
       upstream.
      
      On a HP 288 Pro G2 MT (X9W02AV), the front mic could not be detected.
      In order to get it working, the pin configuration needs to be set
      correctly, and the ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE fixup needs
      to be applied.
      
      Signed-off-by: default avatarMeng Tang <tangmeng@uniontech.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220713063332.30095-1-tangmeng@uniontech.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bbb82d4d
    • Meng Tang's avatar
      ALSA: hda/realtek - Fix headset mic problem for a HP machine with alc671 · 7e2fbf2d
      Meng Tang authored
      commit dbe75d31
      
       upstream.
      
      On a HP 288 Pro G6, the front mic could not be detected.In order to
      get it working, the pin configuration needs to be set correctly, and
      the ALC671_FIXUP_HP_HEADSET_MIC2 fixup needs to be applied.
      
      Signed-off-by: default avatarMeng Tang <tangmeng@uniontech.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220712092222.21738-1-tangmeng@uniontech.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e2fbf2d
    • Meng Tang's avatar
      ALSA: hda/conexant: Apply quirk for another HP ProDesk 600 G3 model · 33d33a66
      Meng Tang authored
      commit d16d69bf
      
       upstream.
      
      There is another HP ProDesk 600 G3 model with the PCI SSID 103c:82b4
      that requires the quirk HP_MIC_NO_PRESENCE. Add the corresponding
      entry to the quirk table.
      
      Signed-off-by: default avatarMeng Tang <tangmeng@uniontech.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220711101744.25189-1-tangmeng@uniontech.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      33d33a66
    • Meng Tang's avatar
      ALSA: hda - Add fixup for Dell Latitidue E5430 · 5e7cc47a
      Meng Tang authored
      commit 841bdf85
      
       upstream.
      
      Another Dell model, another fixup entry: Latitude E5430 needs the same
      fixup as other Latitude E series as workaround for noise problems.
      
      Signed-off-by: default avatarMeng Tang <tangmeng@uniontech.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220712060005.20176-1-tangmeng@uniontech.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e7cc47a
  2. Jul 15, 2022
  3. Jul 12, 2022