lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20071012160550.15119.87511.stgit@warthog.procyon.org.uk>
Date:	Fri, 12 Oct 2007 17:05:50 +0100
From:	David Howells <dhowells@...hat.com>
To:	viro@....linux.org.uk
Cc:	kwc@...i.umich.edu, Trond.Myklebust@...app.com,
	linux-kernel@...r.kernel.org, dhowells@...hat.com
Subject: [PATCH 06/52] CRED: Prepare RAMFS for cred passing

Prepare RAMFS for cred passing.

Signed-off-by: David Howells <dhowells@...hat.com>
---

 fs/ramfs/inode.c      |   16 ++++++++++------
 include/linux/ramfs.h |    3 ++-
 mm/tiny-shmem.c       |    3 ++-
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index fe3642a..29100e2 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -49,14 +49,15 @@ static struct backing_dev_info ramfs_backing_dev_info = {
 			  BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP,
 };
 
-struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev)
+struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev,
+			      struct cred *cred)
 {
 	struct inode * inode = new_inode(sb);
 
 	if (inode) {
 		inode->i_mode = mode;
-		inode->i_uid = current->cred->uid;
-		inode->i_gid = current->cred->gid;
+		inode->i_uid = cred->uid;
+		inode->i_gid = cred->gid;
 		inode->i_blocks = 0;
 		inode->i_mapping->a_ops = &ramfs_aops;
 		inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info;
@@ -92,7 +93,8 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev)
 static int
 ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
 {
-	struct inode * inode = ramfs_get_inode(dir->i_sb, mode, dev);
+	struct cred *cred = current->cred;
+	struct inode * inode = ramfs_get_inode(dir->i_sb, mode, dev, cred);
 	int error = -ENOSPC;
 
 	if (inode) {
@@ -124,10 +126,11 @@ static int ramfs_create(struct inode *dir, struct dentry *dentry, int mode, stru
 
 static int ramfs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
 {
+	struct cred *cred = current->cred;
 	struct inode *inode;
 	int error = -ENOSPC;
 
-	inode = ramfs_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0);
+	inode = ramfs_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0, cred);
 	if (inode) {
 		int l = strlen(symname)+1;
 		error = page_symlink(inode, symname, l);
@@ -162,6 +165,7 @@ static const struct super_operations ramfs_ops = {
 
 static int ramfs_fill_super(struct super_block * sb, void * data, int silent)
 {
+	struct cred *cred = current->cred;
 	struct inode * inode;
 	struct dentry * root;
 
@@ -171,7 +175,7 @@ static int ramfs_fill_super(struct super_block * sb, void * data, int silent)
 	sb->s_magic = RAMFS_MAGIC;
 	sb->s_op = &ramfs_ops;
 	sb->s_time_gran = 1;
-	inode = ramfs_get_inode(sb, S_IFDIR | 0755, 0);
+	inode = ramfs_get_inode(sb, S_IFDIR | 0755, 0, cred);
 	if (!inode)
 		return -ENOMEM;
 
diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h
index b160fb1..124b0c3 100644
--- a/include/linux/ramfs.h
+++ b/include/linux/ramfs.h
@@ -1,7 +1,8 @@
 #ifndef _LINUX_RAMFS_H
 #define _LINUX_RAMFS_H
 
-struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev);
+struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev,
+			      struct cred *cred);
 extern int ramfs_get_sb(struct file_system_type *fs_type,
 	 int flags, const char *dev_name, void *data, struct vfsmount *mnt);
 
diff --git a/mm/tiny-shmem.c b/mm/tiny-shmem.c
index 8803471..3d4d602 100644
--- a/mm/tiny-shmem.c
+++ b/mm/tiny-shmem.c
@@ -48,6 +48,7 @@ module_init(init_tmpfs)
  */
 struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
 {
+	struct cred *cred = current->cred;
 	int error;
 	struct file *file;
 	struct inode *inode;
@@ -72,7 +73,7 @@ struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)
 		goto put_dentry;
 
 	error = -ENOSPC;
-	inode = ramfs_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0);
+	inode = ramfs_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0, cred);
 	if (!inode)
 		goto close_file;
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ