]> Pileus Git - ~andy/linux/blobdiff - fs/cifs/connect.c
Merge branch 'sfc-3.9' into master
[~andy/linux] / fs / cifs / connect.c
index 541169459223d37c48f66837d4ad11e382c1d593..54125e04fd0c88d4c17d7833b557e21c1696bcb3 100644 (file)
@@ -987,6 +987,41 @@ static int get_option_ul(substring_t args[], unsigned long *option)
        return rc;
 }
 
+static int get_option_uid(substring_t args[], kuid_t *result)
+{
+       unsigned long value;
+       kuid_t uid;
+       int rc;
+
+       rc = get_option_ul(args, &value);
+       if (rc)
+               return rc;
+
+       uid = make_kuid(current_user_ns(), value);
+       if (!uid_valid(uid))
+               return -EINVAL;
+
+       *result = uid;
+       return 0;
+}
+
+static int get_option_gid(substring_t args[], kgid_t *result)
+{
+       unsigned long value;
+       kgid_t gid;
+       int rc;
+
+       rc = get_option_ul(args, &value);
+       if (rc)
+               return rc;
+
+       gid = make_kgid(current_user_ns(), value);
+       if (!gid_valid(gid))
+               return -EINVAL;
+
+       *result = gid;
+       return 0;
+}
 
 static int cifs_parse_security_flavors(char *value,
                                       struct smb_vol *vol)
@@ -996,7 +1031,7 @@ static int cifs_parse_security_flavors(char *value,
 
        switch (match_token(value, cifs_secflavor_tokens, args)) {
        case Opt_sec_krb5:
-               vol->secFlg |= CIFSSEC_MAY_KRB5;
+               vol->secFlg |= CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_SIGN;
                break;
        case Opt_sec_krb5i:
                vol->secFlg |= CIFSSEC_MAY_KRB5 | CIFSSEC_MUST_SIGN;
@@ -1424,47 +1459,42 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
 
                /* Numeric Values */
                case Opt_backupuid:
-                       if (get_option_ul(args, &option)) {
+                       if (get_option_uid(args, &vol->backupuid)) {
                                cERROR(1, "%s: Invalid backupuid value",
                                        __func__);
                                goto cifs_parse_mount_err;
                        }
-                       vol->backupuid = option;
                        vol->backupuid_specified = true;
                        break;
                case Opt_backupgid:
-                       if (get_option_ul(args, &option)) {
+                       if (get_option_gid(args, &vol->backupgid)) {
                                cERROR(1, "%s: Invalid backupgid value",
                                        __func__);
                                goto cifs_parse_mount_err;
                        }
-                       vol->backupgid = option;
                        vol->backupgid_specified = true;
                        break;
                case Opt_uid:
-                       if (get_option_ul(args, &option)) {
+                       if (get_option_uid(args, &vol->linux_uid)) {
                                cERROR(1, "%s: Invalid uid value",
                                        __func__);
                                goto cifs_parse_mount_err;
                        }
-                       vol->linux_uid = option;
                        uid_specified = true;
                        break;
                case Opt_cruid:
-                       if (get_option_ul(args, &option)) {
+                       if (get_option_uid(args, &vol->cred_uid)) {
                                cERROR(1, "%s: Invalid cruid value",
                                        __func__);
                                goto cifs_parse_mount_err;
                        }
-                       vol->cred_uid = option;
                        break;
                case Opt_gid:
-                       if (get_option_ul(args, &option)) {
+                       if (get_option_gid(args, &vol->linux_gid)) {
                                cERROR(1, "%s: Invalid gid value",
                                                __func__);
                                goto cifs_parse_mount_err;
                        }
-                       vol->linux_gid = option;
                        gid_specified = true;
                        break;
                case Opt_file_mode:
@@ -1917,7 +1947,7 @@ srcip_matches(struct sockaddr *srcaddr, struct sockaddr *rhs)
        }
        case AF_INET6: {
                struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *)srcaddr;
-               struct sockaddr_in6 *vaddr6 = (struct sockaddr_in6 *)&rhs;
+               struct sockaddr_in6 *vaddr6 = (struct sockaddr_in6 *)rhs;
                return ipv6_addr_equal(&saddr6->sin6_addr, &vaddr6->sin6_addr);
        }
        default:
@@ -2241,7 +2271,7 @@ static int match_session(struct cifs_ses *ses, struct smb_vol *vol)
 {
        switch (ses->server->secType) {
        case Kerberos:
-               if (vol->cred_uid != ses->cred_uid)
+               if (!uid_eq(vol->cred_uid, ses->cred_uid))
                        return 0;
                break;
        default:
@@ -2713,7 +2743,7 @@ compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data)
        if (new->rsize && new->rsize < old->rsize)
                return 0;
 
-       if (old->mnt_uid != new->mnt_uid || old->mnt_gid != new->mnt_gid)
+       if (!uid_eq(old->mnt_uid, new->mnt_uid) || !gid_eq(old->mnt_gid, new->mnt_gid))
                return 0;
 
        if (old->mnt_file_mode != new->mnt_file_mode ||