Linux filesystem development
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruen@suse.de>
To: "Linux-FSDevel" <linux-fsdevel@vger.kernel.org>
Subject: [RFC] Apply the umask in VFS optionally (also POSIX ACL kernel infrastructure)
Date: Sun, 4 Aug 2002 15:46:43 +0200	[thread overview]
Message-ID: <200208041546.43303.agruen@suse.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]

Hello,

[This is a copy of a previous posting to linux-kernel.]

The umask(2) is usually applied to the mode parameters to open(2), mkdir(2),
creat(2) and mknod(2) in the VFS. With POSIX Access Control Lists the umask
must only be applied in some situations, and must have no effect in others.
Currently there is no way for a file system to find out the original mode
parameter passed to the system calls.

There are two ways to solve this problem, namely, to (1) move the code that
applies the umask into the file systems, or to (2) apply the umask in the VFS
optionally only. Option (1) is intrusive on existing file systems, and might
introduce bugs, while (2) slightly complicates the VFS, but leaves file
systems unaffected.

I believe that (2) is the more reasonable choice in this case, so I propose
this patch, which adds the MS_NOUMASK mount option. The flag is set by the
file system, if the file system does not want the VFS to apply the umask,
after which the file system itself is responsible for applying the umask
where appropriate.

Finally, I have a question related to this. We had a bug with kernel tasks,
which don't have a umask associated with them (nfsd in particular). Should
kernel tasks that create files be required to have a valid fs_struct (which
includes the umask), or should this be special cased in file systems?

Regards,
Andreas.

------------------------------------------------------------------
 Andreas Gruenbacher                                SuSE Linux AG
 mailto:agruen@suse.de                     Deutschherrnstr. 15-19
 http://www.suse.de/                   D-90429 Nuernberg, Germany

[-- Attachment #2: linux-2.5.30-ms_noumask.diff --]
[-- Type: text/x-diff, Size: 2152 bytes --]

Apply the umask in VFS optionally

This patch adds the MS_NOUMASK mount option. This mount option is set by the file system, if the file system does not want the VFS to apply the umask.

diff -Nur linux-2.5.30/include/linux/fs.h linux-2.5.30.patch/include/linux/fs.h
--- linux-2.5.30/include/linux/fs.h	Thu Aug  1 23:16:15 2002
+++ linux-2.5.30.patch/include/linux/fs.h	Fri Aug  2 15:21:29 2002
@@ -110,6 +110,7 @@
 #define MS_MOVE		8192
 #define MS_REC		16384
 #define MS_VERBOSE	32768
+#define MS_NOUMASK	(1<<16) /* VFS does not apply the umask */
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
 
@@ -164,6 +165,7 @@
 #define IS_IMMUTABLE(inode)	((inode)->i_flags & S_IMMUTABLE)
 #define IS_NOATIME(inode)	(__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
 #define IS_NODIRATIME(inode)	__IS_FLG(inode, MS_NODIRATIME)
+#define IS_NOUMASK(inode)	__IS_FLG(inode, MS_NOUMASK)
 
 #define IS_DEADDIR(inode)	((inode)->i_flags & S_DEAD)
 
diff -Nur linux-2.5.30/fs/namei.c linux-2.5.30.patch/fs/namei.c
--- linux-2.5.30/fs/namei.c	Thu Aug  1 23:16:18 2002
+++ linux-2.5.30.patch/fs/namei.c	Fri Aug  2 15:35:10 2002
@@ -1279,8 +1279,9 @@
 
 	/* Negative dentry, just create the file */
 	if (!dentry->d_inode) {
-		error = vfs_create(dir->d_inode, dentry,
-				   mode & ~current->fs->umask);
+		if (!IS_NOUMASK(dir->d_inode))
+			mode &= ~current->fs->umask;
+		error = vfs_create(dir->d_inode, dentry, mode);
 		up(&dir->d_inode->i_sem);
 		dput(nd->dentry);
 		nd->dentry = dentry;
@@ -1442,7 +1443,8 @@
 	dentry = lookup_create(&nd, 0);
 	error = PTR_ERR(dentry);
 
-	mode &= ~current->fs->umask;
+	if (!IS_NOUMASK(nd.dentry->d_inode))
+		mode &= ~current->fs->umask;
 	if (!IS_ERR(dentry)) {
 		switch (mode & S_IFMT) {
 		case 0: case S_IFREG:
@@ -1508,8 +1510,9 @@
 		dentry = lookup_create(&nd, 1);
 		error = PTR_ERR(dentry);
 		if (!IS_ERR(dentry)) {
-			error = vfs_mkdir(nd.dentry->d_inode, dentry,
-					  mode & ~current->fs->umask);
+			if (!IS_NOUMASK(nd.dentry->d_inode))
+				mode &= ~current->fs->umask;
+			error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
 			dput(dentry);
 		}
 		up(&nd.dentry->d_inode->i_sem);

             reply	other threads:[~2002-08-04 13:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-04 13:46 Andreas Gruenbacher [this message]
2002-08-04 14:42 ` [RFC] Apply the umask in VFS optionally (also POSIX ACL kernel infrastructure) Christoph Hellwig
2002-08-05 11:41   ` Andreas Gruenbacher
2002-08-05 12:24     ` Christoph Hellwig

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=200208041546.43303.agruen@suse.de \
    --to=agruen@suse.de \
    --cc=linux-fsdevel@vger.kernel.org \
    /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