From: Greg Kroah-Hartman Date: Sun, 8 Sep 2024 14:21:21 +0000 (+0200) Subject: 5.15-stable patches X-Git-Tag: v4.19.322~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=54c2f63cffe06d931e50737442f49efaf0b3c6b3;p=thirdparty%2Fkernel%2Fstable-queue.git 5.15-stable patches added patches: cifs-check-the-lease-context-if-we-actually-got-a-lease.patch --- diff --git a/queue-5.15/cifs-check-the-lease-context-if-we-actually-got-a-lease.patch b/queue-5.15/cifs-check-the-lease-context-if-we-actually-got-a-lease.patch new file mode 100644 index 00000000000..6c8327588cf --- /dev/null +++ b/queue-5.15/cifs-check-the-lease-context-if-we-actually-got-a-lease.patch @@ -0,0 +1,94 @@ +From 66d45ca1350a3bb8d5f4db8879ccad3ed492337a Mon Sep 17 00:00:00 2001 +From: Ronnie Sahlberg +Date: Fri, 17 Feb 2023 13:35:00 +1000 +Subject: cifs: Check the lease context if we actually got a lease + +From: Ronnie Sahlberg + +commit 66d45ca1350a3bb8d5f4db8879ccad3ed492337a upstream. + +Some servers may return that we got a lease in rsp->OplockLevel +but then in the lease context contradict this and say we got no lease +at all. Thus we need to check the context if we have a lease. +Additionally, If we do not get a lease we need to make sure we close +the handle before we return an error to the caller. + +Signed-off-by: Ronnie Sahlberg +Cc: stable@vger.kernel.org +Reviewed-by: Bharath SM +Reviewed-by: Paulo Alcantara (SUSE) +Signed-off-by: Steve French +Signed-off-by: Meetakshi Setiya +Signed-off-by: Greg Kroah-Hartman +--- + fs/cifs/smb2ops.c | 24 ++++++++++++++++-------- + 1 file changed, 16 insertions(+), 8 deletions(-) + +--- a/fs/cifs/smb2ops.c ++++ b/fs/cifs/smb2ops.c +@@ -886,8 +886,6 @@ int open_cached_dir(unsigned int xid, st + goto oshr_exit; + } + +- atomic_inc(&tcon->num_remote_opens); +- + o_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base; + oparms.fid->persistent_fid = o_rsp->PersistentFileId; + oparms.fid->volatile_fid = o_rsp->VolatileFileId; +@@ -897,8 +895,6 @@ int open_cached_dir(unsigned int xid, st + + tcon->crfid.tcon = tcon; + tcon->crfid.is_valid = true; +- tcon->crfid.dentry = dentry; +- dget(dentry); + kref_init(&tcon->crfid.refcount); + + /* BB TBD check to see if oplock level check can be removed below */ +@@ -907,14 +903,16 @@ int open_cached_dir(unsigned int xid, st + * See commit 2f94a3125b87. Increment the refcount when we + * get a lease for root, release it if lease break occurs + */ +- kref_get(&tcon->crfid.refcount); +- tcon->crfid.has_lease = true; + rc = smb2_parse_contexts(server, rsp_iov, + &oparms.fid->epoch, + oparms.fid->lease_key, &oplock, + NULL, NULL); + if (rc) + goto oshr_exit; ++ ++ if (!(oplock & SMB2_LEASE_READ_CACHING_HE)) ++ goto oshr_exit; ++ + } else + goto oshr_exit; + +@@ -928,7 +926,10 @@ int open_cached_dir(unsigned int xid, st + (char *)&tcon->crfid.file_all_info)) + tcon->crfid.file_all_info_is_valid = true; + tcon->crfid.time = jiffies; +- ++ tcon->crfid.dentry = dentry; ++ dget(dentry); ++ kref_get(&tcon->crfid.refcount); ++ tcon->crfid.has_lease = true; + + oshr_exit: + mutex_unlock(&tcon->crfid.fid_mutex); +@@ -937,8 +938,15 @@ oshr_free: + SMB2_query_info_free(&rqst[1]); + free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base); + free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base); +- if (rc == 0) ++ if (rc) { ++ if (tcon->crfid.is_valid) ++ SMB2_close(0, tcon, oparms.fid->persistent_fid, ++ oparms.fid->volatile_fid); ++ } ++ if (rc == 0) { + *cfid = &tcon->crfid; ++ atomic_inc(&tcon->num_remote_opens); ++ } + return rc; + } + diff --git a/queue-5.15/series b/queue-5.15/series index 9d114882b5e..75dec7eee90 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -172,3 +172,4 @@ lib-generic-radix-tree.c-fix-rare-race-in-__genradix.patch mips-cevt-r4k-don-t-call-get_c0_compare_int-if-timer.patch ata-pata_macio-use-warn-instead-of-bug.patch nfsv4-add-missing-rescheduling-points-in-nfs_client_.patch +cifs-check-the-lease-context-if-we-actually-got-a-lease.patch