linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Almaz Alexandrovich <almaz.alexandrovich@paragon-software.com>
To: <ntfs3@lists.linux.dev>
Cc: <linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>
Subject: [PATCH 2/3] fs/ntfs3: Fix double free on remount
Date: Fri, 27 May 2022 17:22:02 +0300	[thread overview]
Message-ID: <d196d00e-1d08-36e5-a721-7b04614ec35a@paragon-software.com> (raw)
In-Reply-To: <75a1215a-eda2-d0dc-b962-0334356eef7c@paragon-software.com>

Pointer to options was freed twice on remount
Fixes xfstest generic/361
Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
  fs/ntfs3/super.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index d41d76979e12..697a84ed395e 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -30,6 +30,7 @@
  #include <linux/fs_context.h>
  #include <linux/fs_parser.h>
  #include <linux/log2.h>
+#include <linux/minmax.h>
  #include <linux/module.h>
  #include <linux/nls.h>
  #include <linux/seq_file.h>
@@ -390,7 +391,7 @@ static int ntfs_fs_reconfigure(struct fs_context *fc)
  		return -EINVAL;
  	}
  
-	memcpy(sbi->options, new_opts, sizeof(*new_opts));
+	swap(sbi->options, fc->fs_private);
  
  	return 0;
  }
@@ -897,6 +898,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
  	ref.high = 0;
  
  	sbi->sb = sb;
+	sbi->options = fc->fs_private;
+	fc->fs_private = NULL;
  	sb->s_flags |= SB_NODIRATIME;
  	sb->s_magic = 0x7366746e; // "ntfs"
  	sb->s_op = &ntfs_sops;
@@ -1260,8 +1263,6 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
  		goto put_inode_out;
  	}
  
-	fc->fs_private = NULL;
-
  	return 0;
  
  put_inode_out:
@@ -1414,7 +1415,6 @@ static int ntfs_init_fs_context(struct fs_context *fc)
  	mutex_init(&sbi->compress.mtx_lzx);
  #endif
  
-	sbi->options = opts;
  	fc->s_fs_info = sbi;
  ok:
  	fc->fs_private = opts;
-- 
2.36.1


  parent reply	other threads:[~2022-05-27 14:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27 14:15 [PATCH 0/3] fs/ntfs3: Refactoring and bugfix Almaz Alexandrovich
2022-05-27 14:21 ` [PATCH 1/3] fs/ntfs3: Refactoring of indx_find function Almaz Alexandrovich
2022-05-27 16:07   ` Joe Perches
2022-05-30 17:11     ` Konstantin Komarov
2022-05-28  0:06   ` Dave Chinner
2022-05-30 16:15     ` Konstantin Komarov
2022-05-27 14:22 ` Almaz Alexandrovich [this message]
2022-05-27 14:22 ` [PATCH 3/3] fs/ntfs3: Refactor ni_try_remove_attr_list function Almaz Alexandrovich

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=d196d00e-1d08-36e5-a721-7b04614ec35a@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).