]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.4
authorSasha Levin <sashal@kernel.org>
Mon, 29 Nov 2021 03:16:55 +0000 (22:16 -0500)
committerSasha Levin <sashal@kernel.org>
Mon, 29 Nov 2021 03:16:55 +0000 (22:16 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.4/f2fs-set-sbi_need_fsck-flag-when-inconsistent-node-b.patch [new file with mode: 0644]
queue-5.4/series
queue-5.4/smb3-do-not-error-on-fsync-when-readonly.patch [new file with mode: 0644]

diff --git a/queue-5.4/f2fs-set-sbi_need_fsck-flag-when-inconsistent-node-b.patch b/queue-5.4/f2fs-set-sbi_need_fsck-flag-when-inconsistent-node-b.patch
new file mode 100644 (file)
index 0000000..4499ecc
--- /dev/null
@@ -0,0 +1,38 @@
+From f839bffbc12fb6aef730154d7d06072fb66110be Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 18 Sep 2021 20:46:36 +0800
+Subject: f2fs: set SBI_NEED_FSCK flag when inconsistent node block found
+
+From: Weichao Guo <guoweichao@oppo.com>
+
+[ Upstream commit 6663b138ded1a59e630c9e605e42aa7fde490cdc ]
+
+Inconsistent node block will cause a file fail to open or read,
+which could make the user process crashes or stucks. Let's mark
+SBI_NEED_FSCK flag to trigger a fix at next fsck time. After
+unlinking the corrupted file, the user process could regenerate
+a new one and work correctly.
+
+Signed-off-by: Weichao Guo <guoweichao@oppo.com>
+Reviewed-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/node.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
+index 4cb182c20eedd..0cd1d51dde06d 100644
+--- a/fs/f2fs/node.c
++++ b/fs/f2fs/node.c
+@@ -1385,6 +1385,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
+                         nid, nid_of_node(page), ino_of_node(page),
+                         ofs_of_node(page), cpver_of_node(page),
+                         next_blkaddr_of_node(page));
++              set_sbi_flag(sbi, SBI_NEED_FSCK);
+               err = -EINVAL;
+ out_err:
+               ClearPageUptodate(page);
+-- 
+2.33.0
+
index a1acb6e93b490b6b814e029429290bc2f11ff7f8..8d5d6c3f4b0ccbbc307c9dbc5ab01255fd01b88d 100644 (file)
@@ -73,3 +73,5 @@ net-smc-don-t-call-clcsock-shutdown-twice-when-smc-s.patch
 net-hns3-fix-vf-rss-failed-problem-after-pf-enable-m.patch
 net-mscc-ocelot-don-t-downgrade-timestamping-rx-filt.patch
 net-mscc-ocelot-correctly-report-the-timestamping-rx.patch
+f2fs-set-sbi_need_fsck-flag-when-inconsistent-node-b.patch
+smb3-do-not-error-on-fsync-when-readonly.patch
diff --git a/queue-5.4/smb3-do-not-error-on-fsync-when-readonly.patch b/queue-5.4/smb3-do-not-error-on-fsync-when-readonly.patch
new file mode 100644 (file)
index 0000000..36025ac
--- /dev/null
@@ -0,0 +1,94 @@
+From d71a74c56f782ac90af402eda47068938309cab0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 10 Nov 2021 01:47:48 -0600
+Subject: smb3: do not error on fsync when readonly
+
+From: Steve French <stfrench@microsoft.com>
+
+[ Upstream commit 71e6864eacbef0b2645ca043cdfbac272cb6cea3 ]
+
+Linux allows doing a flush/fsync on a file open for read-only,
+but the protocol does not allow that.  If the file passed in
+on the flush is read-only try to find a writeable handle for
+the same inode, if that is not possible skip sending the
+fsync call to the server to avoid breaking the apps.
+
+Reported-by: Julian Sikorski <belegdol@gmail.com>
+Tested-by: Julian Sikorski <belegdol@gmail.com>
+Suggested-by: Jeremy Allison <jra@samba.org>
+Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
+Signed-off-by: Steve French <stfrench@microsoft.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/cifs/file.c | 35 +++++++++++++++++++++++++++++------
+ 1 file changed, 29 insertions(+), 6 deletions(-)
+
+diff --git a/fs/cifs/file.c b/fs/cifs/file.c
+index a9746af5a44db..03c85beecec10 100644
+--- a/fs/cifs/file.c
++++ b/fs/cifs/file.c
+@@ -2577,12 +2577,23 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
+       tcon = tlink_tcon(smbfile->tlink);
+       if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) {
+               server = tcon->ses->server;
+-              if (server->ops->flush)
+-                      rc = server->ops->flush(xid, tcon, &smbfile->fid);
+-              else
++              if (server->ops->flush == NULL) {
+                       rc = -ENOSYS;
++                      goto strict_fsync_exit;
++              }
++
++              if ((OPEN_FMODE(smbfile->f_flags) & FMODE_WRITE) == 0) {
++                      smbfile = find_writable_file(CIFS_I(inode), FIND_WR_ANY);
++                      if (smbfile) {
++                              rc = server->ops->flush(xid, tcon, &smbfile->fid);
++                              cifsFileInfo_put(smbfile);
++                      } else
++                              cifs_dbg(FYI, "ignore fsync for file not open for write\n");
++              } else
++                      rc = server->ops->flush(xid, tcon, &smbfile->fid);
+       }
++strict_fsync_exit:
+       free_xid(xid);
+       return rc;
+ }
+@@ -2594,6 +2605,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
+       struct cifs_tcon *tcon;
+       struct TCP_Server_Info *server;
+       struct cifsFileInfo *smbfile = file->private_data;
++      struct inode *inode = file_inode(file);
+       struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
+       rc = file_write_and_wait_range(file, start, end);
+@@ -2608,12 +2620,23 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
+       tcon = tlink_tcon(smbfile->tlink);
+       if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) {
+               server = tcon->ses->server;
+-              if (server->ops->flush)
+-                      rc = server->ops->flush(xid, tcon, &smbfile->fid);
+-              else
++              if (server->ops->flush == NULL) {
+                       rc = -ENOSYS;
++                      goto fsync_exit;
++              }
++
++              if ((OPEN_FMODE(smbfile->f_flags) & FMODE_WRITE) == 0) {
++                      smbfile = find_writable_file(CIFS_I(inode), FIND_WR_ANY);
++                      if (smbfile) {
++                              rc = server->ops->flush(xid, tcon, &smbfile->fid);
++                              cifsFileInfo_put(smbfile);
++                      } else
++                              cifs_dbg(FYI, "ignore fsync for file not open for write\n");
++              } else
++                      rc = server->ops->flush(xid, tcon, &smbfile->fid);
+       }
++fsync_exit:
+       free_xid(xid);
+       return rc;
+ }
+-- 
+2.33.0
+