* Re: Build infrastructure for storing NTLM creds in kernel keyring
[not found] ` <73A4A0D322484441A6CEF0FE91E5D263-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
@ 2010-06-25 20:16 ` Jeff Layton
2010-07-06 10:04 ` Igor Druzhinin
0 siblings, 1 reply; 15+ messages in thread
From: Jeff Layton @ 2010-06-25 20:16 UTC (permalink / raw)
To: Igor Druzhinin; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA
On Fri, 25 Jun 2010 22:36:04 +0400
"Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > I think the right thing to do is to not worry about upcalls for this at
> > first. Instead I think you'll want to create something like a
> > "ntlminit" program that takes user, password and host or domainname and
> > puts that information in the keyring. Then just fix the kernel to look
> > in the keyring for that information when doing a session setup.
> >
> > Eventually you may want to allow the kernel to upcall for these but you
> > have to figure out how that upcall should get those creds. Should it
> > try to prompt a user somehow? What if the process is being run out of
> > cron?
> >
> > To use the PAM mechanism you'll need to write a PAM module for it
> > (probably an authentication module). This is also something I wouldn't
> > worry about yet. That can be done later once you have the initial code
> > working.
>
> I've already started to write some code for a project and if I understood
> correctly I see its design as follows.
>
> Some userspace program (in my opinion, it may be mount.cifs helper program)
> checks the user-specific keyring for credentials on current user name and
> the destination host or domain name. If there is no one, it requests the
> password else it uses them. Then it tries to mount the resource. If it's ok
> then it puts the requested password or precalculated NT session key in the
> payload of key of some type (own registered type or "user"), the user and
> the domain name or destination server address could be saved in the key
> description. On CIFS session establishing the kernel can call request_key()
> and find the appropriate credentials in the user's keyring under the
> description and type
>
> Is this a correct realisation algorithm or it should be in other way?
cc'ing linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org to bring the discussion to a wider
audience...
That's not quite what I had envisioned. The main reason for putting
NTLM creds into the keyring is so that the kernel can fetch them when
it needs to establish a session. Right now that only happens at mount
time, but that will change when support for multisession mounts goes in.
At that point, the kernel will need to be able to fetch credentials for
users that were not involved in mounting the share. This would allow us
to use NTLM credentials instead of krb5 creds on a multisession mount.
So really what I was envisioning is a standalone program that puts
username/password/domain_or_hostname into the keyring. I had sort of
pictured an "ntlminit" program, similar to how krb5's kinit works
today. Instead of putting kerberos creds into a ccache though, it would
put NTLM creds into the keyring.
Along with that, we want a way for the kernel to use this info to
establish sessions. For now, that mostly occurs at mount time, but
eventually we want to be able to upcall for this info on the fly so
that we can do multisession mounts without requiring kerberos.
>From root's standpoint with the code as it stands today, they might
do something like:
# ntlminit -u username -h hostname
Password:
# mount -t cifs -o sec=ntlmv2 //server/share /mnt/mountpoint
...mount.cifs could then be modified to look and see whether there are
already creds in the keyring that are suitable for the mount. If there
are, then it could skip querying for the password.
> Is it preffered to register own type of key?
Yes, you'll probably want your own keytype for this, but maybe one of
the user keytypes would be a better choice. You'll probably need to do
a little research to figure out what's most suitable. I'm not yet clear
on whether a userspace program is allowed to spawn a new keytype.
> Where else it is necessary to look up keyrings for credentials except
> for session establishing on mount operation?
During session establishment. In the current code, that's limited to
mount and reconnect times. When multisession mounts go in, then it will
be able to happen any time a "new" user enters the mount. The code
needs to be written with that in mind.
Let me know if you have other questions...
Cheers,
--
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
2010-06-25 20:16 ` Jeff Layton
@ 2010-07-06 10:04 ` Igor Druzhinin
[not found] ` <C3BD4CBCCAD04D9EA6E04D3B157A69A4-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
0 siblings, 1 reply; 15+ messages in thread
From: Igor Druzhinin @ 2010-07-06 10:04 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA
As I saw current kernel code had no method for checking from userspace is
the entered credentials are wrong without mount. Is it's right?
But if user want to update them there are should be a mechanism for clearing
old or wrong creds. As my opinion it may be something like --clear option.
Besides, is it right to store multiple identical creds in keyring or creds
with the same user and domain_host name?
Regards,
Igor Druzhinin
----- Original Message -----
From: "Jeff Layton" <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
To: "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Sent: Saturday, June 26, 2010 12:16 AM
Subject: Re: Build infrastructure for storing NTLM creds in kernel keyring
On Fri, 25 Jun 2010 22:36:04 +0400
"Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > I think the right thing to do is to not worry about upcalls for this at
> > first. Instead I think you'll want to create something like a
> > "ntlminit" program that takes user, password and host or domainname and
> > puts that information in the keyring. Then just fix the kernel to look
> > in the keyring for that information when doing a session setup.
> >
> > Eventually you may want to allow the kernel to upcall for these but you
> > have to figure out how that upcall should get those creds. Should it
> > try to prompt a user somehow? What if the process is being run out of
> > cron?
> >
> > To use the PAM mechanism you'll need to write a PAM module for it
> > (probably an authentication module). This is also something I wouldn't
> > worry about yet. That can be done later once you have the initial code
> > working.
>
> I've already started to write some code for a project and if I understood
> correctly I see its design as follows.
>
> Some userspace program (in my opinion, it may be mount.cifs helper
> program)
> checks the user-specific keyring for credentials on current user name and
> the destination host or domain name. If there is no one, it requests the
> password else it uses them. Then it tries to mount the resource. If it's
> ok
> then it puts the requested password or precalculated NT session key in the
> payload of key of some type (own registered type or "user"), the user and
> the domain name or destination server address could be saved in the key
> description. On CIFS session establishing the kernel can call
> request_key()
> and find the appropriate credentials in the user's keyring under the
> description and type
>
> Is this a correct realisation algorithm or it should be in other way?
cc'ing linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org to bring the discussion to a wider
audience...
That's not quite what I had envisioned. The main reason for putting
NTLM creds into the keyring is so that the kernel can fetch them when
it needs to establish a session. Right now that only happens at mount
time, but that will change when support for multisession mounts goes in.
At that point, the kernel will need to be able to fetch credentials for
users that were not involved in mounting the share. This would allow us
to use NTLM credentials instead of krb5 creds on a multisession mount.
So really what I was envisioning is a standalone program that puts
username/password/domain_or_hostname into the keyring. I had sort of
pictured an "ntlminit" program, similar to how krb5's kinit works
today. Instead of putting kerberos creds into a ccache though, it would
put NTLM creds into the keyring.
Along with that, we want a way for the kernel to use this info to
establish sessions. For now, that mostly occurs at mount time, but
eventually we want to be able to upcall for this info on the fly so
that we can do multisession mounts without requiring kerberos.
>From root's standpoint with the code as it stands today, they might
do something like:
# ntlminit -u username -h hostname
Password:
# mount -t cifs -o sec=ntlmv2 //server/share /mnt/mountpoint
...mount.cifs could then be modified to look and see whether there are
already creds in the keyring that are suitable for the mount. If there
are, then it could skip querying for the password.
> Is it preffered to register own type of key?
Yes, you'll probably want your own keytype for this, but maybe one of
the user keytypes would be a better choice. You'll probably need to do
a little research to figure out what's most suitable. I'm not yet clear
on whether a userspace program is allowed to spawn a new keytype.
> Where else it is necessary to look up keyrings for credentials except
> for session establishing on mount operation?
During session establishment. In the current code, that's limited to
mount and reconnect times. When multisession mounts go in, then it will
be able to happen any time a "new" user enters the mount. The code
needs to be written with that in mind.
Let me know if you have other questions...
Cheers,
--
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
[not found] ` <C3BD4CBCCAD04D9EA6E04D3B157A69A4-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
@ 2010-07-06 11:00 ` Jeff Layton
[not found] ` <20100706070056.0b37e3d3-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
0 siblings, 1 reply; 15+ messages in thread
From: Jeff Layton @ 2010-07-06 11:00 UTC (permalink / raw)
To: Igor Druzhinin; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA
On Tue, 6 Jul 2010 14:04:44 +0400
"Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> As I saw current kernel code had no method for checking from userspace is
> the entered credentials are wrong without mount. Is it's right?
Correct. You really can't check without connecting to the server.
> But if user want to update them there are should be a mechanism for clearing
> old or wrong creds. As my opinion it may be something like --clear option.
Sounds good. You will want to be able to update or clear invalid creds.
> Besides, is it right to store multiple identical creds in keyring or creds
> with the same user and domain_host name?
Not sure that I see any point in multiple creds per user@host or
user@domain. Only one will ever be valid for each combination. Why
would you want multiple sets? How would you know which ones to use?
--
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
[not found] ` <20100706070056.0b37e3d3-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
@ 2010-07-06 11:09 ` Jeff Layton
0 siblings, 0 replies; 15+ messages in thread
From: Jeff Layton @ 2010-07-06 11:09 UTC (permalink / raw)
To: Jeff Layton; +Cc: Igor Druzhinin, linux-cifs-u79uwXL29TY76Z2rM5mHXA
On Tue, 6 Jul 2010 07:00:56 -0400
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org> wrote:
> On Tue, 6 Jul 2010 14:04:44 +0400
> "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > As I saw current kernel code had no method for checking from userspace is
> > the entered credentials are wrong without mount. Is it's right?
>
> Correct. You really can't check without connecting to the server.
We certainly could have this tool use libsmbclient to connect to the
server and authenticate to test the creds. I wouldn't bother with that
for the initial implementation though -- keep it simple. Still it's
something to keep in mind while you're coding this up.
>
> > But if user want to update them there are should be a mechanism for clearing
> > old or wrong creds. As my opinion it may be something like --clear option.
>
> Sounds good. You will want to be able to update or clear invalid creds.
>
> > Besides, is it right to store multiple identical creds in keyring or creds
> > with the same user and domain_host name?
>
> Not sure that I see any point in multiple creds per user@host or
> user@domain. Only one will ever be valid for each combination. Why
> would you want multiple sets? How would you know which ones to use?
>
--
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
@ 2010-07-08 16:14 Igor Druzhinin
[not found] ` <469B064927F7461992FFB15852A3B90F-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
0 siblings, 1 reply; 15+ messages in thread
From: Igor Druzhinin @ 2010-07-08 16:14 UTC (permalink / raw)
To: linux-cifs-u79uwXL29TY76Z2rM5mHXA
Hello,
After small research I was defined with a key format. It is a "user" key
type with the description in next format
ntlminit:host_ip_addr:username:domain for everyone host_ip_addr returned by
getaddrinfo() from host entered by the user. The domain field can be empty
and payload consists of plain password.
Now I am puting my keys directly in the session keyring. Whether it is
necessary to create separate keyring or it is possible to do without it?
Also I have thought over algorithm of addition of a key in session keyring.
If at least for one of the host's IP addresses there is a key with it in the
description (with the same username and domain name of course) new keys are
not will be added. Whether it is correct?
Regards,
Igor Druzhinin
----- Original Message -----
From: "Jeff Layton" <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
To: "Jeff Layton" <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
Cc: "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>; <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Sent: Tuesday, July 06, 2010 3:09 PM
Subject: Re: Build infrastructure for storing NTLM creds in kernel keyring
> On Tue, 6 Jul 2010 07:00:56 -0400
> Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org> wrote:
>
>> On Tue, 6 Jul 2010 14:04:44 +0400
>> "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>
>> > As I saw current kernel code had no method for checking from userspace
>> > is
>> > the entered credentials are wrong without mount. Is it's right?
>>
>> Correct. You really can't check without connecting to the server.
>
> We certainly could have this tool use libsmbclient to connect to the
> server and authenticate to test the creds. I wouldn't bother with that
> for the initial implementation though -- keep it simple. Still it's
> something to keep in mind while you're coding this up.
>
>>
>> > But if user want to update them there are should be a mechanism for
>> > clearing
>> > old or wrong creds. As my opinion it may be something like --clear
>> > option.
>>
>> Sounds good. You will want to be able to update or clear invalid creds.
>>
>> > Besides, is it right to store multiple identical creds in keyring or
>> > creds
>> > with the same user and domain_host name?
>>
>> Not sure that I see any point in multiple creds per user@host or
>> user@domain. Only one will ever be valid for each combination. Why
>> would you want multiple sets? How would you know which ones to use?
>>
>
>
> --
> Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
[not found] ` <469B064927F7461992FFB15852A3B90F-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
@ 2010-07-08 16:59 ` Jeff Layton
2010-07-08 17:28 ` Igor Druzhinin
2010-07-09 8:54 ` Igor Druzhinin
0 siblings, 2 replies; 15+ messages in thread
From: Jeff Layton @ 2010-07-08 16:59 UTC (permalink / raw)
To: Igor Druzhinin; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA
On Thu, 8 Jul 2010 20:14:23 +0400
"Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hello,
> After small research I was defined with a key format. It is a "user" key
> type with the description in next format
> ntlminit:host_ip_addr:username:domain for everyone host_ip_addr returned by
> getaddrinfo() from host entered by the user. The domain field can be empty
> and payload consists of plain password.
>
Sounds reasonable. user keys are probably the best thing since they
won't depend on having the cifs kmod loaded. The tricky part though is
how to prevent password disclosure. We wouldn't want anyone to walk up
to someone's machine after they've entered these creds and then be able
to see what their passwords are.
> Now I am puting my keys directly in the session keyring. Whether it is
> necessary to create separate keyring or it is possible to do without it?
>
I don't think you need a separate keyring. The session keyring is
probably fine, but maybe that would help the disclosure problem.
> Also I have thought over algorithm of addition of a key in session keyring.
> If at least for one of the host's IP addresses there is a key with it in the
> description (with the same username and domain name of course) new keys are
> not will be added. Whether it is correct?
>
Hmm, well...I was going on the assumption that a username will only
have one password per host. There is a situation though where that
wouldn't necessarily be the case -- if the server is running multiple
SMB servers on different ports.
Also, we probably need to consider the case of someone that has
multiple mounts that use the same domain-level credentials, potentially
to multiple servers. In that situation, you don't necessarily want to
have to reenter the same creds for each IP address. It would be nice to
be able to say "this username/password combo is for hosts in domain EXAMPLE",
and then tell the kernel at mount time "this host is in domain EXAMPLE" and
let the kernel use those credentials.
The kernel already takes a domain= mount option, but it doesn't really
do much now and could be used for this.
For now, I'd probably recommend getting something working with just
host-level credentials, and maybe add support for domain-level creds
once you have that working.
--
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
2010-07-08 16:59 ` Jeff Layton
@ 2010-07-08 17:28 ` Igor Druzhinin
[not found] ` <7E471FB7A6424D8595FEB4122BC8E0BA-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
2010-07-09 8:54 ` Igor Druzhinin
1 sibling, 1 reply; 15+ messages in thread
From: Igor Druzhinin @ 2010-07-08 17:28 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA
As I have seen the domain name from domain= option parameter directly copied
to SMB Session Setup packet in Primary Domain field that tells to server in
what domain it is necessary to search for the information on an account. I
think that short domain name that was entered in domain= field - for example
LAN can be interpreted on one host as LAN.XXX.COM and LAN.YYY.COM on
another.
----- Original Message -----
From: "Jeff Layton" <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
To: "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Sent: Thursday, July 08, 2010 8:59 PM
Subject: Re: Build infrastructure for storing NTLM creds in kernel keyring
> On Thu, 8 Jul 2010 20:14:23 +0400
> "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> Hello,
>> After small research I was defined with a key format. It is a "user" key
>> type with the description in next format
>> ntlminit:host_ip_addr:username:domain for everyone host_ip_addr returned
>> by
>> getaddrinfo() from host entered by the user. The domain field can be
>> empty
>> and payload consists of plain password.
>>
>
> Sounds reasonable. user keys are probably the best thing since they
> won't depend on having the cifs kmod loaded. The tricky part though is
> how to prevent password disclosure. We wouldn't want anyone to walk up
> to someone's machine after they've entered these creds and then be able
> to see what their passwords are.
>
>> Now I am puting my keys directly in the session keyring. Whether it is
>> necessary to create separate keyring or it is possible to do without it?
>>
>
> I don't think you need a separate keyring. The session keyring is
> probably fine, but maybe that would help the disclosure problem.
>
>> Also I have thought over algorithm of addition of a key in session
>> keyring.
>> If at least for one of the host's IP addresses there is a key with it in
>> the
>> description (with the same username and domain name of course) new keys
>> are
>> not will be added. Whether it is correct?
>>
>
> Hmm, well...I was going on the assumption that a username will only
> have one password per host. There is a situation though where that
> wouldn't necessarily be the case -- if the server is running multiple
> SMB servers on different ports.
>
> Also, we probably need to consider the case of someone that has
> multiple mounts that use the same domain-level credentials, potentially
> to multiple servers. In that situation, you don't necessarily want to
> have to reenter the same creds for each IP address. It would be nice to
> be able to say "this username/password combo is for hosts in domain
> EXAMPLE",
> and then tell the kernel at mount time "this host is in domain EXAMPLE"
> and
> let the kernel use those credentials.
>
> The kernel already takes a domain= mount option, but it doesn't really
> do much now and could be used for this.
>
> For now, I'd probably recommend getting something working with just
> host-level credentials, and maybe add support for domain-level creds
> once you have that working.
>
> --
> Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
[not found] ` <7E471FB7A6424D8595FEB4122BC8E0BA-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
@ 2010-07-08 18:04 ` Jeff Layton
0 siblings, 0 replies; 15+ messages in thread
From: Jeff Layton @ 2010-07-08 18:04 UTC (permalink / raw)
To: Igor Druzhinin; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA
On Thu, 8 Jul 2010 21:28:34 +0400
"Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> As I have seen the domain name from domain= option parameter directly copied
> to SMB Session Setup packet in Primary Domain field that tells to server in
> what domain it is necessary to search for the information on an account. I
> think that short domain name that was entered in domain= field - for example
> LAN can be interpreted on one host as LAN.XXX.COM and LAN.YYY.COM on
> another.
Yes, it does get copied in. I'm just not sure that the server really
cares about it at all. The entire domain= parameter could use a
thorough review, in other words...
--
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
2010-07-08 16:59 ` Jeff Layton
2010-07-08 17:28 ` Igor Druzhinin
@ 2010-07-09 8:54 ` Igor Druzhinin
1 sibling, 0 replies; 15+ messages in thread
From: Igor Druzhinin @ 2010-07-09 8:54 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA
About password disclosure. Now I see two ways to solution a problem of
password disclosure.
The first is to put precalculated NT Session key in a key. But then it
becomes impossible to use a cache for other methods of authorisation as LM
and Plain Password.
The second is to remove from a key all privileges except View and Write.
With "user" type of key Search privilege as I have clarified influences on
reading from a key, and the Read flag does not influence on it. Strange
behaviour. But then it is necessary to search in the keyring manually both
in userspace and in the kernel.
----- Original Message -----
From: "Jeff Layton" <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
To: "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Sent: Thursday, July 08, 2010 8:59 PM
Subject: Re: Build infrastructure for storing NTLM creds in kernel keyring
> On Thu, 8 Jul 2010 20:14:23 +0400
> "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> Hello,
>> After small research I was defined with a key format. It is a "user" key
>> type with the description in next format
>> ntlminit:host_ip_addr:username:domain for everyone host_ip_addr returned
>> by
>> getaddrinfo() from host entered by the user. The domain field can be
>> empty
>> and payload consists of plain password.
>>
>
> Sounds reasonable. user keys are probably the best thing since they
> won't depend on having the cifs kmod loaded. The tricky part though is
> how to prevent password disclosure. We wouldn't want anyone to walk up
> to someone's machine after they've entered these creds and then be able
> to see what their passwords are.
>
>> Now I am puting my keys directly in the session keyring. Whether it is
>> necessary to create separate keyring or it is possible to do without it?
>>
>
> I don't think you need a separate keyring. The session keyring is
> probably fine, but maybe that would help the disclosure problem.
>
>> Also I have thought over algorithm of addition of a key in session
>> keyring.
>> If at least for one of the host's IP addresses there is a key with it in
>> the
>> description (with the same username and domain name of course) new keys
>> are
>> not will be added. Whether it is correct?
>>
>
> Hmm, well...I was going on the assumption that a username will only
> have one password per host. There is a situation though where that
> wouldn't necessarily be the case -- if the server is running multiple
> SMB servers on different ports.
>
> Also, we probably need to consider the case of someone that has
> multiple mounts that use the same domain-level credentials, potentially
> to multiple servers. In that situation, you don't necessarily want to
> have to reenter the same creds for each IP address. It would be nice to
> be able to say "this username/password combo is for hosts in domain
> EXAMPLE",
> and then tell the kernel at mount time "this host is in domain EXAMPLE"
> and
> let the kernel use those credentials.
>
> The kernel already takes a domain= mount option, but it doesn't really
> do much now and could be used for this.
>
> For now, I'd probably recommend getting something working with just
> host-level credentials, and maybe add support for domain-level creds
> once you have that working.
>
> --
> Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
[not found] ` <20100722093121.4c64b102@barsoom.rdu.redhat.com>
@ 2010-07-29 13:52 ` Igor Druzhinin
[not found] ` <54DA210795E649C1A62B5E10BF366BB3-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
0 siblings, 1 reply; 15+ messages in thread
From: Igor Druzhinin @ 2010-07-29 13:52 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA
Hello,
I've created a mirror cifs-utils repository where is embedded cifscreds
utility. I've fixed a few bugs and added multilanguage support for it. Now
it is locale-dependent, but then I plan to use the UCS-2 encoding. You can
use the option --enable-cifscreds=yes of configure script to build
cifscreds. I've also moved resolve_host routine in a separate file and made
appropriate patches.
git://gitorious.org/cifs-utils/cifs-utils.git
Regards,
Igor Druzhinin
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
[not found] ` <54DA210795E649C1A62B5E10BF366BB3-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
@ 2010-08-04 11:31 ` Jeff Layton
2010-08-05 15:43 ` Igor Druzhinin
0 siblings, 1 reply; 15+ messages in thread
From: Jeff Layton @ 2010-08-04 11:31 UTC (permalink / raw)
To: Igor Druzhinin
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
dhowells-H+wXaHxf7aLQT0dZR+AlfA
On Thu, 29 Jul 2010 17:52:35 +0400
"Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hello,
> I've created a mirror cifs-utils repository where is embedded cifscreds
> utility. I've fixed a few bugs and added multilanguage support for it. Now
> it is locale-dependent, but then I plan to use the UCS-2 encoding. You can
> use the option --enable-cifscreds=yes of configure script to build
> cifscreds. I've also moved resolve_host routine in a separate file and made
> appropriate patches.
>
> git://gitorious.org/cifs-utils/cifs-utils.git
>
> Regards,
> Igor Druzhinin
>
(cc'ing David Howells since he wrote most of the keyctl stuff and may be interested)
Sorry that it has taken me a while to review this, I've been a bit
swamped with work.
First, it looks like there are some problems with newlines. The new
files that were added seem to have CR+LF line terminators. There are
also quite a few whitespace problems in there -- spaces leading tabs,
etc. In general, we follow kernel coding style with cifs-utils, so
running your patches through checkpatch.pl in the kernel sources is a
good idea.
Also, I don't see much need for the MULTI_LANG ifdef's. Is there any
reason not to make it always use MULTI_LANG? If so, I'd remove the code
that's ifdef'ed out.
There are also several routines that seem to already be in libc. For
instance, wstrtolower seems to do the same thing as towlower. I'd
suggest using libc routines rather than rolling your own where possible.
On to the code...
----------------[snip]---------------
/* find the best fit command */
best = NULL;
n = strnlen(argv[1], MAX_COMMAND_SIZE);
for (cmd = commands; cmd->action; cmd++) {
if (memcmp(cmd->name, argv[1], n) != 0)
continue;
----------------[snip]---------------
This looks a little dangerous. Sure, you're bounds checking the
strnlen, but think about what happens if someone passes in a long
string as the command:
memcmp("add", "reallylongcommandstring", strlen("reallylongcommandstring"));
That memcmp is going to walk off the end of "add". Depending on how the
memory is allocated, it could segfault.
In cifscreds_add:
if (keyctl(KEYCTL_SETPERM, key, KEY_POS_VIEW | KEY_POS_WRITE | \
KEY_USR_VIEW | KEY_USR_WRITE) < 0)
fprintf(stderr, "error: Setting permissons on key\n");
...would it be safer to attempt to remove the key if we can't set perms
on it?
That's all I've got time to review at the moment. Have you made any
progress with the kernel piece for this?
Nice work so far!
--
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
2010-08-04 11:31 ` Jeff Layton
@ 2010-08-05 15:43 ` Igor Druzhinin
[not found] ` <9EE2EFBFF2304A849754EEE0F1C1CE29-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
0 siblings, 1 reply; 15+ messages in thread
From: Igor Druzhinin @ 2010-08-05 15:43 UTC (permalink / raw)
To: Jeff Layton
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
dhowells-H+wXaHxf7aLQT0dZR+AlfA
> First, it looks like there are some problems with newlines. The new
> files that were added seem to have CR+LF line terminators. There are
> also quite a few whitespace problems in there -- spaces leading tabs,
> etc. In general, we follow kernel coding style with cifs-utils, so
> running your patches through checkpatch.pl in the kernel sources is a
> good idea.
Checked and patched.
> Also, I don't see much need for the MULTI_LANG ifdef's. Is there any
> reason not to make it always use MULTI_LANG? If so, I'd remove the code
> that's ifdef'ed out.
Now I am still not sure of the correctness of my strategy of
internationalization. MULTI_LANG ifdef's will help me to correct necessary
sites in case of its change.
> There are also several routines that seem to already be in libc. For
> instance, wstrtolower seems to do the same thing as towlower. I'd
> suggest using libc routines rather than rolling your own where possible.
As I saw in the GNU libc documentation there is no routines for conversion
string to lowercase.
> That memcmp is going to walk off the end of "add". Depending on how the
> memory is allocated, it could segfault.
Patched.
> In cifscreds_add:
>
> if (keyctl(KEYCTL_SETPERM, key, KEY_POS_VIEW |
> KEY_POS_WRITE | \
> KEY_USR_VIEW | KEY_USR_WRITE) < 0)
> fprintf(stderr, "error: Setting permissons
> on key\n");
>
> ...would it be safer to attempt to remove the key if we can't set perms
> on it?
Yes, already fixed.
> That's all I've got time to review at the moment. Have you made any
> progress with the kernel piece for this?
Yes, I have developed an algorithm and wrote some code samples.
This will require some changes in mount.cifs. The kernel will look for the
key during parsing of pass= option in cifs_parse_mount_options routine. As
an option pass= follows the options ip=, user= and dom= problems shouldn't
arise. If successful, password will be used from the key, otherwise from the
pass= option. mount.cifs can independently verify the presence of the key
and does not require a password from the user.
Regards,
Igor Druzhinin
----- Original Message -----
From: "Jeff Layton" <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
To: "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>; <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Sent: Wednesday, August 04, 2010 3:31 PM
Subject: Re: Build infrastructure for storing NTLM creds in kernel keyring
> On Thu, 29 Jul 2010 17:52:35 +0400
> "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> Hello,
>> I've created a mirror cifs-utils repository where is embedded cifscreds
>> utility. I've fixed a few bugs and added multilanguage support for it.
>> Now
>> it is locale-dependent, but then I plan to use the UCS-2 encoding. You
>> can
>> use the option --enable-cifscreds=yes of configure script to build
>> cifscreds. I've also moved resolve_host routine in a separate file and
>> made
>> appropriate patches.
>>
>> git://gitorious.org/cifs-utils/cifs-utils.git
>>
>> Regards,
>> Igor Druzhinin
>>
>
> (cc'ing David Howells since he wrote most of the keyctl stuff and may be
> interested)
>
> Sorry that it has taken me a while to review this, I've been a bit
> swamped with work.
>
> First, it looks like there are some problems with newlines. The new
> files that were added seem to have CR+LF line terminators. There are
> also quite a few whitespace problems in there -- spaces leading tabs,
> etc. In general, we follow kernel coding style with cifs-utils, so
> running your patches through checkpatch.pl in the kernel sources is a
> good idea.
>
> Also, I don't see much need for the MULTI_LANG ifdef's. Is there any
> reason not to make it always use MULTI_LANG? If so, I'd remove the code
> that's ifdef'ed out.
>
> There are also several routines that seem to already be in libc. For
> instance, wstrtolower seems to do the same thing as towlower. I'd
> suggest using libc routines rather than rolling your own where possible.
>
> On to the code...
>
> ----------------[snip]---------------
> /* find the best fit command */
> best = NULL;
> n = strnlen(argv[1], MAX_COMMAND_SIZE);
>
> for (cmd = commands; cmd->action; cmd++) {
> if (memcmp(cmd->name, argv[1], n) != 0)
> continue;
> ----------------[snip]---------------
>
> This looks a little dangerous. Sure, you're bounds checking the
> strnlen, but think about what happens if someone passes in a long
> string as the command:
>
> memcmp("add", "reallylongcommandstring",
> strlen("reallylongcommandstring"));
>
> That memcmp is going to walk off the end of "add". Depending on how the
> memory is allocated, it could segfault.
>
> In cifscreds_add:
>
> if (keyctl(KEYCTL_SETPERM, key, KEY_POS_VIEW |
> KEY_POS_WRITE | \
> KEY_USR_VIEW | KEY_USR_WRITE) < 0)
> fprintf(stderr, "error: Setting permissons
> on key\n");
>
> ...would it be safer to attempt to remove the key if we can't set perms
> on it?
>
> That's all I've got time to review at the moment. Have you made any
> progress with the kernel piece for this?
>
> Nice work so far!
> --
> Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
[not found] ` <9EE2EFBFF2304A849754EEE0F1C1CE29-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
@ 2010-08-05 18:03 ` Jeff Layton
2010-08-05 18:48 ` Igor Druzhinin
0 siblings, 1 reply; 15+ messages in thread
From: Jeff Layton @ 2010-08-05 18:03 UTC (permalink / raw)
To: Igor Druzhinin
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
dhowells-H+wXaHxf7aLQT0dZR+AlfA
On Thu, 5 Aug 2010 19:43:57 +0400
"Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > First, it looks like there are some problems with newlines. The new
> > files that were added seem to have CR+LF line terminators. There are
> > also quite a few whitespace problems in there -- spaces leading tabs,
> > etc. In general, we follow kernel coding style with cifs-utils, so
> > running your patches through checkpatch.pl in the kernel sources is a
> > good idea.
>
> Checked and patched.
>
> > Also, I don't see much need for the MULTI_LANG ifdef's. Is there any
> > reason not to make it always use MULTI_LANG? If so, I'd remove the code
> > that's ifdef'ed out.
>
> Now I am still not sure of the correctness of my strategy of
> internationalization. MULTI_LANG ifdef's will help me to correct necessary
> sites in case of its change.
>
Fair enough then...
> > There are also several routines that seem to already be in libc. For
> > instance, wstrtolower seems to do the same thing as towlower. I'd
> > suggest using libc routines rather than rolling your own where possible.
>
> As I saw in the GNU libc documentation there is no routines for conversion
> string to lowercase.
>
Ahh you're correct -- towlower only operates on a single character.
> > That memcmp is going to walk off the end of "add". Depending on how the
> > memory is allocated, it could segfault.
>
> Patched.
>
I pulled down your latest code and it doesn't appear to be patched. Am
I missing something?
--
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
2010-08-05 18:03 ` Jeff Layton
@ 2010-08-05 18:48 ` Igor Druzhinin
[not found] ` <583072918FF1484C9380D991E5A4E83C-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
0 siblings, 1 reply; 15+ messages in thread
From: Igor Druzhinin @ 2010-08-05 18:48 UTC (permalink / raw)
To: Jeff Layton
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
dhowells-H+wXaHxf7aLQT0dZR+AlfA
> I pulled down your latest code and it doesn't appear to be patched. Am
> I missing something?
----------------[snip]---------------
struct command {
int (*action)(int argc, char *argv[]);
const char name[MAX_COMMAND_SIZE];
const char *format;
};
----------------[snip]---------------
Now, under each field we will allocate exactly MAX_COMMAND_SIZE bytes.
During the comparison we will not walk outside the allocated area.
----------------[snip]---------------
n = strnlen(argv[1], MAX_COMMAND_SIZE);
for (cmd = commands; cmd->action; cmd++) {
if (memcmp(cmd->name, argv[1], n) != 0)
continue;
----------------[snip]---------------
Regards,
Igor Druzhinin
----- Original Message -----
From: "Jeff Layton" <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
To: "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>; <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Sent: Thursday, August 05, 2010 10:03 PM
Subject: Re: Build infrastructure for storing NTLM creds in kernel keyring
> On Thu, 5 Aug 2010 19:43:57 +0400
> "Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> > First, it looks like there are some problems with newlines. The new
>> > files that were added seem to have CR+LF line terminators. There are
>> > also quite a few whitespace problems in there -- spaces leading tabs,
>> > etc. In general, we follow kernel coding style with cifs-utils, so
>> > running your patches through checkpatch.pl in the kernel sources is a
>> > good idea.
>>
>> Checked and patched.
>>
>> > Also, I don't see much need for the MULTI_LANG ifdef's. Is there any
>> > reason not to make it always use MULTI_LANG? If so, I'd remove the code
>> > that's ifdef'ed out.
>>
>> Now I am still not sure of the correctness of my strategy of
>> internationalization. MULTI_LANG ifdef's will help me to correct
>> necessary
>> sites in case of its change.
>>
>
> Fair enough then...
>
>> > There are also several routines that seem to already be in libc. For
>> > instance, wstrtolower seems to do the same thing as towlower. I'd
>> > suggest using libc routines rather than rolling your own where
>> > possible.
>>
>> As I saw in the GNU libc documentation there is no routines for
>> conversion
>> string to lowercase.
>>
>
> Ahh you're correct -- towlower only operates on a single character.
>
>> > That memcmp is going to walk off the end of "add". Depending on how the
>> > memory is allocated, it could segfault.
>>
>> Patched.
>>
>
> I pulled down your latest code and it doesn't appear to be patched. Am
> I missing something?
>
> --
> Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Build infrastructure for storing NTLM creds in kernel keyring
[not found] ` <583072918FF1484C9380D991E5A4E83C-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
@ 2010-08-05 20:12 ` Jeff Layton
0 siblings, 0 replies; 15+ messages in thread
From: Jeff Layton @ 2010-08-05 20:12 UTC (permalink / raw)
To: Igor Druzhinin
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
dhowells-H+wXaHxf7aLQT0dZR+AlfA
On Thu, 5 Aug 2010 22:48:21 +0400
"Igor Druzhinin" <jaxbrigs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > I pulled down your latest code and it doesn't appear to be patched. Am
> > I missing something?
>
> ----------------[snip]---------------
> struct command {
> int (*action)(int argc, char *argv[]);
> const char name[MAX_COMMAND_SIZE];
> const char *format;
> };
> ----------------[snip]---------------
>
> Now, under each field we will allocate exactly MAX_COMMAND_SIZE bytes.
> During the comparison we will not walk outside the allocated area.
>
> ----------------[snip]---------------
> n = strnlen(argv[1], MAX_COMMAND_SIZE);
>
> for (cmd = commands; cmd->action; cmd++) {
> if (memcmp(cmd->name, argv[1], n) != 0)
> continue;
> ----------------[snip]---------------
Ahh ok, thanks for clarifying. I had envisioned fixing this another
way, but this should be fine.
Now that that's fixed, I think this piece is pretty much done. When you
get time, please post it as a patch to cifs-utils to the linux-cifs
mailing list so that others can comment. If no one has objections, I'll
plan to merge it soon.
> Yes, I have developed an algorithm and wrote some code samples.
> This will require some changes in mount.cifs. The kernel will look for the
> key during parsing of pass= option in cifs_parse_mount_options routine. As
> an option pass= follows the options ip=, user= and dom= problems shouldn't
> arise. If successful, password will be used from the key, otherwise from the
> pass= option. mount.cifs can independently verify the presence of the key
> and does not require a password from the user.
Cool -- I look forward to seeing that part.
I don't think however that you should assume that mount options come in
any particular order. We do occasionally get people who use cifs
without a mount helper at all or who pass in options that the mount
helper would ordinarily fill out itself (ip=, for instance).
Nice work!
--
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2010-08-05 20:12 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-08 16:14 Build infrastructure for storing NTLM creds in kernel keyring Igor Druzhinin
[not found] ` <469B064927F7461992FFB15852A3B90F-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
2010-07-08 16:59 ` Jeff Layton
2010-07-08 17:28 ` Igor Druzhinin
[not found] ` <7E471FB7A6424D8595FEB4122BC8E0BA-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
2010-07-08 18:04 ` Jeff Layton
2010-07-09 8:54 ` Igor Druzhinin
[not found] <CC75E34383A8445493DD41AF4F7E7857@lan.jax.org.ru>
[not found] ` <20100721100503.672a735e@tlielax.poochiereds.net>
[not found] ` <9DFCDE0105DF4B70AEA82A8A2B2A2A94@lan.jax.org.ru>
[not found] ` <20100722093121.4c64b102@barsoom.rdu.redhat.com>
2010-07-29 13:52 ` Igor Druzhinin
[not found] ` <54DA210795E649C1A62B5E10BF366BB3-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
2010-08-04 11:31 ` Jeff Layton
2010-08-05 15:43 ` Igor Druzhinin
[not found] ` <9EE2EFBFF2304A849754EEE0F1C1CE29-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
2010-08-05 18:03 ` Jeff Layton
2010-08-05 18:48 ` Igor Druzhinin
[not found] ` <583072918FF1484C9380D991E5A4E83C-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
2010-08-05 20:12 ` Jeff Layton
[not found] <20100430091431.624ee020@tlielax.poochiereds.net>
[not found] ` <EB4CC79E8F0546FF8AFBFD746C856421@lan.jax.org.ru>
[not found] ` <20100525121037.219129da@corrin.poochiereds.net>
[not found] ` <2AF95C52855747BABAE21349F35C773E@lan.jax.org.ru>
[not found] ` <20100601074406.5b8f7a87@tlielax.poochiereds.net>
[not found] ` <73A4A0D322484441A6CEF0FE91E5D263@lan.jax.org.ru>
[not found] ` <73A4A0D322484441A6CEF0FE91E5D263-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
2010-06-25 20:16 ` Jeff Layton
2010-07-06 10:04 ` Igor Druzhinin
[not found] ` <C3BD4CBCCAD04D9EA6E04D3B157A69A4-PUkIMHyhFB22ZuJnPpCLiw@public.gmane.org>
2010-07-06 11:00 ` Jeff Layton
[not found] ` <20100706070056.0b37e3d3-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2010-07-06 11:09 ` Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox