Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3086341pxf; Sun, 28 Mar 2021 11:11:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoZU0AkhtV1bu8hXyK3DjBXzvWgwoyq6RrYhsq0vdAu3c8m1A1hizm/uIwLkAWOqBZEaGQ X-Received: by 2002:a17:906:bd2:: with SMTP id y18mr25502202ejg.482.1616955100874; Sun, 28 Mar 2021 11:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616955100; cv=none; d=google.com; s=arc-20160816; b=IxInTicPAr4E0Kobv3R3wGzrQqMtBYPhi/KkxMQCJsFna94UDinnDvI4cAnrK7DgHs skwcyR9R15e3OswQuwLQE/HSZgv7wJoJfx7uHwe/o2VOwl7GDik8g+oZpsIGy2uOg3s3 Tj7ysjvGp+5W+fAI9IQ7sB7SD4HjgKpqg05h1wmXMGvLI9Q5G774dsg0hJ5Vsns8pRIj W1g6yR5HrIc2wfg5KYLmBSHvvIa2yqrms/YYmkvVYXJprszSdI4BO/Ly08EoyR8LFLyo 8SJmbIVAtUkuO5/sjtNyjFXVWbnkt2cuv9tdzytzD77EUV7Gq2U/8EG0v6w69tWB9m1W svYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=FD7WL8tCpgKoK5jN+dfKiXOuJHvRLAhOX7BoNU+VAgM=; b=HyheddMFIUvH85xLf60VZPV7xyHBWL7H4dFksjqSHrkQamwx63UEimjFDpHGHde7Ki 7FHhhXdKUp4eQ8pSthDobfdOIPx46y4JTxJ29fMd7VerjdInYdrsRibUzZ3x0P99XwC5 83Wr/hJiQpQbxJeF+NwqBDSEZ3LSteyZGJx7ZlKL4zZg3SpfVefx/y0f5f/mSPodUiRJ xCgBWrWek4+/CVosPRjWaw5t1bAvP2yz59se+hlwl6/K9dzbjO/B79sCtaogtt81UEv7 1L0dLprLGF5gKhrPHTHFKntPw+efODfzvkaqQOvnD/PzcHVKv2Thk3kTp8+icutkse8t oRPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l19si11212796edq.269.2021.03.28.11.11.18; Sun, 28 Mar 2021 11:11:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbhC1SH2 (ORCPT + 99 others); Sun, 28 Mar 2021 14:07:28 -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.