Skip to content
Snippets Groups Projects
Select Git revision
  • 14d6d86c210aea1a83c19a8f6391ecabcbefed94
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

strncpy_from_user.c

Blame
    • Daniel Xu's avatar
      6fa6d280
      lib/strncpy_from_user.c: Mask out bytes after NUL terminator. · 6fa6d280
      Daniel Xu authored
      
      do_strncpy_from_user() may copy some extra bytes after the NUL
      terminator into the destination buffer. This usually does not matter for
      normal string operations. However, when BPF programs key BPF maps with
      strings, this matters a lot.
      
      A BPF program may read strings from user memory by calling the
      bpf_probe_read_user_str() helper which eventually calls
      do_strncpy_from_user(). The program can then key a map with the
      destination buffer. BPF map keys are fixed-width and string-agnostic,
      meaning that map keys are treated as a set of bytes.
      
      The issue is when do_strncpy_from_user() overcopies bytes after the NUL
      terminator, it can result in seemingly identical strings occupying
      multiple slots in a BPF map. This behavior is subtle and totally
      unexpected by the user.
      
      This commit masks out the bytes following the NUL while preserving
      long-sized stride in the fast path.
      
      Fixes: 6ae08ae3 ("bpf: Add probe_read_{user, kernel} and probe_read_{user, kernel}_str helpers")
      Signed-off-by: default avatarDaniel Xu <dxu@dxuuu.xyz>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/21efc982b3e9f2f7b0379eed642294caaa0c27a7.1605642949.git.dxu@dxuuu.xyz
      6fa6d280
      History
      lib/strncpy_from_user.c: Mask out bytes after NUL terminator.
      Daniel Xu authored
      
      do_strncpy_from_user() may copy some extra bytes after the NUL
      terminator into the destination buffer. This usually does not matter for
      normal string operations. However, when BPF programs key BPF maps with
      strings, this matters a lot.
      
      A BPF program may read strings from user memory by calling the
      bpf_probe_read_user_str() helper which eventually calls
      do_strncpy_from_user(). The program can then key a map with the
      destination buffer. BPF map keys are fixed-width and string-agnostic,
      meaning that map keys are treated as a set of bytes.
      
      The issue is when do_strncpy_from_user() overcopies bytes after the NUL
      terminator, it can result in seemingly identical strings occupying
      multiple slots in a BPF map. This behavior is subtle and totally
      unexpected by the user.
      
      This commit masks out the bytes following the NUL while preserving
      long-sized stride in the fast path.
      
      Fixes: 6ae08ae3 ("bpf: Add probe_read_{user, kernel} and probe_read_{user, kernel}_str helpers")
      Signed-off-by: default avatarDaniel Xu <dxu@dxuuu.xyz>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/21efc982b3e9f2f7b0379eed642294caaa0c27a7.1605642949.git.dxu@dxuuu.xyz
    tcp_ipv6.c 51.37 KiB
    /*
     *	TCP over IPv6
     *	Linux INET6 implementation
     *
     *	Authors:
     *	Pedro Roque		<roque@di.fc.ul.pt>
     *
     *	Based on:
     *	linux/net/ipv4/tcp.c
     *	linux/net/ipv4/tcp_input.c
     *	linux/net/ipv4/tcp_output.c
     *
     *	Fixes:
     *	Hideaki YOSHIFUJI	:	sin6_scope_id support
     *	YOSHIFUJI Hideaki @USAGI and:	Support IPV6_V6ONLY socket option, which
     *	Alexey Kuznetsov		allow both IPv4 and IPv6 sockets to bind
     *					a single port at the same time.
     *	YOSHIFUJI Hideaki @USAGI:	convert /proc/net/tcp6 to seq_file.
     *
     *	This program is free software; you can redistribute it and/or
     *      modify it under the terms of the GNU General Public License
     *      as published by the Free Software Foundation; either version
     *      2 of the License, or (at your option) any later version.
     */
    
    #include <linux/bottom_half.h>
    #include <linux/module.h>
    #include <linux/errno.h>
    #include <linux/types.h>
    #include <linux/socket.h>
    #include <linux/sockios.h>
    #include <linux/net.h>
    #include <linux/jiffies.h>
    #include <linux/in.h>
    #include <linux/in6.h>
    #include <linux/netdevice.h>
    #include <linux/init.h>
    #include <linux/jhash.h>
    #include <linux/ipsec.h>
    #include <linux/times.h>
    #include <linux/slab.h>
    #include <linux/uaccess.h>
    #include <linux/ipv6.h>
    #include <linux/icmpv6.h>
    #include <linux/random.h>
    
    #include <net/tcp.h>
    #include <net/ndisc.h>
    #include <net/inet6_hashtables.h>
    #include <net/inet6_connection_sock.h>
    #include <net/ipv6.h>
    #include <net/transp_v6.h>
    #include <net/addrconf.h>
    #include <net/ip6_route.h>
    #include <net/ip6_checksum.h>
    #include <net/inet_ecn.h>
    #include <net/protocol.h>
    #include <net/xfrm.h>
    #include <net/snmp.h>
    #include <net/dsfield.h>
    #include <net/timewait_sock.h>
    #include <net/inet_common.h>
    #include <net/secure_seq.h>
    #include <net/busy_poll.h>
    
    #include <linux/proc_fs.h>
    #include <linux/seq_file.h>
    
    #include <crypto/hash.h>
    #include <linux/scatterlist.h>