2004-03-01 09:49:40

by Urban Widmark

[permalink] [raw]
Subject: Re: [SELINUX] Handle fuse binary mount data.

On Sun, 29 Feb 2004, James Morris wrote:

> It seems more like a property of the filesystem type: perhaps add
> FS_BINARY_MOUNTDATA to fs_flags for such filesystems, per the patch below.
...
> diff -urN -X dontdiff linux-2.6.3-mm4.o/fs/smbfs/inode.c linux-2.6.3-mm4.w/fs/smbfs/inode.c
> --- linux-2.6.3-mm4.o/fs/smbfs/inode.c 2003-10-15 08:53:19.000000000 -0400
> +++ linux-2.6.3-mm4.w/fs/smbfs/inode.c 2004-02-29 19:50:58.172037088 -0500
> @@ -778,6 +778,7 @@
> .name = "smbfs",
> .get_sb = smb_get_sb,
> .kill_sb = kill_anon_super,
> + .fs_flags = FS_BINARY_MOUNTDATA,
> };
>
> static int __init init_smb_fs(void)

smbfs does not have a binary mountdata, unless the smbmount used is really
old (samba 2.0). If that means that it should get a FS_BINARY_MOUNTDATA
flag or not, I don't know.

/Urban


2004-03-01 13:15:25

by James Morris

[permalink] [raw]
Subject: Re: [SELINUX] Handle fuse binary mount data.

On Mon, 1 Mar 2004, Urban Widmark wrote:

> On Sun, 29 Feb 2004, James Morris wrote:
>
> > It seems more like a property of the filesystem type: perhaps add
> > FS_BINARY_MOUNTDATA to fs_flags for such filesystems, per the patch below.
> ...
> > diff -urN -X dontdiff linux-2.6.3-mm4.o/fs/smbfs/inode.c linux-2.6.3-mm4.w/fs/smbfs/inode.c
> > --- linux-2.6.3-mm4.o/fs/smbfs/inode.c 2003-10-15 08:53:19.000000000 -0400
> > +++ linux-2.6.3-mm4.w/fs/smbfs/inode.c 2004-02-29 19:50:58.172037088 -0500
> > @@ -778,6 +778,7 @@
> > .name = "smbfs",
> > .get_sb = smb_get_sb,
> > .kill_sb = kill_anon_super,
> > + .fs_flags = FS_BINARY_MOUNTDATA,
> > };
> >
> > static int __init init_smb_fs(void)
>
> smbfs does not have a binary mountdata, unless the smbmount used is really
> old (samba 2.0). If that means that it should get a FS_BINARY_MOUNTDATA
> flag or not, I don't know.

Well, smb_fill_super() looks like it is dealing with binary mount data
initially, and we need to treat it as such. This should be fixed properly
so that different versions of smbfs have different filesystem types, like
NFS.


- James
--
James Morris
<[email protected]>


2004-03-01 19:53:08

by Urban Widmark

[permalink] [raw]
Subject: Re: [SELINUX] Handle fuse binary mount data.

On Mon, 1 Mar 2004, James Morris wrote:

> Well, smb_fill_super() looks like it is dealing with binary mount data
> initially, and we need to treat it as such. This should be fixed properly
> so that different versions of smbfs have different filesystem types, like
> NFS.

There are no different versions of smbfs, and nfs does not have different
filesystem types for v2 and v3.

The thing smbfs does first is to check if it is binary or ascii^Wutf-8 by
looking at the first 4 bytes which is guaranteed by smbmount to be
(int)6 or the beginning of a string "vers".

I'm not seriously suggesting it, but if the selinux code always passed the
full page of mount data unchanged if it didn't find any of its flags then
it should be ok (in this case) to not mark smbfs as using a binary mount
data. And couldn't that work with all the binary filesystems without
adding any flags?

If smb_get_sb could map to a different "struct file_system_type" from what
it gets from the VFS that should work. Code below is not to be applied to
anything by anyone (yes, that means you Andrew :)

Seems easier to just disable the old smbmounts from working.

/Urban


diff -urN -X exclude linux-2.6.3-rc1-orig/fs/smbfs/inode.c linux-2.6.3-rc1-smbfs/fs/smbfs/inode.c
--- linux-2.6.3-rc1-orig/fs/smbfs/inode.c Mon Feb 9 19:25:13 2004
+++ linux-2.6.3-rc1-smbfs/fs/smbfs/inode.c Mon Mar 1 19:58:23 2004
@@ -770,6 +770,19 @@
static struct super_block *smb_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
{
+ struct super_block *sb;
+ struct smb_mount_data *oldmnt;
+ int ver;
+
+ oldmnt = (struct smb_mount_data *) data;
+ ver = oldmnt->version;
+ if (ver == SMB_MOUNT_OLDVERSION) {
+ struct file_system_type *type = get_fs_type("smbfs_binary");
+ sb = get_sb_nodev(type, flags, data, smb_fill_super);
+ put_filesystem(type);
+ return sb;
+ }
+
return get_sb_nodev(fs_type, flags, data, smb_fill_super);
}

@@ -780,6 +793,14 @@
.kill_sb = kill_anon_super,
};

+static struct file_system_type smb_fs_type_binary = {
+ .owner = THIS_MODULE,
+ .name = "smbfs_binary",
+ .get_sb = smb_get_sb,
+ .kill_sb = kill_anon_super,
+ .fs_flags = FS_BINARY_MOUNTDATA,
+};
+
static int __init init_smb_fs(void)
{
int err;
@@ -799,9 +820,14 @@
goto out_request;
err = register_filesystem(&smb_fs_type);
if (err)
+ goto out_register;
+ err = register_filesystem(&smb_fs_type_binary);
+ if (err)
goto out;
return 0;
out:
+ unregister_filesystem(&smb_fs_type);
+out_register:
smb_destroy_request_cache();
out_request:
destroy_inodecache();
@@ -813,6 +839,7 @@
{
DEBUG1("unregistering ...\n");
unregister_filesystem(&smb_fs_type);
+ unregister_filesystem(&smb_fs_type_binary);
smb_destroy_request_cache();
destroy_inodecache();
#ifdef DEBUG_SMB_MALLOC