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: 9258889 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 B40F06077C for ; Tue, 2 Aug 2016 16:45:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A370A28504 for ; Tue, 2 Aug 2016 16:45:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9541B2857C; Tue, 2 Aug 2016 16:45:01 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 41F642853F for ; Tue, 2 Aug 2016 16:45:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966137AbcHBQor (ORCPT ); Tue, 2 Aug 2016 12:44:47 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:34861 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933080AbcHBMAx (ORCPT ); Tue, 2 Aug 2016 08:00:53 -0400 Received: by mail-pa0-f65.google.com with SMTP id cf3so11814583pad.2; Tue, 02 Aug 2016 05:00:53 -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=brr2r8Buzy9zo/kkiUEr0WSPxSGXS6UUERodUGmtFEHGKY5HpkdvBFs71ArVUvwMop D1HbLsFlD6KROw+ksPuXlcB65S1eZhywT/GPnC9Mvig3fWtK3VSOWa7GtnPM+F81Krr7 wGpBUEdzcrcGiN2P32NxK6DGMlIm8meuR40m54iOcGxyileu43Zp68moesh4D5xeVftX hriStEQmHKtn15ex1Fe4+bqshZhlD0oqK0aIZwU02s+hGPPmszmxgXtFV04EL+V0hu76 wRtJTUWnr/dK694HKmpyujcMsnnUaR8mdAmOK9QrWo0QyHQzX91129uwzbIK9lNZCsmN b6/w== X-Gm-Message-State: AEkoousSbpNy0mNRhVb49VAPyr9XqWmKiv3Nmp63o4ezf41+1Z6q+HeEWrzLSHsnS5aysQ== 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 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 RESEND] fs: return EPERM on immutable inode Date: Tue, 2 Aug 2016 19:58:28 +0800 Message-Id: <1470139108-13115-1-git-send-email-guaneryu@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.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 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; }