Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-62156

__get_skb_tcphdr() stap builtin throws ERROR: read fault

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • rhel-8.10
    • systemtap
    • None
    • No
    • Important
    • rhel-sst-pt-perf-debug
    • ssg_platform_tools
    • 2
    • False
    • Hide

      None

      Show
      None
    • No
    • None
    • None
    • None
    • Unspecified Release Note Type - Unknown
    • s390x
    • None

      What were you trying to do that didn't work?

      This following script works on x86 but fails on s390x.

      cat dropwatch_by_port.stp
      %

      { #include <linux/version.h> #include <net/sock.h> #include <net/tcp.h> #include <net/ip.h> #include <linux/skbuff.h> %}

      function get_tcp_seq:long (tcphdr:long) %

      { long seq; seq = ((struct tcphdr *)STAP_ARG_tcphdr)->seq; STAP_RETURN(seq); %}

      function get_tcp_ack:long (tcphdr:long) %

      { long ack; ack = ((struct tcphdr *)STAP_ARG_tcphdr)->ack; STAP_RETURN(ack); %}

      function get_tcp_sport(tcphdr:long) %

      { int sport; sport = 0xffff & ((struct tcphdr *)STAP_ARG_tcphdr)->source; STAP_RETURN(sport); %}

      function get_tcp_dport(tcphdr:long) %

      { int dport; dport = 0xffff & ((struct tcphdr *)STAP_ARG_tcphdr)->dest; STAP_RETURN(dport); %}

      function __tcp_skb_seq:long (tcphdr:long)

      { return @cast(tcphdr, "tcphdr", "kernel<linux/tcp.h>")->seq }

      function get_ip_src:long (skb_param:long) %

      { struct iphdr *iph; long saddr; iph=ip_hdr((struct sk_buff*)STAP_ARG_skb_param); saddr =(long)iph->saddr; STAP_RETURN(saddr); %}

      function get_ip_dst:long (skb_param:long) %

      { struct iphdr *iph; long daddr; iph=ip_hdr((struct sk_buff*)STAP_ARG_skb_param); daddr =(long)iph->daddr; STAP_RETURN(daddr); %}

      function get_ip_protocol:long (skb_param:long) %

      { struct iphdr *iph; long protocol; iph=ip_hdr((struct sk_buff*)STAP_ARG_skb_param); protocol=(long)iph->protocol; STAP_RETURN(protocol); %}

      probe kernel.function("kfree_skb_reason")
      {
      if ($skb)

      { tcphdr = __get_skb_tcphdr($skb); printf("__get_skb_tcphdr() %x executed\n", tcphdr); }

      }

      What is the impact of this issue to you?

      Limits debugging.

      Please provide the package NVR for which the bug is seen:

      1. uname -r
        4.18.0-553.24.1.el8_10.s390x
      1. rpm -qa|grep systemt
        systemtap-client-4.9-3.el8.s390x
        systemtap-4.9-3.el8.s390x
        systemtap-runtime-4.9-3.el8.s390x
        systemtap-devel-4.9-3.el8.s390x

      How reproducible is this bug?:

      Just run the above script on a s390x VM:

      stap -g dropwatch_by_port.stp -v
      Pass 1: parsed user script and 482 library scripts using 123416virt/101780res/11220shr/90220data kb, in 310usr/40sys/357real ms.
      Pass 2: analyzed script: 4 probes, 3 functions, 4 embeds, 3 globals using 172448virt/152216res/12548shr/139252data kb, in 1070usr/30sys/1102real ms.
      Pass 3: translated to C into "/tmp/stapWzbr5i/stap_b13489c3d1a64c879e69bc99aa666efc_18624_src.c" using 172448virt/152408res/12740shr/139252data kb, in 10usr/0sys/10real ms.
      Pass 4: compiled C into "stap_b13489c3d1a64c879e69bc99aa666efc_18624.ko" in 3350usr/820sys/3518real ms.
      Pass 5: starting run.
      ERROR: read fault [man error::fault] at 0xb2d501c2 near identifier '__get_skb_tcphdr_new' at /usr/share/systemtap/tapset/linux/tcp.stp:93:23
      WARNING: Number of errors: 1, skipped probes: 0
      WARNING: /usr/bin/staprun exited with status: 1
      Pass 5: run completed in 20usr/30sys/3397real ms.
      Pass 5: run failed. [man error::pass5]

      Expected results

      The stap script should run.

      Actual results

      The script fails a above.

      But it works fine on x86 VM:

      1. stap -g dropwatch_by_port.stp -v
        Pass 1: parsed user script and 486 library scripts using 301772virt/97276res/16804shr/82224data kb, in 210usr/60sys/272real ms.
        Pass 2: analyzed script: 4 probes, 3 functions, 4 embeds, 3 globals using 367368virt/164064res/17936shr/147820data kb, in 1720usr/50sys/1776real ms.
        Pass 3: translated to C into "/tmp/stap2qqnQF/stap_ffa56d03298a180a2ba8af6e1a01fb0b_18598_src.c" using 367368virt/164256res/18128shr/147820data kb, in 10usr/0sys/13real ms.
        Pass 4: compiled C into "stap_ffa56d03298a180a2ba8af6e1a01fb0b_18598.ko" in 3770usr/1490sys/4578real ms.
        Pass 5: starting run.
        __get_skb_tcphdr() ffff97bdb0880876 executed
        __get_skb_tcphdr() ffff97bdac869c7e executed

      As a workaround use:

      function get_tcp_hdr:long (skb_param:long) %

      { long th; th = (long)skb_transport_header((struct sk_buff*)STAP_ARG_skb_param); STAP_RETURN(th); %}

      probe kernel.function("kfree_skb_reason")
      {
      if ($skb)
      {
      protocol = get_ip_protocol($skb)
      if (protocol == 6)
      {
      tcphdr = get_tcp_hdr($skb);

              rhtorsys Frank Eigler
              rhn-support-jmaxwell Jonathan Maxwell
              Frank Eigler Frank Eigler
              qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: