Daniel Borkmann
f6fadff33e
tls: fix NULL pointer dereference on poll
...
While hacking on kTLS, I ran into the following panic from an
unprivileged netserver / netperf TCP session:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
PGD 800000037f378067 P4D 800000037f378067 PUD 3c0e61067 PMD 0
Oops: 0010 [#1 ] SMP KASAN PTI
CPU: 1 PID: 2289 Comm: netserver Not tainted 4.17.0+ #139
Hardware name: LENOVO 20FBCTO1WW/20FBCTO1WW, BIOS N1FET47W (1.21 ) 11/28/2016
RIP: 0010: (null)
Code: Bad RIP value.
RSP: 0018:ffff88036abcf740 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: ffff88036f5f6800 RCX: 1ffff1006debed26
RDX: ffff88036abcf920 RSI: ffff8803cb1a4f00 RDI: ffff8803c258c280
RBP: ffff8803c258c280 R08: ffff8803c258c280 R09: ffffed006f559d48
R10: ffff88037aacea43 R11: ffffed006f559d49 R12: ffff8803c258c280
R13: ffff8803cb1a4f20 R14: 00000000000000db R15: ffffffffc168a350
FS: 00007f7e631f4700(0000) GS:ffff8803d1c80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 00000003ccf64005 CR4: 00000000003606e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
? tls_sw_poll+0xa4/0x160 [tls]
? sock_poll+0x20a/0x680
? do_select+0x77b/0x11a0
? poll_schedule_timeout.constprop.12+0x130/0x130
? pick_link+0xb00/0xb00
? read_word_at_a_time+0x13/0x20
? vfs_poll+0x270/0x270
? deref_stack_reg+0xad/0xe0
? __read_once_size_nocheck.constprop.6+0x10/0x10
[...]
Debugging further, it turns out that calling into ctx->sk_poll() is
invalid since sk_poll itself is NULL which was saved from the original
TCP socket in order for tls_sw_poll() to invoke it.
Looks like the recent conversion from poll to poll_mask callback started
in 1525242310 ("net: add support for ->poll_mask in proto_ops") missed
to eventually convert kTLS, too: TCP's ->poll was converted over to the
->poll_mask in commit 2c7d3daceb ("net/tcp: convert to ->poll_mask")
and therefore kTLS wrongly saved the ->poll old one which is now NULL.
Convert kTLS over to use ->poll_mask instead. Also instead of POLLIN |
POLLRDNORM use the proper EPOLLIN | EPOLLRDNORM bits as the case in
tcp_poll_mask() as well that is mangled here.
Fixes: 2c7d3daceb ("net/tcp: convert to ->poll_mask")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dave Watson <davejwatson@fb.com>
Tested-by: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-06-11 16:29:54 -07:00
..
9p
bluetooth
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
2018-06-06 18:39:49 -07:00
caif
caif: reduce stack size with KASAN
2018-01-19 14:02:12 -05:00
iucv
net/iucv: convert to ->poll_mask
2018-05-26 09:16:44 +02:00
netfilter
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
2018-06-11 14:24:32 -07:00
netns
netfilter: nf_tables: fix chain dependency validation
2018-06-01 09:46:22 +02:00
nfc
phonet
proc: introduce proc_create_net{,_data}
2018-05-16 07:24:30 +02:00
sctp
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
2018-06-06 18:39:49 -07:00
tc_act
net/sched: act_csum: don't use spinlock in the fast path
2018-01-23 19:51:46 -05:00
6lowpan.h
act_api.h
net/sched: remove tcf_idr_cleanup()
2018-03-23 21:52:19 -04:00
addrconf.h
net/ipv6: Add support for specifying metric of connected routes
2018-05-29 10:12:45 -04:00
af_ieee802154.h
af_rxrpc.h
rxrpc, afs: Use debug_ids rather than pointers in traces
2018-03-27 23:03:00 +01:00
af_unix.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
af_vsock.h
VSOCK: use TCP state constants for sk_state
2017-10-05 18:44:17 -07:00
ah.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
arp.h
ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY
2018-01-15 14:53:43 -05:00
atmclip.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
ax25.h
proc: introduce proc_create_seq{,_data}
2018-05-16 07:23:35 +02:00
ax88796.h
net-next: ax88796: add interrupt status callback to platform data
2018-04-19 16:11:11 -04:00
bond_3ad.h
bond_alb.h
bond_options.h
bonding.h
bonding: allow use of tx hashing in balance-alb
2018-05-16 12:15:11 -04:00
busy_poll.h
net: refactor socket_poll
2018-05-26 09:16:44 +02:00
calipso.h
cfg80211-wext.h
cfg80211.h
nl80211: Update ERP info using NL80211_CMD_UPDATE_CONNECT_PARAMS
2018-05-23 11:21:35 +02:00
cfg802154.h
checksum.h
cipso_ipv4.h
cls_cgroup.h
codel.h
codel_impl.h
codel_qdisc.h
compat.h
net: remove compat_sys_*() prototypes from net/compat.h
2018-04-02 20:16:17 +02:00
datalink.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
dcbevent.h
dcbnl.h
net/dcb: Add dcbnl buffer attribute
2018-05-24 14:22:59 -07:00
devlink.h
devlink: Add extack to reload and port_{un, }split operations
2018-06-05 12:32:37 -04:00
dn.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
2017-11-04 09:26:51 +09:00
dn_dev.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
dn_fib.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
dn_neigh.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
dn_nsp.h
net/decnet: Convert timers to use timer_setup()
2017-10-18 12:39:36 +01:00
dn_route.h
decnet: Move dn_next into decnet route structure.
2017-11-30 09:54:25 -05:00
dsa.h
net: dsa: Plug in PHYLINK support
2018-05-11 12:03:06 -04:00
dsfield.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
dst.h
net: core: dst: Add kernel-doc for 'net' parameter
2018-03-05 12:52:45 -05:00
dst_cache.h
net: core: dst_cache_set_ip6: Rename 'addr' parameter to 'saddr' for consistency
2018-03-05 12:52:45 -05:00
dst_metadata.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
2017-11-04 09:26:51 +09:00
dst_ops.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
erspan.h
erspan: set bso bit based on mirrored packet's len
2018-05-20 18:31:42 -04:00
esp.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
ethoc.h
inet: whitespace cleanup
2018-02-28 11:43:28 -05:00
failover.h
net: Introduce generic failover module
2018-05-28 22:59:54 -04:00
fib_notifier.h
net: Add extack to fib_notifier_info
2017-11-01 11:50:43 +09:00
fib_rules.h
net: fib_rules: add extack support
2018-04-23 10:21:24 -04:00
firewire.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
flow.h
net: Remove unused get_hash_from_flow functions
2018-03-04 13:04:23 -05:00
flow_dissector.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
2018-05-11 20:53:22 -04:00
fou.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
fq.h
fq: support filtering a given tin
2017-10-11 09:49:34 +02:00
fq_impl.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
2017-10-30 21:09:24 +09:00
garp.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
gen_stats.h
net: sched: add support for TCQ_F_NOLOCK subqueues to sch_mq
2017-12-08 13:32:26 -05:00
genetlink.h
genetlink: fix genlmsg_nlhdr()
2017-11-16 10:49:00 +09:00
geneve.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
gre.h
net: GRE: Add is_gretap_dev, is_ip6gretap_dev
2018-02-27 14:46:26 -05:00
gro_cells.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
gtp.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
gue.h
fou: fix some member types in guehdr
2017-12-11 14:10:06 -05:00
hwbm.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
icmp.h
ieee80211_radiotap.h
mac80211: support reporting A-MPDU EOF bit value/known
2018-02-22 21:13:02 +01:00
ieee802154_netdev.h
if_inet6.h
net/ipv6: Add support for specifying metric of connected routes
2018-05-29 10:12:45 -04:00
ife.h
net: sched: ife: handle malformed tlv length
2018-04-22 21:12:00 -04:00
ila.h
inet6_connection_sock.h
inet6_hashtables.h
inet_common.h
net: Introduce __inet_bind() and __inet6_bind
2018-03-31 02:15:43 +02:00
inet_connection_sock.h
net: ipv4: remove define INET_CSK_DEBUG and unnecessary EXPORT_SYMBOL
2018-05-10 17:43:55 -04:00
inet_ecn.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
2017-11-04 09:26:51 +09:00
inet_frag.h
inet: frags: reorganize struct netns_frags
2018-03-31 23:25:39 -04:00
inet_hashtables.h
inet: Add a 2nd listener hashtable (port+addr)
2017-12-03 10:18:28 -05:00
inet_sock.h
udp: generate gso with UDP_SEGMENT
2018-04-26 15:08:04 -04:00
inet_timewait_sock.h
net-tcp: remove useless tw_timeout field
2018-06-05 10:45:24 -04:00
inetpeer.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
ip.h
ipv4: support sport, dport and ip_proto in RTM_GETROUTE
2018-05-23 15:14:12 -04:00
ip6_checksum.h
ip6_fib.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
2018-06-06 18:39:49 -07:00
ip6_route.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
2018-05-24 22:20:51 -04:00
ip6_tunnel.h
ip6_gre: add erspan v2 support
2017-12-15 12:34:00 -05:00
ip_fib.h
net/ipv4: Add helper to return path MTU based on fib result
2018-05-22 10:51:09 +02:00
ip_tunnels.h
net/ipv4: Update ip_tunnel_metadata_cnt static key to modern api
2018-05-10 15:13:33 -04:00
ip_vs.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
2018-06-11 14:24:32 -07:00
ipcomp.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
ipconfig.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
ipv6.h
ipv6: omit traffic class when calculating flow hash
2018-06-04 13:21:18 -04:00
ipx.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
iw_handler.h
net: Spelling s/stucture/structure/
2018-03-27 09:51:23 +02:00
kcm.h
l3mdev.h
lapb.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
lib80211.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
llc.h
llc_c_ac.h
net: LLC: Convert timers to use timer_setup()
2017-10-25 12:06:25 +09:00
llc_c_ev.h
llc_c_st.h
llc_conn.h
llc: delete timers synchronously in llc_sk_free()
2018-04-22 14:55:03 -04:00
llc_if.h
llc_pdu.h
llc_s_ac.h
llc_s_ev.h
llc_s_st.h
llc_sap.h
lwtunnel.h
net: Move ipv4 set_lwt_redirect helper to lwtunnel
2018-02-14 14:43:32 -05:00
mac80211.h
mac80211: Support adding duration for prepare_tx() callback
2018-05-23 11:06:10 +02:00
mac802154.h
mip6.h
mld.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
mpls.h
mpls_iptunnel.h
mrp.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
ncsi.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
ndisc.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
neighbour.h
neighbour: support for NTF_EXT_LEARNED flag
2018-04-25 13:19:59 -04:00
net_failover.h
net: Introduce net_failover driver
2018-05-28 22:59:54 -04:00
net_namespace.h
net: Introduce net_rwsem to protect net_namespace_list
2018-03-29 13:47:53 -04:00
net_ratelimit.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
netevent.h
net/ipv6: Add support for path selection using hash of 5-tuple
2018-03-04 13:04:23 -05:00
netlabel.h
netlink.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
netprio_cgroup.h
netrom.h
proc: introduce proc_create_seq{,_data}
2018-05-16 07:23:35 +02:00
nexthop.h
net: fix rtnh_ok()
2018-04-07 22:32:31 -04:00
nl802154.h
nsh.h
openvswitch: enable NSH support
2017-11-08 16:12:33 +09:00
p8022.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
page_pool.h
xdp: introduce xdp_return_frame_rx_napi
2018-05-24 18:36:15 -07:00
ping.h
ipv{4,6}/ping: simplify proc file creation
2018-05-16 07:23:35 +02:00
pkt_cls.h
net: sched: mq: request stats from offloads
2018-05-29 09:49:16 -04:00
pkt_sched.h
net: remove prototype of qdisc_lookup_class()
2018-01-16 14:56:54 -05:00
pptp.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
protocol.h
psample.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
psnap.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
raw.h
ipv{4,6}/raw: simplify ѕeq_file code
2018-05-16 07:23:35 +02:00
rawv6.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
red.h
net_sched: red: Avoid illegal values
2017-12-05 14:37:13 -05:00
regulatory.h
cfg80211: read wmm rules from regulatory database
2018-03-29 11:11:40 +02:00
request_sock.h
tcp: socket option to set TCP fast open key
2017-10-20 13:21:36 +01:00
rose.h
proc: introduce proc_create_seq{,_data}
2018-05-16 07:23:35 +02:00
route.h
net/ipv4: Add support for specifying metric of connected routes
2018-05-29 10:12:45 -04:00
rsi_91x.h
Bluetooth: btrsi: add new rsi bluetooth driver
2018-03-13 18:37:02 +02:00
rtnetlink.h
rtnetlink: Remove VLA usage
2018-05-31 22:48:46 -04:00
sch_generic.h
net: sched: add qstats.qlen to qlen
2018-05-29 09:49:15 -04:00
scm.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
secure_seq.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
seg6.h
ipv6: sr: export function lookup_nexthop
2018-05-24 11:57:35 +02:00
seg6_hmac.h
seg6_local.h
bpf: Add IPv6 Segment Routing helpers
2018-05-24 11:57:35 +02:00
slhc_vj.h
slip: Check if rstate is initialized before uncompressing
2018-04-11 10:33:46 -04:00
smc.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
snmp.h
sock.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
2018-06-06 18:39:49 -07:00
sock_reuseport.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
Space.h
net/mac89x0: Convert to platform_driver
2018-03-01 21:21:36 -05:00
stp.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
strparser.h
strparser: Add __strp_unpause and use it in ktls.
2018-06-06 14:07:53 -04:00
switchdev.h
switchdev: Add fdb.added_by_user to switchdev notifications
2018-05-03 13:46:47 -04:00
tcp.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
2018-06-06 18:39:49 -07:00
tcp_states.h
tcp: remove the hardcode in the definition of TCPF Macro
2018-02-21 15:06:05 -05:00
timewait_sock.h
tipc.h
flow_dissector: do not rely on implicit casts
2018-05-08 00:02:41 -04:00
tls.h
tls: fix NULL pointer dereference on poll
2018-06-11 16:29:54 -07:00
transp_v6.h
udp: fix rx queue len reported by diag and proc interface
2018-06-08 19:55:15 -04:00
tso.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
tun_proto.h
udp.h
udp: fix rx queue len reported by diag and proc interface
2018-06-08 19:55:15 -04:00
udp_tunnel.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
udplite.h
udplite: fix partial checksum initialization
2018-02-16 15:57:42 -05:00
vsock_addr.h
vxlan.h
vxlan: add ttl inherit support
2018-04-17 13:53:13 -04:00
wext.h
lift handling of SIOCIW... out of dev_ioctl()
2018-01-24 19:13:45 -05:00
wimax.h
x25.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
x25device.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
xdp.h
xdp: add MEM_TYPE_ZERO_COPY
2018-06-05 15:46:26 +02:00
xdp_sock.h
xsk: wire upp Tx zero-copy functions
2018-06-05 15:48:34 +02:00
xfrm.h
audit/stable-4.18 PR 20180605
2018-06-06 16:34:00 -07:00