From patchwork Tue Oct 31 22:13:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 10035449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3BB0D602B5 for ; Tue, 31 Oct 2017 22:13:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 312CB28B1F for ; Tue, 31 Oct 2017 22:13:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 263D828B21; Tue, 31 Oct 2017 22:13:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACAB228B1F for ; Tue, 31 Oct 2017 22:13:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753846AbdJaWNM (ORCPT ); Tue, 31 Oct 2017 18:13:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:59568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753612AbdJaWNM (ORCPT ); Tue, 31 Oct 2017 18:13:12 -0400 Received: from garbanzo.do-not-panic.com (c-73-15-241-2.hsd1.ca.comcast.net [73.15.241.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7DEE6218B4; Tue, 31 Oct 2017 22:13:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DEE6218B4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mcgrof@kernel.org From: "Luis R. Rodriguez" To: darrick.wong@oracle.com Cc: dhowells@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, "Luis R. Rodriguez" Subject: [RFC] xfs: fix reporting supported extra file attributes for statx() Date: Tue, 31 Oct 2017 15:13:05 -0700 Message-Id: <20171031221305.12908-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.13.2 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP statx(2) notes that any attribute that is not indicated as supported by stx_attributes_mask has no usable value. Commit 5f955f26f3d42d ("xfs: report crtime and attribute flags to statx") added support for informing userspace of extra file attributes but forgot to list these flags as supported making reporting them rather useless for the pedantic userspace author. $ git describe --contains 5f955f26f3d42d04aba65590a32eb70eedb7f37d v4.11-rc6~5^2^2~2 Fixes: 5f955f26f3d42d ("xfs: report crtime and attribute flags to statx") Signed-off-by: Luis R. Rodriguez --- Its unclear why David left these out or if it was just a mistake, I checked the original patch thread [0] but it was not clear in the end. David? Also, I posted a patch to add support to clearing these flags through xfs_repair on symlinks [1] due to the pain this can cause as you have no option but to use xfs_db to fix these otherwise. Since we *didn't* list these extra file attributes as supported, it begs the question if instead we should only set them *and* this mask if !S_ISLNK(inode->i_mode)). If so, that also begs the question if we should add further sanity check on the xfs setattr to ensure these are never set on symbolic links, despite the fact that FS_IOC_FSSETXATTR ioctl won't be able to set them... A long shot question in terms of semantics is if all the above is rather generic for Linux, is if the VFS should even be checking for immutable or append flags on unlink for symbolic links. [0] https://patchwork.kernel.org/patch/9607879/ [1] https://lkml.kernel.org/r/20171031215156.12544-1-mcgrof@kernel.org fs/xfs/xfs_iops.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 17081c77ef86..6b7d293a4aab 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -531,6 +531,10 @@ xfs_vn_getattr( if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP) stat->attributes |= STATX_ATTR_NODUMP; + stat->attributes_mask |= (STATX_ATTR_IMMUTABLE | + STATX_ATTR_APPEND | + STATX_ATTR_NODUMP); + switch (inode->i_mode & S_IFMT) { case S_IFBLK: case S_IFCHR: