cifs: Support for an upcall to map SID to an uid and a gid
Subsystems (2)
PATCH 1/1 cifs: Support for an upcall to map SID to an uid and a gid
From: Shirish Pargaonkar <[email protected]>
Use a cifs upcall to map a SID to either an uid or a gid using winbind.
There is a corrosponding patch for the cifs.upcall binary in cifs-utils rpm that is being posted also.
A new type of key, cifs_acl_key_type, is used.
To map a SID, which can be either a Onwer SID or a Group SID, key description starts with the string "os" or "gs" followed by SID converted to a string. Without "os" or "gs", cifs.upcall does not know whether SID needs to be mapped to either an uid or a gid.
Once a key is instantiated, get rid of it since cifs does not need to use in any way.
winbind does the id mapping and looks up name for the newly mapped SID/uid or SID/gid combination.
For now, cifs.upcall is only used to map a SID to an id (uid or gid) but it would be used to obtain an SID (string) for an id.
An entry such as this
create cifs.cifs_acl * * /usr/sbin/cifs.upcall %k
is needed in the file /etc/request-key.conf.
--- fs/cifs/cifsacl.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++----- fs/cifs/cifsacl.h | 8 ++++ fs/cifs/cifsfs.c | 7 +++ 3 files changed, 122 insertions(+), 10 deletions(-)
fs/cifs/cifsacl.c +107 -10
@@ -23,6 +23,9 @@#include <linux/fs.h> #include <linux/slab.h> +#include <linux/string.h> +#include <keys/user-type.h> +#include <linux/key-type.h> #include "cifspdu.h" #include "cifsglob.h" #include "cifsacl.h"
@@ -52,6 +55,102 @@ static const struct cifs_sid sid_authusers = {/* group users */ static const struct cifs_sid sid_user = {1 ,2 , {0 ,0 ,0 ,0 ,0 ,5 }, {} }; +static int +cifs_acl_key_instantiate (struct key *key,const void *data,size_t datalen) +{ +char *payload; + + payload =kmalloc (datalen,GFP_KERNEL ); +if (!payload) +return -ENOMEM ; + +memcpy (payload, data, datalen); + key->payload.data = payload; +return 0 ; +} + +static void +cifs_acl_key_destroy (struct key *key) +{ +kfree (key->payload.data); +} + +struct key_type cifs_acl_key_type = { + .name ="cifs.cifs_acl" , + .instantiate = cifs_acl_key_instantiate, + .destroy = cifs_acl_key_destroy, + .describe = user_describe, + .match = user_match, +}; + +static void +sid_to_str (struct cifs_sid *sidptr,char *sidstr) +{ +int i; +unsigned long saval; +char *strptr; + + strptr = sidstr; + +sprintf (strptr,"%s" ,"S" ); + strptr = sidstr +strlen (sidstr); + +sprintf (strptr,"-%d" , sidptr->revision); + strptr = sidstr +strlen (sidstr); + +for (i =0 ; i <6 ; ++i) { +if (sidptr->authority[i]) { +sprintf (strptr,"-%d" , sidptr->authority[i]); + strptr = sidstr +strlen (sidstr); + } + } + +for (i =0 ; i < sidptr->num_subauth; ++i) { + saval =le32_to_cpu (sidptr->sub_auth[i]); +sprintf (strptr,"-%ld" , saval); + strptr = sidstr +strlen (sidstr); + } +} + +static int +sid_to_id (struct cifs_sid *psid,struct cifs_fattr *fattr,uint sidtype) +{ +int rc =0 ; +char *sidstr, *strptr; +struct key *idkey; + + sidstr =kzalloc (SIDLEN ,GFP_KERNEL ); +if (!sidstr) +return -ENOMEM ; + strptr = sidstr; + +if (sidtype ==SIDOWNER ) +sprintf (strptr,"%s" ,"os:" ); +else if (sidtype ==SIDGROUP ) +sprintf (strptr,"%s" ,"gs:" ); +else { + rc = -EINVAL ; + goto idresolve_err; + } + strptr = sidstr +strlen (sidstr); + +sid_to_str (psid, strptr); + + idkey =request_key (&cifs_acl_key_type, sidstr,"" ); +if (IS_ERR (idkey)) +cFYI (1 ,"%s: idkey error: %d\n" , __func__, -ENOKEY ); +else { +if (sidtype ==SIDOWNER ) + fattr->cf_uid = *(unsigned long *)idkey->payload.value; +else if (sidtype ==SIDGROUP ) + fattr->cf_gid = *(unsigned long *)idkey->payload.value; +key_put (idkey); + } + +idresolve_err: +kfree (sidstr); +return rc; +}int match_sid (struct cifs_sid *ctsid) {
@@ -438,7 +537,6 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,return 0 ; } -static int parse_sid (struct cifs_sid *psid,char *end_of_acl) {/* BB need to add parm so we can store the SID BB */
@@ -476,7 +574,7 @@ static int parse_sid(struct cifs_sid *psid, char *end_of_acl)static int parse_sec_desc (struct cifs_ntsd *pntsd,int acl_len,struct cifs_fattr *fattr) { -int rc; +int rc =0 ;struct cifs_sid *owner_sid_ptr, *group_sid_ptr;struct cifs_acl *dacl_ptr;/* no need for SACL ptr */ char *end_of_acl = ((char *)pntsd) + acl_len;
@@ -500,10 +598,16 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len, rc =parse_sid (owner_sid_ptr, end_of_acl);if (rc)return rc; + rc =sid_to_id (owner_sid_ptr, fattr,SIDOWNER ); +if (rc) +cFYI (1 ,"Can't resolve SID to an uid" ); rc =parse_sid (group_sid_ptr, end_of_acl);if (rc)return rc; + rc =sid_to_id (group_sid_ptr, fattr,SIDGROUP ); +if (rc) +cFYI (1 ,"Can't resolve SID to a gid" );if (dacloffset) parse_dacl(dacl_ptr, end_of_acl, owner_sid_ptr,
@@ -511,14 +615,7 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,else cFYI (1 ,"no ACL" );/* BB grant all or default perms? */ -/* cifscred->uid = owner_sid_ptr->rid; -cifscred->gid = group_sid_ptr->rid; -memcpy((void *)(&(cifscred->osid)), (void *)owner_sid_ptr, -sizeof(struct cifs_sid)); -memcpy((void *)(&(cifscred->gsid)), (void *)group_sid_ptr, -sizeof(struct cifs_sid)); */ - -return 0 ; +return rc; }
fs/cifs/cifsacl.h +8 -0
@@ -39,6 +39,10 @@#define ACCESS_ALLOWED 0#define ACCESS_DENIED 1 +#define SIDOWNER 1 +#define SIDGROUP 2 +#define SIDLEN 150/* S- 1 revision- 6 authorities- max 5 sub authorities */ +struct cifs_ntsd {__le16 revision;/* revision level */ __le16 type;
@@ -76,6 +80,10 @@ struct cifs_wksid {#ifdef CONFIG_CIFS_EXPERIMENTAL +#ifdef __KERNEL__ +extern struct key_type cifs_acl_key_type; +#endif /* KERNEL */ +extern int match_sid (struct cifs_sid *);extern int compare_sids (const struct cifs_sid *,const struct cifs_sid *);
fs/cifs/cifsfs.c +7 -0
@@ -46,6 +46,7 @@#include <linux/mm.h> #include <linux/key-type.h> #include "cifs_spnego.h" +#include "cifsacl.h" #include "fscache.h" #define CIFS_MAGIC_NUMBER 0xFF534D42/* the first four bytes of SMB PDUs */
@@ -973,11 +974,16 @@ init_cifs(void) rc =register_key_type (&cifs_spnego_key_type);if (rc) goto out_unregister_filesystem; + rc =register_key_type (&cifs_acl_key_type); +if (rc) + goto out_unregister_keytype;#endif return 0 ;#ifdef CONFIG_CIFS_UPCALL +out_unregister_keytype: +unregister_key_type (&cifs_spnego_key_type); out_unregister_filesystem:unregister_filesystem (&cifs_fs_type);#endif
@@ -1004,6 +1010,7 @@ exit_cifs(void)cifs_dfs_release_automount_timer ();#endif #ifdef CONFIG_CIFS_UPCALL +unregister_key_type (&cifs_acl_key_type);unregister_key_type (&cifs_spnego_key_type);#endif unregister_filesystem (&cifs_fs_type);
Signature · 1 line
1.6.0.2
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20101211111716.1e21be41-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org
Quoted 83 lines · Jeff Layton
Quoted 80 lines · On Tue, 7 Dec 2010 11:11:12 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…
From: Shirish Pargaonkar <[email protected]>
Use a cifs upcall to map a SID to either an uid or a gid using winbind.
There is a corrosponding patch for the cifs.upcall binary in cifs-utils rpm that is being posted also.
A new type of key,
cifs_acl_key_type, is used.
To map a SID, which can be either a Onwer SID or a Group SID, key description starts with the string "os" or "gs" followed by SID converted to a string. Without "os" or "gs", cifs.upcall does not know whether SID needs to be mapped to either an uid or a gid.Once a key is instantiated, get rid of it since cifs does not need to use in any way.
winbind does the id mapping and looks up name for the newly mapped SID/uid or SID/gid combination.For now, cifs.upcall is only used to map a SID to an id (uid or gid) but it would be used to obtain an SID (string) for an id.
An entry such as this
create cifs.cifs_acl * *
/usr/sbin/cifs.upcall%kis needed in the file
/etc/request-key.conf.Signed-off-by Shirish Pargaonkar <[email protected]>---
fs/cifs/cifsacl.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++-----fs/cifs/cifsacl.h| 8 ++++
fs/cifs/cifsfs.c | 7 +++3 files changed, 122 insertions(+), 10 deletions(-)fs/cifs/cifsacl.c +28
-0@@ -23,6 +23,9 @@ #include <linux/fs.h> #include <linux/slab.h> +#include <linux/string.h> +#include <keys/user-type.h> +#include <linux/key-type.h> #include "cifspdu.h" #include "cifsglob.h" #include "cifsacl.h"@@ -52,6 +55,102 @@ static const struct cifs_sid sid_authusers = { /* group users */ static const struct cifs_sid sid_user = {1, 2 , {0, 0, 0, 0, 0, 5}, {} }; +static int +cifs_acl_key_instantiate (struct key *key,const void *data,size_t datalen) +{ + char *payload; + + payload = kmalloc(datalen, GFP_KERNEL); + if (!payload) + return -ENOMEM; + + memcpy(payload, data, datalen); + key->payload.data = payload; + return 0; +} + +static void +cifs_acl_key_destroy (struct key *key) +{ + kfree(key->payload.data); +} + +struct key_type cifs_acl_key_type = { + .name = "cifs.cifs_acl", + .instantiate = cifs_acl_key_instantiate, + .destroy = cifs_acl_key_destroy, + .describe = user_describe,
Quoted 8 lines
fs/cifs/cifsacl.c static const struct cifs_sid sid_authusers = { · line 85
Quoted 3 lines
fs/cifs/cifsacl.c +3
-0+ .match = user_match, +}; +Nit: these don't have so much to do with ACL's per-se, as much as idmapping. Maybe these functions and the key type should be called "cifs_idmap_*" and "cifs.idmap" ? It might be clearer to admins what this is for.
Yes, will change the name as you suggested, that sounds right, rather that acl.
Quoted 68 lines
Quoted 68 lines
fs/cifs/cifsacl.c +67
-0+static void +sid_to_str (struct cifs_sid *sidptr,char *sidstr) +{ + int i; + unsigned long saval; + char *strptr; + + strptr = sidstr; + + sprintf(strptr, "%s", "S"); + strptr = sidstr + strlen(sidstr); + + sprintf(strptr, "-%d", sidptr->revision); + strptr = sidstr + strlen(sidstr); + + for (i = 0; i < 6; ++i) { + if (sidptr->authority[i]) { + sprintf(strptr, "-%d", sidptr->authority[i]); + strptr = sidstr + strlen(sidstr); + } + } + + for (i = 0; i < sidptr->num_subauth; ++i) { + saval = le32_to_cpu(sidptr->sub_auth[i]); + sprintf(strptr, "-%ld", saval); + strptr = sidstr + strlen(sidstr); + } +} + +static int +sid_to_id (struct cifs_sid *psid,struct cifs_fattr *fattr,uint sidtype) +{ + int rc = 0; + char *sidstr, *strptr; + struct key *idkey; + + sidstr = kzalloc(SIDLEN, GFP_KERNEL); + if (!sidstr) + return -ENOMEM; + strptr = sidstr; + + if (sidtype == SIDOWNER) + sprintf(strptr, "%s", "os:"); + else if (sidtype == SIDGROUP) + sprintf(strptr, "%s", "gs:"); + else { + rc = -EINVAL; + goto idresolve_err; + } + strptr = sidstr + strlen(sidstr); + + sid_to_str(psid, strptr); + + idkey = request_key(&cifs_acl_key_type, sidstr, ""); + if (IS_ERR(idkey)) + cFYI(1, "%s: idkey error: %d\n", __func__, -ENOKEY); + else { + if (sidtype == SIDOWNER) + fattr->cf_uid = *(unsigned long *)idkey->payload.value; + else if (sidtype == SIDGROUP) + fattr->cf_gid = *(unsigned long *)idkey->payload.value; + key_put(idkey); + } + +idresolve_err: + kfree(sidstr); + return rc;
Quoted 8 lines
fs/cifs/cifsacl.c static const struct cifs_sid sid_authusers = { · line 154
Quoted 2 lines
fs/cifs/cifsacl.c +1
-0+}What about security? With this code, it'll be possible for a user to "stuff" the cache with idmapping. In the situation where the kernel is trying to enforce permissions on the client, it'll be possible to trick it into mapping a sid to a uid of your choosing. I think you need to guard against that.
That means cifs module will have to know what was the range of ids for uids and gids to be allocated by winbind as dictated by entries in smb.conf and if a returned id happens not to be in that range, discard it and assign default id of 0 (root).
winbind know the range from smb.conf, it could be any smb.conf file, not necessarily under /etc/samba/smb.conf.
How would cifs module know that range.
Not sure if winbind has an API to query the ranges. And even if it had, it is possible that winbind deamon itself is not running.
Quoted 4 lines
You'll also be doing an upcall every time a different user needs to map a SID to a UID/GID.
Quoted 8 lines
Finally, calling into the keys API every time you want to map an ID sounds rather inefficient. This might take quite some time if you were doing "ls -l" on a large directory.
Would it be better to consider taking the info in the key and populating a different cache? You could register it with a shrinker and prune off LRU entries if memory gets tight.
Will look into this. One thing that concerns me is if a cached etnry for a SID with its name and an id (either an uid or a gid), if that SID now represents a different object and has differernt name, would not cached info be incorrect? Not sure if this can ever happen or how would it happen and if it does, what would be a trigger for a cache revalidation and purges!
Quoted 3 lines
--
Jeff Layton <[email protected]>
Quoted 173 lines · On Sat, 11 Dec 2010 15:47:12 -0600 Shirish Pargaonkar…
Quoted 83 lines · Jeff Layton
Quoted 80 lines · On Tue, 7 Dec 2010 11:11:12 -0600 [email protected] wrote:
From: Shirish Pargaonkar <[email protected]>
Use a cifs upcall to map a SID to either an uid or a gid using winbind.
There is a corrosponding patch for the cifs.upcall binary in cifs-utils rpm that is being posted also.
A new type of key,
cifs_acl_key_type, is used.
To map a SID, which can be either a Onwer SID or a Group SID, key description starts with the string "os" or "gs" followed by SID converted to a string. Without "os" or "gs", cifs.upcall does not know whether SID needs to be mapped to either an uid or a gid.Once a key is instantiated, get rid of it since cifs does not need to use in any way.
winbind does the id mapping and looks up name for the newly mapped SID/uid or SID/gid combination.For now, cifs.upcall is only used to map a SID to an id (uid or gid) but it would be used to obtain an SID (string) for an id.
An entry such as this
create cifs.cifs_acl * *
/usr/sbin/cifs.upcall%kis needed in the file
/etc/request-key.conf.Signed-off-by Shirish Pargaonkar <[email protected]>---
fs/cifs/cifsacl.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++-----fs/cifs/cifsacl.h| 8 ++++
fs/cifs/cifsfs.c | 7 +++3 files changed, 122 insertions(+), 10 deletions(-)fs/cifs/cifsacl.c +28
-0@@ -23,6 +23,9 @@ #include <linux/fs.h> #include <linux/slab.h> +#include <linux/string.h> +#include <keys/user-type.h> +#include <linux/key-type.h> #include "cifspdu.h" #include "cifsglob.h" #include "cifsacl.h"@@ -52,6 +55,102 @@ static const struct cifs_sid sid_authusers = { /* group users */ static const struct cifs_sid sid_user = {1, 2 , {0, 0, 0, 0, 0, 5}, {} }; +static int +cifs_acl_key_instantiate (struct key *key,const void *data,size_t datalen) +{ + char *payload; + + payload = kmalloc(datalen, GFP_KERNEL); + if (!payload) + return -ENOMEM; + + memcpy(payload, data, datalen); + key->payload.data = payload; + return 0; +} + +static void +cifs_acl_key_destroy (struct key *key) +{ + kfree(key->payload.data); +} + +struct key_type cifs_acl_key_type = { + .name = "cifs.cifs_acl", + .instantiate = cifs_acl_key_instantiate, + .destroy = cifs_acl_key_destroy, + .describe = user_describe,Quoted 8 lines
fs/cifs/cifsacl.c static const struct cifs_sid sid_authusers = { · line 85
Quoted 3 lines
fs/cifs/cifsacl.c +3
-0+ .match = user_match, +}; +Nit: these don't have so much to do with ACL's per-se, as much as idmapping. Maybe these functions and the key type should be called "cifs_idmap_*" and "cifs.idmap" ? It might be clearer to admins what this is for.
Yes, will change the name as you suggested, that sounds right, rather that acl.
Quoted 68 lines
Quoted 68 lines
fs/cifs/cifsacl.c +67
-0+static void +sid_to_str (struct cifs_sid *sidptr,char *sidstr) +{ + int i; + unsigned long saval; + char *strptr; + + strptr = sidstr; + + sprintf(strptr, "%s", "S"); + strptr = sidstr + strlen(sidstr); + + sprintf(strptr, "-%d", sidptr->revision); + strptr = sidstr + strlen(sidstr); + + for (i = 0; i < 6; ++i) { + if (sidptr->authority[i]) { + sprintf(strptr, "-%d", sidptr->authority[i]); + strptr = sidstr + strlen(sidstr); + } + } + + for (i = 0; i < sidptr->num_subauth; ++i) { + saval = le32_to_cpu(sidptr->sub_auth[i]); + sprintf(strptr, "-%ld", saval); + strptr = sidstr + strlen(sidstr); + } +} + +static int +sid_to_id (struct cifs_sid *psid,struct cifs_fattr *fattr,uint sidtype) +{ + int rc = 0; + char *sidstr, *strptr; + struct key *idkey; + + sidstr = kzalloc(SIDLEN, GFP_KERNEL); + if (!sidstr) + return -ENOMEM; + strptr = sidstr; + + if (sidtype == SIDOWNER) + sprintf(strptr, "%s", "os:"); + else if (sidtype == SIDGROUP) + sprintf(strptr, "%s", "gs:"); + else { + rc = -EINVAL; + goto idresolve_err; + } + strptr = sidstr + strlen(sidstr); + + sid_to_str(psid, strptr); + + idkey = request_key(&cifs_acl_key_type, sidstr, ""); + if (IS_ERR(idkey)) + cFYI(1, "%s: idkey error: %d\n", __func__, -ENOKEY); + else { + if (sidtype == SIDOWNER) + fattr->cf_uid = *(unsigned long *)idkey->payload.value; + else if (sidtype == SIDGROUP) + fattr->cf_gid = *(unsigned long *)idkey->payload.value; + key_put(idkey); + } + +idresolve_err: + kfree(sidstr); + return rc;Quoted 8 lines
fs/cifs/cifsacl.c static const struct cifs_sid sid_authusers = { · line 154
Quoted 2 lines
fs/cifs/cifsacl.c +1
-0+}What about security? With this code, it'll be possible for a user to "stuff" the cache with idmapping. In the situation where the kernel is trying to enforce permissions on the client, it'll be possible to trick it into mapping a sid to a uid of your choosing. I think you need to guard against that.
Quoted 10 lines
That means cifs module will have to know what was the range of ids for uids and gids to be allocated by winbind as dictated by entries in smb.conf and if a returned id happens not to be in that range, discard it and assign default id of 0 (root).
winbind know the range from smb.conf, it could be any smb.conf file, not necessarily under/etc/samba/smb.conf.
How would cifs module know that range.
Not sure if winbind has an API to query the ranges. And even if it had, it is possible that winbind deamon itself is not running.
Maybe I wasn't clear... The danger here is that I have the ability to put info of my own choosing into my keyring via an add_key() syscall from userspace.
You need to do something like the override_creds trick that dns_query does.
Quoted 13 lines
Quoted 4 lines
You'll also be doing an upcall every time a different user needs to map a SID to a UID/GID.
Quoted 8 lines
Finally, calling into the keys API every time you want to map an ID sounds rather inefficient. This might take quite some time if you were doing "ls -l" on a large directory.
Would it be better to consider taking the info in the key and populating a different cache? You could register it with a shrinker and prune off LRU entries if memory gets tight.
Quoted 7 lines
Will look into this. One thing that concerns me is if a cached etnry for a SID with its name and an id (either an uid or a gid), if that SID now represents a different object and has differernt name, would not cached info be incorrect? Not sure if this can ever happen or how would it happen and if it does, what would be a trigger for a cache revalidation and purges!
Sure, mappings can change. But, you still have the same problem with what you're proposing in these patches. The userspace program isn't setting a timeout on the key. Once a mapping is put in the keyring, it's there until it's revoked. You probably want to set a max TTL for the entries in the cache regardless of what scheme is used.
idmap lookups need to be pretty fast as you'll be calling them a lot. Consider the case of "ls -l" on a large directory. Some slowness for the upcall to populate the entry in the cache is probably acceptable. Slowness on subsequent cached lookups of that same entry will be painful.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 9 lines · Jeff Layton
Quoted 8 lines
Will look into this. One thing that concerns me is if a cached etnry for a SID with its name and an id (either an uid or a gid), if that SID now represents a different object and has differernt name, would not cached info be incorrect? Not sure if this can ever happen or how would it happen and if it does, what would be a trigger for a cache revalidation and purges!
Quoted 5 lines
Sure, mappings can change. But, you still have the same problem with what you're proposing in these patches. The userspace program isn't setting a timeout on the key. Once a mapping is put in the keyring, it's there until it's revoked. You probably want to set a max TTL for the entries in the cache regardless of what scheme is used.
I was under the impression that SIDs are never reused. Perhaps I am mistaken.
Signature · 2 lines
Regards, Richard Sharpe
A message that is not in the archive (sent off-list or not yet received): AANLkTiniGp28dxZuoTcjyp0OMEoQ-7E0yE6T8B+VHOLj-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 10 lines · On Sat, 11 Dec 2010 19:57:11 -0500 Richard Sharpe…
Quoted 9 lines · Jeff Layton
Quoted 8 lines
Will look into this. One thing that concerns me is if a cached etnry for a SID with its name and an id (either an uid or a gid), if that SID now represents a different object and has differernt name, would not cached info be incorrect? Not sure if this can ever happen or how would it happen and if it does, what would be a trigger for a cache revalidation and purges!
Quoted 8 lines
Quoted 5 lines
Sure, mappings can change. But, you still have the same problem with what you're proposing in these patches. The userspace program isn't setting a timeout on the key. Once a mapping is put in the keyring, it's there until it's revoked. You probably want to set a max TTL for the entries in the cache regardless of what scheme is used.
I was under the impression that SIDs are never reused. Perhaps I am mistaken.
That may be, but the mapping of a SID is dependent upon settings in config files that could change. It seems reasonable to me to only cache these mappings for a period of time in the event that they do. That period of time could default to being rather long and be tunable.
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20101211221159.36e6c814-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org
Quoted 19 lines · Jeff Layton
Quoted 16 lines · On Sat, 11 Dec 2010 19:57:11 -0500 Richard Sharpe…
Quoted 14 lines · Jeff Layton
Quoted 8 lines
Will look into this. One thing that concerns me is if a cached etnry for a SID with its name and an id (either an uid or a gid), if that SID now represents a different object and has differernt name, would not cached info be incorrect? Not sure if this can ever happen or how would it happen and if it does, what would be a trigger for a cache revalidation and purges!
Sure, mappings can change. But, you still have the same problem with what you're proposing in these patches. The userspace program isn't setting a timeout on the key. Once a mapping is put in the keyring, it's there until it's revoked. You probably want to set a max TTL for the entries in the cache regardless of what scheme is used.
Quoted 7 lines
Quoted 2 lines
I was under the impression that SIDs are never reused. Perhaps I am mistaken.
That may be, but the mapping of a SID is dependent upon settings in config files that could change. It seems reasonable to me to only cache these mappings for a period of time in the event that they do. That period of time could default to being rather long and be tunable.
I think that instead some explicit signal should be made to indicate that a mapping has changed, so you don't have to worry about cache times. It should change *very* rarely and only on specific administrator intervention. We do a lot of things to avoid this happening in the normal course of events.
Andrew Bartlett
Signature · 3 lines
Andrew Bartlett http://samba.org/~abartlet/ Authentication Developer, Samba Team http://samba.org Samba Developer, Cisco Inc.
Quoted 28 lines · On Sun, 12 Dec 2010 14:48:04 +1100 Andrew Bartlett…
Quoted 19 lines · Jeff Layton
Quoted 16 lines · On Sat, 11 Dec 2010 19:57:11 -0500 Richard Sharpe…
Quoted 14 lines · Jeff Layton
Quoted 8 lines
Will look into this. One thing that concerns me is if a cached etnry for a SID with its name and an id (either an uid or a gid), if that SID now represents a different object and has differernt name, would not cached info be incorrect? Not sure if this can ever happen or how would it happen and if it does, what would be a trigger for a cache revalidation and purges!
Sure, mappings can change. But, you still have the same problem with what you're proposing in these patches. The userspace program isn't setting a timeout on the key. Once a mapping is put in the keyring, it's there until it's revoked. You probably want to set a max TTL for the entries in the cache regardless of what scheme is used.
Quoted 7 lines
Quoted 2 lines
I was under the impression that SIDs are never reused. Perhaps I am mistaken.
That may be, but the mapping of a SID is dependent upon settings in config files that could change. It seems reasonable to me to only cache these mappings for a period of time in the event that they do. That period of time could default to being rather long and be tunable.
Quoted 6 lines
I think that instead some explicit signal should be made to indicate that a mapping has changed, so you don't have to worry about cache times. It should change *very* rarely and only on specific administrator intervention. We do a lot of things to avoid this happening in the normal course of events.
What would provide this signal? winbindd? I suppose we could add a knob or something under /sys that tells cifs to dump the idmap cache.
We would also have to consider however how to deal with someone running an old winbindd that doesn't signal the kernel properly.
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20101212063929.77a619e4-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Quoted 38 lines · Jeff Layton
Quoted 28 lines · On Sun, 12 Dec 2010 14:48:04 +1100 Andrew Bartlett…
Quoted 19 lines · Jeff Layton
Quoted 16 lines · On Sat, 11 Dec 2010 19:57:11 -0500 Richard Sharpe…
Quoted 14 lines · Jeff Layton
Quoted 8 lines
Will look into this. One thing that concerns me is if a cached etnry for a SID with its name and an id (either an uid or a gid), if that SID now represents a different object and has differernt name, would not cached info be incorrect? Not sure if this can ever happen or how would it happen and if it does, what would be a trigger for a cache revalidation and purges!
Sure, mappings can change. But, you still have the same problem with what you're proposing in these patches. The userspace program isn't setting a timeout on the key. Once a mapping is put in the keyring, it's there until it's revoked. You probably want to set a max TTL for the entries in the cache regardless of what scheme is used.
Quoted 7 lines
Quoted 2 lines
I was under the impression that SIDs are never reused. Perhaps I am mistaken.
That may be, but the mapping of a SID is dependent upon settings in config files that could change. It seems reasonable to me to only cache these mappings for a period of time in the event that they do. That period of time could default to being rather long and be tunable.
Quoted 6 lines
I think that instead some explicit signal should be made to indicate that a mapping has changed, so you don't have to worry about cache times. It should change *very* rarely and only on specific administrator intervention. We do a lot of things to avoid this happening in the normal course of events.
Quoted 2 lines
What would provide this signal? winbindd? I suppose we could add a knob or something under /sys that tells cifs to dump the idmap cache.
I think a /sys knob seems appropriate, perhaps easily sent a command option on the same utility used for the upcall?
Quoted 2 lines
We would also have to consider however how to deal with someone running an old winbindd that doesn't signal the kernel properly.
That's a very interesting question, as after a manual reconfiguration perhaps even winbind might not know it changed. It depends how deeply the administrator changed things (changing the idmap_rid config settings might matter for example). I'll let others who deal with idmap more often comment.
Andrew Bartlett
Signature · 3 lines
Andrew Bartlett http://samba.org/~abartlet/ Authentication Developer, Samba Team http://samba.org Samba Developer, Cisco Inc.
Quoted 45 lines · On Mon, 13 Dec 2010 14:22:09 +1100 Andrew Bartlett…
Quoted 38 lines · Jeff Layton
Quoted 28 lines · On Sun, 12 Dec 2010 14:48:04 +1100 Andrew Bartlett…
Quoted 19 lines · Jeff Layton
Quoted 16 lines · On Sat, 11 Dec 2010 19:57:11 -0500 Richard Sharpe…
Quoted 14 lines · Jeff Layton
Quoted 8 lines
Will look into this. One thing that concerns me is if a cached etnry for a SID with its name and an id (either an uid or a gid), if that SID now represents a different object and has differernt name, would not cached info be incorrect? Not sure if this can ever happen or how would it happen and if it does, what would be a trigger for a cache revalidation and purges!
Sure, mappings can change. But, you still have the same problem with what you're proposing in these patches. The userspace program isn't setting a timeout on the key. Once a mapping is put in the keyring, it's there until it's revoked. You probably want to set a max TTL for the entries in the cache regardless of what scheme is used.
Quoted 7 lines
Quoted 2 lines
I was under the impression that SIDs are never reused. Perhaps I am mistaken.
That may be, but the mapping of a SID is dependent upon settings in config files that could change. It seems reasonable to me to only cache these mappings for a period of time in the event that they do. That period of time could default to being rather long and be tunable.
Quoted 6 lines
I think that instead some explicit signal should be made to indicate that a mapping has changed, so you don't have to worry about cache times. It should change *very* rarely and only on specific administrator intervention. We do a lot of things to avoid this happening in the normal course of events.
Quoted 2 lines
What would provide this signal? winbindd? I suppose we could add a knob or something under /sys that tells cifs to dump the idmap cache.
I think a /sys knob seems appropriate, perhaps easily sent a command option on the same utility used for the upcall?
Quoted 9 lines
Quoted 2 lines
We would also have to consider however how to deal with someone running an old winbindd that doesn't signal the kernel properly.
That's a very interesting question, as after a manual reconfiguration perhaps even winbind might not know it changed. It depends how deeply the administrator changed things (changing the
idmap_ridconfig settings might matter for example). I'll let others who deal with idmap more often comment.
The other option is just to have a manual knob that flushes the cache, and add something like this to the cifs.upcall manpage: "If you change your idmapping configuration, then you'll probably also want to flush the idmap cache." Maybe it's a rare enough thing that we shouldn't sweat trying to make it too automatic.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 58 lines · Jeff Layton
Quoted 45 lines · On Mon, 13 Dec 2010 14:22:09 +1100 Andrew Bartlett <[email protected]> wrote:
Quoted 38 lines · Jeff Layton
Quoted 28 lines · On Sun, 12 Dec 2010 14:48:04 +1100 Andrew Bartlett <[email protected]> wrote:
Quoted 19 lines · Jeff Layton
Quoted 16 lines · On Sat, 11 Dec 2010 19:57:11 -0500 Richard Sharpe…
Quoted 14 lines · Jeff Layton
Quoted 8 lines
Will look into this. One thing that concerns me is if a cached etnry for a SID with its name and an id (either an uid or a gid), if that SID now represents a different object and has differernt name, would not cached info be incorrect? Not sure if this can ever happen or how would it happen and if it does, what would be a trigger for a cache revalidation and purges!
Sure, mappings can change. But, you still have the same problem with what you're proposing in these patches. The userspace program isn't setting a timeout on the key. Once a mapping is put in the keyring, it's there until it's revoked. You probably want to set a max TTL for the entries in the cache regardless of what scheme is used.
Quoted 7 lines
Quoted 2 lines
I was under the impression that SIDs are never reused. Perhaps I am mistaken.
That may be, but the mapping of a SID is dependent upon settings in config files that could change. It seems reasonable to me to only cache these mappings for a period of time in the event that they do. That period of time could default to being rather long and be tunable.
Quoted 6 lines
I think that instead some explicit signal should be made to indicate that a mapping has changed, so you don't have to worry about cache times. It should change *very* rarely and only on specific administrator intervention. We do a lot of things to avoid this happening in the normal course of events.
Quoted 2 lines
What would provide this signal? winbindd? I suppose we could add a knob or something under /sys that tells cifs to dump the idmap cache.
I think a /sys knob seems appropriate, perhaps easily sent a command option on the same utility used for the upcall?
Quoted 9 lines
Quoted 2 lines
We would also have to consider however how to deal with someone running an old winbindd that doesn't signal the kernel properly.
That's a very interesting question, as after a manual reconfiguration perhaps even winbind might not know it changed. It depends how deeply the administrator changed things (changing the
idmap_ridconfig settings might matter for example). I'll let others who deal with idmap more often comment.
Quoted 9 lines
The other option is just to have a manual knob that flushes the cache, and add something like this to the cifs.upcall manpage: "If you change your idmapping configuration, then you'll probably also want to flush the idmap cache." Maybe it's a rare enough thing that we shouldn't sweat trying to make it too automatic.
--
Jeff Layton <[email protected]>
# date; cat /proc/keys | grep cifs
Tue Dec 14 16:16:20 CST 2010
26fb212d I----- 1 perm 1f030000 0 0 keyring .cifs_idmap: empty 2fb33fb5 IR---- 2 expd 1f030000 0 0 keyring .cifs_idmap: empty
# date; cat /proc/keys | grep cifs
Tue Dec 14 16:16:29 CST 2010
26fb212d I----- 1 perm 1f030000 0 0 keyring .cifs_idmap: 2/4 2fb33fb5 IR---- 2 expd 1f030000 0 0 keyring .cifs_idmap: empty
# date; cat /proc/keys | grep cifs
Tue Dec 14 16:20:10 CST 2010
26fb212d I----- 1 perm 1f030000 0 0 keyring .cifs_idmap: 2/4 2fb33fb5 IR---- 2 expd 1f030000 0 0 keyring .cifs_idmap: empty
Should not these two entries expire after a minute if
key->expiry = KEY_EXPIRY_TIMEOUT;
in function cifs_idmap_key_instantiate()
if
#define KEY_EXPIRY_TIMEOUT 60*HZ
I was expecting this to be empty instead of 2/4 after more than a minute of inactivity.
26fb212d I----- 1 perm 1f030000 0 0 keyring .cifs_idmap: 2/4
A message that is not in the archive (sent off-list or not yet received): 20101213061622.7e78e475-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Quoted 6 lines · Jeff Layton
The other option is just to have a manual knob that flushes the cache, and add something like this to the cifs.upcall manpage: "If you change your idmapping configuration, then you'll probably also want to flush the idmap cache." Maybe it's a rare enough thing that we shouldn't sweat trying to make it too automatic.
I think that's a reasonable approach.
Signature · 3 lines
Andrew Bartlett http://samba.org/~abartlet/ Authentication Developer, Samba Team http://samba.org Samba Developer, Cisco Inc.