public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Replace exec_permission_lite() with inlined vfs_permission()
@ 2002-05-03  1:44 Paul Menage
  2002-05-03  2:16 ` Alexander Viro
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Menage @ 2002-05-03  1:44 UTC (permalink / raw)
  To: viro, torvalds; +Cc: pmenage, linux-kernel


Since exec_permission_lite() is now basically an inlined and
constant-propagated duplicate of vfs_permission(), this patch drops
exec_permission_lite() and makes vfs_permission() inlined (but not
static) and calls it from link_path_walk() if the inode doesn't have an
i_op->permission() method.

diff -X /mnt/elbrus/home/pmenage/dontdiff -aur linux-2.5.13/fs/namei.c linux-2.5.13-permission/fs/namei.c
--- linux-2.5.13/fs/namei.c	Thu May  2 17:22:48 2002
+++ linux-2.5.13-permission/fs/namei.c	Thu May  2 17:48:11 2002
@@ -153,7 +153,7 @@
  * for filesystem access without changing the "normal" uids which
  * are used for other things..
  */
-int vfs_permission(struct inode * inode, int mask)
+inline int vfs_permission(struct inode * inode, int mask)
 {
 	umode_t			mode = inode->i_mode;
 
@@ -300,40 +300,6 @@
 }
 
 /*
- * Short-cut version of permission(), for calling by
- * path_walk(), when dcache lock is held.  Combines parts
- * of permission() and vfs_permission(), and tests ONLY for
- * MAY_EXEC permission.
- *
- * If appropriate, check DAC only.  If not appropriate, or
- * short-cut DAC fails, then call permission() to do more
- * complete permission check.
- */
-static inline int exec_permission_lite(struct inode *inode)
-{
-	umode_t	mode = inode->i_mode;
-
-	if ((inode->i_op && inode->i_op->permission))
-		return -EAGAIN;
-
-	if (current->fsuid == inode->i_uid)
-		mode >>= 6;
-	else if (in_group_p(inode->i_gid))
-		mode >>= 3;
-
-	if (mode & MAY_EXEC)
-		return 0;
-
-	if ((inode->i_mode & S_IXUGO) && capable(CAP_DAC_OVERRIDE))
-		return 0;
-
-	if (S_ISDIR(inode->i_mode) && capable(CAP_DAC_READ_SEARCH))
-		return 0;
-
-	return -EACCES;
-}
-
-/*
  * This is called when everything else fails, and we actually have
  * to go to the low-level filesystem to find out what we should do..
  *
@@ -578,11 +544,12 @@
 		struct qstr this;
 		unsigned int c;
 
-		err = exec_permission_lite(inode);
-		if (err == -EAGAIN) {
+		if(inode->i_op && inode->i_op->permission) {
 			unlock_nd(nd);
 			err = permission(inode, MAY_EXEC);
 			lock_nd(nd);
+		} else {
+			err = vfs_permission(inode, MAY_EXEC);
 		}
  		if (err)
 			break;



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-05-03 18:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-03  1:44 [PATCH] Replace exec_permission_lite() with inlined vfs_permission() Paul Menage
2002-05-03  2:16 ` Alexander Viro
2002-05-03  2:36   ` Paul Menage
2002-05-03  9:03   ` Paul Menage
2002-05-03  9:09     ` Alexander Viro
2002-05-03 17:23       ` Paul Menage
2002-05-03 18:14         ` Trond Myklebust
2002-05-03  9:10     ` Paul Menage

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox