1. 06 Jun, 2019 1 commit
    • Daniel Borkmann's avatar
      bpf: fix unconnected udp hooks · 983695fa
      Daniel Borkmann authored
      Intention of cgroup bind/connect/sendmsg BPF hooks is to act transparently
      to applications as also stated in original motivation in 7828f20e ("Merge
      branch 'bpf-cgroup-bind-connect'"). When recently integrating the latter
      two hooks into Cilium to enable host based load-balancing with Kubernetes,
      I ran into the issue that pods couldn't start up as DNS got broken. Kubernetes
      typically sets up DNS as a service and is thus subject to load-balancing.
      
      Upon further debugging, it turns out that the cgroupv2 sendmsg BPF hooks API
      is currently insufficient and thus not usable as-is for standard applications
      shipped with most distros. To break down the issue we ran into with a simple
      example:
      
        # cat /etc/resolv.conf
        nameserver 147.75.207.207
        nameserver 147.75.207.208
      
      For the purpose of a simple test, we set up above IPs as service IPs and
      transparently redirect traffic to a different DNS backend server for that
      node:
      
        # cilium service list
        ID   Frontend            Backend
        1    147.75.207.207:53   1 => 8.8.8.8:53
        2    147.75.207.208:53   1 => 8.8.8.8:53
      
      The attached BPF program is basically selecting one of the backends if the
      service IP/port matches on the cgroup hook. DNS breaks here, because the
      hooks are not transparent enough to applications which have built-in msg_name
      address checks:
      
        # nslookup 1.1.1.1
        ;; reply from unexpected source: 8.8.8.8#53, expected 147.75.207.207#53
        ;; reply from unexpected source: 8.8.8.8#53, expected 147.75.207.208#53
        ;; reply from unexpected source: 8.8.8.8#53, expected 147.75.207.207#53
        [...]
        ;; connection timed out; no servers could be reached
      
        # dig 1.1.1.1
        ;; reply from unexpected source: 8.8.8.8#53, expected 147.75.207.207#53
        ;; reply from unexpected source: 8.8.8.8#53, expected 147.75.207.208#53
        ;; reply from unexpected source: 8.8.8.8#53, expected 147.75.207.207#53
        [...]
      
        ; <<>> DiG 9.11.3-1ubuntu1.7-Ubuntu <<>> 1.1.1.1
        ;; global options: +cmd
        ;; connection timed out; no servers could be reached
      
      For comparison, if none of the service IPs is used, and we tell nslookup
      to use 8.8.8.8 directly it works just fine, of course:
      
        # nslookup 1.1.1.1 8.8.8.8
        1.1.1.1.in-addr.arpa	name = one.one.one.one.
      
      In order to fix this and thus act more transparent to the application,
      this needs reverse translation on recvmsg() side. A minimal fix for this
      API is to add similar recvmsg() hooks behind the BPF cgroups static key
      such that the program can track state and replace the current sockaddr_in{,6}
      with the original service IP. From BPF side, this basically tracks the
      service tuple plus socket cookie in an LRU map where the reverse NAT can
      then be retrieved via map value as one example. Side-note: the BPF cgroups
      static key should be converted to a per-hook static key in future.
      
      Same example after this fix:
      
        # cilium service list
        ID   Frontend            Backend
        1    147.75.207.207:53   1 => 8.8.8.8:53
        2    147.75.207.208:53   1 => 8.8.8.8:53
      
      Lookups work fine now:
      
        # nslookup 1.1.1.1
        1.1.1.1.in-addr.arpa    name = one.one.one.one.
      
        Authoritative answers can be found from:
      
        # dig 1.1.1.1
      
        ; <<>> DiG 9.11.3-1ubuntu1.7-Ubuntu <<>> 1.1.1.1
        ;; global options: +cmd
        ;; Got answer:
        ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 51550
        ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
      
        ;; OPT PSEUDOSECTION:
        ; EDNS: version: 0, flags:; udp: 512
        ;; QUESTION SECTION:
        ;1.1.1.1.                       IN      A
      
        ;; AUTHORITY SECTION:
        .                       23426   IN      SOA     a.root-servers.net. nstld.verisign-grs.com. 2019052001 1800 900 604800 86400
      
        ;; Query time: 17 msec
        ;; SERVER: 147.75.207.207#53(147.75.207.207)
        ;; WHEN: Tue May 21 12:59:38 UTC 2019
        ;; MSG SIZE  rcvd: 111
      
      And from an actual packet level it shows that we're using the back end
      server when talking via 147.75.207.20{7,8} front end:
      
        # tcpdump -i any udp
        [...]
        12:59:52.698732 IP foo.42011 > google-public-dns-a.google.com.domain: 18803+ PTR? 1.1.1.1.in-addr.arpa. (38)
        12:59:52.698735 IP foo.42011 > google-public-dns-a.google.com.domain: 18803+ PTR? 1.1.1.1.in-addr.arpa. (38)
        12:59:52.701208 IP google-public-dns-a.google.com.domain > foo.42011: 18803 1/0/0 PTR one.one.one.one. (67)
        12:59:52.701208 IP google-public-dns-a.google.com.domain > foo.42011: 18803 1/0/0 PTR one.one.one.one. (67)
        [...]
      
      In order to be flexible and to have same semantics as in sendmsg BPF
      programs, we only allow return codes in [1,1] range. In the sendmsg case
      the program is called if msg->msg_name is present which can be the case
      in both, connected and unconnected UDP.
      
      The former only relies on the sockaddr_in{,6} passed via connect(2) if
      passed msg->msg_name was NULL. Therefore, on recvmsg side, we act in similar
      way to call into the BPF program whenever a non-NULL msg->msg_name was
      passed independent of sk->sk_state being TCP_ESTABLISHED or not. Note
      that for TCP case, the msg->msg_name is ignored in the regular recvmsg
      path and therefore not relevant.
      
      For the case of ip{,v6}_recv_error() paths, picked up via MSG_ERRQUEUE,
      the hook is not called. This is intentional as it aligns with the same
      semantics as in case of TCP cgroup BPF hooks right now. This might be
      better addressed in future through a different bpf_attach_type such
      that this case can be distinguished from the regular recvmsg paths,
      for example.
      
      Fixes: 1cedee13 ("bpf: Hooks for sys_sendmsg")
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAndrey Ignatov <rdna@fb.com>
      Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Acked-by: default avatarMartynas Pumputis <m@lambda.lt>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      983695fa
  2. 05 Jun, 2019 2 commits
    • Krzesimir Nowak's avatar
      tools: bpftool: Fix JSON output when lookup fails · 1884c066
      Krzesimir Nowak authored
      In commit 9a5ab8bf ("tools: bpftool: turn err() and info() macros
      into functions") one case of error reporting was special cased, so it
      could report a lookup error for a specific key when dumping the map
      element. What the code forgot to do is to wrap the key and value keys
      into a JSON object, so an example output of pretty JSON dump of a
      sockhash map (which does not support looking up its values) is:
      
      [
          "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x00"
          ],
          "value": {
              "error": "Operation not supported"
          },
          "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x01"
          ],
          "value": {
              "error": "Operation not supported"
          }
      ]
      
      Note the key-value pairs inside the toplevel array. They should be
      wrapped inside a JSON object, otherwise it is an invalid JSON. This
      commit fixes this, so the output now is:
      
      [{
              "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x00"
              ],
              "value": {
                  "error": "Operation not supported"
              }
          },{
              "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x01"
              ],
              "value": {
                  "error": "Operation not supported"
              }
          }
      ]
      
      Fixes: 9a5ab8bf ("tools: bpftool: turn err() and info() macros into functions")
      Cc: Quentin Monnet <quentin.monnet@netronome.com>
      Signed-off-by: default avatarKrzesimir Nowak <krzesimir@kinvolk.io>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      1884c066
    • Hangbin Liu's avatar
      selftests/bpf: move test_lirc_mode2_user to TEST_GEN_PROGS_EXTENDED · 25a7991c
      Hangbin Liu authored
      test_lirc_mode2_user is included in test_lirc_mode2.sh test and should
      not be run directly.
      
      Fixes: 6bdd533c ("bpf: add selftest for lirc_mode2 type program")
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      25a7991c
  3. 03 Jun, 2019 3 commits
    • Alexei Starovoitov's avatar
      Merge branch 'reuseport-fixes' · e7f3dd28
      Alexei Starovoitov authored
      Martin Lau says:
      
      ====================
      s series has fixes when running reuseport's bpf_prog for udp lookup.
      If there is reuseport's bpf_prog, the common issue is the reuseport code
      path expects skb->data pointing to the transport header (udphdr here).
      A couple of commits broke this expectation.  The issue is specific
      to running bpf_prog, so bpf tag is used for this series.
      
      Please refer to the individual commit message for details.
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      e7f3dd28
    • Martin KaFai Lau's avatar
      bpf: udp: Avoid calling reuseport's bpf_prog from udp_gro · 257a525f
      Martin KaFai Lau authored
      When the commit a6024562 ("udp: Add GRO functions to UDP socket")
      added udp[46]_lib_lookup_skb to the udp_gro code path, it broke
      the reuseport_select_sock() assumption that skb->data is pointing
      to the transport header.
      
      This patch follows an earlier __udp6_lib_err() fix by
      passing a NULL skb to avoid calling the reuseport's bpf_prog.
      
      Fixes: a6024562 ("udp: Add GRO functions to UDP socket")
      Cc: Tom Herbert <tom@herbertland.com>
      Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      257a525f
    • Martin KaFai Lau's avatar
      bpf: udp: ipv6: Avoid running reuseport's bpf_prog from __udp6_lib_err · 4ac30c4b
      Martin KaFai Lau authored
      __udp6_lib_err() may be called when handling icmpv6 message. For example,
      the icmpv6 toobig(type=2).  __udp6_lib_lookup() is then called
      which may call reuseport_select_sock().  reuseport_select_sock() will
      call into a bpf_prog (if there is one).
      
      reuseport_select_sock() is expecting the skb->data pointing to the
      transport header (udphdr in this case).  For example, run_bpf_filter()
      is pulling the transport header.
      
      However, in the __udp6_lib_err() path, the skb->data is pointing to the
      ipv6hdr instead of the udphdr.
      
      One option is to pull and push the ipv6hdr in __udp6_lib_err().
      Instead of doing this, this patch follows how the original
      commit 538950a1 ("soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF")
      was done in IPv4, which has passed a NULL skb pointer to
      reuseport_select_sock().
      
      Fixes: 538950a1 ("soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF")
      Cc: Craig Gallek <kraig@google.com>
      Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Acked-by: default avatarCraig Gallek <kraig@google.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      4ac30c4b
  4. 01 Jun, 2019 2 commits
    • Luke Nelson's avatar
      bpf, riscv: clear high 32 bits for ALU32 add/sub/neg/lsh/rsh/arsh · 1e692f09
      Luke Nelson authored
      In BPF, 32-bit ALU operations should zero-extend their results into
      the 64-bit registers.
      
      The current BPF JIT on RISC-V emits incorrect instructions that perform
      sign extension only (e.g., addw, subw) on 32-bit add, sub, lsh, rsh,
      arsh, and neg. This behavior diverges from the interpreter and JITs
      for other architectures.
      
      This patch fixes the bugs by performing zero extension on the destination
      register of 32-bit ALU operations.
      
      Fixes: 2353ecc6 ("bpf, riscv: add BPF JIT for RV64G")
      Cc: Xi Wang <xi.wang@gmail.com>
      Signed-off-by: default avatarLuke Nelson <luke.r.nels@gmail.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Acked-by: default avatarBjörn Töpel <bjorn.topel@gmail.com>
      Reviewed-by: default avatarPalmer Dabbelt <palmer@sifive.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      1e692f09
    • Michal Rostecki's avatar
      libbpf: Return btf_fd for load_sk_storage_btf · cfd49210
      Michal Rostecki authored
      Before this change, function load_sk_storage_btf expected that
      libbpf__probe_raw_btf was returning a BTF descriptor, but in fact it was
      returning an information about whether the probe was successful (0 or
      1). load_sk_storage_btf was using that value as an argument of the close
      function, which was resulting in closing stdout and thus terminating the
      process which called that function.
      
      That bug was visible in bpftool. `bpftool feature` subcommand was always
      exiting too early (because of closed stdout) and it didn't display all
      requested probes. `bpftool -j feature` or `bpftool -p feature` were not
      returning a valid json object.
      
      This change renames the libbpf__probe_raw_btf function to
      libbpf__load_raw_btf, which now returns a BTF descriptor, as expected in
      load_sk_storage_btf.
      
      v2:
      - Fix typo in the commit message.
      
      v3:
      - Simplify BTF descriptor handling in bpf_object__probe_btf_* functions.
      - Rename libbpf__probe_raw_btf function to libbpf__load_raw_btf and
      return a BTF descriptor.
      
      v4:
      - Fix typo in the commit message.
      
      Fixes: d7c4b398 ("libbpf: detect supported kernel BTF features and sanitize BTF")
      Signed-off-by: default avatarMichal Rostecki <mrostecki@opensuse.org>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      cfd49210
  5. 29 May, 2019 4 commits
  6. 24 May, 2019 1 commit
    • John Fastabend's avatar
      bpf: sockmap, fix use after free from sleep in psock backlog workqueue · bd95e678
      John Fastabend authored
      Backlog work for psock (sk_psock_backlog) might sleep while waiting
      for memory to free up when sending packets. However, while sleeping
      the socket may be closed and removed from the map by the user space
      side.
      
      This breaks an assumption in sk_stream_wait_memory, which expects the
      wait queue to be still there when it wakes up resulting in a
      use-after-free shown below. To fix his mark sendmsg as MSG_DONTWAIT
      to avoid the sleep altogether. We already set the flag for the
      sendpage case but we missed the case were sendmsg is used.
      Sockmap is currently the only user of skb_send_sock_locked() so only
      the sockmap paths should be impacted.
      
      ==================================================================
      BUG: KASAN: use-after-free in remove_wait_queue+0x31/0x70
      Write of size 8 at addr ffff888069a0c4e8 by task kworker/0:2/110
      
      CPU: 0 PID: 110 Comm: kworker/0:2 Not tainted 5.0.0-rc2-00335-g28f9d1a3-dirty #14
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-2.fc27 04/01/2014
      Workqueue: events sk_psock_backlog
      Call Trace:
       print_address_description+0x6e/0x2b0
       ? remove_wait_queue+0x31/0x70
       kasan_report+0xfd/0x177
       ? remove_wait_queue+0x31/0x70
       ? remove_wait_queue+0x31/0x70
       remove_wait_queue+0x31/0x70
       sk_stream_wait_memory+0x4dd/0x5f0
       ? sk_stream_wait_close+0x1b0/0x1b0
       ? wait_woken+0xc0/0xc0
       ? tcp_current_mss+0xc5/0x110
       tcp_sendmsg_locked+0x634/0x15d0
       ? tcp_set_state+0x2e0/0x2e0
       ? __kasan_slab_free+0x1d1/0x230
       ? kmem_cache_free+0x70/0x140
       ? sk_psock_backlog+0x40c/0x4b0
       ? process_one_work+0x40b/0x660
       ? worker_thread+0x82/0x680
       ? kthread+0x1b9/0x1e0
       ? ret_from_fork+0x1f/0x30
       ? check_preempt_curr+0xaf/0x130
       ? iov_iter_kvec+0x5f/0x70
       ? kernel_sendmsg_locked+0xa0/0xe0
       skb_send_sock_locked+0x273/0x3c0
       ? skb_splice_bits+0x180/0x180
       ? start_thread+0xe0/0xe0
       ? update_min_vruntime.constprop.27+0x88/0xc0
       sk_psock_backlog+0xb3/0x4b0
       ? strscpy+0xbf/0x1e0
       process_one_work+0x40b/0x660
       worker_thread+0x82/0x680
       ? process_one_work+0x660/0x660
       kthread+0x1b9/0x1e0
       ? __kthread_create_on_node+0x250/0x250
       ret_from_fork+0x1f/0x30
      
      Fixes: 20bf50de ("skbuff: Function to send an skbuf on a socket")
      Reported-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Tested-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      bd95e678
  7. 23 May, 2019 3 commits
    • Jakub Sitnicki's avatar
      bpf: sockmap, restore sk_write_space when psock gets dropped · 186bcc3d
      Jakub Sitnicki authored
      Once psock gets unlinked from its sock (sk_psock_drop), user-space can
      still trigger a call to sk->sk_write_space by setting TCP_NOTSENT_LOWAT
      socket option. This causes a null-ptr-deref because we try to read
      psock->saved_write_space from sk_psock_write_space:
      
      ==================================================================
      BUG: KASAN: null-ptr-deref in sk_psock_write_space+0x69/0x80
      Read of size 8 at addr 00000000000001a0 by task sockmap-echo/131
      
      CPU: 0 PID: 131 Comm: sockmap-echo Not tainted 5.2.0-rc1-00094-gf49aa1de #81
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      ?-20180724_192412-buildhw-07.phx2.fedoraproject.org-1.fc29 04/01/2014
      Call Trace:
       ? sk_psock_write_space+0x69/0x80
       __kasan_report.cold.2+0x5/0x3f
       ? sk_psock_write_space+0x69/0x80
       kasan_report+0xe/0x20
       sk_psock_write_space+0x69/0x80
       tcp_setsockopt+0x69a/0xfc0
       ? tcp_shutdown+0x70/0x70
       ? fsnotify+0x5b0/0x5f0
       ? remove_wait_queue+0x90/0x90
       ? __fget_light+0xa5/0xf0
       __sys_setsockopt+0xe6/0x180
       ? sockfd_lookup_light+0xb0/0xb0
       ? vfs_write+0x195/0x210
       ? ksys_write+0xc9/0x150
       ? __x64_sys_read+0x50/0x50
       ? __bpf_trace_x86_fpu+0x10/0x10
       __x64_sys_setsockopt+0x61/0x70
       do_syscall_64+0xc5/0x520
       ? vmacache_find+0xc0/0x110
       ? syscall_return_slowpath+0x110/0x110
       ? handle_mm_fault+0xb4/0x110
       ? entry_SYSCALL_64_after_hwframe+0x3e/0xbe
       ? trace_hardirqs_off_caller+0x4b/0x120
       ? trace_hardirqs_off_thunk+0x1a/0x3a
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x7f2e5e7cdcce
      Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb b1 66 2e 0f 1f 84 00 00 00 00 00
      0f 1f 44 00 00 f3 0f 1e fa 49 89 ca b8 36 00 00 00 0f 05 <48> 3d 01 f0 ff
      ff 73 01 c3 48 8b 0d 8a 11 0c 00 f7 d8 64 89 01 48
      RSP: 002b:00007ffed011b778 EFLAGS: 00000206 ORIG_RAX: 0000000000000036
      RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f2e5e7cdcce
      RDX: 0000000000000019 RSI: 0000000000000006 RDI: 0000000000000007
      RBP: 00007ffed011b790 R08: 0000000000000004 R09: 00007f2e5e84ee80
      R10: 00007ffed011b788 R11: 0000000000000206 R12: 00007ffed011b78c
      R13: 00007ffed011b788 R14: 0000000000000007 R15: 0000000000000068
      ==================================================================
      
      Restore the saved sk_write_space callback when psock is being dropped to
      fix the crash.
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      186bcc3d
    • Björn Töpel's avatar
      selftests: bpf: add zero extend checks for ALU32 and/or/xor · 00d83045
      Björn Töpel authored
      Add three tests to test_verifier/basic_instr that make sure that the
      high 32-bits of the destination register is cleared after an ALU32
      and/or/xor.
      Signed-off-by: default avatarBjörn Töpel <bjorn.topel@gmail.com>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      00d83045
    • Björn Töpel's avatar
      bpf, riscv: clear target register high 32-bits for and/or/xor on ALU32 · fe121ee5
      Björn Töpel authored
      When using 32-bit subregisters (ALU32), the RISC-V JIT would not clear
      the high 32-bits of the target register and therefore generate
      incorrect code.
      
      E.g., in the following code:
      
        $ cat test.c
        unsigned int f(unsigned long long a,
        	       unsigned int b)
        {
        	return (unsigned int)a & b;
        }
      
        $ clang-9 -target bpf -O2 -emit-llvm -S test.c -o - | \
        	llc-9 -mattr=+alu32 -mcpu=v3
        	.text
        	.file	"test.c"
        	.globl	f
        	.p2align	3
        	.type	f,@function
        f:
        	r0 = r1
        	w0 &= w2
        	exit
        .Lfunc_end0:
        	.size	f, .Lfunc_end0-f
      
      The JIT would not clear the high 32-bits of r0 after the
      and-operation, which in this case might give an incorrect return
      value.
      
      After this patch, that is not the case, and the upper 32-bits are
      cleared.
      Reported-by: default avatarJiong Wang <jiong.wang@netronome.com>
      Fixes: 2353ecc6 ("bpf, riscv: add BPF JIT for RV64G")
      Signed-off-by: default avatarBjörn Töpel <bjorn.topel@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      fe121ee5
  8. 21 May, 2019 18 commits
  9. 20 May, 2019 6 commits
    • Gustavo A. R. Silva's avatar
      vlan: Mark expected switch fall-through · fa2c52be
      Gustavo A. R. Silva authored
      In preparation to enabling -Wimplicit-fallthrough, mark switch
      cases where we are expecting to fall through.
      
      This patch fixes the following warning:
      
      net/8021q/vlan_dev.c: In function ‘vlan_dev_ioctl’:
      net/8021q/vlan_dev.c:374:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
         if (!net_eq(dev_net(dev), &init_net))
            ^
      net/8021q/vlan_dev.c:376:2: note: here
        case SIOCGMIIPHY:
        ^~~~
      
      Warning level 3 was used: -Wimplicit-fallthrough=3
      
      This patch is part of the ongoing efforts to enable
      -Wimplicit-fallthrough.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fa2c52be
    • Gustavo A. R. Silva's avatar
      macvlan: Mark expected switch fall-through · 02596252
      Gustavo A. R. Silva authored
      In preparation to enabling -Wimplicit-fallthrough, mark switch
      cases where we are expecting to fall through.
      
      This patch fixes the following warning:
      
      drivers/net/macvlan.c: In function ‘macvlan_do_ioctl’:
      drivers/net/macvlan.c:839:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
         if (!net_eq(dev_net(dev), &init_net))
            ^
      drivers/net/macvlan.c:841:2: note: here
        case SIOCGHWTSTAMP:
        ^~~~
      
      Warning level 3 was used: -Wimplicit-fallthrough=3
      
      This patch is part of the ongoing efforts to enable
      -Wimplicit-fallthrough.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      02596252
    • Erez Alfasi's avatar
      net/mlx4_en: ethtool, Remove unsupported SFP EEPROM high pages query · 135dd959
      Erez Alfasi authored
      Querying EEPROM high pages data for SFP module is currently
      not supported by our driver but is still tried, resulting in
      invalid FW queries.
      
      Set the EEPROM ethtool data length to 256 for SFP module to
      limit the reading for page 0 only and prevent invalid FW queries.
      
      Fixes: 7202da8b ("ethtool, net/mlx4_en: Cable info, get_module_info/eeprom ethtool support")
      Signed-off-by: default avatarErez Alfasi <ereza@mellanox.com>
      Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      135dd959
    • Junwei Hu's avatar
      tipc: fix modprobe tipc failed after switch order of device registration · 526f5b85
      Junwei Hu authored
      Error message printed:
      modprobe: ERROR: could not insert 'tipc': Address family not
      supported by protocol.
      when modprobe tipc after the following patch: switch order of
      device registration, commit 7e27e8d6
      ("tipc: switch order of device registration to fix a crash")
      
      Because sock_create_kern(net, AF_TIPC, ...) called by
      tipc_topsrv_create_listener() in the initialization process
      of tipc_init_net(), so tipc_socket_init() must be execute before that.
      Meanwhile, tipc_net_id need to be initialized when sock_create()
      called, and tipc_socket_init() is no need to be called for each namespace.
      
      I add a variable tipc_topsrv_net_ops, and split the
      register_pernet_subsys() of tipc into two parts, and split
      tipc_socket_init() with initialization of pernet params.
      
      By the way, I fixed resources rollback error when tipc_bcast_init()
      failed in tipc_init_net().
      
      Fixes: 7e27e8d6 ("tipc: switch order of device registration to fix a crash")
      Signed-off-by: default avatarJunwei Hu <hujunwei4@huawei.com>
      Reported-by: default avatarWang Wang <wangwang2@huawei.com>
      Reported-by: syzbot+1e8114b61079bfe9cbc5@syzkaller.appspotmail.com
      Reviewed-by: default avatarKang Zhou <zhoukang7@huawei.com>
      Reviewed-by: default avatarSuanming Mou <mousuanming@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      526f5b85
    • Linus Torvalds's avatar
      Merge tag 'for-5.2-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux · f49aa1de
      Linus Torvalds authored
      Pull btrfs fixes from David Sterba:
       "Notable highlights:
      
         - fixes for some long-standing bugs in fsync that were quite hard to
           catch but now finaly fixed
      
         - some fixups to error handling paths that did not properly clean up
           (locking, memory)
      
         - fix to space reservation for inheriting properties"
      
      * tag 'for-5.2-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        Btrfs: tree-checker: detect file extent items with overlapping ranges
        Btrfs: fix race between ranged fsync and writeback of adjacent ranges
        Btrfs: avoid fallback to transaction commit during fsync of files with holes
        btrfs: extent-tree: Fix a bug that btrfs is unable to add pinned bytes
        btrfs: sysfs: don't leak memory when failing add fsid
        btrfs: sysfs: Fix error path kobject memory leak
        Btrfs: do not abort transaction at btrfs_update_root() after failure to COW path
        btrfs: use the existing reserved items for our first prop for inheritance
        btrfs: don't double unlock on error in btrfs_punch_hole
        btrfs: Check the compression level before getting a workspace
      f49aa1de
    • Linus Torvalds's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net · 78e03651
      Linus Torvalds authored
      Pull networking fixes from David Miller:1) Use after free in __dev_map_entry_free(), from Eric Dumazet.
      
       1) Use after free in __dev_map_entry_free(), from Eric Dumazet.
      
       2) Fix TCP retransmission timestamps on passive Fast Open, from Yuchung
          Cheng.
      
       3) Orphan NFC, we'll take the patches directly into my tree. From
          Johannes Berg.
      
       4) We can't recycle cloned TCP skbs, from Eric Dumazet.
      
       5) Some flow dissector bpf test fixes, from Stanislav Fomichev.
      
       6) Fix RCU marking and warnings in rhashtable, from Herbert Xu.
      
       7) Fix some potential fib6 leaks, from Eric Dumazet.
      
       8) Fix a _decode_session4 uninitialized memory read bug fix that got
          lost in a merge. From Florian Westphal.
      
       9) Fix ipv6 source address routing wrt. exception route entries, from
          Wei Wang.
      
      10) The netdev_xmit_more() conversion was not done %100 properly in mlx5
          driver, fix from Tariq Toukan.
      
      11) Clean up botched merge on netfilter kselftest, from Florian
          Westphal.
      
      * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (74 commits)
        of_net: fix of_get_mac_address retval if compiled without CONFIG_OF
        net: fix kernel-doc warnings for socket.c
        net: Treat sock->sk_drops as an unsigned int when printing
        kselftests: netfilter: fix leftover net/net-next merge conflict
        mlxsw: core: Prevent reading unsupported slave address from SFP EEPROM
        mlxsw: core: Prevent QSFP module initialization for old hardware
        vsock/virtio: Initialize core virtio vsock before registering the driver
        net/mlx5e: Fix possible modify header actions memory leak
        net/mlx5e: Fix no rewrite fields with the same match
        net/mlx5e: Additional check for flow destination comparison
        net/mlx5e: Add missing ethtool driver info for representors
        net/mlx5e: Fix number of vports for ingress ACL configuration
        net/mlx5e: Fix ethtool rxfh commands when CONFIG_MLX5_EN_RXNFC is disabled
        net/mlx5e: Fix wrong xmit_more application
        net/mlx5: Fix peer pf disable hca command
        net/mlx5: E-Switch, Correct type to u16 for vport_num and int for vport_index
        net/mlx5: Add meaningful return codes to status_to_err function
        net/mlx5: Imply MLXFW in mlx5_core
        Revert "tipc: fix modprobe tipc failed after switch order of device registration"
        vsock/virtio: free packets during the socket release
        ...
      78e03651