Shrink stack space usage in cifs_construct_tcon
authorSteve French <sfrench@us.ibm.com>
Tue, 1 Mar 2011 05:02:57 +0000 (05:02 +0000)
committerSteve French <sfrench@us.ibm.com>
Thu, 19 May 2011 14:10:48 +0000 (14:10 +0000)
We were reserving MAX_USERNAME (now 256) on stack for
something which only needs to fit about 24 bytes ie
string krb50x +  printf version of uid

Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/cifsglob.h
fs/cifs/connect.c

index 6e211b67b2736b5f1dcf2328a36d5941d52bf9af..108a1e99aa9fc9911a29c1a5fbfd40a848d21b7d 100644 (file)
@@ -274,7 +274,8 @@ struct cifsSesInfo {
        int capabilities;
        char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for
                                TCP names - will ipv6 and sctp addresses fit? */
-       char *user_name;
+       char *user_name;        /* must not be null except during init of sess
+                                  and after mount option parsing we fill it */
        char *domainName;
        char *password;
        struct session_key auth_key;
index 68b7dbf24b9281a0c8d922fc1fcad88586f4b147..8d72acbd5c1328a7f8ad0ce9636b996cf35165d5 100644 (file)
@@ -3258,7 +3258,9 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid)
        struct cifsSesInfo *ses;
        struct cifsTconInfo *tcon = NULL;
        struct smb_vol *vol_info;
-       char username[MAX_USERNAME_SIZE + 1];
+       char username[28]; /* big enough for "krb50x" + hex of ULONG_MAX 6+16 */
+                          /* We used to have this as MAX_USERNAME which is   */
+                          /* way too big now (256 instead of 32) */
 
        vol_info = kzalloc(sizeof(*vol_info), GFP_KERNEL);
        if (vol_info == NULL) {