Linux-CIFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] cifs: fix NULL dereference in match_prepath
@ 2020-01-22  1:07 Ronnie Sahlberg
  2020-01-22  1:29 ` Steve French
  0 siblings, 1 reply; 2+ messages in thread
From: Ronnie Sahlberg @ 2020-01-22  1:07 UTC (permalink / raw)
  To: linux-cifs; +Cc: Ronnie Sahlberg

RHBZ: 1760879

Fix an oops in match_prepath() by making sure that the prepath string is not
NULL before we pass it into strcmp().

This is similar to other checks we make for example in cifs_root_iget()

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/connect.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 05ea0e2b7e0e..0aa3623ae0e1 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3709,8 +3709,10 @@ match_prepath(struct super_block *sb, struct cifs_mnt_data *mnt_data)
 {
 	struct cifs_sb_info *old = CIFS_SB(sb);
 	struct cifs_sb_info *new = mnt_data->cifs_sb;
-	bool old_set = old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
-	bool new_set = new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
+	bool old_set = (old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) &&
+		old->prepath;
+	bool new_set = (new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) &&
+		new->prepath;
 
 	if (old_set && new_set && !strcmp(new->prepath, old->prepath))
 		return 1;
-- 
2.13.6


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] cifs: fix NULL dereference in match_prepath
  2020-01-22  1:07 [PATCH] cifs: fix NULL dereference in match_prepath Ronnie Sahlberg
@ 2020-01-22  1:29 ` Steve French
  0 siblings, 0 replies; 2+ messages in thread
From: Steve French @ 2020-01-22  1:29 UTC (permalink / raw)
  To: Ronnie Sahlberg; +Cc: linux-cifs

merged into cifs-2.6.git for-next

On Tue, Jan 21, 2020 at 7:08 PM Ronnie Sahlberg <lsahlber@redhat.com> wrote:
>
> RHBZ: 1760879
>
> Fix an oops in match_prepath() by making sure that the prepath string is not
> NULL before we pass it into strcmp().
>
> This is similar to other checks we make for example in cifs_root_iget()
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/connect.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 05ea0e2b7e0e..0aa3623ae0e1 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -3709,8 +3709,10 @@ match_prepath(struct super_block *sb, struct cifs_mnt_data *mnt_data)
>  {
>         struct cifs_sb_info *old = CIFS_SB(sb);
>         struct cifs_sb_info *new = mnt_data->cifs_sb;
> -       bool old_set = old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
> -       bool new_set = new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
> +       bool old_set = (old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) &&
> +               old->prepath;
> +       bool new_set = (new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) &&
> +               new->prepath;
>
>         if (old_set && new_set && !strcmp(new->prepath, old->prepath))
>                 return 1;
> --
> 2.13.6
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-22  1:07 [PATCH] cifs: fix NULL dereference in match_prepath Ronnie Sahlberg
2020-01-22  1:29 ` Steve French

Linux-CIFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-cifs/0 linux-cifs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-cifs linux-cifs/ https://lore.kernel.org/linux-cifs \
		linux-cifs@vger.kernel.org
	public-inbox-index linux-cifs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-cifs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git