Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: He Wang <xw897002528@gmail.com>
Cc: He Wang <xw897002528@gmail.com>,
	Namjae Jeon <linkinjeon@kernel.org>,
	Steve French <sfrench@samba.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Tom Talpey <tom@talpey.com>,
	linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] ksmbd: fix unexpectedly changed path in ksmbd_vfs_kern_path_locked
Date: Mon,  6 Jan 2025 03:39:54 +0000	[thread overview]
Message-ID: <20250106033956.27445-2-xw897002528@gmail.com> (raw)
In-Reply-To: <20250106033956.27445-1-xw897002528@gmail.com>

When `ksmbd_vfs_kern_path_locked` met an error and it is not the last
entry, it will exit without restoring changed path buffer. But later this
buffer may be used as the filename for creation.

Signed-off-by: He Wang <xw897002528@gmail.com>
---
 fs/smb/server/vfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 88d167a5f..40f08eac5 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -1264,6 +1264,8 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
 					      filepath,
 					      flags,
 					      path);
+			if (!is_last)
+				next[0] = '/';
 			if (err)
 				goto out2;
 			else if (is_last)
@@ -1271,7 +1273,6 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
 			path_put(parent_path);
 			*parent_path = *path;
 
-			next[0] = '/';
 			remain_len -= filename_len + 1;
 		}
 
-- 
2.46.2


  reply	other threads:[~2025-01-06  3:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-06  3:39 [PATCH 1/2] ksmbd: fix possibly wrong init value for RDMA buffer size He Wang
2025-01-06  3:39 ` He Wang [this message]
2025-01-06  8:30 ` Namjae Jeon
2025-01-07 21:04 ` Tom Talpey
2025-01-07 23:14   ` Namjae Jeon
2025-01-07 23:32     ` Steve French
     [not found]   ` <CAPG2z08PyX3VZ4mxzEr_FtmiafGi=cNGpOzG7rjWxihjxeyTjQ@mail.gmail.com>
2025-01-08 13:58     ` Tom Talpey
     [not found]       ` <CAPG2z08fdWGMLovAo663nTant4S8oyPoWL5Vo7Rdc8JzaTRsMw@mail.gmail.com>
2025-01-08 16:38         ` Tom Talpey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250106033956.27445-2-xw897002528@gmail.com \
    --to=xw897002528@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=sfrench@samba.org \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox