CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Florian Westphal <[email protected]>
TO: [email protected]
CC: Florian Westphal <[email protected]>

Hi Florian,

I love your patch! Perhaps something to improve:

[auto build test WARNING on kselftest/next]
[also build test WARNING on mptcp/export linus/master v5.14-rc5 next-20210811]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    
https://github.com/0day-ci/linux/commits/Florian-Westphal/mptcp-add-SOL_MPTCP-getsockopt-support/20210811-212510
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: i386-randconfig-m021-20210811 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

smatch warnings:
net/mptcp/sockopt.c:759 mptcp_get_subflow_data() warn: check for integer 
overflow 'len'

vim +/len +759 net/mptcp/sockopt.c

d6a9cf7d54d73f1 Florian Westphal 2021-08-11  728  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  729  static int 
mptcp_get_subflow_data(struct mptcp_subflow_data *sfd,
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  730                                
  char __user *optval, int __user *_u_optlen)
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  731  {
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  732  #define MIN_INFO_OPTLEN_SIZE  
16
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  733        int len, copylen;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  734  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  735        if (get_user(len, 
_u_optlen))
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  736                return -EFAULT;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  737  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  738        if (len <= 
MIN_INFO_OPTLEN_SIZE)
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  739                return -EINVAL;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  740  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  741        memset(sfd, 0, 
sizeof(*sfd));
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  742  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  743        copylen = 
min_t(unsigned int, len, sizeof(*sfd));
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  744        if (copy_from_user(sfd, 
optval, copylen))
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  745                return -EFAULT;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  746  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  747        /* size_subflow_data is 
u32, but len is signed */
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  748        if 
(sfd->size_subflow_data > INT_MAX ||
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  749            sfd->size_user > 
INT_MAX)
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  750                return -EINVAL;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  751  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  752        if 
(sfd->size_subflow_data < MIN_INFO_OPTLEN_SIZE ||
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  753            
sfd->size_subflow_data > len)
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  754                return -EINVAL;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  755  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  756        if (sfd->num_subflows 
|| sfd->size_kernel)
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  757                return -EINVAL;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  758  
d6a9cf7d54d73f1 Florian Westphal 2021-08-11 @759        return len - 
sfd->size_subflow_data;
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  760  }
d6a9cf7d54d73f1 Florian Westphal 2021-08-11  761  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to