[kbuild] [linux-next:master 12558/12912] net/ipv4/tcp_ipv4.c:576 tcp_v4_err() error: uninitialized symbol 'skb'.

2020-05-27 Thread Dan Carpenter
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
master
head:   b0523c7b1c9d0edcd6c0fe6d2cb558a9ad5c60a8
commit: 45af29ca761c275e350cca659856bc56f1035ef9 [12558/12912] tcp: allow 
traceroute -Mtcp for unpriv users

config: i386-randconfig-m021-20200526 (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot 
Reported-by: Dan Carpenter 

smatch warnings:
net/ipv4/tcp_ipv4.c:576 tcp_v4_err() error: uninitialized symbol 'skb'.

# 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=45af29ca761c275e350cca659856bc56f1035ef9
git remote add linux-next 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote update linux-next
git checkout 45af29ca761c275e350cca659856bc56f1035ef9
vim +/skb +576 net/ipv4/tcp_ipv4.c

32bbd8793f24b0 Stefano Brivio2018-11-08  422  int tcp_v4_err(struct sk_buff 
*icmp_skb, u32 info)
^1da177e4c3f41 Linus Torvalds2005-04-16  423  {
b71d1d426d263b Eric Dumazet  2011-04-22  424const struct iphdr *iph 
= (const struct iphdr *)icmp_skb->data;
4d1a2d9ec1c17d Damian Lukowski   2009-08-26  425struct tcphdr *th = 
(struct tcphdr *)(icmp_skb->data + (iph->ihl << 2));
f1ecd5d9e73666 Damian Lukowski   2009-08-26  426struct 
inet_connection_sock *icsk;
^1da177e4c3f41 Linus Torvalds2005-04-16  427struct tcp_sock *tp;
^1da177e4c3f41 Linus Torvalds2005-04-16  428struct inet_sock *inet;
4d1a2d9ec1c17d Damian Lukowski   2009-08-26  429const int type = 
icmp_hdr(icmp_skb)->type;
4d1a2d9ec1c17d Damian Lukowski   2009-08-26  430const int code = 
icmp_hdr(icmp_skb)->code;
^1da177e4c3f41 Linus Torvalds2005-04-16  431struct sock *sk;
f1ecd5d9e73666 Damian Lukowski   2009-08-26  432struct sk_buff *skb;
0a672f74131dd6 Yuchung Cheng 2014-05-11  433struct request_sock 
*fastopen;
9a568de4818dea Eric Dumazet  2017-05-16  434u32 seq, snd_una;
9a568de4818dea Eric Dumazet  2017-05-16  435s32 remaining;
9a568de4818dea Eric Dumazet  2017-05-16  436u32 delta_us;
^1da177e4c3f41 Linus Torvalds2005-04-16  437int err;
4d1a2d9ec1c17d Damian Lukowski   2009-08-26  438struct net *net = 
dev_net(icmp_skb->dev);
^1da177e4c3f41 Linus Torvalds2005-04-16  439  
26e3736090e103 Eric Dumazet  2015-03-22  440sk = 
__inet_lookup_established(net, _hashinfo, iph->daddr,
26e3736090e103 Eric Dumazet  2015-03-22  441
   th->dest, iph->saddr, ntohs(th->source),
3fa6f616a7a4d0 David Ahern   2017-08-07  442
   inet_iif(icmp_skb), 0);
^1da177e4c3f41 Linus Torvalds2005-04-16  443if (!sk) {
5d3848bc33b7d1 Eric Dumazet  2016-04-27  444
__ICMP_INC_STATS(net, ICMP_MIB_INERRORS);
32bbd8793f24b0 Stefano Brivio2018-11-08  445return -ENOENT;
^1da177e4c3f41 Linus Torvalds2005-04-16  446}

I guess can "sk->sk_state" start as TCP_SYN_SENT/RECV?  Smatch doesn't
know.

^1da177e4c3f41 Linus Torvalds2005-04-16  447if (sk->sk_state == 
TCP_TIME_WAIT) {
9469c7b4aa210c YOSHIFUJI Hideaki 2006-10-10  448
inet_twsk_put(inet_twsk(sk));
32bbd8793f24b0 Stefano Brivio2018-11-08  449return 0;
^1da177e4c3f41 Linus Torvalds2005-04-16  450}
26e3736090e103 Eric Dumazet  2015-03-22  451seq = ntohl(th->seq);
32bbd8793f24b0 Stefano Brivio2018-11-08  452if (sk->sk_state == 
TCP_NEW_SYN_RECV) {
32bbd8793f24b0 Stefano Brivio2018-11-08  453tcp_req_err(sk, 
seq, type == ICMP_PARAMETERPROB ||
9cf7490360bf2c Eric Dumazet  2016-02-02  454
 type == ICMP_TIME_EXCEEDED ||
9cf7490360bf2c Eric Dumazet  2016-02-02  455
 (type == ICMP_DEST_UNREACH &&
9cf7490360bf2c Eric Dumazet  2016-02-02  456
  (code == ICMP_NET_UNREACH ||
9cf7490360bf2c Eric Dumazet  2016-02-02  457
   code == ICMP_HOST_UNREACH)));
32bbd8793f24b0 Stefano Brivio2018-11-08  458return 0;
32bbd8793f24b0 Stefano Brivio2018-11-08  459}
^1da177e4c3f41 Linus Torvalds2005-04-16  460  
^1da177e4c3f41 Linus Torvalds2005-04-16  461bh_lock_sock(sk);
^1da177e4c3f41 Linus Torvalds2005-04-16  462/* If too many ICMPs 
get dropped on busy
^1da177e4c3f41 Linus Torvalds2005-04-16  463 * servers this needs 
to be solved differently.
563d34d0578626 Eric Dumazet  2012-07-23  464 * We do take care of 
PMTU discovery (RFC1191) special case :
563d34d0578626 Eric Dumazet  2012-07-23  465 * we can receive 
locally generated ICMP messages while socket is held.
^1da177e4c3f41 Linus Torvalds

[kbuild] [linux-next:master 12558/12912] net/ipv4/tcp_ipv4.c:576 tcp_v4_err() error: uninitialized symbol 'skb'.

2020-05-26 Thread kbuild test robot
CC: kbuild-...@lists.01.org
TO: Eric Dumazet 
CC: "Maciej Żenczykowski" 

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
master
head:   b0523c7b1c9d0edcd6c0fe6d2cb558a9ad5c60a8
commit: 45af29ca761c275e350cca659856bc56f1035ef9 [12558/12912] tcp: allow 
traceroute -Mtcp for unpriv users
:: branch date: 6 hours ago
:: commit date: 16 hours ago
config: i386-randconfig-m021-20200526 (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot 
Reported-by: Dan Carpenter 

smatch warnings:
net/ipv4/tcp_ipv4.c:576 tcp_v4_err() error: uninitialized symbol 'skb'.

# 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=45af29ca761c275e350cca659856bc56f1035ef9
git remote add linux-next 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote update linux-next
git checkout 45af29ca761c275e350cca659856bc56f1035ef9
vim +/skb +576 net/ipv4/tcp_ipv4.c

26e3736090e103 Eric Dumazet  2015-03-22  405  
^1da177e4c3f41 Linus Torvalds2005-04-16  406  /*
^1da177e4c3f41 Linus Torvalds2005-04-16  407   * This routine is called by 
the ICMP module when it gets some
^1da177e4c3f41 Linus Torvalds2005-04-16  408   * sort of error condition.  
If err < 0 then the socket should
^1da177e4c3f41 Linus Torvalds2005-04-16  409   * be closed and the error 
returned to the user.  If err > 0
^1da177e4c3f41 Linus Torvalds2005-04-16  410   * it's just the icmp type << 
8 | icmp code.  After adjustment
^1da177e4c3f41 Linus Torvalds2005-04-16  411   * header points to the first 
8 bytes of the tcp header.  We need
^1da177e4c3f41 Linus Torvalds2005-04-16  412   * to find the appropriate 
port.
^1da177e4c3f41 Linus Torvalds2005-04-16  413   *
^1da177e4c3f41 Linus Torvalds2005-04-16  414   * The locking strategy used 
here is very "optimistic". When
^1da177e4c3f41 Linus Torvalds2005-04-16  415   * someone else accesses the 
socket the ICMP is just dropped
^1da177e4c3f41 Linus Torvalds2005-04-16  416   * and for some paths there 
is no check at all.
^1da177e4c3f41 Linus Torvalds2005-04-16  417   * A more general error queue 
to queue errors for later handling
^1da177e4c3f41 Linus Torvalds2005-04-16  418   * is probably better.
^1da177e4c3f41 Linus Torvalds2005-04-16  419   *
^1da177e4c3f41 Linus Torvalds2005-04-16  420   */
^1da177e4c3f41 Linus Torvalds2005-04-16  421  
32bbd8793f24b0 Stefano Brivio2018-11-08  422  int tcp_v4_err(struct sk_buff 
*icmp_skb, u32 info)
^1da177e4c3f41 Linus Torvalds2005-04-16  423  {
b71d1d426d263b Eric Dumazet  2011-04-22  424const struct iphdr *iph 
= (const struct iphdr *)icmp_skb->data;
4d1a2d9ec1c17d Damian Lukowski   2009-08-26  425struct tcphdr *th = 
(struct tcphdr *)(icmp_skb->data + (iph->ihl << 2));
f1ecd5d9e73666 Damian Lukowski   2009-08-26  426struct 
inet_connection_sock *icsk;
^1da177e4c3f41 Linus Torvalds2005-04-16  427struct tcp_sock *tp;
^1da177e4c3f41 Linus Torvalds2005-04-16  428struct inet_sock *inet;
4d1a2d9ec1c17d Damian Lukowski   2009-08-26  429const int type = 
icmp_hdr(icmp_skb)->type;
4d1a2d9ec1c17d Damian Lukowski   2009-08-26  430const int code = 
icmp_hdr(icmp_skb)->code;
^1da177e4c3f41 Linus Torvalds2005-04-16  431struct sock *sk;
f1ecd5d9e73666 Damian Lukowski   2009-08-26  432struct sk_buff *skb;
0a672f74131dd6 Yuchung Cheng 2014-05-11  433struct request_sock 
*fastopen;
9a568de4818dea Eric Dumazet  2017-05-16  434u32 seq, snd_una;
9a568de4818dea Eric Dumazet  2017-05-16  435s32 remaining;
9a568de4818dea Eric Dumazet  2017-05-16  436u32 delta_us;
^1da177e4c3f41 Linus Torvalds2005-04-16  437int err;
4d1a2d9ec1c17d Damian Lukowski   2009-08-26  438struct net *net = 
dev_net(icmp_skb->dev);
^1da177e4c3f41 Linus Torvalds2005-04-16  439  
26e3736090e103 Eric Dumazet  2015-03-22  440sk = 
__inet_lookup_established(net, _hashinfo, iph->daddr,
26e3736090e103 Eric Dumazet  2015-03-22  441
   th->dest, iph->saddr, ntohs(th->source),
3fa6f616a7a4d0 David Ahern   2017-08-07  442
   inet_iif(icmp_skb), 0);
^1da177e4c3f41 Linus Torvalds2005-04-16  443if (!sk) {
5d3848bc33b7d1 Eric Dumazet  2016-04-27  444
__ICMP_INC_STATS(net, ICMP_MIB_INERRORS);
32bbd8793f24b0 Stefano Brivio2018-11-08  445return -ENOENT;
^1da177e4c3f41 Linus Torvalds2005-04-16  446}
^1da177e4c3f41 Linus Torvalds2005-04-16  447if (sk->sk_state == 
TCP_TIME_WAIT) {
9469c7b4aa210c YOSHIFUJI Hideaki 2006-10-10  448
inet_twsk_put(inet_twsk(sk));
32bbd8793f24b0 Stefano Brivio2018-11-08  449return 0;
^1da177e4c3f41 Linus