net: Fix use after free by removing length arg from sk_data_ready callbacks.
authorDavid S. Miller <davem@davemloft.net>
Fri, 11 Apr 2014 20:15:36 +0000 (16:15 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 11 Apr 2014 20:15:36 +0000 (16:15 -0400)
commit676d23690fb62b5d51ba5d659935e9f7d9da9f8e
treef6fbceee43e05c724868153ca37b702fb5e43b8c
parentad20d5f673898578f9d8a156d7a4c921f5ca4584
net: Fix use after free by removing length arg from sk_data_ready callbacks.

Several spots in the kernel perform a sequence like:

skb_queue_tail(&sk->s_receive_queue, skb);
sk->sk_data_ready(sk, skb->len);

But at the moment we place the SKB onto the socket receive queue it
can be consumed and freed up.  So this skb->len access is potentially
to freed up memory.

Furthermore, the skb->len can be modified by the consumer so it is
possible that the value isn't accurate.

And finally, no actual implementation of this callback actually uses
the length argument.  And since nobody actually cared about it's
value, lots of call sites pass arbitrary values in such as '0' and
even '1'.

So just remove the length argument from the callback, that way there
is no confusion whatsoever and all of these use-after-free cases get
fixed as a side effect.

Based upon a patch by Eric Dumazet and his suggestion to audit this
issue tree-wide.

Signed-off-by: David S. Miller <davem@davemloft.net>
58 files changed:
drivers/scsi/iscsi_tcp.c
drivers/scsi/iscsi_tcp.h
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
drivers/target/iscsi/iscsi_target_core.h
drivers/target/iscsi/iscsi_target_nego.c
fs/dlm/lowcomms.c
fs/ncpfs/ncp_fs_sb.h
fs/ncpfs/sock.c
fs/ocfs2/cluster/tcp.c
fs/ocfs2/cluster/tcp_internal.h
include/linux/sunrpc/svcsock.h
include/net/sctp/sctp.h
include/net/sock.h
net/atm/clip.c
net/atm/lec.c
net/atm/mpc.c
net/atm/raw.c
net/atm/signaling.c
net/ax25/ax25_in.c
net/bluetooth/l2cap_sock.c
net/bluetooth/rfcomm/core.c
net/bluetooth/rfcomm/sock.c
net/bluetooth/sco.c
net/caif/caif_socket.c
net/ceph/messenger.c
net/core/skbuff.c
net/core/sock.c
net/dccp/input.c
net/dccp/minisocks.c
net/decnet/dn_nsp_in.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c
net/iucv/af_iucv.c
net/key/af_key.c
net/netlink/af_netlink.c
net/netrom/af_netrom.c
net/nfc/llcp_core.c
net/packet/af_packet.c
net/phonet/pep-gprs.c
net/phonet/pep.c
net/rds/tcp.h
net/rds/tcp_listen.c
net/rds/tcp_recv.c
net/rose/af_rose.c
net/rxrpc/ar-input.c
net/rxrpc/ar-internal.h
net/sctp/socket.c
net/sctp/ulpqueue.c
net/sunrpc/svcsock.c
net/sunrpc/xprtsock.c
net/tipc/server.c
net/tipc/socket.c
net/unix/af_unix.c
net/vmw_vsock/vmci_transport_notify.c
net/vmw_vsock/vmci_transport_notify_qstate.c
net/x25/af_x25.c
net/x25/x25_in.c