From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B0F9C433E1 for ; Sun, 28 Mar 2021 18:08:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 295E861981 for ; Sun, 28 Mar 2021 18:08:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231438AbhC1SHa (ORCPT ); Sun, 28 Mar 2021 14:07:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229950AbhC1SHF (ORCPT ); Sun, 28 Mar 2021 14:07:05 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DB0DC061756; Sun, 28 Mar 2021 11:07:05 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lQZoU-000UU0-Fw; Sun, 28 Mar 2021 18:07:02 +0000 Date: Sun, 28 Mar 2021 18:07:02 +0000 From: Al Viro To: Miklos Szeredi Cc: linux-fsdevel@vger.kernel.org, "Darrick J . Wong" , Amir Goldstein , David Sterba , Christian Brauner , Eric Biggers , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 01/18] vfs: add fileattr ops Message-ID: References: <20210325193755.294925-1-mszeredi@redhat.com> <20210325193755.294925-2-mszeredi@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210325193755.294925-2-mszeredi@redhat.com> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 25, 2021 at 08:37:38PM +0100, Miklos Szeredi wrote: > +int vfs_fileattr_get(struct dentry *dentry, struct fileattr *fa) > +{ > + struct inode *inode = d_inode(dentry); > + > + if (d_is_special(dentry)) > + return -ENOTTY; FWIW - why? For uses via ioctl() you simply won't get there with device nodes et.al. - they have file_operations of their own. If we add syscall(s) for getting/setting those, there's no reason for e.g. a device node not to have those attributes... > +static int ioctl_getflags(struct file *file, void __user *argp) unsigned int __user *argp, surely? > +{ > + struct fileattr fa = { .flags_valid = true }; /* hint only */ > + unsigned int flags; > + int err; > + > + err = vfs_fileattr_get(file->f_path.dentry, &fa); > + if (!err) { > + flags = fa.flags; > + if (copy_to_user(argp, &flags, sizeof(flags))) > + err = -EFAULT; ... and put_user() here. > + } > + return err; > +} > + > +static int ioctl_setflags(struct file *file, void __user *argp) > +{ > + struct fileattr fa; > + unsigned int flags; > + int err; > + > + if (copy_from_user(&flags, argp, sizeof(flags))) > + return -EFAULT; > + > + err = mnt_want_write_file(file); > + if (!err) { > + fileattr_fill_flags(&fa, flags); > + err = vfs_fileattr_set(file_mnt_user_ns(file), file_dentry(file), &fa); > + mnt_drop_write_file(file); > + } > + return err; > +} Similar here.