From patchwork Tue Aug 2 11:58:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 9256171 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 E8CC160865 for ; Tue, 2 Aug 2016 12:01:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9FAA28524 for ; Tue, 2 Aug 2016 12:01:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC7F428526; Tue, 2 Aug 2016 12:01:06 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from oss.sgi.com (oss.sgi.com [192.48.182.195]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C811728524 for ; Tue, 2 Aug 2016 12:01:02 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id BFD227CBB; Tue, 2 Aug 2016 07:01:00 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id 632F97CBA for ; Tue, 2 Aug 2016 07:00:58 -0500 (CDT) Received: from cuda.sgi.com (cuda1.sgi.com [192.48.157.11]) by relay1.corp.sgi.com (Postfix) with ESMTP id 1897F8F8035 for ; Tue, 2 Aug 2016 05:00:55 -0700 (PDT) X-ASG-Debug-ID: 1470139252-0bf8157e6d3b5310001-NocioJ Received: from mail-pa0-f66.google.com (mail-pa0-f66.google.com [209.85.220.66]) by cuda.sgi.com with ESMTP id 9rg5GfMUjAY7fEvm (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Tue, 02 Aug 2016 05:00:52 -0700 (PDT) X-Barracuda-Envelope-From: guaneryu@gmail.com X-Barracuda-Effective-Source-IP: mail-pa0-f66.google.com[209.85.220.66] X-Barracuda-Apparent-Source-IP: 209.85.220.66 Received: by mail-pa0-f66.google.com with SMTP id q2so11865405pap.0 for ; Tue, 02 Aug 2016 05:00:52 -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; bh=aL3VGbqFF7iaM90WryJeH7ia9mUoiBsTK0njnPToLos=; b=dHSnoI4VbhVDkUAufEZjQEfttk+7evgdL4J/T14pb1mDGAQhr56Cycwcq9a7N8b8J+ GXHPSpqa4qz9/d7ItrcXp4hPFM9N/ndY5oXdQph1IG96B6EF2Fpg5gkGTl/ujlr/Rk6h Hl8CQFR0ucNNzW2aMuZmh9LvIt4tMuEVcN5Mm4RcDB2uOWLjnoxkUikGxrgc8cF+x/Lf A9JcsKgAMNrBFaIUDv/y5JJsp6tYKF5IdmCPsWH9vkLXKF6aP713qqVUrSkHP/tovfNH Pv9XzgT09EnWtCh6iF78XJqPuQrWXeq34aDpLmKIpvtiPCv6dM7uWmGKkIlf5hlOywVx SgyQ== 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; bh=aL3VGbqFF7iaM90WryJeH7ia9mUoiBsTK0njnPToLos=; b=VaskvkDKU5zHZ7adUjSw9zeNYXjwGzkN/jjPeH/7pBnnfrsOx9DkK+r/YIscPcr7yf UpTU/nKajH8Z66y0QL9sVadOz3jYuiduurBG4wqId7WUl0t1SRgjshHoAd7q5RD+nX7s wB9VB0A1MlD6HyiSYuKH88fU8HV9h3E+93oqN8Z3BtsSsuYM7ZAl2PYhypTV6HXqG0Os 8OgCYO0XGovx6Ulk0AjISJaN5ni5s0/HTb9EpVFZDrnPE8JvTEDIQabGeSqJkupVD2DD OLwcH9dgTYAtVNuA06d7I3dtmUxAP7O0Gzd1/iIMYKzHiezQ3lmn5AAXcQowWTiLrwvT fCcw== X-Gm-Message-State: AEkoousN+y7I0MjcWSlikNH7zXr4SXbs09OL67yfkXZzVdbEqHau+Nxeoc+MnSB+lh8/1g== X-Received: by 10.66.42.33 with SMTP id k1mr104915927pal.111.1470139251970; Tue, 02 Aug 2016 05:00:51 -0700 (PDT) Received: from localhost ([128.199.137.77]) by smtp.gmail.com with ESMTPSA id c8sm4425215pfe.39.2016.08.02.05.00.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Aug 2016 05:00:51 -0700 (PDT) From: Eryu Guan To: linux-fsdevel@vger.kernel.org Subject: [PATCH v2 RESEND] fs: return EPERM on immutable inode Date: Tue, 2 Aug 2016 19:58:28 +0800 X-ASG-Orig-Subj: [PATCH v2 RESEND] fs: return EPERM on immutable inode Message-Id: <1470139108-13115-1-git-send-email-guaneryu@gmail.com> X-Mailer: git-send-email 2.7.4 X-Barracuda-Connect: mail-pa0-f66.google.com[209.85.220.66] X-Barracuda-Start-Time: 1470139252 X-Barracuda-Encrypted: ECDHE-RSA-AES128-GCM-SHA256 X-Barracuda-URL: https://192.48.157.11:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 2248 X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=2.7 tests=BSF_SC0_MISMATCH_TO, DKIM_SIGNED, DKIM_VERIFIED X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.31691 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BSF_SC0_MISMATCH_TO Envelope rcpt doesn't match header -0.00 DKIM_VERIFIED Domain Keys Identified Mail: signature passes verification 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature Cc: open list , "supporter:XFS FILESYSTEM" , "open list:GFS2 FILE SYSTEM" , Eryu Guan , Alexander Viro , Bob Peterson , Steven Whitehouse X-BeenThere: xfs@oss.sgi.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com 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 Reviewed-by: Christoph Hellwig --- v2: - update commit log to mention that it's found by running LTP 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 e0621ca..e4da0ec 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1800,7 +1800,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 (gfs2_holder_initialized(&i_gh)) diff --git a/fs/namei.c b/fs/namei.c index c386a32..adb0414 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -410,7 +410,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; /* * Updating mtime will likely cause i_uid and i_gid to be 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 9a7c878..3d6820f 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; }