Skip to contentSkip to conversation

cifs: writing past end of struct in cifs_convert_address()

PATCH In review Dan Carpenter 2 participants 3 messages Mar 1, 2012 – Mar 29, 2012 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: writing past end of struct in cifs_convert_address()

"s6->sin6_scope_id" is an int bits but strict_strtoul() writes a long so this can corrupt memory on 64 bit systems.

fs/cifs/netmisc.c +1 -2
index 73e47e8..cab99b5 100644
@@ -197,8 +197,7 @@ cifs_convert_address(struct sockaddr *dst, const char *src, int len)
 		memcpy(scope_id, pct + 1, slen);
 		scope_id[slen] = '\0';
 
-		rc = strict_strtoul(scope_id, 0,
-					(unsigned long *)&s6->sin6_scope_id);
+		rc = kstrtouint(scope_id, 0, &s6->sin6_scope_id);
 		rc = (rc = 0) ? 1 : 0;
 	}
 

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#2 lore raw
Quoted 10 lines · On Thu, 1 Mar 2012 10:06:52 +0300 Dan Carpenter <[email protected]>…

"s6->sin6_scope_id" is an int bits but strict_strtoul() writes a long so this can corrupt memory on 64 bit systems.

fs/cifs/netmisc.c +0 -0
index 73e47e8..cab99b5 100644

fs/cifs/netmisc.c cifs_convert_address(struct sockaddr *dst, const char *src, int len) · line 203

Quoted 9 lines
fs/cifs/netmisc.c +1 -2
@@ -197,8 +197,7 @@ cifs_convert_address(struct sockaddr *dst, const char *src, int len)
 		memcpy(scope_id, pct + 1, slen);
 		scope_id[slen] = '\0';
 
-		rc = strict_strtoul(scope_id, 0,
-					(unsigned long *)&s6->sin6_scope_id);
+		rc = kstrtouint(scope_id, 0, &s6->sin6_scope_id);
 		rc = (rc = 0) ? 1 : 0;
 	}
 
Reviewed-by
#3 lore raw
In reply to a message not in the archive
Quoted 10 lines · On Thu, 1 Mar 2012 10:06:52 +0300 Dan Carpenter <[email protected]>…

"s6->sin6_scope_id" is an int bits but strict_strtoul() writes a long so this can corrupt memory on 64 bit systems.

fs/cifs/netmisc.c +0 -0
index 73e47e8..cab99b5 100644

fs/cifs/netmisc.c cifs_convert_address(struct sockaddr *dst, const char *src, int len) · line 203

Quoted 9 lines
fs/cifs/netmisc.c +1 -2
@@ -197,8 +197,7 @@ cifs_convert_address(struct sockaddr *dst, const char *src, int len)
 		memcpy(scope_id, pct + 1, slen);
 		scope_id[slen] = '\0';
 
-		rc = strict_strtoul(scope_id, 0,
-					(unsigned long *)&s6->sin6_scope_id);
+		rc = kstrtouint(scope_id, 0, &s6->sin6_scope_id);
 		rc = (rc = 0) ? 1 : 0;
 	}