]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 4.19
authorSasha Levin <sashal@kernel.org>
Sun, 10 Mar 2024 02:31:49 +0000 (21:31 -0500)
committerSasha Levin <sashal@kernel.org>
Sun, 10 Mar 2024 02:31:49 +0000 (21:31 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
19 files changed:
queue-4.19/btrfs-ref-verify-free-ref-cache-before-clearing-moun.patch [new file with mode: 0644]
queue-4.19/exit-fix-typo-in-comment-s-sub-theads-sub-threads.patch [new file with mode: 0644]
queue-4.19/exit-wait_task_zombie-kill-the-no-longer-necessary-s.patch [new file with mode: 0644]
queue-4.19/getrusage-add-the-signal_struct-sig-local-variable.patch [new file with mode: 0644]
queue-4.19/getrusage-move-thread_group_cputime_adjusted-outside.patch [new file with mode: 0644]
queue-4.19/getrusage-use-__for_each_thread.patch [new file with mode: 0644]
queue-4.19/getrusage-use-sig-stats_lock-rather-than-lock_task_s.patch [new file with mode: 0644]
queue-4.19/hv_netvsc-make-netvsc-vf-binding-check-both-mac-and-.patch [new file with mode: 0644]
queue-4.19/hv_netvsc-register-vf-in-netvsc_probe-if-net_device_.patch [new file with mode: 0644]
queue-4.19/hv_netvsc-use-netif_is_bond_master-instead-of-open-c.patch [new file with mode: 0644]
queue-4.19/input-i8042-fix-strange-behavior-of-touchpad-on-clev.patch [new file with mode: 0644]
queue-4.19/selftests-mm-fix-map_hugetlb-failure-on-64k-page-siz.patch [new file with mode: 0644]
queue-4.19/selftests-vm-fix-display-of-page-size-in-map_hugetlb.patch [new file with mode: 0644]
queue-4.19/selftests-vm-fix-map_hugetlb-length-used-for-testing.patch [new file with mode: 0644]
queue-4.19/series
queue-4.19/tools-selftest-vm-allow-choosing-mem-size-and-page-s.patch [new file with mode: 0644]
queue-4.19/um-allow-not-setting-extra-rpaths-in-the-linux-binar.patch [new file with mode: 0644]
queue-4.19/um-fix-adding-no-pie-for-clang.patch [new file with mode: 0644]
queue-4.19/y2038-rusage-use-__kernel_old_timeval.patch [new file with mode: 0644]

diff --git a/queue-4.19/btrfs-ref-verify-free-ref-cache-before-clearing-moun.patch b/queue-4.19/btrfs-ref-verify-free-ref-cache-before-clearing-moun.patch
new file mode 100644 (file)
index 0000000..54502de
--- /dev/null
@@ -0,0 +1,62 @@
+From e4cb568eba3cb6ab1d80757b3e9d12002bc8d847 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 3 Jan 2024 13:31:27 +0300
+Subject: btrfs: ref-verify: free ref cache before clearing mount opt
+
+From: Fedor Pchelkin <pchelkin@ispras.ru>
+
+[ Upstream commit f03e274a8b29d1d1c1bbd7f764766cb5ca537ab7 ]
+
+As clearing REF_VERIFY mount option indicates there were some errors in a
+ref-verify process, a ref cache is not relevant anymore and should be
+freed.
+
+btrfs_free_ref_cache() requires REF_VERIFY option being set so call
+it just before clearing the mount option.
+
+Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
+
+Reported-by: syzbot+be14ed7728594dc8bd42@syzkaller.appspotmail.com
+Fixes: fd708b81d972 ("Btrfs: add a extent ref verify tool")
+CC: stable@vger.kernel.org # 5.4+
+Closes: https://lore.kernel.org/lkml/000000000000e5a65c05ee832054@google.com/
+Reported-by: syzbot+c563a3c79927971f950f@syzkaller.appspotmail.com
+Closes: https://lore.kernel.org/lkml/0000000000007fe09705fdc6086c@google.com/
+Reviewed-by: Anand Jain <anand.jain@oracle.com>
+Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/btrfs/ref-verify.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c
+index b26739d0e991b..7bb816a6d1e19 100644
+--- a/fs/btrfs/ref-verify.c
++++ b/fs/btrfs/ref-verify.c
+@@ -891,8 +891,10 @@ int btrfs_ref_tree_mod(struct btrfs_root *root, u64 bytenr, u64 num_bytes,
+ out_unlock:
+       spin_unlock(&root->fs_info->ref_verify_lock);
+ out:
+-      if (ret)
++      if (ret) {
++              btrfs_free_ref_cache(fs_info);
+               btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY);
++      }
+       return ret;
+ }
+@@ -1021,8 +1023,8 @@ int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info)
+               }
+       }
+       if (ret) {
+-              btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY);
+               btrfs_free_ref_cache(fs_info);
++              btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY);
+       }
+       btrfs_free_path(path);
+       return ret;
+-- 
+2.43.0
+
diff --git a/queue-4.19/exit-fix-typo-in-comment-s-sub-theads-sub-threads.patch b/queue-4.19/exit-fix-typo-in-comment-s-sub-theads-sub-threads.patch
new file mode 100644 (file)
index 0000000..19e4644
--- /dev/null
@@ -0,0 +1,33 @@
+From 5e69a18318c2c3aa65b9097c68737049a5619921 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 3 Aug 2022 10:43:42 +0200
+Subject: exit: Fix typo in comment: s/sub-theads/sub-threads
+
+From: Ingo Molnar <mingo@kernel.org>
+
+[ Upstream commit dcca34754a3f5290406403b8066e3b15dda9f4bf ]
+
+Cc: linux-kernel@vger.kernel.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Stable-dep-of: c1be35a16b2f ("exit: wait_task_zombie: kill the no longer necessary spin_lock_irq(siglock)")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/exit.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kernel/exit.c b/kernel/exit.c
+index 0d1cca15e66fe..24e6953f606d2 100644
+--- a/kernel/exit.c
++++ b/kernel/exit.c
+@@ -1164,7 +1164,7 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
+                * p->signal fields because the whole thread group is dead
+                * and nobody can change them.
+                *
+-               * psig->stats_lock also protects us from our sub-theads
++               * psig->stats_lock also protects us from our sub-threads
+                * which can reap other children at the same time. Until
+                * we change k_getrusage()-like users to rely on this lock
+                * we have to take ->siglock as well.
+-- 
+2.43.0
+
diff --git a/queue-4.19/exit-wait_task_zombie-kill-the-no-longer-necessary-s.patch b/queue-4.19/exit-wait_task_zombie-kill-the-no-longer-necessary-s.patch
new file mode 100644 (file)
index 0000000..8b06e95
--- /dev/null
@@ -0,0 +1,65 @@
+From 0e387f9976f89c7172d46ff6d0fdbb14d453ae07 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 23 Jan 2024 16:34:00 +0100
+Subject: exit: wait_task_zombie: kill the no longer necessary
+ spin_lock_irq(siglock)
+
+From: Oleg Nesterov <oleg@redhat.com>
+
+[ Upstream commit c1be35a16b2f1fe21f4f26f9de030ad6eaaf6a25 ]
+
+After the recent changes nobody use siglock to read the values protected
+by stats_lock, we can kill spin_lock_irq(&current->sighand->siglock) and
+update the comment.
+
+With this patch only __exit_signal() and thread_group_start_cputime() take
+stats_lock under siglock.
+
+Link: https://lkml.kernel.org/r/20240123153359.GA21866@redhat.com
+Signed-off-by: Oleg Nesterov <oleg@redhat.com>
+Signed-off-by: Dylan Hatch <dylanbhatch@google.com>
+Cc: Eric W. Biederman <ebiederm@xmission.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/exit.c | 10 +++-------
+ 1 file changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/kernel/exit.c b/kernel/exit.c
+index 24e6953f606d2..a948ce8927975 100644
+--- a/kernel/exit.c
++++ b/kernel/exit.c
+@@ -1165,17 +1165,14 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
+                * and nobody can change them.
+                *
+                * psig->stats_lock also protects us from our sub-threads
+-               * which can reap other children at the same time. Until
+-               * we change k_getrusage()-like users to rely on this lock
+-               * we have to take ->siglock as well.
++               * which can reap other children at the same time.
+                *
+                * We use thread_group_cputime_adjusted() to get times for
+                * the thread group, which consolidates times for all threads
+                * in the group including the group leader.
+                */
+               thread_group_cputime_adjusted(p, &tgutime, &tgstime);
+-              spin_lock_irq(&current->sighand->siglock);
+-              write_seqlock(&psig->stats_lock);
++              write_seqlock_irq(&psig->stats_lock);
+               psig->cutime += tgutime + sig->cutime;
+               psig->cstime += tgstime + sig->cstime;
+               psig->cgtime += task_gtime(p) + sig->gtime + sig->cgtime;
+@@ -1198,8 +1195,7 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
+                       psig->cmaxrss = maxrss;
+               task_io_accounting_add(&psig->ioac, &p->ioac);
+               task_io_accounting_add(&psig->ioac, &sig->ioac);
+-              write_sequnlock(&psig->stats_lock);
+-              spin_unlock_irq(&current->sighand->siglock);
++              write_sequnlock_irq(&psig->stats_lock);
+       }
+       if (wo->wo_rusage)
+-- 
+2.43.0
+
diff --git a/queue-4.19/getrusage-add-the-signal_struct-sig-local-variable.patch b/queue-4.19/getrusage-add-the-signal_struct-sig-local-variable.patch
new file mode 100644 (file)
index 0000000..e4b27b0
--- /dev/null
@@ -0,0 +1,93 @@
+From e139342d06aa6b38d38bc1c72d2f5d62a78ca07e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 9 Sep 2023 19:25:54 +0200
+Subject: getrusage: add the "signal_struct *sig" local variable
+
+From: Oleg Nesterov <oleg@redhat.com>
+
+[ Upstream commit c7ac8231ace9b07306d0299969e42073b189c70a ]
+
+No functional changes, cleanup/preparation.
+
+Link: https://lkml.kernel.org/r/20230909172554.GA20441@redhat.com
+Signed-off-by: Oleg Nesterov <oleg@redhat.com>
+Cc: Eric W. Biederman <ebiederm@xmission.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Stable-dep-of: daa694e41375 ("getrusage: move thread_group_cputime_adjusted() outside of lock_task_sighand()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/sys.c | 37 +++++++++++++++++++------------------
+ 1 file changed, 19 insertions(+), 18 deletions(-)
+
+diff --git a/kernel/sys.c b/kernel/sys.c
+index e18bef5a8f9f5..d0d4f4c586518 100644
+--- a/kernel/sys.c
++++ b/kernel/sys.c
+@@ -1718,6 +1718,7 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+       unsigned long flags;
+       u64 tgutime, tgstime, utime, stime;
+       unsigned long maxrss = 0;
++      struct signal_struct *sig = p->signal;
+       memset((char *)r, 0, sizeof (*r));
+       utime = stime = 0;
+@@ -1725,7 +1726,7 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+       if (who == RUSAGE_THREAD) {
+               task_cputime_adjusted(current, &utime, &stime);
+               accumulate_thread_rusage(p, r);
+-              maxrss = p->signal->maxrss;
++              maxrss = sig->maxrss;
+               goto out;
+       }
+@@ -1735,15 +1736,15 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+       switch (who) {
+       case RUSAGE_BOTH:
+       case RUSAGE_CHILDREN:
+-              utime = p->signal->cutime;
+-              stime = p->signal->cstime;
+-              r->ru_nvcsw = p->signal->cnvcsw;
+-              r->ru_nivcsw = p->signal->cnivcsw;
+-              r->ru_minflt = p->signal->cmin_flt;
+-              r->ru_majflt = p->signal->cmaj_flt;
+-              r->ru_inblock = p->signal->cinblock;
+-              r->ru_oublock = p->signal->coublock;
+-              maxrss = p->signal->cmaxrss;
++              utime = sig->cutime;
++              stime = sig->cstime;
++              r->ru_nvcsw = sig->cnvcsw;
++              r->ru_nivcsw = sig->cnivcsw;
++              r->ru_minflt = sig->cmin_flt;
++              r->ru_majflt = sig->cmaj_flt;
++              r->ru_inblock = sig->cinblock;
++              r->ru_oublock = sig->coublock;
++              maxrss = sig->cmaxrss;
+               if (who == RUSAGE_CHILDREN)
+                       break;
+@@ -1752,14 +1753,14 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+               thread_group_cputime_adjusted(p, &tgutime, &tgstime);
+               utime += tgutime;
+               stime += tgstime;
+-              r->ru_nvcsw += p->signal->nvcsw;
+-              r->ru_nivcsw += p->signal->nivcsw;
+-              r->ru_minflt += p->signal->min_flt;
+-              r->ru_majflt += p->signal->maj_flt;
+-              r->ru_inblock += p->signal->inblock;
+-              r->ru_oublock += p->signal->oublock;
+-              if (maxrss < p->signal->maxrss)
+-                      maxrss = p->signal->maxrss;
++              r->ru_nvcsw += sig->nvcsw;
++              r->ru_nivcsw += sig->nivcsw;
++              r->ru_minflt += sig->min_flt;
++              r->ru_majflt += sig->maj_flt;
++              r->ru_inblock += sig->inblock;
++              r->ru_oublock += sig->oublock;
++              if (maxrss < sig->maxrss)
++                      maxrss = sig->maxrss;
+               t = p;
+               do {
+                       accumulate_thread_rusage(t, r);
+-- 
+2.43.0
+
diff --git a/queue-4.19/getrusage-move-thread_group_cputime_adjusted-outside.patch b/queue-4.19/getrusage-move-thread_group_cputime_adjusted-outside.patch
new file mode 100644 (file)
index 0000000..06a302e
--- /dev/null
@@ -0,0 +1,111 @@
+From ab471181fa68797493022f088304f11d00895e79 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 22 Jan 2024 16:50:50 +0100
+Subject: getrusage: move thread_group_cputime_adjusted() outside of
+ lock_task_sighand()
+
+From: Oleg Nesterov <oleg@redhat.com>
+
+[ Upstream commit daa694e4137571b4ebec330f9a9b4d54aa8b8089 ]
+
+Patch series "getrusage: use sig->stats_lock", v2.
+
+This patch (of 2):
+
+thread_group_cputime() does its own locking, we can safely shift
+thread_group_cputime_adjusted() which does another for_each_thread loop
+outside of ->siglock protected section.
+
+This is also preparation for the next patch which changes getrusage() to
+use stats_lock instead of siglock, thread_group_cputime() takes the same
+lock.  With the current implementation recursive read_seqbegin_or_lock()
+is fine, thread_group_cputime() can't enter the slow mode if the caller
+holds stats_lock, yet this looks more safe and better performance-wise.
+
+Link: https://lkml.kernel.org/r/20240122155023.GA26169@redhat.com
+Link: https://lkml.kernel.org/r/20240122155050.GA26205@redhat.com
+Signed-off-by: Oleg Nesterov <oleg@redhat.com>
+Reported-by: Dylan Hatch <dylanbhatch@google.com>
+Tested-by: Dylan Hatch <dylanbhatch@google.com>
+Cc: Eric W. Biederman <ebiederm@xmission.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/sys.c | 34 +++++++++++++++++++---------------
+ 1 file changed, 19 insertions(+), 15 deletions(-)
+
+diff --git a/kernel/sys.c b/kernel/sys.c
+index d0d4f4c586518..ab621d7837c97 100644
+--- a/kernel/sys.c
++++ b/kernel/sys.c
+@@ -1717,17 +1717,19 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+       struct task_struct *t;
+       unsigned long flags;
+       u64 tgutime, tgstime, utime, stime;
+-      unsigned long maxrss = 0;
++      unsigned long maxrss;
++      struct mm_struct *mm;
+       struct signal_struct *sig = p->signal;
+-      memset((char *)r, 0, sizeof (*r));
++      memset(r, 0, sizeof(*r));
+       utime = stime = 0;
++      maxrss = 0;
+       if (who == RUSAGE_THREAD) {
+               task_cputime_adjusted(current, &utime, &stime);
+               accumulate_thread_rusage(p, r);
+               maxrss = sig->maxrss;
+-              goto out;
++              goto out_thread;
+       }
+       if (!lock_task_sighand(p, &flags))
+@@ -1750,9 +1752,6 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+                       break;
+       case RUSAGE_SELF:
+-              thread_group_cputime_adjusted(p, &tgutime, &tgstime);
+-              utime += tgutime;
+-              stime += tgstime;
+               r->ru_nvcsw += sig->nvcsw;
+               r->ru_nivcsw += sig->nivcsw;
+               r->ru_minflt += sig->min_flt;
+@@ -1772,19 +1771,24 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+       }
+       unlock_task_sighand(p, &flags);
+-out:
+-      r->ru_utime = ns_to_kernel_old_timeval(utime);
+-      r->ru_stime = ns_to_kernel_old_timeval(stime);
++      if (who == RUSAGE_CHILDREN)
++              goto out_children;
+-      if (who != RUSAGE_CHILDREN) {
+-              struct mm_struct *mm = get_task_mm(p);
++      thread_group_cputime_adjusted(p, &tgutime, &tgstime);
++      utime += tgutime;
++      stime += tgstime;
+-              if (mm) {
+-                      setmax_mm_hiwater_rss(&maxrss, mm);
+-                      mmput(mm);
+-              }
++out_thread:
++      mm = get_task_mm(p);
++      if (mm) {
++              setmax_mm_hiwater_rss(&maxrss, mm);
++              mmput(mm);
+       }
++
++out_children:
+       r->ru_maxrss = maxrss * (PAGE_SIZE / 1024); /* convert pages to KBs */
++      r->ru_utime = ns_to_kernel_old_timeval(utime);
++      r->ru_stime = ns_to_kernel_old_timeval(stime);
+ }
+ SYSCALL_DEFINE2(getrusage, int, who, struct rusage __user *, ru)
+-- 
+2.43.0
+
diff --git a/queue-4.19/getrusage-use-__for_each_thread.patch b/queue-4.19/getrusage-use-__for_each_thread.patch
new file mode 100644 (file)
index 0000000..4b15bca
--- /dev/null
@@ -0,0 +1,43 @@
+From b5edab81df191439299794e96abce226e76fb896 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 9 Sep 2023 19:26:29 +0200
+Subject: getrusage: use __for_each_thread()
+
+From: Oleg Nesterov <oleg@redhat.com>
+
+[ Upstream commit 13b7bc60b5353371460a203df6c38ccd38ad7a3a ]
+
+do/while_each_thread should be avoided when possible.
+
+Plus this change allows to avoid lock_task_sighand(), we can use rcu
+and/or sig->stats_lock instead.
+
+Link: https://lkml.kernel.org/r/20230909172629.GA20454@redhat.com
+Signed-off-by: Oleg Nesterov <oleg@redhat.com>
+Cc: Eric W. Biederman <ebiederm@xmission.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Stable-dep-of: f7ec1cd5cc7e ("getrusage: use sig->stats_lock rather than lock_task_sighand()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/sys.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/kernel/sys.c b/kernel/sys.c
+index ab621d7837c97..521a76d4adbbb 100644
+--- a/kernel/sys.c
++++ b/kernel/sys.c
+@@ -1760,10 +1760,8 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+               r->ru_oublock += sig->oublock;
+               if (maxrss < sig->maxrss)
+                       maxrss = sig->maxrss;
+-              t = p;
+-              do {
++              __for_each_thread(sig, t)
+                       accumulate_thread_rusage(t, r);
+-              } while_each_thread(p, t);
+               break;
+       default:
+-- 
+2.43.0
+
diff --git a/queue-4.19/getrusage-use-sig-stats_lock-rather-than-lock_task_s.patch b/queue-4.19/getrusage-use-sig-stats_lock-rather-than-lock_task_s.patch
new file mode 100644 (file)
index 0000000..6a8604a
--- /dev/null
@@ -0,0 +1,92 @@
+From acec7bcf715f661a3a2afb874767985bdf412950 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 22 Jan 2024 16:50:53 +0100
+Subject: getrusage: use sig->stats_lock rather than lock_task_sighand()
+
+From: Oleg Nesterov <oleg@redhat.com>
+
+[ Upstream commit f7ec1cd5cc7ef3ad964b677ba82b8b77f1c93009 ]
+
+lock_task_sighand() can trigger a hard lockup. If NR_CPUS threads call
+getrusage() at the same time and the process has NR_THREADS, spin_lock_irq
+will spin with irqs disabled O(NR_CPUS * NR_THREADS) time.
+
+Change getrusage() to use sig->stats_lock, it was specifically designed
+for this type of use. This way it runs lockless in the likely case.
+
+TODO:
+       - Change do_task_stat() to use sig->stats_lock too, then we can
+         remove spin_lock_irq(siglock) in wait_task_zombie().
+
+       - Turn sig->stats_lock into seqcount_rwlock_t, this way the
+         readers in the slow mode won't exclude each other. See
+         https://lore.kernel.org/all/20230913154907.GA26210@redhat.com/
+
+       - stats_lock has to disable irqs because ->siglock can be taken
+         in irq context, it would be very nice to change __exit_signal()
+         to avoid the siglock->stats_lock dependency.
+
+Link: https://lkml.kernel.org/r/20240122155053.GA26214@redhat.com
+Signed-off-by: Oleg Nesterov <oleg@redhat.com>
+Reported-by: Dylan Hatch <dylanbhatch@google.com>
+Tested-by: Dylan Hatch <dylanbhatch@google.com>
+Cc: Eric W. Biederman <ebiederm@xmission.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/sys.c | 16 +++++++++++++---
+ 1 file changed, 13 insertions(+), 3 deletions(-)
+
+diff --git a/kernel/sys.c b/kernel/sys.c
+index 521a76d4adbbb..62930aac0bad7 100644
+--- a/kernel/sys.c
++++ b/kernel/sys.c
+@@ -1720,7 +1720,9 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+       unsigned long maxrss;
+       struct mm_struct *mm;
+       struct signal_struct *sig = p->signal;
++      unsigned int seq = 0;
++retry:
+       memset(r, 0, sizeof(*r));
+       utime = stime = 0;
+       maxrss = 0;
+@@ -1732,8 +1734,7 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+               goto out_thread;
+       }
+-      if (!lock_task_sighand(p, &flags))
+-              return;
++      flags = read_seqbegin_or_lock_irqsave(&sig->stats_lock, &seq);
+       switch (who) {
+       case RUSAGE_BOTH:
+@@ -1760,14 +1761,23 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+               r->ru_oublock += sig->oublock;
+               if (maxrss < sig->maxrss)
+                       maxrss = sig->maxrss;
++
++              rcu_read_lock();
+               __for_each_thread(sig, t)
+                       accumulate_thread_rusage(t, r);
++              rcu_read_unlock();
++
+               break;
+       default:
+               BUG();
+       }
+-      unlock_task_sighand(p, &flags);
++
++      if (need_seqretry(&sig->stats_lock, seq)) {
++              seq = 1;
++              goto retry;
++      }
++      done_seqretry_irqrestore(&sig->stats_lock, seq, flags);
+       if (who == RUSAGE_CHILDREN)
+               goto out_children;
+-- 
+2.43.0
+
diff --git a/queue-4.19/hv_netvsc-make-netvsc-vf-binding-check-both-mac-and-.patch b/queue-4.19/hv_netvsc-make-netvsc-vf-binding-check-both-mac-and-.patch
new file mode 100644 (file)
index 0000000..862ea49
--- /dev/null
@@ -0,0 +1,60 @@
+From 69b3bedfffe4f0f4b65cdf7095c1e24524268a96 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 23 Apr 2021 18:12:35 -0700
+Subject: hv_netvsc: Make netvsc/VF binding check both MAC and serial number
+
+From: Dexuan Cui <decui@microsoft.com>
+
+[ Upstream commit 64ff412ad41fe3a5bf759ff4844dc1382176485c ]
+
+Currently the netvsc/VF binding logic only checks the PCI serial number.
+
+The Microsoft Azure Network Adapter (MANA) supports multiple net_device
+interfaces (each such interface is called a "vPort", and has its unique
+MAC address) which are backed by the same VF PCI device, so the binding
+logic should check both the MAC address and the PCI serial number.
+
+The change should not break any other existing VF drivers, because
+Hyper-V NIC SR-IOV implementation requires the netvsc network
+interface and the VF network interface have the same MAC address.
+
+Co-developed-by: Haiyang Zhang <haiyangz@microsoft.com>
+Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
+Co-developed-by: Shachar Raindel <shacharr@microsoft.com>
+Signed-off-by: Shachar Raindel <shacharr@microsoft.com>
+Acked-by: Stephen Hemminger <stephen@networkplumber.org>
+Signed-off-by: Dexuan Cui <decui@microsoft.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Stable-dep-of: 9cae43da9867 ("hv_netvsc: Register VF in netvsc_probe if NET_DEVICE_REGISTER missed")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/hyperv/netvsc_drv.c | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
+index ce17917b6f76f..fcf89ee5080f1 100644
+--- a/drivers/net/hyperv/netvsc_drv.c
++++ b/drivers/net/hyperv/netvsc_drv.c
+@@ -2141,8 +2141,17 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev)
+               if (!ndev_ctx->vf_alloc)
+                       continue;
+-              if (ndev_ctx->vf_serial == serial)
+-                      return hv_get_drvdata(ndev_ctx->device_ctx);
++              if (ndev_ctx->vf_serial != serial)
++                      continue;
++
++              ndev = hv_get_drvdata(ndev_ctx->device_ctx);
++              if (ndev->addr_len != vf_netdev->addr_len ||
++                  memcmp(ndev->perm_addr, vf_netdev->perm_addr,
++                         ndev->addr_len) != 0)
++                      continue;
++
++              return ndev;
++
+       }
+       /* Fallback path to check synthetic vf with help of mac addr.
+-- 
+2.43.0
+
diff --git a/queue-4.19/hv_netvsc-register-vf-in-netvsc_probe-if-net_device_.patch b/queue-4.19/hv_netvsc-register-vf-in-netvsc_probe-if-net_device_.patch
new file mode 100644 (file)
index 0000000..a00ad48
--- /dev/null
@@ -0,0 +1,184 @@
+From 8001e888c93f3dbf8a5d5ecae3f1165c67b1eea5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 1 Feb 2024 20:40:38 -0800
+Subject: hv_netvsc: Register VF in netvsc_probe if NET_DEVICE_REGISTER missed
+
+From: Shradha Gupta <shradhagupta@linux.microsoft.com>
+
+[ Upstream commit 9cae43da9867412f8bd09aee5c8a8dc5e8dc3dc2 ]
+
+If hv_netvsc driver is unloaded and reloaded, the NET_DEVICE_REGISTER
+handler cannot perform VF register successfully as the register call
+is received before netvsc_probe is finished. This is because we
+register register_netdevice_notifier() very early( even before
+vmbus_driver_register()).
+To fix this, we try to register each such matching VF( if it is visible
+as a netdevice) at the end of netvsc_probe.
+
+Cc: stable@vger.kernel.org
+Fixes: 85520856466e ("hv_netvsc: Fix race of register_netdevice_notifier and VF register")
+Suggested-by: Dexuan Cui <decui@microsoft.com>
+Signed-off-by: Shradha Gupta <shradhagupta@linux.microsoft.com>
+Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
+Reviewed-by: Dexuan Cui <decui@microsoft.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/hyperv/netvsc_drv.c | 82 +++++++++++++++++++++++++--------
+ 1 file changed, 62 insertions(+), 20 deletions(-)
+
+diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
+index 2d1c6f10d4e19..e24513e34306c 100644
+--- a/drivers/net/hyperv/netvsc_drv.c
++++ b/drivers/net/hyperv/netvsc_drv.c
+@@ -54,6 +54,10 @@
+ #define LINKCHANGE_INT (2 * HZ)
+ #define VF_TAKEOVER_INT (HZ / 10)
++/* Macros to define the context of vf registration */
++#define VF_REG_IN_PROBE               1
++#define VF_REG_IN_NOTIFIER    2
++
+ static unsigned int ring_size __ro_after_init = 128;
+ module_param(ring_size, uint, 0444);
+ MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
+@@ -2025,7 +2029,7 @@ static rx_handler_result_t netvsc_vf_handle_frame(struct sk_buff **pskb)
+ }
+ static int netvsc_vf_join(struct net_device *vf_netdev,
+-                        struct net_device *ndev)
++                        struct net_device *ndev, int context)
+ {
+       struct net_device_context *ndev_ctx = netdev_priv(ndev);
+       int ret;
+@@ -2048,7 +2052,11 @@ static int netvsc_vf_join(struct net_device *vf_netdev,
+               goto upper_link_failed;
+       }
+-      schedule_delayed_work(&ndev_ctx->vf_takeover, VF_TAKEOVER_INT);
++      /* If this registration is called from probe context vf_takeover
++       * is taken care of later in probe itself.
++       */
++      if (context == VF_REG_IN_NOTIFIER)
++              schedule_delayed_work(&ndev_ctx->vf_takeover, VF_TAKEOVER_INT);
+       call_netdevice_notifiers(NETDEV_JOIN, vf_netdev);
+@@ -2186,7 +2194,7 @@ static int netvsc_prepare_bonding(struct net_device *vf_netdev)
+       return NOTIFY_DONE;
+ }
+-static int netvsc_register_vf(struct net_device *vf_netdev)
++static int netvsc_register_vf(struct net_device *vf_netdev, int context)
+ {
+       struct net_device_context *net_device_ctx;
+       struct netvsc_device *netvsc_dev;
+@@ -2225,7 +2233,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
+       netdev_info(ndev, "VF registering: %s\n", vf_netdev->name);
+-      if (netvsc_vf_join(vf_netdev, ndev) != 0)
++      if (netvsc_vf_join(vf_netdev, ndev, context) != 0)
+               return NOTIFY_DONE;
+       dev_hold(vf_netdev);
+@@ -2285,10 +2293,31 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev)
+       return NOTIFY_OK;
+ }
++static int check_dev_is_matching_vf(struct net_device *event_ndev)
++{
++      /* Skip NetVSC interfaces */
++      if (event_ndev->netdev_ops == &device_ops)
++              return -ENODEV;
++
++      /* Avoid non-Ethernet type devices */
++      if (event_ndev->type != ARPHRD_ETHER)
++              return -ENODEV;
++
++      /* Avoid Vlan dev with same MAC registering as VF */
++      if (is_vlan_dev(event_ndev))
++              return -ENODEV;
++
++      /* Avoid Bonding master dev with same MAC registering as VF */
++      if (netif_is_bond_master(event_ndev))
++              return -ENODEV;
++
++      return 0;
++}
++
+ static int netvsc_probe(struct hv_device *dev,
+                       const struct hv_vmbus_device_id *dev_id)
+ {
+-      struct net_device *net = NULL;
++      struct net_device *net = NULL, *vf_netdev;
+       struct net_device_context *net_device_ctx;
+       struct netvsc_device_info *device_info = NULL;
+       struct netvsc_device *nvdev;
+@@ -2391,6 +2420,30 @@ static int netvsc_probe(struct hv_device *dev,
+       }
+       list_add(&net_device_ctx->list, &netvsc_dev_list);
++
++      /* When the hv_netvsc driver is unloaded and reloaded, the
++       * NET_DEVICE_REGISTER for the vf device is replayed before probe
++       * is complete. This is because register_netdevice_notifier() gets
++       * registered before vmbus_driver_register() so that callback func
++       * is set before probe and we don't miss events like NETDEV_POST_INIT
++       * So, in this section we try to register the matching vf device that
++       * is present as a netdevice, knowing that its register call is not
++       * processed in the netvsc_netdev_notifier(as probing is progress and
++       * get_netvsc_byslot fails).
++       */
++      for_each_netdev(dev_net(net), vf_netdev) {
++              ret = check_dev_is_matching_vf(vf_netdev);
++              if (ret != 0)
++                      continue;
++
++              if (net != get_netvsc_byslot(vf_netdev))
++                      continue;
++
++              netvsc_prepare_bonding(vf_netdev);
++              netvsc_register_vf(vf_netdev, VF_REG_IN_PROBE);
++              __netvsc_vf_setup(net, vf_netdev);
++              break;
++      }
+       rtnl_unlock();
+       kfree(device_info);
+@@ -2483,28 +2536,17 @@ static int netvsc_netdev_event(struct notifier_block *this,
+                              unsigned long event, void *ptr)
+ {
+       struct net_device *event_dev = netdev_notifier_info_to_dev(ptr);
++      int ret = 0;
+-      /* Skip our own events */
+-      if (event_dev->netdev_ops == &device_ops)
+-              return NOTIFY_DONE;
+-
+-      /* Avoid non-Ethernet type devices */
+-      if (event_dev->type != ARPHRD_ETHER)
+-              return NOTIFY_DONE;
+-
+-      /* Avoid Vlan dev with same MAC registering as VF */
+-      if (is_vlan_dev(event_dev))
+-              return NOTIFY_DONE;
+-
+-      /* Avoid Bonding master dev with same MAC registering as VF */
+-      if (netif_is_bond_master(event_dev))
++      ret = check_dev_is_matching_vf(event_dev);
++      if (ret != 0)
+               return NOTIFY_DONE;
+       switch (event) {
+       case NETDEV_POST_INIT:
+               return netvsc_prepare_bonding(event_dev);
+       case NETDEV_REGISTER:
+-              return netvsc_register_vf(event_dev);
++              return netvsc_register_vf(event_dev, VF_REG_IN_NOTIFIER);
+       case NETDEV_UNREGISTER:
+               return netvsc_unregister_vf(event_dev);
+       case NETDEV_UP:
+-- 
+2.43.0
+
diff --git a/queue-4.19/hv_netvsc-use-netif_is_bond_master-instead-of-open-c.patch b/queue-4.19/hv_netvsc-use-netif_is_bond_master-instead-of-open-c.patch
new file mode 100644 (file)
index 0000000..2ff9a83
--- /dev/null
@@ -0,0 +1,38 @@
+From 00c15579fcd65da0bb3bd0d8534c989cd62eb851 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 10 Oct 2021 13:03:28 +0900
+Subject: hv_netvsc: use netif_is_bond_master() instead of open code
+
+From: Juhee Kang <claudiajkang@gmail.com>
+
+[ Upstream commit c60882a4566a0a62dc3a40c85131103aad83dcb3 ]
+
+Use netif_is_bond_master() function instead of open code, which is
+((event_dev->priv_flags & IFF_BONDING) && (event_dev->flags & IFF_MASTER)).
+This patch doesn't change logic.
+
+Signed-off-by: Juhee Kang <claudiajkang@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Stable-dep-of: 9cae43da9867 ("hv_netvsc: Register VF in netvsc_probe if NET_DEVICE_REGISTER missed")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/hyperv/netvsc_drv.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
+index fcf89ee5080f1..2d1c6f10d4e19 100644
+--- a/drivers/net/hyperv/netvsc_drv.c
++++ b/drivers/net/hyperv/netvsc_drv.c
+@@ -2497,8 +2497,7 @@ static int netvsc_netdev_event(struct notifier_block *this,
+               return NOTIFY_DONE;
+       /* Avoid Bonding master dev with same MAC registering as VF */
+-      if ((event_dev->priv_flags & IFF_BONDING) &&
+-          (event_dev->flags & IFF_MASTER))
++      if (netif_is_bond_master(event_dev))
+               return NOTIFY_DONE;
+       switch (event) {
+-- 
+2.43.0
+
diff --git a/queue-4.19/input-i8042-fix-strange-behavior-of-touchpad-on-clev.patch b/queue-4.19/input-i8042-fix-strange-behavior-of-touchpad-on-clev.patch
new file mode 100644 (file)
index 0000000..8b2d35c
--- /dev/null
@@ -0,0 +1,52 @@
+From fd000a4083a42d343cf3f1c054593c71fbbed838 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 5 Dec 2023 17:36:01 +0100
+Subject: Input: i8042 - fix strange behavior of touchpad on Clevo NS70PU
+
+From: Werner Sembach <wse@tuxedocomputers.com>
+
+[ Upstream commit a60e6c3918d20848906ffcdfcf72ca6a8cfbcf2e ]
+
+When closing the laptop lid with an external screen connected, the mouse
+pointer has a constant movement to the lower right corner. Opening the
+lid again stops this movement, but after that the touchpad does no longer
+register clicks.
+
+The touchpad is connected both via i2c-hid and PS/2, the predecessor of
+this device (NS70MU) has the same layout in this regard and also strange
+behaviour caused by the psmouse and the i2c-hid driver fighting over
+touchpad control. This fix is reusing the same workaround by just
+disabling the PS/2 aux port, that is only used by the touchpad, to give the
+i2c-hid driver the lone control over the touchpad.
+
+v2: Rebased on current master
+
+Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/r/20231205163602.16106-1-wse@tuxedocomputers.com
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/serio/i8042-x86ia64io.h | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
+index 06d99931519bd..ce9209f336957 100644
+--- a/drivers/input/serio/i8042-x86ia64io.h
++++ b/drivers/input/serio/i8042-x86ia64io.h
+@@ -1183,6 +1183,12 @@ static const struct dmi_system_id i8042_dmi_quirk_table[] __initconst = {
+                                       SERIO_QUIRK_RESET_ALWAYS | SERIO_QUIRK_NOLOOP |
+                                       SERIO_QUIRK_NOPNP)
+       },
++      {
++              .matches = {
++                      DMI_MATCH(DMI_BOARD_NAME, "NS5x_7xPU"),
++              },
++              .driver_data = (void *)(SERIO_QUIRK_NOAUX)
++      },
+       {
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_NAME, "NJ50_70CU"),
+-- 
+2.43.0
+
diff --git a/queue-4.19/selftests-mm-fix-map_hugetlb-failure-on-64k-page-siz.patch b/queue-4.19/selftests-mm-fix-map_hugetlb-failure-on-64k-page-siz.patch
new file mode 100644 (file)
index 0000000..dbf63e0
--- /dev/null
@@ -0,0 +1,61 @@
+From bae1e8eecbd138816a7781bd29f886dd0e720005 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 19 Jan 2024 06:14:29 -0700
+Subject: selftests: mm: fix map_hugetlb failure on 64K page size systems
+
+From: Nico Pache <npache@redhat.com>
+
+[ Upstream commit 91b80cc5b39f00399e8e2d17527cad2c7fa535e2 ]
+
+On systems with 64k page size and 512M huge page sizes, the allocation and
+test succeeds but errors out at the munmap.  As the comment states, munmap
+will failure if its not HUGEPAGE aligned.  This is due to the length of
+the mapping being 1/2 the size of the hugepage causing the munmap to not
+be hugepage aligned.  Fix this by making the mapping length the full
+hugepage if the hugepage is larger than the length of the mapping.
+
+Link: https://lkml.kernel.org/r/20240119131429.172448-1-npache@redhat.com
+Signed-off-by: Nico Pache <npache@redhat.com>
+Cc: Donet Tom <donettom@linux.vnet.ibm.com>
+Cc: Shuah Khan <shuah@kernel.org>
+Cc: Christophe Leroy <christophe.leroy@c-s.fr>
+Cc: Michael Ellerman <mpe@ellerman.id.au>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/testing/selftests/vm/map_hugetlb.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/selftests/vm/map_hugetlb.c
+index 5a2d7b8efc407..ab349c6db00d4 100644
+--- a/tools/testing/selftests/vm/map_hugetlb.c
++++ b/tools/testing/selftests/vm/map_hugetlb.c
+@@ -15,6 +15,7 @@
+ #include <unistd.h>
+ #include <sys/mman.h>
+ #include <fcntl.h>
++#include "vm_util.h"
+ #define LENGTH (256UL*1024*1024)
+ #define PROTECTION (PROT_READ | PROT_WRITE)
+@@ -70,10 +71,16 @@ int main(int argc, char **argv)
+ {
+       void *addr;
+       int ret;
++      size_t hugepage_size;
+       size_t length = LENGTH;
+       int flags = FLAGS;
+       int shift = 0;
++      hugepage_size = default_huge_page_size();
++      /* munmap with fail if the length is not page aligned */
++      if (hugepage_size > length)
++              length = hugepage_size;
++
+       if (argc > 1)
+               length = atol(argv[1]) << 20;
+       if (argc > 2) {
+-- 
+2.43.0
+
diff --git a/queue-4.19/selftests-vm-fix-display-of-page-size-in-map_hugetlb.patch b/queue-4.19/selftests-vm-fix-display-of-page-size-in-map_hugetlb.patch
new file mode 100644 (file)
index 0000000..956198c
--- /dev/null
@@ -0,0 +1,40 @@
+From 52b816bb50eb00a5395df8a37a52043eadc3e42f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 18 Sep 2020 21:20:28 -0700
+Subject: selftests/vm: fix display of page size in map_hugetlb
+
+From: Christophe Leroy <christophe.leroy@csgroup.eu>
+
+[ Upstream commit 1ec882fc81e3177faf055877310dbdb0c68eb7db ]
+
+The displayed size is in bytes while the text says it is in kB.
+
+Shift it by 10 to really display kBytes.
+
+Fixes: fa7b9a805c79 ("tools/selftest/vm: allow choosing mem size and page size in map_hugetlb")
+Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Cc: <stable@vger.kernel.org>
+Link: https://lkml.kernel.org/r/e27481224564a93d14106e750de31189deaa8bc8.1598861977.git.christophe.leroy@csgroup.eu
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/testing/selftests/vm/map_hugetlb.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/selftests/vm/map_hugetlb.c
+index ab349c6db00d4..7b41cc6ecb0bf 100644
+--- a/tools/testing/selftests/vm/map_hugetlb.c
++++ b/tools/testing/selftests/vm/map_hugetlb.c
+@@ -90,7 +90,7 @@ int main(int argc, char **argv)
+       }
+       if (shift)
+-              printf("%u kB hugepages\n", 1 << shift);
++              printf("%u kB hugepages\n", 1 << (shift - 10));
+       else
+               printf("Default size hugepages\n");
+       printf("Mapping %lu Mbytes\n", (unsigned long)length >> 20);
+-- 
+2.43.0
+
diff --git a/queue-4.19/selftests-vm-fix-map_hugetlb-length-used-for-testing.patch b/queue-4.19/selftests-vm-fix-map_hugetlb-length-used-for-testing.patch
new file mode 100644 (file)
index 0000000..83d1456
--- /dev/null
@@ -0,0 +1,80 @@
+From fbe0827af2aa1e840b048d5c85c51af790082f8d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 Apr 2020 21:11:51 -0700
+Subject: selftests/vm: fix map_hugetlb length used for testing read and write
+
+From: Christophe Leroy <christophe.leroy@c-s.fr>
+
+[ Upstream commit cabc30da10e677c67ab9a136b1478175734715c5 ]
+
+Commit fa7b9a805c79 ("tools/selftest/vm: allow choosing mem size and page
+size in map_hugetlb") added the possibility to change the size of memory
+mapped for the test, but left the read and write test using the default
+value.  This is unnoticed when mapping a length greater than the default
+one, but segfaults otherwise.
+
+Fix read_bytes() and write_bytes() by giving them the real length.
+
+Also fix the call to munmap().
+
+Fixes: fa7b9a805c79 ("tools/selftest/vm: allow choosing mem size and page size in map_hugetlb")
+Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Reviewed-by: Leonardo Bras <leonardo@linux.ibm.com>
+Cc: Michael Ellerman <mpe@ellerman.id.au>
+Cc: Shuah Khan <shuah@kernel.org>
+Cc: <stable@vger.kernel.org>
+Link: http://lkml.kernel.org/r/9a404a13c871c4bd0ba9ede68f69a1225180dd7e.1580978385.git.christophe.leroy@c-s.fr
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/testing/selftests/vm/map_hugetlb.c | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/selftests/vm/map_hugetlb.c
+index 7b41cc6ecb0bf..c65c55b7a789f 100644
+--- a/tools/testing/selftests/vm/map_hugetlb.c
++++ b/tools/testing/selftests/vm/map_hugetlb.c
+@@ -46,20 +46,20 @@ static void check_bytes(char *addr)
+       printf("First hex is %x\n", *((unsigned int *)addr));
+ }
+-static void write_bytes(char *addr)
++static void write_bytes(char *addr, size_t length)
+ {
+       unsigned long i;
+-      for (i = 0; i < LENGTH; i++)
++      for (i = 0; i < length; i++)
+               *(addr + i) = (char)i;
+ }
+-static int read_bytes(char *addr)
++static int read_bytes(char *addr, size_t length)
+ {
+       unsigned long i;
+       check_bytes(addr);
+-      for (i = 0; i < LENGTH; i++)
++      for (i = 0; i < length; i++)
+               if (*(addr + i) != (char)i) {
+                       printf("Mismatch at %lu\n", i);
+                       return 1;
+@@ -103,11 +103,11 @@ int main(int argc, char **argv)
+       printf("Returned address is %p\n", addr);
+       check_bytes(addr);
+-      write_bytes(addr);
+-      ret = read_bytes(addr);
++      write_bytes(addr, length);
++      ret = read_bytes(addr, length);
+       /* munmap() length of MAP_HUGETLB memory must be hugepage aligned */
+-      if (munmap(addr, LENGTH)) {
++      if (munmap(addr, length)) {
+               perror("munmap");
+               exit(1);
+       }
+-- 
+2.43.0
+
index 782d1d517fee6c11622d3e0a74a29864043b05c3..727b4df6a9aa1a82a109a51f8fc7289c33233e95 100644 (file)
@@ -21,3 +21,21 @@ netrom-fix-a-data-race-around-sysctl_netrom_transpor.patch-9711
 netrom-fix-a-data-race-around-sysctl_netrom_routing_.patch
 netrom-fix-a-data-race-around-sysctl_netrom_link_fai.patch
 netrom-fix-data-races-around-sysctl_net_busy_read.patch
+btrfs-ref-verify-free-ref-cache-before-clearing-moun.patch
+tools-selftest-vm-allow-choosing-mem-size-and-page-s.patch
+selftests-mm-fix-map_hugetlb-failure-on-64k-page-siz.patch
+um-allow-not-setting-extra-rpaths-in-the-linux-binar.patch
+um-fix-adding-no-pie-for-clang.patch
+input-i8042-fix-strange-behavior-of-touchpad-on-clev.patch
+hv_netvsc-make-netvsc-vf-binding-check-both-mac-and-.patch
+hv_netvsc-use-netif_is_bond_master-instead-of-open-c.patch
+hv_netvsc-register-vf-in-netvsc_probe-if-net_device_.patch
+y2038-rusage-use-__kernel_old_timeval.patch
+getrusage-add-the-signal_struct-sig-local-variable.patch
+getrusage-move-thread_group_cputime_adjusted-outside.patch
+getrusage-use-__for_each_thread.patch
+getrusage-use-sig-stats_lock-rather-than-lock_task_s.patch
+exit-fix-typo-in-comment-s-sub-theads-sub-threads.patch
+exit-wait_task_zombie-kill-the-no-longer-necessary-s.patch
+selftests-vm-fix-display-of-page-size-in-map_hugetlb.patch
+selftests-vm-fix-map_hugetlb-length-used-for-testing.patch
diff --git a/queue-4.19/tools-selftest-vm-allow-choosing-mem-size-and-page-s.patch b/queue-4.19/tools-selftest-vm-allow-choosing-mem-size-and-page-s.patch
new file mode 100644 (file)
index 0000000..be7568b
--- /dev/null
@@ -0,0 +1,77 @@
+From e7115befe1ee9aba30e9c3e9dc8334aac7e83d02 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 8 Feb 2019 15:02:55 +0000
+Subject: tools/selftest/vm: allow choosing mem size and page size in
+ map_hugetlb
+
+From: Christophe Leroy <christophe.leroy@c-s.fr>
+
+[ Upstream commit fa7b9a805c797b729022029aaa3a2b7c35fff4c6 ]
+
+map_hugetlb maps 256Mbytes of memory with default hugepage size.
+
+This patch allows the user to pass the size and page shift as an
+argument in order to use different size and page size.
+
+Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Stable-dep-of: 91b80cc5b39f ("selftests: mm: fix map_hugetlb failure on 64K page size systems")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/testing/selftests/vm/map_hugetlb.c | 29 ++++++++++++++++++++++--
+ 1 file changed, 27 insertions(+), 2 deletions(-)
+
+diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/selftests/vm/map_hugetlb.c
+index 9b777fa95f090..5a2d7b8efc407 100644
+--- a/tools/testing/selftests/vm/map_hugetlb.c
++++ b/tools/testing/selftests/vm/map_hugetlb.c
+@@ -23,6 +23,14 @@
+ #define MAP_HUGETLB 0x40000 /* arch specific */
+ #endif
++#ifndef MAP_HUGE_SHIFT
++#define MAP_HUGE_SHIFT 26
++#endif
++
++#ifndef MAP_HUGE_MASK
++#define MAP_HUGE_MASK 0x3f
++#endif
++
+ /* Only ia64 requires this */
+ #ifdef __ia64__
+ #define ADDR (void *)(0x8000000000000000UL)
+@@ -58,12 +66,29 @@ static int read_bytes(char *addr)
+       return 0;
+ }
+-int main(void)
++int main(int argc, char **argv)
+ {
+       void *addr;
+       int ret;
++      size_t length = LENGTH;
++      int flags = FLAGS;
++      int shift = 0;
++
++      if (argc > 1)
++              length = atol(argv[1]) << 20;
++      if (argc > 2) {
++              shift = atoi(argv[2]);
++              if (shift)
++                      flags |= (shift & MAP_HUGE_MASK) << MAP_HUGE_SHIFT;
++      }
++
++      if (shift)
++              printf("%u kB hugepages\n", 1 << shift);
++      else
++              printf("Default size hugepages\n");
++      printf("Mapping %lu Mbytes\n", (unsigned long)length >> 20);
+-      addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, -1, 0);
++      addr = mmap(ADDR, length, PROTECTION, flags, -1, 0);
+       if (addr == MAP_FAILED) {
+               perror("mmap");
+               exit(1);
+-- 
+2.43.0
+
diff --git a/queue-4.19/um-allow-not-setting-extra-rpaths-in-the-linux-binar.patch b/queue-4.19/um-allow-not-setting-extra-rpaths-in-the-linux-binar.patch
new file mode 100644 (file)
index 0000000..25b0d22
--- /dev/null
@@ -0,0 +1,82 @@
+From 06b09ca94077de57219d39171e2808b105fe780d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 8 Mar 2021 14:02:37 +0100
+Subject: um: allow not setting extra rpaths in the linux binary
+
+From: Johannes Berg <johannes.berg@intel.com>
+
+[ Upstream commit 386093c68ba3e8bcfe7f46deba901e0e80713c29 ]
+
+There doesn't seem to be any reason for the rpath being set in
+the binaries, at on systems that I tested on. On the other hand,
+setting rpath is actually harming binaries in some cases, e.g.
+if using nix-based compilation environments where /lib & /lib64
+are not part of the actual environment.
+
+Add a new Kconfig option (under EXPERT, for less user confusion)
+that allows disabling the rpath additions.
+
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Stable-dep-of: 846cfbeed09b ("um: Fix adding '-no-pie' for clang")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/um/Kconfig      | 13 +++++++++++++
+ arch/um/Makefile     |  3 ++-
+ arch/x86/Makefile.um |  2 +-
+ 3 files changed, 16 insertions(+), 2 deletions(-)
+
+diff --git a/arch/um/Kconfig b/arch/um/Kconfig
+index 8f0cb28099392..251c77474e7b8 100644
+--- a/arch/um/Kconfig
++++ b/arch/um/Kconfig
+@@ -88,6 +88,19 @@ config LD_SCRIPT_DYN
+       depends on !LD_SCRIPT_STATIC
+         select MODULE_REL_CRCS if MODVERSIONS
++config LD_SCRIPT_DYN_RPATH
++      bool "set rpath in the binary" if EXPERT
++      default y
++      depends on LD_SCRIPT_DYN
++      help
++        Add /lib (and /lib64 for 64-bit) to the linux binary's rpath
++        explicitly.
++
++        You may need to turn this off if compiling for nix systems
++        that have their libraries in random /nix directories and
++        might otherwise unexpected use libraries from /lib or /lib64
++        instead of the desired ones.
++
+ config HOSTFS
+       tristate "Host filesystem"
+       help
+diff --git a/arch/um/Makefile b/arch/um/Makefile
+index ab1066c38944e..439edee0b2878 100644
+--- a/arch/um/Makefile
++++ b/arch/um/Makefile
+@@ -119,7 +119,8 @@ archheaders:
+ archprepare: include/generated/user_constants.h
+ LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
+-LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib $(call cc-option, -no-pie)
++LINK-$(CONFIG_LD_SCRIPT_DYN) += $(call cc-option, -no-pie)
++LINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib
+ CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
+       $(call cc-option, -fno-stack-protector,) \
+diff --git a/arch/x86/Makefile.um b/arch/x86/Makefile.um
+index 91085a08de6cb..8bc3d493d429a 100644
+--- a/arch/x86/Makefile.um
++++ b/arch/x86/Makefile.um
+@@ -51,7 +51,7 @@ ELF_FORMAT := elf64-x86-64
+ # Not on all 64-bit distros /lib is a symlink to /lib64. PLD is an example.
+-LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64
++LINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib64
+ LINK-y += -m64
+ # Do unit-at-a-time unconditionally on x86_64, following the host
+-- 
+2.43.0
+
diff --git a/queue-4.19/um-fix-adding-no-pie-for-clang.patch b/queue-4.19/um-fix-adding-no-pie-for-clang.patch
new file mode 100644 (file)
index 0000000..a55a744
--- /dev/null
@@ -0,0 +1,68 @@
+From 639b65dc8b8fa707d56b378ab98e284a9bd12ad0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 23 Jan 2024 15:59:54 -0700
+Subject: um: Fix adding '-no-pie' for clang
+
+From: Nathan Chancellor <nathan@kernel.org>
+
+[ Upstream commit 846cfbeed09b45d985079a9173cf390cc053715b ]
+
+The kernel builds with -fno-PIE, so commit 883354afbc10 ("um: link
+vmlinux with -no-pie") added the compiler linker flag '-no-pie' via
+cc-option because '-no-pie' was only supported in GCC 6.1.0 and newer.
+
+While this works for GCC, this does not work for clang because cc-option
+uses '-c', which stops the pipeline right before linking, so '-no-pie'
+is unconsumed and clang warns, causing cc-option to fail just as it
+would if the option was entirely unsupported:
+
+  $ clang -Werror -no-pie -c -o /dev/null -x c /dev/null
+  clang-16: error: argument unused during compilation: '-no-pie' [-Werror,-Wunused-command-line-argument]
+
+A recent version of clang exposes this because it generates a relocation
+under '-mcmodel=large' that is not supported in PIE mode:
+
+  /usr/sbin/ld: init/main.o: relocation R_X86_64_32 against symbol `saved_command_line' can not be used when making a PIE object; recompile with -fPIE
+  /usr/sbin/ld: failed to set dynamic section sizes: bad value
+  clang: error: linker command failed with exit code 1 (use -v to see invocation)
+
+Remove the cc-option check altogether. It is wasteful to invoke the
+compiler to check for '-no-pie' because only one supported compiler
+version does not support it, GCC 5.x (as it is supported with the
+minimum version of clang and GCC 6.1.0+). Use a combination of the
+gcc-min-version macro and CONFIG_CC_IS_CLANG to unconditionally add
+'-no-pie' with CONFIG_LD_SCRIPT_DYN=y, so that it is enabled with all
+compilers that support this. Furthermore, using gcc-min-version can help
+turn this back into
+
+  LINK-$(CONFIG_LD_SCRIPT_DYN) += -no-pie
+
+when the minimum version of GCC is bumped past 6.1.0.
+
+Cc: stable@vger.kernel.org
+Closes: https://github.com/ClangBuiltLinux/linux/issues/1982
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/um/Makefile | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/arch/um/Makefile b/arch/um/Makefile
+index 439edee0b2878..5ac1b16ce3c10 100644
+--- a/arch/um/Makefile
++++ b/arch/um/Makefile
+@@ -119,7 +119,9 @@ archheaders:
+ archprepare: include/generated/user_constants.h
+ LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
+-LINK-$(CONFIG_LD_SCRIPT_DYN) += $(call cc-option, -no-pie)
++ifdef CONFIG_LD_SCRIPT_DYN
++LINK-$(call gcc-min-version, 60100)$(CONFIG_CC_IS_CLANG) += -no-pie
++endif
+ LINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib
+ CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
+-- 
+2.43.0
+
diff --git a/queue-4.19/y2038-rusage-use-__kernel_old_timeval.patch b/queue-4.19/y2038-rusage-use-__kernel_old_timeval.patch
new file mode 100644 (file)
index 0000000..f9eea9a
--- /dev/null
@@ -0,0 +1,81 @@
+From b1f8135104cc84fba34c7bba1b72a225df1ae90f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 25 Oct 2019 22:46:48 +0200
+Subject: y2038: rusage: use __kernel_old_timeval
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+[ Upstream commit bdd565f817a74b9e30edec108f7cb1dbc762b8a6 ]
+
+There are two 'struct timeval' fields in 'struct rusage'.
+
+Unfortunately the definition of timeval is now ambiguous when used in
+user space with a libc that has a 64-bit time_t, and this also changes
+the 'rusage' definition in user space in a way that is incompatible with
+the system call interface.
+
+While there is no good solution to avoid all ambiguity here, change
+the definition in the kernel headers to be compatible with the kernel
+ABI, using __kernel_old_timeval as an unambiguous base type.
+
+In previous discussions, there was also a plan to add a replacement
+for rusage based on 64-bit timestamps and nanosecond resolution,
+i.e. 'struct __kernel_timespec'. I have patches for that as well,
+if anyone thinks we should do that.
+
+Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Stable-dep-of: daa694e41375 ("getrusage: move thread_group_cputime_adjusted() outside of lock_task_sighand()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/alpha/kernel/osf_sys.c   | 2 +-
+ include/uapi/linux/resource.h | 4 ++--
+ kernel/sys.c                  | 4 ++--
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
+index cff52d8ffdb12..d5694f263dd61 100644
+--- a/arch/alpha/kernel/osf_sys.c
++++ b/arch/alpha/kernel/osf_sys.c
+@@ -964,7 +964,7 @@ put_tv32(struct timeval32 __user *o, struct timespec64 *i)
+ }
+ static inline long
+-put_tv_to_tv32(struct timeval32 __user *o, struct timeval *i)
++put_tv_to_tv32(struct timeval32 __user *o, struct __kernel_old_timeval *i)
+ {
+       return copy_to_user(o, &(struct timeval32){
+                               .tv_sec = i->tv_sec,
+diff --git a/include/uapi/linux/resource.h b/include/uapi/linux/resource.h
+index cc00fd0796317..74ef57b38f9f5 100644
+--- a/include/uapi/linux/resource.h
++++ b/include/uapi/linux/resource.h
+@@ -22,8 +22,8 @@
+ #define       RUSAGE_THREAD   1               /* only the calling thread */
+ struct        rusage {
+-      struct timeval ru_utime;        /* user time used */
+-      struct timeval ru_stime;        /* system time used */
++      struct __kernel_old_timeval ru_utime;   /* user time used */
++      struct __kernel_old_timeval ru_stime;   /* system time used */
+       __kernel_long_t ru_maxrss;      /* maximum resident set size */
+       __kernel_long_t ru_ixrss;       /* integral shared memory size */
+       __kernel_long_t ru_idrss;       /* integral unshared data size */
+diff --git a/kernel/sys.c b/kernel/sys.c
+index 3548467f6459b..e18bef5a8f9f5 100644
+--- a/kernel/sys.c
++++ b/kernel/sys.c
+@@ -1772,8 +1772,8 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
+       unlock_task_sighand(p, &flags);
+ out:
+-      r->ru_utime = ns_to_timeval(utime);
+-      r->ru_stime = ns_to_timeval(stime);
++      r->ru_utime = ns_to_kernel_old_timeval(utime);
++      r->ru_stime = ns_to_kernel_old_timeval(stime);
+       if (who != RUSAGE_CHILDREN) {
+               struct mm_struct *mm = get_task_mm(p);
+-- 
+2.43.0
+