Skip to contentSkip to conversation

Shared flags

PATCH In review Pavel Shilovsky 6 participants 11 messages Nov 10, 2008 – Nov 16, 2008 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Shared flags

Hello!
We have situation during our work with Wine and Cifs-client then we have to use sharing access policy to files and we used 3 free bits from 21 to 23 of attribute flag(it allows to do NT-semantic for opening files in open() and it is necessary for correct implementation of function NTCreateFile in Wine). We think that it'll be useful not only for us and we proffer to add into the file kernel/include/asm-generic/fcntl.h following flags:

#define O_DENYREAD 004000000 /* Do not permit read access */
#define O_DENYWRITE 010000000 /* Do not permit write access */
#define O_DENYDELETE 020000000 /* Do not permit delete or rename operations*/

Yes, it'll change semantic of calling open() function, but by default(if not to use these flags) functionality won't changed, and if we use it we'll acquire new resources for organization file access policy. On the other hand, we patched cifs with inverting these flags, because according to CIFS protocol
#define FILE_SHARE_ALL 0x00000007
ones have opposite meaning.

Summary of changes:
[1/2] patch added share flags in kernel/include/asm-generic/fcntl.h [2/2] patch added the use of share flags in cifs client

Here is a public git repository
http://git.etersoft.ru/people/kipruss/packages/?p=cifs-2.6.git;a=shortlog;h=refs/heads/etersoft-to-kernel

Yours faithfully,
Pavel Shilovsky.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 9 lines · Pavel Shilovsky

Hello!
We have situation during our work with Wine and Cifs-client then we have to use sharing access policy to files and we used 3 free bits from 21 to 23 of attribute flag(it allows to do NT-semantic for opening files in open() and it is necessary for correct implementation of function NTCreateFile in Wine). We think that it'll be useful not only for us and we proffer to add into the file kernel/include/asm-generic/fcntl.h following flags:

Quoted 4 lines

#define O_DENYREAD 004000000 /* Do not permit read access */
#define O_DENYWRITE 010000000 /* Do not permit write access */
#define O_DENYDELETE 020000000 /* Do not permit delete or rename operations*/

I'm not completely opposed to these, but the patches you postd are rather incomplete:

(1) you need to add it to fcntl.h for those architetures not using the generic fcntl.h or those who would have overlapping bits with the generic defintions.
(2) you also need to enforce these semantics in the VFS for local filesystems

Now if (2) doesn't cause too much overhead I would say it's fine, if not I would rather avoid it.

Also please Cc the linux-api list for userspace API updates.

--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 3 lines · Pavel Shilovsky

#define O_DENYREAD 004000000 /* Do not permit read access */
#define O_DENYWRITE 010000000 /* Do not permit write access */
#define O_DENYDELETE 020000000 /* Do not permit delete or rename operations*/

(2) you also need to enforce these semantics in the VFS for local filesystems

Now if (2) doesn't cause too much overhead I would say it's fine, if not I would rather avoid it.

On the face of it, they look like they have similar denial-of-service potential as mandatory locks. For example, a root process cleaning out /tmp gets stuck because a user process has O_DENYDELETE set.

-- Jamie

#4 lore raw
Quoted 9 lines · Jamie Lokier
Quoted 8 lines · Christoph Hellwig
Quoted 3 lines · Pavel Shilovsky

#define O_DENYREAD 004000000 /* Do not permit read access */
#define O_DENYWRITE 010000000 /* Do not permit write access */
#define O_DENYDELETE 020000000 /* Do not permit delete or rename operations*/

(2) you also need to enforce these semantics in the VFS for local filesystems

Quoted 6 lines
Quoted 2 lines

Now if (2) doesn't cause too much overhead I would say it's fine, if not I would rather avoid it.

On the face of it, they look like they have similar denial-of-service potential as mandatory locks. For example, a root process cleaning out /tmp gets stuck because a user process has O_DENYDELETE set.

Oh, that's the part I forgot to mention in the previous mail, all of these option of course can only be root only, everything else would be - as you say - a complete security nightmare.

#5 lore raw
Quoted 16 lines · Christoph Hellwig
Quoted 14 lines · Jamie Lokier
Quoted 12 lines · Christoph Hellwig
Quoted 4 lines · Pavel Shilovsky

#define O_DENYREAD 004000000 /* Do not permit read access */
#define O_DENYWRITE 010000000 /* Do not permit write access */
#define O_DENYDELETE 020000000 /* Do not permit delete or rename operations*/

(2) you also need to enforce these semantics in the VFS for local filesystems

Now if (2) doesn't cause too much overhead I would say it's fine, if not I would rather avoid it.

Quoted 10 lines
Quoted 4 lines

On the face of it, they look like they have similar denial-of-service potential as mandatory locks. For example, a root process cleaning out /tmp gets stuck because a user process has O_DENYDELETE set.

Oh, that's the part I forgot to mention in the previous mail, all of these option of course can only be root only, everything else would be - as you say - a complete security nightmare.

We suggest to switch on this flags with special options during mounting. By default, it'll be switch off. This solution deletes possibility of such situations, like in example.

Pavel Shilovsky.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 3 lines · Pavel Shilovsky

We suggest to switch on this flags with special options during mounting. By default, it'll be switch off.
This solution deletes possibility of such situations, like in example.

Sorry, having completely weird open modes only for one filesystem, and only depending on mount options is not very nice to the user.

And options or not allowing the above functionality for regular users is a security issue.

--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 3 lines · Pavel Shilovsky

We suggest to switch on this flags with special options during mounting. By default, it'll be switch off.
This solution deletes possibility of such situations, like in example.

Sorry, having completely weird open modes only for one filesystem, and only depending on mount options is not very nice to the user.

And options or not allowing the above functionality for regular users is a security issue.

A generic mount option is currently used for mandatory locking - this is very similar.

The only different I see, for security, is with mandatory locking a process which doesn't want to get stuck can check the permission bits before opening a file. But I'm not aware of anything actually doing this.

-- Jamie

#9 lore raw
Quoted 6 lines · Jamie Lokier

A generic mount option is currently used for mandatory locking - this is very similar.

The only different I see, for security, is with mandatory locking a process which doesn't want to get stuck can check the permission bits before opening a file. But I'm not aware of anything actually doing this.

More importantly the admin can do it. And mandatory locking doesn't mean you can't remove something, with would be a complete nightmare. It also doesn't apply to directories, which from my reading of the patch this one would do. But yeah, doing the read/write part as as a special case of mandlock on open might make some sense, but I'm still not too convinced.

That more I think about these option the less I like the idea, it's just going to cause a lot of problems to help with some wine issues that hasn't even been explained yet.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw

I think that it'll be interesting for others filesystems. Also I should say that solution with mounting options let us increase usual possibilities to organize access policy. If you need it, you switch it on, if don't (like in example) you simply don't use it! In conclusion, we have increased functionality without any troubles.

Also, I should say that share flags is necessary for working with wine, because NTCreateFile use it...

Quoted 16 lines · On Saturday 15 November 2008 14:39:38 you wrote:
Quoted 7 lines · Jamie Lokier

A generic mount option is currently used for mandatory locking - this is very similar.

The only different I see, for security, is with mandatory locking a process which doesn't want to get stuck can check the permission bits before opening a file. But I'm not aware of anything actually doing this.

More importantly the admin can do it. And mandatory locking doesn't mean you can't remove something, with would be a complete nightmare. It also doesn't apply to directories, which from my reading of the patch this one would do. But yeah, doing the read/write part as as a special case of mandlock on open might make some sense, but I'm still not too convinced.

Quoted 3 lines

That more I think about these option the less I like the idea, it's just going to cause a lot of problems to help with some wine issues that hasn't even been explained yet.

--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw
In reply to Christoph Hellwig

I think that it'll be interesting for others filesystems. Also I should say that solution with mounting options let us increase usual possibilities to organize access policy. If you need it, you switch it on, if don't (like in example) you simply don't use it! In conclusion, we have increased functionality without any troubles.

Also, I should say that share flags is necessary for working with wine, because NTCreateFile use it...

Quoted 19 lines · On Saturday 15 November 2008 14:39:38 you wrote:
Quoted 7 lines · Jamie Lokier

A generic mount option is currently used for mandatory locking - this is very similar.

The only different I see, for security, is with mandatory locking a process which doesn't want to get stuck can check the permission bits before opening a file. But I'm not aware of anything actually doing this.

More importantly the admin can do it. And mandatory locking doesn't mean you can't remove something, with would be a complete nightmare. It also doesn't apply to directories, which from my reading of the patch this one would do. But yeah, doing the read/write part as as a special case of mandlock on open might make some sense, but I'm still not too convinced.

That more I think about these option the less I like the idea, it's just going to cause a lot of problems to help with some wine issues that hasn't even been explained yet.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#14 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines · Pavel Shilovsky

We suggest to switch on this flags with special options during mounting. By default, it'll be switch off.
This solution deletes possibility of such situations, like in example.

Sorry, having completely weird open modes only for one filesystem, and

FWIW, I could see something like this being used for nfsv4 OPENs

Benny

Quoted 9 lines

only depending on mount options is not very nice to the user.

And options or not allowing the above functionality for regular users is a security issue.

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html