All of lore.kernel.org
 help / color / mirror / Atom feed
* fs: Limit sys_mount to only request filesystem modules prevents mount -t cifs from working
@ 2013-03-11 12:57 ` Arthur Marsh
  0 siblings, 0 replies; 5+ messages in thread
From: Arthur Marsh @ 2013-03-11 12:57 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Serge Hallyn, Kees Cook, linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Hi, I found that Linux kernel 3.9.0-rc2 would not mount a remote cifs 
filesystem, and ran a git bisect which identified the following commit:

am64:/mnt# mount -t cifs //192.168.1.104/homes homes
Password:
am64:/mnt# cd /usr/src/linux
am64:/usr/src/linux# git bisect good
7f78e0351394052e1a6293e175825eb5c7869507 is the first bad commit
commit 7f78e0351394052e1a6293e175825eb5c7869507
Author: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
Date:   Sat Mar 2 19:39:14 2013 -0800

     fs: Limit sys_mount to only request filesystem modules.

     Modify the request_module to prefix the file system type with "fs-"
     and add aliases to all of the filesystems that can be built as modules
     to match.

     A common practice is to build all of the kernel code and leave code
     that is not commonly needed as modules, with the result that many
     users are exposed to any bug anywhere in the kernel.

     Looking for filesystems with a fs- prefix limits the pool of possible
     modules that can be loaded by mount to just filesystems trivially
     making things safer with no real cost.

     Using aliases means user space can control the policy of which
     filesystem modules are auto-loaded by editing /etc/modprobe.d/*.conf
     with blacklist and alias directives.  Allowing simple, safe,
     well understood work-arounds to known problematic software.

     This also addresses a rare but unfortunate problem where the filesystem
     name is not the same as it's module name and module auto-loading
     would not work.  While writing this patch I saw a handful of such
     cases.  The most significant being autofs that lives in the module
     autofs4.

     This is relevant to user namespaces because we can reach the request
     module in get_fs_type() without having any special permissions, and
     people get uncomfortable when a user specified string (in this case
     the filesystem type) goes all of the way to request_module.

     After having looked at this issue I don't think there is any
     particular reason to perform any filtering or permission checks beyond
     making it clear in the module request that we want a filesystem
     module.  The common pattern in the kernel is to call request_module()
     without regards to the users permissions.  In general all a filesystem
     module does once loaded is call register_filesystem() and go to sleep.
     Which means there is not much attack surface exposed by loading a
     filesytem module unless the filesystem is mounted.  In a user
     namespace filesystems are not mounted unless .fs_flags = 
FS_USERNS_MOUNT,
     which most filesystems do not set today.

     Acked-by: Serge Hallyn <serge.hallyn-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
     Acked-by: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
     Reported-by: Kees Cook <keescook-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
     Signed-off-by: "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>

:040000 040000 32250b65261f4e17804c8af3a106f224dd24bc11 
0cd45f52d550f32b1642281cf1a5d7b94d95f38f M      arch
:040000 040000 9658d1fd413b8797fe06fb2ca8ce681d4dbbedb0 
cd27a1ae4c6ee320ccf6a3872e00f80461325142 M      drivers
:040000 040000 bd510940beafe8c3cd4574da21e7b4acd78d1895 
9785b166b9b4ced468bcc8b6b236bfea42311fbd M      fs
:040000 040000 fa3800a44a3950111115454c47bd30a2db0790e8 
d1bb23380c6c15ef78309d492862f6ca35ce80f2 M      include
:040000 040000 8e24a9945ccff63df12d57cb3fae48e80ce26249 
2e03caba8fa769daed63101e15ef51366cdc9058 M      net
am64:/usr/src/linux#

Is there a patch already present somewhere to fix this problem?

Regards,

Arthur.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* fs: Limit sys_mount to only request filesystem modules prevents mount -t cifs from working
@ 2013-03-11 12:57 ` Arthur Marsh
  0 siblings, 0 replies; 5+ messages in thread
From: Arthur Marsh @ 2013-03-11 12:57 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: Serge Hallyn, Kees Cook, linux-cifs, linux-kernel

Hi, I found that Linux kernel 3.9.0-rc2 would not mount a remote cifs 
filesystem, and ran a git bisect which identified the following commit:

am64:/mnt# mount -t cifs //192.168.1.104/homes homes
Password:
am64:/mnt# cd /usr/src/linux
am64:/usr/src/linux# git bisect good
7f78e0351394052e1a6293e175825eb5c7869507 is the first bad commit
commit 7f78e0351394052e1a6293e175825eb5c7869507
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Sat Mar 2 19:39:14 2013 -0800

     fs: Limit sys_mount to only request filesystem modules.

     Modify the request_module to prefix the file system type with "fs-"
     and add aliases to all of the filesystems that can be built as modules
     to match.

     A common practice is to build all of the kernel code and leave code
     that is not commonly needed as modules, with the result that many
     users are exposed to any bug anywhere in the kernel.

     Looking for filesystems with a fs- prefix limits the pool of possible
     modules that can be loaded by mount to just filesystems trivially
     making things safer with no real cost.

     Using aliases means user space can control the policy of which
     filesystem modules are auto-loaded by editing /etc/modprobe.d/*.conf
     with blacklist and alias directives.  Allowing simple, safe,
     well understood work-arounds to known problematic software.

     This also addresses a rare but unfortunate problem where the filesystem
     name is not the same as it's module name and module auto-loading
     would not work.  While writing this patch I saw a handful of such
     cases.  The most significant being autofs that lives in the module
     autofs4.

     This is relevant to user namespaces because we can reach the request
     module in get_fs_type() without having any special permissions, and
     people get uncomfortable when a user specified string (in this case
     the filesystem type) goes all of the way to request_module.

     After having looked at this issue I don't think there is any
     particular reason to perform any filtering or permission checks beyond
     making it clear in the module request that we want a filesystem
     module.  The common pattern in the kernel is to call request_module()
     without regards to the users permissions.  In general all a filesystem
     module does once loaded is call register_filesystem() and go to sleep.
     Which means there is not much attack surface exposed by loading a
     filesytem module unless the filesystem is mounted.  In a user
     namespace filesystems are not mounted unless .fs_flags = 
FS_USERNS_MOUNT,
     which most filesystems do not set today.

     Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
     Acked-by: Kees Cook <keescook@chromium.org>
     Reported-by: Kees Cook <keescook@google.com>
     Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

:040000 040000 32250b65261f4e17804c8af3a106f224dd24bc11 
0cd45f52d550f32b1642281cf1a5d7b94d95f38f M      arch
:040000 040000 9658d1fd413b8797fe06fb2ca8ce681d4dbbedb0 
cd27a1ae4c6ee320ccf6a3872e00f80461325142 M      drivers
:040000 040000 bd510940beafe8c3cd4574da21e7b4acd78d1895 
9785b166b9b4ced468bcc8b6b236bfea42311fbd M      fs
:040000 040000 fa3800a44a3950111115454c47bd30a2db0790e8 
d1bb23380c6c15ef78309d492862f6ca35ce80f2 M      include
:040000 040000 8e24a9945ccff63df12d57cb3fae48e80ce26249 
2e03caba8fa769daed63101e15ef51366cdc9058 M      net
am64:/usr/src/linux#

Is there a patch already present somewhere to fix this problem?

Regards,

Arthur.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fs: Limit sys_mount to only request filesystem modules prevents mount -t cifs from working
  2013-03-11 12:57 ` Arthur Marsh
  (?)
@ 2013-03-11 13:37 ` Eric W. Biederman
       [not found]   ` <87obeqnjlm.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
  -1 siblings, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2013-03-11 13:37 UTC (permalink / raw)
  To: Arthur Marsh; +Cc: Serge Hallyn, Kees Cook, linux-cifs, linux-kernel

Arthur Marsh <arthur.marsh@internode.on.net> writes:

> Hi, I found that Linux kernel 3.9.0-rc2 would not mount a remote cifs
> filesystem, and ran a git bisect which identified the following
> commit:
>
> Is there a patch already present somewhere to fix this problem?
>

Grr.  It was in linux-next for nearly a week and I checked an double
checked that patch.

This should fix it. 

Eric


diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 1a052c0..3cf8a15 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -777,6 +777,7 @@ struct file_system_type cifs_fs_type = {
 	.kill_sb = cifs_kill_sb,
 	/*  .fs_flags */
 };
+MODULE_ALIAS_FS("cifs");
 const struct inode_operations cifs_dir_inode_ops = {
 	.create = cifs_create,
 	.atomic_open = cifs_atomic_open,

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: fs: Limit sys_mount to only request filesystem modules prevents mount -t cifs from working
  2013-03-11 13:37 ` Eric W. Biederman
@ 2013-03-11 16:01       ` Arthur Marsh
  0 siblings, 0 replies; 5+ messages in thread
From: Arthur Marsh @ 2013-03-11 16:01 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Serge Hallyn, Kees Cook, linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA



Eric W. Biederman wrote, on 12/03/13 00:07:
> Arthur Marsh<arthur.marsh-CkBdp7X+a1oIQCUVoCVjmQ@public.gmane.org>  writes:
>
>> Hi, I found that Linux kernel 3.9.0-rc2 would not mount a remote cifs
>> filesystem, and ran a git bisect which identified the following
>> commit:
>>
>> Is there a patch already present somewhere to fix this problem?
>>
>
> Grr.  It was in linux-next for nearly a week and I checked an double
> checked that patch.
>
> This should fix it.
>
> Eric
>
>
> diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
> index 1a052c0..3cf8a15 100644
> --- a/fs/cifs/cifsfs.c
> +++ b/fs/cifs/cifsfs.c
> @@ -777,6 +777,7 @@ struct file_system_type cifs_fs_type = {
>   	.kill_sb = cifs_kill_sb,
>   	/*  .fs_flags */
>   };
> +MODULE_ALIAS_FS("cifs");
>   const struct inode_operations cifs_dir_inode_ops = {
>   	.create = cifs_create,
>   	.atomic_open = cifs_atomic_open,
>

Confirmed... cifs mounts now work again thanks.

Regards,

Arthur.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: fs: Limit sys_mount to only request filesystem modules prevents mount -t cifs from working
@ 2013-03-11 16:01       ` Arthur Marsh
  0 siblings, 0 replies; 5+ messages in thread
From: Arthur Marsh @ 2013-03-11 16:01 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: Serge Hallyn, Kees Cook, linux-cifs, linux-kernel



Eric W. Biederman wrote, on 12/03/13 00:07:
> Arthur Marsh<arthur.marsh@internode.on.net>  writes:
>
>> Hi, I found that Linux kernel 3.9.0-rc2 would not mount a remote cifs
>> filesystem, and ran a git bisect which identified the following
>> commit:
>>
>> Is there a patch already present somewhere to fix this problem?
>>
>
> Grr.  It was in linux-next for nearly a week and I checked an double
> checked that patch.
>
> This should fix it.
>
> Eric
>
>
> diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
> index 1a052c0..3cf8a15 100644
> --- a/fs/cifs/cifsfs.c
> +++ b/fs/cifs/cifsfs.c
> @@ -777,6 +777,7 @@ struct file_system_type cifs_fs_type = {
>   	.kill_sb = cifs_kill_sb,
>   	/*  .fs_flags */
>   };
> +MODULE_ALIAS_FS("cifs");
>   const struct inode_operations cifs_dir_inode_ops = {
>   	.create = cifs_create,
>   	.atomic_open = cifs_atomic_open,
>

Confirmed... cifs mounts now work again thanks.

Regards,

Arthur.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-03-11 16:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-11 12:57 fs: Limit sys_mount to only request filesystem modules prevents mount -t cifs from working Arthur Marsh
2013-03-11 12:57 ` Arthur Marsh
2013-03-11 13:37 ` Eric W. Biederman
     [not found]   ` <87obeqnjlm.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-03-11 16:01     ` Arthur Marsh
2013-03-11 16:01       ` Arthur Marsh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.