From: Andy Whitcroft <apw@canonical.com>
To: Miklos Szeredi <miklos@szeredi.hu>, Andy Whitcroft <apw@canonical.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
mszeredi@suse.cz
Subject: [PATCH 1/2] inode_only_permission: export inode level permissions checks
Date: Tue, 6 Mar 2012 16:18:05 +0000 [thread overview]
Message-ID: <1331050686-1815-1-git-send-email-apw@canonical.com> (raw)
In-Reply-To: <20120306161224.GE9978@shadowen.org>
We need to be able to check inode permissions (but not filesystem implied
permissions) for stackable filesystems. Now that permissions involve
checking with the security LSM, cgroups and basic inode permissions it is
easy to miss a key permission check and introduce a security vunerability.
Expose a new interface for these checks.
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
fs/namei.c | 34 +++++++++++++++++++++++++---------
include/linux/fs.h | 1 +
2 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index e2ba628..16c77a4 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -328,6 +328,30 @@ static inline int do_inode_permission(struct inode *inode, int mask)
}
/**
+ * inode_only_permission - check access rights to a given inode only
+ * @inode: inode to check permissions on
+ * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC, ...)
+ *
+ * Uses to check read/write/execute permissions on an inode directly, we do
+ * not check filesystem permissions.
+ */
+int inode_only_permission(struct inode *inode, int mask)
+{
+ int retval;
+
+ retval = do_inode_permission(inode, mask);
+ if (retval)
+ return retval;
+
+ retval = devcgroup_inode_permission(inode, mask);
+ if (retval)
+ return retval;
+
+ return security_inode_permission(inode, mask);
+}
+EXPORT_SYMBOL(inode_only_permission);
+
+/**
* inode_permission - check for access rights to a given inode
* @inode: inode to check permission on
* @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC, ...)
@@ -360,15 +384,7 @@ int inode_permission(struct inode *inode, int mask)
return -EACCES;
}
- retval = do_inode_permission(inode, mask);
- if (retval)
- return retval;
-
- retval = devcgroup_inode_permission(inode, mask);
- if (retval)
- return retval;
-
- return security_inode_permission(inode, mask);
+ return inode_only_permission(inode, mask);
}
/**
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 871c87f..b06a3b4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2228,6 +2228,7 @@ extern sector_t bmap(struct inode *, sector_t);
#endif
extern int notify_change(struct dentry *, struct iattr *);
extern int inode_permission(struct inode *, int);
+extern int inode_only_permission(struct inode *, int);
extern int generic_permission(struct inode *, int);
static inline bool execute_ok(struct inode *inode)
--
1.7.9
next prev parent reply other threads:[~2012-03-06 16:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-17 15:10 [PATCH 1/1] overlayfs: apply device cgroup and security permissions to overlay files Andy Whitcroft
2012-03-05 17:18 ` Miklos Szeredi
2012-03-06 16:12 ` Andy Whitcroft
2012-03-06 16:18 ` Andy Whitcroft [this message]
2012-03-06 16:18 ` [PATCH 2/2] overlayfs: switch to use inode_only_permissions Andy Whitcroft
2012-03-06 16:37 ` [PATCH 1/2] inode_only_permission: export inode level permissions checks Miklos Szeredi
2012-04-29 15:03 ` [PATCH 1/1] overlayfs: apply device cgroup and security permissions to overlay files Sedat Dilek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1331050686-1815-1-git-send-email-apw@canonical.com \
--to=apw@canonical.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=mszeredi@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome