[vhffs-dev] [1390] ported tuxfamily Linux kernel patch to Linux 2.6.28.9 |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1390
Author: gradator
Date: 2009-04-12 14:05:27 +0200 (Sun, 12 Apr 2009)
Log Message:
-----------
ported tuxfamily Linux kernel patch to Linux 2.6.28.9
Added Paths:
-----------
trunk/vhffs-packages/patches/tfsyscall/tfsyscall-0.1.1-2.6.28.9.patch
Added: trunk/vhffs-packages/patches/tfsyscall/tfsyscall-0.1.1-2.6.28.9.patch
===================================================================
--- trunk/vhffs-packages/patches/tfsyscall/tfsyscall-0.1.1-2.6.28.9.patch (rev 0)
+++ trunk/vhffs-packages/patches/tfsyscall/tfsyscall-0.1.1-2.6.28.9.patch 2009-04-12 12:05:27 UTC (rev 1390)
@@ -0,0 +1,90 @@
+diff -Nru a/fs/open.c b/fs/open.c
+--- a/fs/open.c 2009-04-12 11:36:05.000000000 +0200
++++ b/fs/open.c 2009-04-12 12:02:40.000000000 +0200
+@@ -1079,7 +1079,7 @@
+
+ EXPORT_SYMBOL(fd_install);
+
+-long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
++long old_do_sys_open(int dfd, const char __user *filename, int flags, int mode)
+ {
+ char *tmp = getname(filename);
+ int fd = PTR_ERR(tmp);
+@@ -1101,6 +1101,77 @@
+ return fd;
+ }
+
++long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
++{
++ long fd;
++ struct file *f;
++ struct dentry *d;
++ struct inode *inode;
++ struct group_info *gi;
++ long ngroups,i,j;
++
++ fd = old_do_sys_open( dfd , filename , flags , mode );
++
++ if( fd < 0 )
++ return fd;
++
++ if( current->uid < 10000 && current->gid < 10000 )
++ return fd;
++
++ f = fget( fd );
++ if( f == NULL ) {
++ sys_close( fd );
++ return -EACCES;
++ }
++
++ d = f->f_dentry;
++ if( d == NULL ) {
++ fput( f );
++ sys_close( fd );
++ return -EACCES;
++ }
++
++ inode = d->d_inode;
++ if( inode == NULL ) {
++ fput( f );
++ sys_close( fd );
++ return -EACCES;
++ }
++
++ /* allow open() on system files */
++ if( inode->i_uid < 10000 && inode->i_gid < 10000 ) {
++ fput( f );
++ return fd;
++ }
++
++ /* allow open() if the user or group of file is either the current user or the current group */
++ if( inode->i_gid == current->gid || inode->i_uid == current->uid ) {
++ fput( f );
++ return fd;
++ }
++
++ /* if not check if the file belong to one of the user group */
++ get_group_info( current->group_info );
++ gi = current->group_info;
++ ngroups = gi->ngroups;
++ for( i = 0 ; i < gi->nblocks ; i++) {
++ long cp_count = min( (long)NGROUPS_PER_BLOCK, ngroups );
++ for( j = 0 ; j < cp_count ; j++ ) {
++ if( gi->blocks[i][j] == inode->i_gid ) {
++ put_group_info( gi );
++ fput( f );
++ return fd;
++ }
++ }
++ ngroups -= NGROUPS_PER_BLOCK;
++ }
++ put_group_info( current->group_info );
++
++ fput( f );
++ sys_close( fd );
++ return -EACCES;
++}
++
+ SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode)
+ {
+ long ret;