lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202405111306.MOClscNA-lkp@intel.com>
Date: Sat, 11 May 2024 13:30:00 +0800
From: kernel test robot <lkp@...el.com>
To: zijianzhang@...edance.com, netdev@...r.kernel.org
Cc: llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev,
	edumazet@...gle.com, willemdebruijn.kernel@...il.com,
	cong.wang@...edance.com, xiaochun.lu@...edance.com,
	Zijian Zhang <zijianzhang@...edance.com>
Subject: Re: [PATCH net-next v3 2/3] sock: add MSG_ZEROCOPY notification
 mechanism based on msg_control

Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/zijianzhang-bytedance-com/selftests-fix-OOM-problem-in-msg_zerocopy-selftest/20240511-000153
base:   net-next/main
patch link:    https://lore.kernel.org/r/20240510155900.1825946-3-zijianzhang%40bytedance.com
patch subject: [PATCH net-next v3 2/3] sock: add MSG_ZEROCOPY notification mechanism based on msg_control
config: arm-defconfig (https://download.01.org/0day-ci/archive/20240511/202405111306.MOClscNA-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240511/202405111306.MOClscNA-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405111306.MOClscNA-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> net/core/sock.c:2808:5: warning: stack frame size (1608) exceeds limit (1024) in '__sock_cmsg_send' [-Wframe-larger-than]
   int __sock_cmsg_send(struct sock *sk, struct cmsghdr *cmsg,
       ^
   1 warning generated.


vim +/__sock_cmsg_send +2808 net/core/sock.c

^1da177e4c3f41 Linus Torvalds        2005-04-16  2807  
233baf9a1bc46f xu xin                2022-10-20 @2808  int __sock_cmsg_send(struct sock *sk, struct cmsghdr *cmsg,
f28ea365cdefc3 Edward Jee            2015-10-08  2809  		     struct sockcm_cookie *sockc)
f28ea365cdefc3 Edward Jee            2015-10-08  2810  {
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2811  	u32 tsflags;
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2812  
f28ea365cdefc3 Edward Jee            2015-10-08  2813  	switch (cmsg->cmsg_type) {
f28ea365cdefc3 Edward Jee            2015-10-08  2814  	case SO_MARK:
91f0d8a4813a9a Jakub Kicinski        2022-01-31  2815  		if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_RAW) &&
91f0d8a4813a9a Jakub Kicinski        2022-01-31  2816  		    !ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN))
f28ea365cdefc3 Edward Jee            2015-10-08  2817  			return -EPERM;
f28ea365cdefc3 Edward Jee            2015-10-08  2818  		if (cmsg->cmsg_len != CMSG_LEN(sizeof(u32)))
f28ea365cdefc3 Edward Jee            2015-10-08  2819  			return -EINVAL;
f28ea365cdefc3 Edward Jee            2015-10-08  2820  		sockc->mark = *(u32 *)CMSG_DATA(cmsg);
f28ea365cdefc3 Edward Jee            2015-10-08  2821  		break;
7f1bc6e95d7840 Deepa Dinamani        2019-02-02  2822  	case SO_TIMESTAMPING_OLD:
382a32018b74f4 Thomas Lange          2024-01-04  2823  	case SO_TIMESTAMPING_NEW:
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2824  		if (cmsg->cmsg_len != CMSG_LEN(sizeof(u32)))
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2825  			return -EINVAL;
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2826  
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2827  		tsflags = *(u32 *)CMSG_DATA(cmsg);
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2828  		if (tsflags & ~SOF_TIMESTAMPING_TX_RECORD_MASK)
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2829  			return -EINVAL;
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2830  
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2831  		sockc->tsflags &= ~SOF_TIMESTAMPING_TX_RECORD_MASK;
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2832  		sockc->tsflags |= tsflags;
3dd17e63f5131b Soheil Hassas Yeganeh 2016-04-02  2833  		break;
80b14dee2bea12 Richard Cochran       2018-07-03  2834  	case SCM_TXTIME:
80b14dee2bea12 Richard Cochran       2018-07-03  2835  		if (!sock_flag(sk, SOCK_TXTIME))
80b14dee2bea12 Richard Cochran       2018-07-03  2836  			return -EINVAL;
80b14dee2bea12 Richard Cochran       2018-07-03  2837  		if (cmsg->cmsg_len != CMSG_LEN(sizeof(u64)))
80b14dee2bea12 Richard Cochran       2018-07-03  2838  			return -EINVAL;
80b14dee2bea12 Richard Cochran       2018-07-03  2839  		sockc->transmit_time = get_unaligned((u64 *)CMSG_DATA(cmsg));
80b14dee2bea12 Richard Cochran       2018-07-03  2840  		break;
779f1edec664a7 Soheil Hassas Yeganeh 2016-07-11  2841  	/* SCM_RIGHTS and SCM_CREDENTIALS are semantically in SOL_UNIX. */
779f1edec664a7 Soheil Hassas Yeganeh 2016-07-11  2842  	case SCM_RIGHTS:
779f1edec664a7 Soheil Hassas Yeganeh 2016-07-11  2843  	case SCM_CREDENTIALS:
779f1edec664a7 Soheil Hassas Yeganeh 2016-07-11  2844  		break;
274b6fd4a3053e Zijian Zhang          2024-05-10  2845  	case SCM_ZC_NOTIFICATION: {
274b6fd4a3053e Zijian Zhang          2024-05-10  2846  		int ret, i = 0;
274b6fd4a3053e Zijian Zhang          2024-05-10  2847  		int cmsg_data_len, zc_info_elem_num;
274b6fd4a3053e Zijian Zhang          2024-05-10  2848  		void __user	*usr_addr;
274b6fd4a3053e Zijian Zhang          2024-05-10  2849  		struct zc_info_elem zc_info_kern[SOCK_ZC_INFO_MAX];
274b6fd4a3053e Zijian Zhang          2024-05-10  2850  		unsigned long flags;
274b6fd4a3053e Zijian Zhang          2024-05-10  2851  		struct sk_buff_head *q, local_q;
274b6fd4a3053e Zijian Zhang          2024-05-10  2852  		struct sk_buff *skb, *tmp;
274b6fd4a3053e Zijian Zhang          2024-05-10  2853  		struct sock_exterr_skb *serr;
274b6fd4a3053e Zijian Zhang          2024-05-10  2854  
274b6fd4a3053e Zijian Zhang          2024-05-10  2855  		if (!sock_flag(sk, SOCK_ZEROCOPY) || sk->sk_family == PF_RDS)
274b6fd4a3053e Zijian Zhang          2024-05-10  2856  			return -EINVAL;
274b6fd4a3053e Zijian Zhang          2024-05-10  2857  
274b6fd4a3053e Zijian Zhang          2024-05-10  2858  		cmsg_data_len = cmsg->cmsg_len - sizeof(struct cmsghdr);
274b6fd4a3053e Zijian Zhang          2024-05-10  2859  		if (cmsg_data_len % sizeof(struct zc_info_elem))
274b6fd4a3053e Zijian Zhang          2024-05-10  2860  			return -EINVAL;
274b6fd4a3053e Zijian Zhang          2024-05-10  2861  
274b6fd4a3053e Zijian Zhang          2024-05-10  2862  		zc_info_elem_num = cmsg_data_len / sizeof(struct zc_info_elem);
274b6fd4a3053e Zijian Zhang          2024-05-10  2863  		if (!zc_info_elem_num || zc_info_elem_num > SOCK_ZC_INFO_MAX)
274b6fd4a3053e Zijian Zhang          2024-05-10  2864  			return -EINVAL;
274b6fd4a3053e Zijian Zhang          2024-05-10  2865  
274b6fd4a3053e Zijian Zhang          2024-05-10  2866  		if (in_compat_syscall())
274b6fd4a3053e Zijian Zhang          2024-05-10  2867  			usr_addr = compat_ptr(*(compat_uptr_t *)CMSG_DATA(cmsg));
274b6fd4a3053e Zijian Zhang          2024-05-10  2868  		else
274b6fd4a3053e Zijian Zhang          2024-05-10  2869  			usr_addr = (void __user *)*(void **)CMSG_DATA(cmsg);
274b6fd4a3053e Zijian Zhang          2024-05-10  2870  		if (!access_ok(usr_addr, cmsg_data_len))
274b6fd4a3053e Zijian Zhang          2024-05-10  2871  			return -EFAULT;
274b6fd4a3053e Zijian Zhang          2024-05-10  2872  
274b6fd4a3053e Zijian Zhang          2024-05-10  2873  		q = &sk->sk_error_queue;
274b6fd4a3053e Zijian Zhang          2024-05-10  2874  		skb_queue_head_init(&local_q);
274b6fd4a3053e Zijian Zhang          2024-05-10  2875  		spin_lock_irqsave(&q->lock, flags);
274b6fd4a3053e Zijian Zhang          2024-05-10  2876  		skb = skb_peek(q);
274b6fd4a3053e Zijian Zhang          2024-05-10  2877  		while (skb && i < zc_info_elem_num) {
274b6fd4a3053e Zijian Zhang          2024-05-10  2878  			struct sk_buff *skb_next = skb_peek_next(skb, q);
274b6fd4a3053e Zijian Zhang          2024-05-10  2879  
274b6fd4a3053e Zijian Zhang          2024-05-10  2880  			serr = SKB_EXT_ERR(skb);
274b6fd4a3053e Zijian Zhang          2024-05-10  2881  			if (serr->ee.ee_errno == 0 &&
274b6fd4a3053e Zijian Zhang          2024-05-10  2882  			    serr->ee.ee_origin == SO_EE_ORIGIN_ZEROCOPY) {
274b6fd4a3053e Zijian Zhang          2024-05-10  2883  				zc_info_kern[i].hi = serr->ee.ee_data;
274b6fd4a3053e Zijian Zhang          2024-05-10  2884  				zc_info_kern[i].lo = serr->ee.ee_info;
274b6fd4a3053e Zijian Zhang          2024-05-10  2885  				zc_info_kern[i].zerocopy = !(serr->ee.ee_code
274b6fd4a3053e Zijian Zhang          2024-05-10  2886  								& SO_EE_CODE_ZEROCOPY_COPIED);
274b6fd4a3053e Zijian Zhang          2024-05-10  2887  				__skb_unlink(skb, q);
274b6fd4a3053e Zijian Zhang          2024-05-10  2888  				__skb_queue_tail(&local_q, skb);
274b6fd4a3053e Zijian Zhang          2024-05-10  2889  				i++;
274b6fd4a3053e Zijian Zhang          2024-05-10  2890  			}
274b6fd4a3053e Zijian Zhang          2024-05-10  2891  			skb = skb_next;
274b6fd4a3053e Zijian Zhang          2024-05-10  2892  		}
274b6fd4a3053e Zijian Zhang          2024-05-10  2893  		spin_unlock_irqrestore(&q->lock, flags);
274b6fd4a3053e Zijian Zhang          2024-05-10  2894  
274b6fd4a3053e Zijian Zhang          2024-05-10  2895  		ret = copy_to_user(usr_addr,
274b6fd4a3053e Zijian Zhang          2024-05-10  2896  				   zc_info_kern,
274b6fd4a3053e Zijian Zhang          2024-05-10  2897  					i * sizeof(struct zc_info_elem));
274b6fd4a3053e Zijian Zhang          2024-05-10  2898  
274b6fd4a3053e Zijian Zhang          2024-05-10  2899  		if (unlikely(ret)) {
274b6fd4a3053e Zijian Zhang          2024-05-10  2900  			spin_lock_irqsave(&q->lock, flags);
274b6fd4a3053e Zijian Zhang          2024-05-10  2901  			skb_queue_reverse_walk_safe(&local_q, skb, tmp) {
274b6fd4a3053e Zijian Zhang          2024-05-10  2902  				__skb_unlink(skb, &local_q);
274b6fd4a3053e Zijian Zhang          2024-05-10  2903  				__skb_queue_head(q, skb);
274b6fd4a3053e Zijian Zhang          2024-05-10  2904  			}
274b6fd4a3053e Zijian Zhang          2024-05-10  2905  			spin_unlock_irqrestore(&q->lock, flags);
274b6fd4a3053e Zijian Zhang          2024-05-10  2906  			return -EFAULT;
274b6fd4a3053e Zijian Zhang          2024-05-10  2907  		}
274b6fd4a3053e Zijian Zhang          2024-05-10  2908  
274b6fd4a3053e Zijian Zhang          2024-05-10  2909  		while ((skb = __skb_dequeue(&local_q)))
274b6fd4a3053e Zijian Zhang          2024-05-10  2910  			consume_skb(skb);
274b6fd4a3053e Zijian Zhang          2024-05-10  2911  		break;
274b6fd4a3053e Zijian Zhang          2024-05-10  2912  	}
f28ea365cdefc3 Edward Jee            2015-10-08  2913  	default:
f28ea365cdefc3 Edward Jee            2015-10-08  2914  		return -EINVAL;
f28ea365cdefc3 Edward Jee            2015-10-08  2915  	}
39771b127b4123 Willem de Bruijn      2016-04-02  2916  	return 0;
39771b127b4123 Willem de Bruijn      2016-04-02  2917  }
39771b127b4123 Willem de Bruijn      2016-04-02  2918  EXPORT_SYMBOL(__sock_cmsg_send);
39771b127b4123 Willem de Bruijn      2016-04-02  2919  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ