RDS: fix an integer overflow check
PATCH 1/1 RDS: fix an integer overflow check
"len" is an int. We verified that len was postive already. Since PAGE_SIZE is specified as an unsigned long, the type it promoted to unsigned and the condition is never true.
I'm not sure this check is actually needed. It might be that we could just remove it?
net/rds/info.c +1 -1
@@ -176,7 +176,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval,/* check for all kinds of wrapping and the like */ start = (unsigned long )optval; -if (len <0 || len +PAGE_SIZE -1 < len || start + len < start) { +if (len <0 || len >INT_MAX - (PAGE_SIZE -1 ) || start + len < start) { ret = -EINVAL ; goto out; }
Quoted 14 lines · Dan Carpenter
"len" is an int. We verified that len was postive already. Since
PAGE_SIZEis specified as an unsigned long, the type it promoted to unsigned and the condition is never true.I'm not sure this check is actually needed. It might be that we could just remove it?
Signed-off-by Dan Carpenter <[email protected]>net/rds/info.c +0
-0
net/rds/info.c int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval, · line 179
Quoted 4 lines
net/rds/info.c +0
-1@@ -176,7 +176,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval,/* check for all kinds of wrapping and the like */ start = (unsigned long )optval; -if (len <0 || len +PAGE_SIZE -1 < len || start + len < start) {
Looks the original thought is to check up len + (PAGE_SIZE - 1) < len to avoid integer overflow, but lack of a "()".
However, we only have one add operation in this function which were shown as following:
nr_pages = (PAGE_ALIGN(start + len) - (start & PAGE_MASK))
>> PAGE_SHIFT;
I also gone through the call chains, there is no other (start + len) operations for all transport, I think it's safe to remove this check up if so.
Thanks,
-Jeff
Quoted 8 lines
net/rds/info.c +1
-1+if (len <0 || len >INT_MAX - (PAGE_SIZE -1 ) || start + len < start) { ret = -EINVAL ; goto out; } --To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 22 lines · Jeff Liu
Quoted 14 lines · Dan Carpenter
"len" is an int. We verified that len was postive already. Since
PAGE_SIZEis specified as an unsigned long, the type it promoted to unsigned and the condition is never true.I'm not sure this check is actually needed. It might be that we could just remove it?
Signed-off-by Dan Carpenter <[email protected]>net/rds/info.c +0
-0net/rds/info.c int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval, · line 179
Quoted 4 lines
net/rds/info.c +0
-1@@ -176,7 +176,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval,/* check for all kinds of wrapping and the like */ start = (unsigned long )optval; -if (len <0 || len +PAGE_SIZE -1 < len || start + len < start) {Looks the original thought is to check up len + (
PAGE_SIZE- 1) < len to avoid integer overflow, but lack of a "()".
Quoted 6 lines
However, we only have one add operation in this function which were shown as following:
nr_pages= (PAGE_ALIGN(start + len)- (start &PAGE_MASK))
>>PAGE_SHIFT;I also gone through the call chains, there is no other (start + len)
Sorry, here is a typo. "start + len" is already well-checked. Actually, I means there is no other "len + (PAGE_SIZE - 1)" operations.
Thanks,
-Jeff
Quoted 18 lines
operations for all transport, I think it's safe to remove this check up if so.
Thanks,
-JeffQuoted 8 lines
net/rds/info.c +1
-1+if (len <0 || len >INT_MAX - (PAGE_SIZE -1 ) || start + len < start) { ret = -EINVAL ; goto out; } --To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html_______________________________________________
rds-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/rds-devel