From: kernel test robot <lkp@intel.com>
To: ishaangandhi <ishaangandhi@gmail.com>, davem@davemloft.net
Cc: kbuild-all@lists.01.org, ishaangandhi@gmail.com,
netdev@vger.kernel.org, willemb@google.com
Subject: Re: [PATCH] icmp: support rfc 5837
Date: Fri, 12 Mar 2021 10:28:18 +0800 [thread overview]
Message-ID: <202103121025.4CwjnHqz-lkp@intel.com> (raw)
In-Reply-To: <20210312004706.33046-1-ishaangandhi@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6325 bytes --]
Hi ishaangandhi,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
[also build test WARNING on net/master linus/master sparc-next/master v5.12-rc2 next-20210311]
[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/ishaangandhi/icmp-support-rfc-5837/20210312-084955
base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 1520929e26d54bc3c9e024ee91eee5a19c56b95b
config: i386-randconfig-m021-20210311 (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 <lkp@intel.com>
smatch warnings:
net/ipv4/icmp.c:692 icmp_identify_arrival_interface() error: uninitialized symbol 'name'.
net/ipv4/icmp.c:693 icmp_identify_arrival_interface() error: uninitialized symbol 'name_subobj_len'.
net/ipv4/icmp.c:695 icmp_identify_arrival_interface() error: uninitialized symbol 'name_len'.
net/ipv4/icmp.c:704 icmp_identify_arrival_interface() error: uninitialized symbol 'mtu'.
vim +/name +692 net/ipv4/icmp.c
579
580 /* Appends interface identification object to ICMP packet to identify
581 * the interface on which the original datagram arrived, per RFC 5837.
582 *
583 * Should only be called on the following messages
584 * - ICMPv4 Time Exceeded
585 * - ICMPv4 Destination Unreachable
586 * - ICMPv4 Parameter Problem
587 */
588
589 void icmp_identify_arrival_interface(struct sk_buff *skb, struct net *net, int room,
590 struct icmphdr *icmph)
591 {
592 unsigned int ext_len, if_index, orig_len, offset, extra_space_needed,
593 word_aligned_orig_len, mtu, name_len, name_subobj_len;
594 struct interface_ipv4_addr_sub_obj ip_addr;
595 struct icmp_extobj_hdr *iio_hdr;
596 struct icmp_ext_hdr *ext_hdr;
597 struct net_device *dev;
598 void *subobj_offset;
599 char *name, ctype;
600
601 skb_linearize(skb);
602 if_index = inet_iif(skb);
603 orig_len = skb->len - skb_network_offset(skb);
604 word_aligned_orig_len = (orig_len + 3) & ~0x03;
605
606 // Original datagram length is measured in 32-bit words
607 icmph->un.reserved[1] = word_aligned_orig_len / 4;
608 ctype = ICMP_5837_ARRIVAL_ROLE_CTYPE;
609
610 ext_len = sizeof(struct icmp_ext_hdr) + sizeof(struct icmp_extobj_hdr);
611
612 // Always add if_index to the IIO
613 ext_len += 4;
614 ctype |= ICMP_5837_IF_INDEX_CTYPE;
615
616 dev = dev_get_by_index(net, if_index);
617 // Try to append IP address, name, and MTU
618 if (dev) {
619 ip_addr.addr = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);
620 if (ip_addr.addr) {
621 ip_addr.afi = htons(1);
622 ip_addr.reserved = 0;
623 ctype |= ICMP_5837_IP_ADDR_CTYPE;
624 ext_len += 8;
625 }
626
627 name = dev->name;
628 if (name) {
629 name_len = strlen(name);
630 name_subobj_len = min_t(unsigned int, name_len, ICMP_5837_MAX_NAME_LEN) + 1;
631 name_subobj_len = (name_subobj_len + 3) & ~0x03;
632 ctype |= ICMP_5837_NAME_CTYPE;
633 ext_len += name_subobj_len;
634 }
635
636 mtu = dev->mtu;
637 if (mtu) {
638 ctype |= ICMP_5837_MTU_CTYPE;
639 ext_len += 4;
640 }
641 }
642
643 if (word_aligned_orig_len + ext_len > room) {
644 offset = room - ext_len;
645 extra_space_needed = room - orig_len;
646 } else if (orig_len < ICMP_5837_MIN_ORIG_LEN) {
647 // Original packet must be zero padded to 128 bytes
648 offset = ICMP_5837_MIN_ORIG_LEN;
649 extra_space_needed = offset + ext_len - orig_len;
650 } else {
651 // There is enough room to just add to the end of the packet
652 offset = word_aligned_orig_len;
653 extra_space_needed = ext_len;
654 }
655
656 if (skb_tailroom(skb) < extra_space_needed) {
657 if (pskb_expand_head(skb, 0, extra_space_needed - skb_tailroom(skb), GFP_ATOMIC))
658 return;
659 }
660
661 // Zero-pad from the end of the original message to the beginning of the header
662 if (orig_len < ICMP_5837_MIN_ORIG_LEN) {
663 // Original packet must be zero padded to 128 bytes
664 memset(skb_network_header(skb) + orig_len, 0, ICMP_5837_MIN_ORIG_LEN - orig_len);
665 } else {
666 // Just zero-pad so the original packet is aligned on a 4 byte boundary
667 memset(skb_network_header(skb) + orig_len, 0, word_aligned_orig_len - orig_len);
668 }
669
670 skb_put(skb, extra_space_needed);
671 ext_hdr = (struct icmp_ext_hdr *)(skb_network_header(skb) + offset);
672 iio_hdr = (struct icmp_extobj_hdr *)(ext_hdr + 1);
673 subobj_offset = (void *)(iio_hdr + 1);
674
675 ext_hdr->reserved1 = 0;
676 ext_hdr->reserved2 = 0;
677 ext_hdr->version = 2;
678 ext_hdr->checksum = 0;
679
680 iio_hdr->length = htons(ext_len - 4);
681 iio_hdr->class_num = 2;
682 iio_hdr->class_type = ctype;
683
684 *(__be32 *)subobj_offset = htonl(if_index);
685 subobj_offset += sizeof(__be32);
686
687 if (ip_addr.addr) {
688 *(struct interface_ipv4_addr_sub_obj *)subobj_offset = ip_addr;
689 subobj_offset += sizeof(ip_addr);
690 }
691
> 692 if (name) {
> 693 *(__u8 *)subobj_offset = name_subobj_len;
694 subobj_offset += sizeof(__u8);
> 695 if (name_len >= ICMP_5837_MAX_NAME_LEN) {
696 memcpy(subobj_offset, name, ICMP_5837_MAX_NAME_LEN);
697 } else {
698 memcpy(subobj_offset, name, name_len);
699 memset(subobj_offset + name_len, 0, name_subobj_len - name_len - 1);
700 }
701 subobj_offset += name_subobj_len - sizeof(__u8);
702 }
703
> 704 if (mtu) {
705 *(__be32 *)subobj_offset = htonl(mtu);
706 subobj_offset += sizeof(__be32);
707 }
708
709 ext_hdr->checksum =
710 csum_fold(skb_checksum(skb, skb_network_offset(skb) + offset, ext_len, 0));
711 }
712
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27057 bytes --]
next prev parent reply other threads:[~2021-03-12 2:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-12 0:47 [PATCH] icmp: support rfc 5837 ishaangandhi
2021-03-12 2:14 ` kernel test robot
2021-03-12 2:28 ` kernel test robot [this message]
2021-03-12 2:47 ` Willem de Bruijn
2021-03-12 3:10 ` kernel test robot
2021-03-12 3:10 ` [RFC PATCH] icmp: icmp_identify_arrival_interface() can be static kernel test robot
2021-03-15 8:29 ` [icmp] 42e5e7501e: BUG:KASAN:slab-out-of-bounds_in_pskb_expand_head kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202103121025.4CwjnHqz-lkp@intel.com \
--to=lkp@intel.com \
--cc=davem@davemloft.net \
--cc=ishaangandhi@gmail.com \
--cc=kbuild-all@lists.01.org \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).