]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.7-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 27 Jan 2024 00:41:25 +0000 (16:41 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 27 Jan 2024 00:41:25 +0000 (16:41 -0800)
added patches:
ksmbd-add-missing-set_freezable-for-freezable-kthread.patch
ksmbd-don-t-increment-epoch-if-current-state-and-request-state-are-same.patch
ksmbd-fix-potential-circular-locking-issue-in-smb2_set_ea.patch
ksmbd-send-lease-break-notification-on-file_rename_information.patch
ksmbd-set-v2-lease-version-on-lease-upgrade.patch
mm-page_alloc-unreserve-highatomic-page-blocks-before-oom.patch

queue-6.7/ksmbd-add-missing-set_freezable-for-freezable-kthread.patch [new file with mode: 0644]
queue-6.7/ksmbd-don-t-increment-epoch-if-current-state-and-request-state-are-same.patch [new file with mode: 0644]
queue-6.7/ksmbd-fix-potential-circular-locking-issue-in-smb2_set_ea.patch [new file with mode: 0644]
queue-6.7/ksmbd-send-lease-break-notification-on-file_rename_information.patch [new file with mode: 0644]
queue-6.7/ksmbd-set-v2-lease-version-on-lease-upgrade.patch [new file with mode: 0644]
queue-6.7/mm-page_alloc-unreserve-highatomic-page-blocks-before-oom.patch [new file with mode: 0644]
queue-6.7/series

diff --git a/queue-6.7/ksmbd-add-missing-set_freezable-for-freezable-kthread.patch b/queue-6.7/ksmbd-add-missing-set_freezable-for-freezable-kthread.patch
new file mode 100644 (file)
index 0000000..02e0fd6
--- /dev/null
@@ -0,0 +1,37 @@
+From stable+bounces-15515-greg=kroah.com@vger.kernel.org Tue Jan 23 03:43:02 2024
+From: Namjae Jeon <linkinjeon@kernel.org>
+Date: Tue, 23 Jan 2024 20:42:28 +0900
+Subject: ksmbd: Add missing set_freezable() for freezable kthread
+To: gregkh@linuxfoundation.org, sashal@kernel.org
+Cc: stable@vger.kernel.org, Kevin Hao <haokexin@gmail.com>, Namjae Jeon <linkinjeon@kernel.org>, Steve French <stfrench@microsoft.com>
+Message-ID: <20240123114228.205260-6-linkinjeon@kernel.org>
+
+From: Namjae Jeon <linkinjeon@kernel.org>
+
+From: Kevin Hao <haokexin@gmail.com>
+
+[ Upstream commit 8fb7b723924cc9306bc161f45496497aec733904 ]
+
+The kernel thread function ksmbd_conn_handler_loop() invokes
+the try_to_freeze() in its loop. But all the kernel threads are
+non-freezable by default. So if we want to make a kernel thread to be
+freezable, we have to invoke set_freezable() explicitly.
+
+Signed-off-by: Kevin Hao <haokexin@gmail.com>
+Acked-by: Namjae Jeon <linkinjeon@kernel.org>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/smb/server/connection.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/fs/smb/server/connection.c
++++ b/fs/smb/server/connection.c
+@@ -284,6 +284,7 @@ int ksmbd_conn_handler_loop(void *p)
+               goto out;
+       conn->last_active = jiffies;
++      set_freezable();
+       while (ksmbd_conn_alive(conn)) {
+               if (try_to_freeze())
+                       continue;
diff --git a/queue-6.7/ksmbd-don-t-increment-epoch-if-current-state-and-request-state-are-same.patch b/queue-6.7/ksmbd-don-t-increment-epoch-if-current-state-and-request-state-are-same.patch
new file mode 100644 (file)
index 0000000..e9e9d5b
--- /dev/null
@@ -0,0 +1,61 @@
+From stable+bounces-15513-greg=kroah.com@vger.kernel.org Tue Jan 23 03:42:57 2024
+From: Namjae Jeon <linkinjeon@kernel.org>
+Date: Tue, 23 Jan 2024 20:42:26 +0900
+Subject: ksmbd: don't increment epoch if current state and request state are same
+To: gregkh@linuxfoundation.org, sashal@kernel.org
+Cc: stable@vger.kernel.org, Namjae Jeon <linkinjeon@kernel.org>, Steve French <stfrench@microsoft.com>
+Message-ID: <20240123114228.205260-4-linkinjeon@kernel.org>
+
+From: Namjae Jeon <linkinjeon@kernel.org>
+
+[ Upstream commit b6e9a44e99603fe10e1d78901fdd97681a539612 ]
+
+If existing lease state and request state are same, don't increment
+epoch in create context.
+
+Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/smb/server/oplock.c |    9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+--- a/fs/smb/server/oplock.c
++++ b/fs/smb/server/oplock.c
+@@ -105,7 +105,7 @@ static int alloc_lease(struct oplock_inf
+       lease->is_dir = lctx->is_dir;
+       memcpy(lease->parent_lease_key, lctx->parent_lease_key, SMB2_LEASE_KEY_SIZE);
+       lease->version = lctx->version;
+-      lease->epoch = le16_to_cpu(lctx->epoch);
++      lease->epoch = le16_to_cpu(lctx->epoch) + 1;
+       INIT_LIST_HEAD(&opinfo->lease_entry);
+       opinfo->o_lease = lease;
+@@ -541,6 +541,9 @@ static struct oplock_info *same_client_h
+                               continue;
+                       }
++                      if (lctx->req_state != lease->state)
++                              lease->epoch++;
++
+                       /* upgrading lease */
+                       if ((atomic_read(&ci->op_count) +
+                            atomic_read(&ci->sop_count)) == 1) {
+@@ -1035,7 +1038,7 @@ static void copy_lease(struct oplock_inf
+              SMB2_LEASE_KEY_SIZE);
+       lease2->duration = lease1->duration;
+       lease2->flags = lease1->flags;
+-      lease2->epoch = lease1->epoch++;
++      lease2->epoch = lease1->epoch;
+       lease2->version = lease1->version;
+ }
+@@ -1454,7 +1457,7 @@ void create_lease_buf(u8 *rbuf, struct l
+               memcpy(buf->lcontext.LeaseKey, lease->lease_key,
+                      SMB2_LEASE_KEY_SIZE);
+               buf->lcontext.LeaseFlags = lease->flags;
+-              buf->lcontext.Epoch = cpu_to_le16(++lease->epoch);
++              buf->lcontext.Epoch = cpu_to_le16(lease->epoch);
+               buf->lcontext.LeaseState = lease->state;
+               memcpy(buf->lcontext.ParentLeaseKey, lease->parent_lease_key,
+                      SMB2_LEASE_KEY_SIZE);
diff --git a/queue-6.7/ksmbd-fix-potential-circular-locking-issue-in-smb2_set_ea.patch b/queue-6.7/ksmbd-fix-potential-circular-locking-issue-in-smb2_set_ea.patch
new file mode 100644 (file)
index 0000000..0abd6de
--- /dev/null
@@ -0,0 +1,57 @@
+From stable+bounces-15512-greg=kroah.com@vger.kernel.org Tue Jan 23 03:42:50 2024
+From: Namjae Jeon <linkinjeon@kernel.org>
+Date: Tue, 23 Jan 2024 20:42:25 +0900
+Subject: ksmbd: fix potential circular locking issue in smb2_set_ea()
+To: gregkh@linuxfoundation.org, sashal@kernel.org
+Cc: stable@vger.kernel.org, Namjae Jeon <linkinjeon@kernel.org>, Steve French <stfrench@microsoft.com>
+Message-ID: <20240123114228.205260-3-linkinjeon@kernel.org>
+
+From: Namjae Jeon <linkinjeon@kernel.org>
+
+[ Upstream commit 6fc0a265e1b932e5e97a038f99e29400a93baad0 ]
+
+smb2_set_ea() can be called in parent inode lock range.
+So add get_write argument to smb2_set_ea() not to call nested
+mnt_want_write().
+
+Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/smb/server/smb2pdu.c |    7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+--- a/fs/smb/server/smb2pdu.c
++++ b/fs/smb/server/smb2pdu.c
+@@ -2323,11 +2323,12 @@ out:
+  * @eabuf:    set info command buffer
+  * @buf_len:  set info command buffer length
+  * @path:     dentry path for get ea
++ * @get_write:        get write access to a mount
+  *
+  * Return:    0 on success, otherwise error
+  */
+ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
+-                     const struct path *path)
++                     const struct path *path, bool get_write)
+ {
+       struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+       char *attr_name = NULL, *value;
+@@ -3015,7 +3016,7 @@ int smb2_open(struct ksmbd_work *work)
+                       rc = smb2_set_ea(&ea_buf->ea,
+                                        le32_to_cpu(ea_buf->ccontext.DataLength),
+-                                       &path);
++                                       &path, false);
+                       if (rc == -EOPNOTSUPP)
+                               rc = 0;
+                       else if (rc)
+@@ -5992,7 +5993,7 @@ static int smb2_set_info_file(struct ksm
+                       return -EINVAL;
+               return smb2_set_ea((struct smb2_ea_info *)req->Buffer,
+-                                 buf_len, &fp->filp->f_path);
++                                 buf_len, &fp->filp->f_path, true);
+       }
+       case FILE_POSITION_INFORMATION:
+       {
diff --git a/queue-6.7/ksmbd-send-lease-break-notification-on-file_rename_information.patch b/queue-6.7/ksmbd-send-lease-break-notification-on-file_rename_information.patch
new file mode 100644 (file)
index 0000000..c420b65
--- /dev/null
@@ -0,0 +1,71 @@
+From stable+bounces-15514-greg=kroah.com@vger.kernel.org Tue Jan 23 03:43:01 2024
+From: Namjae Jeon <linkinjeon@kernel.org>
+Date: Tue, 23 Jan 2024 20:42:27 +0900
+Subject: ksmbd: send lease break notification on FILE_RENAME_INFORMATION
+To: gregkh@linuxfoundation.org, sashal@kernel.org
+Cc: stable@vger.kernel.org, Namjae Jeon <linkinjeon@kernel.org>, Steve French <stfrench@microsoft.com>
+Message-ID: <20240123114228.205260-5-linkinjeon@kernel.org>
+
+From: Namjae Jeon <linkinjeon@kernel.org>
+
+[ Upstream commit 3fc74c65b367476874da5fe6f633398674b78e5a ]
+
+Send lease break notification on FILE_RENAME_INFORMATION request.
+This patch fix smb2.lease.v2_epoch2 test failure.
+
+Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/smb/server/oplock.c  |   12 +++++++-----
+ fs/smb/server/smb2pdu.c |    1 +
+ 2 files changed, 8 insertions(+), 5 deletions(-)
+
+--- a/fs/smb/server/oplock.c
++++ b/fs/smb/server/oplock.c
+@@ -541,14 +541,12 @@ static struct oplock_info *same_client_h
+                               continue;
+                       }
+-                      if (lctx->req_state != lease->state)
+-                              lease->epoch++;
+-
+                       /* upgrading lease */
+                       if ((atomic_read(&ci->op_count) +
+                            atomic_read(&ci->sop_count)) == 1) {
+                               if (lease->state != SMB2_LEASE_NONE_LE &&
+                                   lease->state == (lctx->req_state & lease->state)) {
++                                      lease->epoch++;
+                                       lease->state |= lctx->req_state;
+                                       if (lctx->req_state &
+                                               SMB2_LEASE_WRITE_CACHING_LE)
+@@ -559,13 +557,17 @@ static struct oplock_info *same_client_h
+                                   atomic_read(&ci->sop_count)) > 1) {
+                               if (lctx->req_state ==
+                                   (SMB2_LEASE_READ_CACHING_LE |
+-                                   SMB2_LEASE_HANDLE_CACHING_LE))
++                                   SMB2_LEASE_HANDLE_CACHING_LE)) {
++                                      lease->epoch++;
+                                       lease->state = lctx->req_state;
++                              }
+                       }
+                       if (lctx->req_state && lease->state ==
+-                          SMB2_LEASE_NONE_LE)
++                          SMB2_LEASE_NONE_LE) {
++                              lease->epoch++;
+                               lease_none_upgrade(opinfo, lctx->req_state);
++                      }
+               }
+               read_lock(&ci->m_lock);
+       }
+--- a/fs/smb/server/smb2pdu.c
++++ b/fs/smb/server/smb2pdu.c
+@@ -5581,6 +5581,7 @@ static int smb2_rename(struct ksmbd_work
+       if (!file_info->ReplaceIfExists)
+               flags = RENAME_NOREPLACE;
++      smb_break_all_levII_oplock(work, fp, 0);
+       rc = ksmbd_vfs_rename(work, &fp->filp->f_path, new_name, flags);
+ out:
+       kfree(new_name);
diff --git a/queue-6.7/ksmbd-set-v2-lease-version-on-lease-upgrade.patch b/queue-6.7/ksmbd-set-v2-lease-version-on-lease-upgrade.patch
new file mode 100644 (file)
index 0000000..b8d7699
--- /dev/null
@@ -0,0 +1,45 @@
+From stable+bounces-15511-greg=kroah.com@vger.kernel.org Tue Jan 23 03:42:50 2024
+From: Namjae Jeon <linkinjeon@kernel.org>
+Date: Tue, 23 Jan 2024 20:42:24 +0900
+Subject: ksmbd: set v2 lease version on lease upgrade
+To: gregkh@linuxfoundation.org, sashal@kernel.org
+Cc: stable@vger.kernel.org, Namjae Jeon <linkinjeon@kernel.org>, Tom Talpey <tom@talpey.com>, Steve French <stfrench@microsoft.com>
+Message-ID: <20240123114228.205260-2-linkinjeon@kernel.org>
+
+From: Namjae Jeon <linkinjeon@kernel.org>
+
+[ Upstream commit bb05367a66a9990d2c561282f5620bb1dbe40c28 ]
+
+If file opened with v2 lease is upgraded with v1 lease, smb server
+should response v2 lease create context to client.
+This patch fix smb2.lease.v2_epoch2 test failure.
+
+This test case assumes the following scenario:
+ 1. smb2 create with v2 lease(R, LEASE1 key)
+ 2. smb server return smb2 create response with v2 lease context(R,
+LEASE1 key, epoch + 1)
+ 3. smb2 create with v1 lease(RH, LEASE1 key)
+ 4. smb server return smb2 create response with v2 lease context(RH,
+LEASE1 key, epoch + 2)
+
+i.e. If same client(same lease key) try to open a file that is being
+opened with v2 lease with v1 lease, smb server should return v2 lease.
+
+Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
+Acked-by: Tom Talpey <tom@talpey.com>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/smb/server/oplock.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/fs/smb/server/oplock.c
++++ b/fs/smb/server/oplock.c
+@@ -1036,6 +1036,7 @@ static void copy_lease(struct oplock_inf
+       lease2->duration = lease1->duration;
+       lease2->flags = lease1->flags;
+       lease2->epoch = lease1->epoch++;
++      lease2->version = lease1->version;
+ }
+ static int add_lease_global_list(struct oplock_info *opinfo)
diff --git a/queue-6.7/mm-page_alloc-unreserve-highatomic-page-blocks-before-oom.patch b/queue-6.7/mm-page_alloc-unreserve-highatomic-page-blocks-before-oom.patch
new file mode 100644 (file)
index 0000000..b00df92
--- /dev/null
@@ -0,0 +1,104 @@
+From ac3f3b0a55518056bc80ed32a41931c99e1f7d81 Mon Sep 17 00:00:00 2001
+From: Charan Teja Kalla <quic_charante@quicinc.com>
+Date: Fri, 24 Nov 2023 16:27:25 +0530
+Subject: mm: page_alloc: unreserve highatomic page blocks before oom
+
+From: Charan Teja Kalla <quic_charante@quicinc.com>
+
+commit ac3f3b0a55518056bc80ed32a41931c99e1f7d81 upstream.
+
+__alloc_pages_direct_reclaim() is called from slowpath allocation where
+high atomic reserves can be unreserved after there is a progress in
+reclaim and yet no suitable page is found.  Later should_reclaim_retry()
+gets called from slow path allocation to decide if the reclaim needs to be
+retried before OOM kill path is taken.
+
+should_reclaim_retry() checks the available(reclaimable + free pages)
+memory against the min wmark levels of a zone and returns:
+
+a) true, if it is above the min wmark so that slow path allocation will
+   do the reclaim retries.
+
+b) false, thus slowpath allocation takes oom kill path.
+
+should_reclaim_retry() can also unreserves the high atomic reserves **but
+only after all the reclaim retries are exhausted.**
+
+In a case where there are almost none reclaimable memory and free pages
+contains mostly the high atomic reserves but allocation context can't use
+these high atomic reserves, makes the available memory below min wmark
+levels hence false is returned from should_reclaim_retry() leading the
+allocation request to take OOM kill path.  This can turn into a early oom
+kill if high atomic reserves are holding lot of free memory and
+unreserving of them is not attempted.
+
+(early)OOM is encountered on a VM with the below state:
+[  295.998653] Normal free:7728kB boost:0kB min:804kB low:1004kB
+high:1204kB reserved_highatomic:8192KB active_anon:4kB inactive_anon:0kB
+active_file:24kB inactive_file:24kB unevictable:1220kB writepending:0kB
+present:70732kB managed:49224kB mlocked:0kB bounce:0kB free_pcp:688kB
+local_pcp:492kB free_cma:0kB
+[  295.998656] lowmem_reserve[]: 0 32
+[  295.998659] Normal: 508*4kB (UMEH) 241*8kB (UMEH) 143*16kB (UMEH)
+33*32kB (UH) 7*64kB (UH) 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB
+0*4096kB = 7752kB
+
+Per above log, the free memory of ~7MB exist in the high atomic reserves
+is not freed up before falling back to oom kill path.
+
+Fix it by trying to unreserve the high atomic reserves in
+should_reclaim_retry() before __alloc_pages_direct_reclaim() can fallback
+to oom kill path.
+
+Link: https://lkml.kernel.org/r/1700823445-27531-1-git-send-email-quic_charante@quicinc.com
+Fixes: 0aaa29a56e4f ("mm, page_alloc: reserve pageblocks for high-order atomic allocations on demand")
+Signed-off-by: Charan Teja Kalla <quic_charante@quicinc.com>
+Reported-by: Chris Goldsworthy <quic_cgoldswo@quicinc.com>
+Suggested-by: Michal Hocko <mhocko@suse.com>
+Acked-by: Michal Hocko <mhocko@suse.com>
+Acked-by: David Rientjes <rientjes@google.com>
+Cc: Chris Goldsworthy <quic_cgoldswo@quicinc.com>
+Cc: David Hildenbrand <david@redhat.com>
+Cc: Johannes Weiner <hannes@cmpxchg.org>
+Cc: Mel Gorman <mgorman@techsingularity.net>
+Cc: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
+Cc: Vlastimil Babka <vbabka@suse.cz>
+Cc: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ mm/page_alloc.c |   16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+--- a/mm/page_alloc.c
++++ b/mm/page_alloc.c
+@@ -3951,14 +3951,9 @@ should_reclaim_retry(gfp_t gfp_mask, uns
+       else
+               (*no_progress_loops)++;
+-      /*
+-       * Make sure we converge to OOM if we cannot make any progress
+-       * several times in the row.
+-       */
+-      if (*no_progress_loops > MAX_RECLAIM_RETRIES) {
+-              /* Before OOM, exhaust highatomic_reserve */
+-              return unreserve_highatomic_pageblock(ac, true);
+-      }
++      if (*no_progress_loops > MAX_RECLAIM_RETRIES)
++              goto out;
++
+       /*
+        * Keep reclaiming pages while there is a chance this will lead
+@@ -4001,6 +3996,11 @@ should_reclaim_retry(gfp_t gfp_mask, uns
+               schedule_timeout_uninterruptible(1);
+       else
+               cond_resched();
++out:
++      /* Before OOM, exhaust highatomic_reserve */
++      if (!ret)
++              return unreserve_highatomic_pageblock(ac, true);
++
+       return ret;
+ }
index 3a7dc7ace78e0386228ec0ea3a56cc1557572391..f5bbbd5c14e238bca07b327334245e9983573b22 100644 (file)
@@ -134,3 +134,9 @@ serial-sc16is7xx-fix-unconditional-activation-of-thri-interrupt.patch
 serial-sc16is7xx-fix-invalid-sc16is7xx_lines-bitfield-in-case-of-probe-error.patch
 serial-sc16is7xx-remove-obsolete-loop-in-sc16is7xx_port_irq.patch
 serial-sc16is7xx-improve-do-while-loop-in-sc16is7xx_irq.patch
+mm-page_alloc-unreserve-highatomic-page-blocks-before-oom.patch
+ksmbd-set-v2-lease-version-on-lease-upgrade.patch
+ksmbd-fix-potential-circular-locking-issue-in-smb2_set_ea.patch
+ksmbd-don-t-increment-epoch-if-current-state-and-request-state-are-same.patch
+ksmbd-send-lease-break-notification-on-file_rename_information.patch
+ksmbd-add-missing-set_freezable-for-freezable-kthread.patch