From patchwork Wed Apr 6 03:44:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 8757941 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F16C09F372 for ; Wed, 6 Apr 2016 03:45:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14FDF20306 for ; Wed, 6 Apr 2016 03:45:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 37ACC2034A for ; Wed, 6 Apr 2016 03:45:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754423AbcDFDpb (ORCPT ); Tue, 5 Apr 2016 23:45:31 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:34432 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753527AbcDFDpa (ORCPT ); Tue, 5 Apr 2016 23:45:30 -0400 Received: by mail-pa0-f66.google.com with SMTP id hb4so2896121pac.1; Tue, 05 Apr 2016 20:45:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UFENoaUB/7KLZmHpJzmiDmgGfHbWlZNwuxu8apyS7LE=; b=BMoXbUAQZwoKbg7T+Lb6slbFcnSxqrsUxni96QCyoQbM7NNrJbTGVqbmgnBDoqEGdY RR/+R6y/cacjGqN7bc2Sd3s8YmOEXUpddg06qEvPy6veTy7NksgMtIenO4W0aP1J6SmF W8q+DRuH5boDkIl4dYPMxwxaX9wMfQnz5koU+zgCJxGdqjnwvbPhsgeQLzjk8T4QhGLf f2JCAgz56Jhk5yyOfod3fmtTK6qTrNpE/AdoXiim857IrpFr/FieSbUwwrL7iO2yJYXe k4WI2BPUPsmesY0w0lG3IiqruExuMahILE0z0WYPMzq4XWGfRRBo3/h4Cp/9ktEn3b9w Zr7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UFENoaUB/7KLZmHpJzmiDmgGfHbWlZNwuxu8apyS7LE=; b=JnAVxLYKIGXWAgjsXl7iv2KT8jGqqU8gQXHZROSGTrlSb5cRBKfNm/DyBea2W8LrAr jU4vNt/ws7wd2BrG7soN9NMXTqfQ2W7I1PDH2ioFYiVb8gVYu8Rtw3WPf3yh6dzJQmrs 3DIFAp2M6ZUxiW83xPl1W7f5vQTKw4+vfHC+gqNxWKjRkfLtC3WUu5gZLMKnR2MUltmN HtdzR2fPdSbQxAw4sKJ32lJVfdjhxvJ/jzQapuCzDs6UeFK4cu5scfTxVIrP374DpJf1 eQ1MTiMMw5b1/3eYT5HIrq5e+uqre1ct+Yk21ts9P0AI6LTmjIs6KlttaDd9l/XrEKTd taEg== X-Gm-Message-State: AD7BkJKNi6B6t/Bh6l9Vl+A0GjfDH1t/NiA09f4y7mdutC6nLLPn6OtMLfy3kZX+bEzmOA== X-Received: by 10.66.251.132 with SMTP id zk4mr49356129pac.50.1459914329145; Tue, 05 Apr 2016 20:45:29 -0700 (PDT) Received: from localhost ([128.199.137.77]) by smtp.gmail.com with ESMTPSA id p26sm764302pfi.84.2016.04.05.20.45.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Apr 2016 20:45:28 -0700 (PDT) From: Eryu Guan To: linux-fsdevel@vger.kernel.org Cc: Eryu Guan , Steven Whitehouse , Bob Peterson , Alexander Viro , Dave Chinner , xfs@oss.sgi.com (supporter:XFS FILESYSTEM), cluster-devel@redhat.com (open list:GFS2 FILE SYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] fs: return EPERM on immutable inode Date: Wed, 6 Apr 2016 11:44:12 +0800 Message-Id: <1459914252-13462-1-git-send-email-guaneryu@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1459862890-22957-1-git-send-email-guaneryu@gmail.com> References: <1459862890-22957-1-git-send-email-guaneryu@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In most cases, EPERM is returned on immutable inode, and there're only a few places returning EACCES. I noticed this when running LTP on overlayfs, setxattr03 failed due to unexpected EACCES on immutable inode. So converting all EACCES to EPERM on immutable inode. Acked-by: Dave Chinner Signed-off-by: Eryu Guan --- v2: - update commit message to include the background on noticing this issue fs/gfs2/inode.c | 2 +- fs/namei.c | 2 +- fs/utimes.c | 3 ++- fs/xfs/xfs_ioctl.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index bb30f9a..4c68d91 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1757,7 +1757,7 @@ int gfs2_permission(struct inode *inode, int mask) } if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode)) - error = -EACCES; + error = -EPERM; else error = generic_permission(inode, mask); if (unlock) diff --git a/fs/namei.c b/fs/namei.c index 1d9ca2d..7f4a40a 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -408,7 +408,7 @@ int __inode_permission(struct inode *inode, int mask) * Nobody gets write access to an immutable file. */ if (IS_IMMUTABLE(inode)) - return -EACCES; + return -EPERM; } retval = do_inode_permission(inode, mask); diff --git a/fs/utimes.c b/fs/utimes.c index 85c40f4..794f5f5 100644 --- a/fs/utimes.c +++ b/fs/utimes.c @@ -92,10 +92,11 @@ static int utimes_common(struct path *path, struct timespec *times) * then we need to check permissions, because * inode_change_ok() won't do it. */ - error = -EACCES; + error = -EPERM; if (IS_IMMUTABLE(inode)) goto mnt_drop_write_and_out; + error = -EACCES; if (!inode_owner_or_capable(inode)) { error = inode_permission(inode, MAY_WRITE); if (error) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index bcb6c19..4c4c58f 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -232,7 +232,7 @@ xfs_open_by_handle( } if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) { - error = -EACCES; + error = -EPERM; goto out_dput; }