Re: [regression, bisected] Bug 216738 - Adding O_APPEND to O_RDWR with fcntl(fd, F_SETFL) does not work on overlayfs
From: Miklos Szeredi
Date: Thu Nov 24 2022 - 15:34:11 EST
On Thu, 24 Nov 2022 at 18:03, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
> So basically we have this
> static int ovl_change_flags(struct file *file, unsigned int flags)
> {
> struct inode *inode = file_inode(file);
> int err;
>
> flags &= OVL_SETFL_MASK;
>
> if (((flags ^ file->f_flags) & O_APPEND) && IS_APPEND(inode))
> return -EPERM;
>
> if ((flags & O_DIRECT) && !(file->f_mode & FMODE_CAN_ODIRECT))
> return -EINVAL;
>
> if (file->f_op->check_flags) {
> err = file->f_op->check_flags(flags);
> if (err)
> return err;
> }
>
> spin_lock(&file->f_lock);
> file->f_flags = (file->f_flags & ~OVL_SETFL_MASK) | flags;
> spin_unlock(&file->f_lock);
>
> return 0;
> }
> open-coding what setfl() would've done, without updating ->f_iocb_flags...
> Not hard to deal with...
>
> I could pick it in vfs.git #fixes, or Miklos could put it through his tree.
> Miklos, which way would you prefer that to go?
I'll pick this into #overlayfs-next, as a PR for this cycle is needed anyway.
Thanks,
Miklos