From 9ec3505f5aa827cd2bcf87325d04575d82c22426 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 26 Oct 2022 19:02:39 +0200 Subject: [PATCH] 5.15-stable patches added patches: fs-clear-or-set-fmode_lseek-based-on-llseek-function.patch --- ...fmode_lseek-based-on-llseek-function.patch | 51 +++++++++++++++++++ queue-5.15/series | 1 + 2 files changed, 52 insertions(+) create mode 100644 queue-5.15/fs-clear-or-set-fmode_lseek-based-on-llseek-function.patch diff --git a/queue-5.15/fs-clear-or-set-fmode_lseek-based-on-llseek-function.patch b/queue-5.15/fs-clear-or-set-fmode_lseek-based-on-llseek-function.patch new file mode 100644 index 00000000000..0cc98fa5f6a --- /dev/null +++ b/queue-5.15/fs-clear-or-set-fmode_lseek-based-on-llseek-function.patch @@ -0,0 +1,51 @@ +From e7478158e1378325907edfdd960eca98a1be405b Mon Sep 17 00:00:00 2001 +From: "Jason A. Donenfeld" +Date: Wed, 29 Jun 2022 15:06:57 +0200 +Subject: fs: clear or set FMODE_LSEEK based on llseek function + +From: Jason A. Donenfeld + +commit e7478158e1378325907edfdd960eca98a1be405b upstream. + +Pipe-like behaviour on llseek(2) (i.e. unconditionally failing with +-ESPIPE) can be expresses in 3 ways: + 1) ->llseek set to NULL in file_operations + 2) ->llseek set to no_llseek in file_operations + 3) FMODE_LSEEK *not* set in ->f_mode. + +Enforce (3) in cases (1) and (2); that will allow to simplify the +checks and eventually get rid of no_llseek boilerplate. + +Signed-off-by: Jason A. Donenfeld +Signed-off-by: Al Viro +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Saeed Mirzamohammadi +--- + fs/file_table.c | 2 ++ + fs/open.c | 4 ++++ + 2 files changed, 6 insertions(+) + +--- a/fs/file_table.c ++++ b/fs/file_table.c +@@ -198,6 +198,8 @@ static struct file *alloc_file(const str + file->f_mapping = path->dentry->d_inode->i_mapping; + file->f_wb_err = filemap_sample_wb_err(file->f_mapping); + file->f_sb_err = file_sample_sb_err(file); ++ if (fop->llseek && fop->llseek != no_llseek) ++ file->f_mode |= FMODE_LSEEK; + if ((file->f_mode & FMODE_READ) && + likely(fop->read || fop->read_iter)) + file->f_mode |= FMODE_CAN_READ; +--- a/fs/open.c ++++ b/fs/open.c +@@ -834,6 +834,10 @@ static int do_dentry_open(struct file *f + if ((f->f_mode & FMODE_WRITE) && + likely(f->f_op->write || f->f_op->write_iter)) + f->f_mode |= FMODE_CAN_WRITE; ++ if ((f->f_mode & FMODE_LSEEK) && !f->f_op->llseek) ++ f->f_mode &= ~FMODE_LSEEK; ++ if ((f->f_mode & FMODE_LSEEK) && f->f_op->llseek == no_llseek) ++ f->f_mode &= ~FMODE_LSEEK; + + f->f_write_hint = WRITE_LIFE_NOT_SET; + f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); diff --git a/queue-5.15/series b/queue-5.15/series index ba23b38c4ee..82bc8b10c8a 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -29,3 +29,4 @@ media-mceusb-set-timeout-to-at-least-timeout-provided.patch media-venus-dec-handle-the-case-where-find_format-fails.patch x86-topology-fix-multiple-packages-shown-on-a-single-package-system.patch x86-topology-fix-duplicated-core-id-within-a-package.patch +fs-clear-or-set-fmode_lseek-based-on-llseek-function.patch -- 2.47.3