Received: by 10.192.165.156 with SMTP id m28csp790620imm; Fri, 13 Apr 2018 07:54:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+EvYiGepxR4J0Odj+aBGbqBxBSoHhxJr/IYVLC4TEInF7I5tNka6X5k+FQBXsKemP/cBnp X-Received: by 2002:a17:902:e5:: with SMTP id a92-v6mr5517872pla.26.1523631286413; Fri, 13 Apr 2018 07:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523631286; cv=none; d=google.com; s=arc-20160816; b=LYekSnvM2/QD/QCtBf3NExZEbfQMoWN5EzJRn0bfuj+rY+ImVED4ujTWe6jm7PYMsH BV5WHFFqs33EICNLnrli/d5KIFlcdRMpAmrpg2QOQB28J/c1/w64dqnDU1X2gq5u4GwI 8ABAC+lDaFJGuRGp6nt30u+l8qQb4MOcmoT/EhIs/npm1t9DXKVVEPrXnBWUpSiaYQCo snI5GfwvDd3TqpSLtfPn6wstPsatSqVA8FmaWA7/smhNb4La2WF1azvtsHKumFDiovlM COxj6ysBJn5ab7iWd9pQlK29h+Lds4cFUJHrMOGTrVJATpB4VpUZ1+Uestwf7gQieAEL NXBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=xnEc/Y0YU3v+2N+kv8rlczAhZCg32rucJHNr+OtCQ68=; b=wGPZRLzGzXGXbdcskqsL58H6he5KOA0Tp8hVgAL0dBfaxHsT2RlLuq/pELV9W8ejgg R20UxQdkiZ3bqUxvqDhg/s02fjn/3D1DoL3rw6d2fl/vNjq4OH2NHT7BXGVeB8tFSLP8 SzmJH0VGPKUuCOL4Lg9x7bCwFKeuQ5wGsJpMpqsZ4ko17UHDgd/5j1777uvcCK8O3wT5 iC2DDERpn6Qm50gdErIHplx61rGEq9MaWpiHQOW67NQywrXNHYAwV6nA3IFjNy0jHtMd 5N5pts/d2G1hsKo3313tItMSFr8OKsyTL7lutPzCq26Xr5iR7kgg6pP00Ne/gs+KrG01 Nosg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eErekjeW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m137si4040753pga.382.2018.04.13.07.54.32; Fri, 13 Apr 2018 07:54:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eErekjeW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752178AbeDMOtA (ORCPT + 99 others); Fri, 13 Apr 2018 10:49:00 -0400 Received: from mail-yb0-f196.google.com ([209.85.213.196]:40289 "EHLO mail-yb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbeDMOs6 (ORCPT ); Fri, 13 Apr 2018 10:48:58 -0400 Received: by mail-yb0-f196.google.com with SMTP id c10-v6so4515916ybn.7; Fri, 13 Apr 2018 07:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=xnEc/Y0YU3v+2N+kv8rlczAhZCg32rucJHNr+OtCQ68=; b=eErekjeWR/PiOCDIInLfDMeLvLnHO7A/kLB/BBxY0q6xypc6chNrgeduG4vrJP+Ukk FuImbr4kYf6EDgJ4VxgVYs52CNcDthPUFV8DYanjI8sfQ8AcKXBP0hMKlbhHYXbnsmU2 PChOUKEznY3Oo6uq4aLmM/Bmh2UirXQEcggeqEbH9grL5WvCTr7y+FshX41Ty/vwGYn1 dwtP3ePI0W/zBM0nmZlVc58fbg7LP4zE88aDNNks6ABvtiKRhEVABYlhW4N/5KnG5H8h 8gphrksNPfJaVRF2c5urgD4cJR90PEdnu+kNsWJLQDCGfkV6G/KXMy46oc4evRLzKtKq 9Xqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=xnEc/Y0YU3v+2N+kv8rlczAhZCg32rucJHNr+OtCQ68=; b=VsM/7aZytSzKb4XU/3Ji38zBvIRXguuNXn2Hu4bDpe0uz42u5Cz78RSJy43EuNdEZl QCZIGLTcRIx8Ioa96MC+od/IVe2Fd4stWKFowdowOvZRuieV6XM1vG17QqeeFol2E+TL OWjucA5Or4k+AiiXqQjX4nMmQiIFRddC+vJBxwwFGGxDrgWINsRJxkC8DAsCeY0lNxix 8oDhdtCf/iPf3oObKZa/dI611Y0qThkquasLKPcO15thYeCNbiT/LEU3518bbQumKQaI 8K27ZgSnYRyznTUm//x6+V/3YaEnlS90I8ZnXA3buSXCaDHIEgJTJD3lyh9htr/MrKFo wglA== X-Gm-Message-State: ALQs6tDKFagJGNaYMmZSnfFZ6F8+qit7+JPNCMZhXfb0Z1kvxDnSLTbZ CAEs2GcFzGUWIUfXdkYzYj2uIW2EVprao52KS2iEZw== X-Received: by 2002:a25:c841:: with SMTP id y62-v6mr490559ybf.252.1523630937259; Fri, 13 Apr 2018 07:48:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.183.12 with HTTP; Fri, 13 Apr 2018 07:48:56 -0700 (PDT) In-Reply-To: <20180412150826.20988-17-mszeredi@redhat.com> References: <20180412150826.20988-1-mszeredi@redhat.com> <20180412150826.20988-17-mszeredi@redhat.com> From: Amir Goldstein Date: Fri, 13 Apr 2018 17:48:56 +0300 Message-ID: Subject: Re: [RFC PATCH 16/35] ovl: readd lsattr/chattr support To: Miklos Szeredi Cc: overlayfs , linux-fsdevel , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 12, 2018 at 6:08 PM, Miklos Szeredi wrote: > Implement FS_IOC_GETFLAGS and FS_IOC_SETFLAGS. > > Needs vfs_ioctl() exported to modules. > > Signed-off-by: Miklos Szeredi > --- > fs/internal.h | 1 - > fs/ioctl.c | 1 + > fs/overlayfs/file.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > include/linux/fs.h | 2 ++ > 4 files changed, 62 insertions(+), 1 deletion(-) > > diff --git a/fs/internal.h b/fs/internal.h > index 3319bf39e339..d5108d9c6a2f 100644 > --- a/fs/internal.h > +++ b/fs/internal.h > @@ -176,7 +176,6 @@ extern const struct dentry_operations ns_dentry_operations; > */ > extern int do_vfs_ioctl(struct file *file, unsigned int fd, unsigned int cmd, > unsigned long arg); > -extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); > > /* > * iomap support: > diff --git a/fs/ioctl.c b/fs/ioctl.c > index 5ace7efb0d04..696f4c46a868 100644 > --- a/fs/ioctl.c > +++ b/fs/ioctl.c > @@ -49,6 +49,7 @@ long vfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > out: > return error; > } > +EXPORT_SYMBOL(vfs_ioctl); > > static int ioctl_fibmap(struct file *filp, int __user *p) > { > diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c > index 05e3e2f80b89..cc004ff1b05b 100644 > --- a/fs/overlayfs/file.c > +++ b/fs/overlayfs/file.c > @@ -8,6 +8,7 @@ > > #include > #include > +#include > #include > #include > #include "overlayfs.h" > @@ -291,6 +292,63 @@ long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len) > return ret; > } > > +static long ovl_real_ioctl(struct file *file, unsigned int cmd, > + unsigned long arg) > +{ > + struct fd real; > + const struct cred *old_cred; > + long ret; > + > + ret = ovl_real_file(file, &real); > + if (ret) > + return ret; > + > + old_cred = ovl_override_creds(file_inode(file)->i_sb); > + ret = vfs_ioctl(real.file, cmd, arg); > + revert_creds(old_cred); > + > + fdput(real); > + > + return ret; > +} > + > +long ovl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > +{ > + long ret; > + struct inode *inode = file_inode(file); > + > + switch (cmd) { > + case FS_IOC_GETFLAGS: > + ret = ovl_real_ioctl(file, cmd, arg); > + break; > + > + case FS_IOC_SETFLAGS: > + if (!inode_owner_or_capable(inode)) > + return -EACCES; > + > + ret = mnt_want_write_file(file); > + if (ret) > + return ret; > + > + ret = ovl_copy_up(file_dentry(file)); > + if (!ret) { > + ret = ovl_real_ioctl(file, cmd, arg); > + > + inode_lock(inode); > + ovl_copyflags(ovl_inode_real(inode), inode); > + inode_unlock(inode); > + } > + > + mnt_drop_write_file(file); > + break; > + > + default: > + ret = -ENOTTY; I am wondering out loud. This is a change of behavior that fs specific ioctls cannot be executed on overlay file - arguably a good change of behavior, but still a change that applications may got dependent on. Would it have been better to opt-in for this change by a more generic config/mount options, for example "consistent_fd" , instead of "copy_up_shared" and then we can choose whether or not to pass though unknown ioctls to real file. I know we removed the want_write_file() protection from VFS, but still, pass through of ioctls was the legacy behavior. Thoughts? I don't mind to wait and see if someone shouts. Thanks, Amir.