From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
smfrench@gmail.com, hyc.lee@gmail.com, senozhatsky@chromium.org,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH 2/4] ksmbd: remove filename in ksmbd_file
Date: Tue, 1 Mar 2022 13:14:34 +0900 [thread overview]
Message-ID: <Yh2dqrb6SrOlWL9t@google.com> (raw)
In-Reply-To: <20220228234833.10434-2-linkinjeon@kernel.org>
On (22/03/01 08:48), Namjae Jeon wrote:
> -char *convert_to_nt_pathname(char *filename)
> +char *convert_to_nt_pathname(struct ksmbd_share_config *share,
> + struct path *path)
> {
> - char *ab_pathname;
> + char *pathname, *ab_pathname, *nt_pathname = NULL;
> + int share_path_len = strlen(share->path);
>
> - if (strlen(filename) == 0)
> - filename = "\\";
> + pathname = kmalloc(PATH_MAX, GFP_KERNEL);
> + if (!pathname)
> + return ERR_PTR(-EACCES);
>
> - ab_pathname = kstrdup(filename, GFP_KERNEL);
> - if (!ab_pathname)
> - return NULL;
> + ab_pathname = d_path(path, pathname, PATH_MAX);
> + if (IS_ERR(ab_pathname)) {
> + nt_pathname = ERR_PTR(-EACCES);
> + goto free_pathname;
> + }
> +
> + if (strncmp(ab_pathname, share->path, share_path_len)) {
> + nt_pathname = ERR_PTR(-EACCES);
> + goto free_pathname;
> + }
> +
> + nt_pathname = kzalloc(strlen(&ab_pathname[share_path_len]) + 1, GFP_KERNEL);
> + if (!nt_pathname) {
> + nt_pathname = ERR_PTR(-ENOMEM);
> + goto free_pathname;
> + }
> + if (ab_pathname[share_path_len] == '\0')
> + strcpy(nt_pathname, "/");
> + strcat(nt_pathname, &ab_pathname[share_path_len]);
> +
> + ksmbd_conv_path_to_windows(nt_pathname);
>
> - ksmbd_conv_path_to_windows(ab_pathname);
> - return ab_pathname;
> +free_pathname:
> + kfree(pathname);
> + return nt_pathname;
> }
convert_to_nt_pathname() can return NULL
> + filename = convert_to_nt_pathname(work->tcon->share_conf, &fp->filp->f_path);
> + if (IS_ERR(filename))
> + return PTR_ERR(filename);
I don't think this will catch NULL nt_pathname return.
next prev parent reply other threads:[~2022-03-01 4:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 23:48 [PATCH 1/4] ksmbd: remove internal.h include Namjae Jeon
2022-02-28 23:48 ` [PATCH 2/4] ksmbd: remove filename in ksmbd_file Namjae Jeon
2022-03-01 4:14 ` Sergey Senozhatsky [this message]
2022-03-01 8:34 ` Namjae Jeon
2022-03-01 11:21 ` Sergey Senozhatsky
2022-02-28 23:48 ` [PATCH 3/4] ksmbd: increment reference count of parent fp Namjae Jeon
2022-03-01 4:21 ` Sergey Senozhatsky
2022-03-01 8:40 ` Namjae Jeon
2022-02-28 23:48 ` [PATCH v3 4/4] ksmbd: fix racy issue from using ->d_parent and ->d_name Namjae Jeon
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=Yh2dqrb6SrOlWL9t@google.com \
--to=senozhatsky@chromium.org \
--cc=hyc.lee@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=smfrench@gmail.com \
--cc=viro@zeniv.linux.org.uk \
/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