linux/net
Tung Nguyen 30d628ede5 tipc: fix memory leak caused by tipc_buf_append()
[ Upstream commit ceb1eb2fb6 ]

Commit ed42989eab ("tipc: fix the skb_unshare() in tipc_buf_append()")
replaced skb_unshare() with skb_copy() to not reduce the data reference
counter of the original skb intentionally. This is not the correct
way to handle the cloned skb because it causes memory leak in 2
following cases:
 1/ Sending multicast messages via broadcast link
  The original skb list is cloned to the local skb list for local
  destination. After that, the data reference counter of each skb
  in the original list has the value of 2. This causes each skb not
  to be freed after receiving ACK:
  tipc_link_advance_transmq()
  {
   ...
   /* release skb */
   __skb_unlink(skb, &l->transmq);
   kfree_skb(skb); <-- memory exists after being freed
  }

 2/ Sending multicast messages via replicast link
  Similar to the above case, each skb cannot be freed after purging
  the skb list:
  tipc_mcast_xmit()
  {
   ...
   __skb_queue_purge(pkts); <-- memory exists after being freed
  }

This commit fixes this issue by using skb_unshare() instead. Besides,
to avoid use-after-free error reported by KASAN, the pointer to the
fragment is set to NULL before calling skb_unshare() to make sure that
the original skb is not freed after freeing the fragment 2 times in
case skb_unshare() returns NULL.

Fixes: ed42989eab ("tipc: fix the skb_unshare() in tipc_buf_append()")
Acked-by: Jon Maloy <jmaloy@redhat.com>
Reported-by: Thang Hoang Ngo <thang.h.ngo@dektech.com.au>
Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
Link: https://lore.kernel.org/r/20201027032403.1823-1-tung.q.nguyen@dektech.com.au
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-11-01 12:01:04 +01:00
..
6lowpan
9p net/9p: validate fds in p9_fd_open 2020-08-11 15:33:36 +02:00
802
8021q
appletalk appletalk: Fix atalk_proc_init() return path 2020-08-11 15:33:40 +02:00
atm atm: fix a memory leak of vcc->user_back 2020-10-01 13:17:58 +02:00
ax25 AX.25: Prevent integer overflows in connect and sendmsg 2020-07-31 18:39:31 +02:00
batman-adv batman-adv: mcast: fix duplicate mcast packets from BLA backbone to mesh 2020-10-01 13:18:19 +02:00
bluetooth Bluetooth: Only mark socket zapped after unlocking 2020-10-29 09:58:06 +01:00
bpf
bpfilter
bridge netfilter: ebtables: Fixes dropping of small packets in bridge nat 2020-10-29 09:57:57 +01:00
caif
can net: j1939: j1939_session_fresh_new(): fix missing initialization of skbcnt 2020-10-29 09:57:24 +01:00
ceph
core socket: don't clear SOCK_TSTAMP_NEW when SO_TIMESTAMPNS is disabled 2020-11-01 12:01:01 +01:00
dcb net: DCB: Validate DCB_ATTR_DCB_BUFFER argument 2020-09-26 18:03:12 +02:00
dccp
decnet
dns_resolver
dsa dsa: Allow forwarding of redirected IGMP traffic 2020-09-23 12:40:33 +02:00
ethernet
hsr
ieee802154
ife
ipv4 tcp: Prevent low rmem stalls with SO_RCVLOWAT. 2020-11-01 12:01:04 +01:00
ipv6 netfilter: nf_log: missing vlan offload tag and proto 2020-10-29 09:57:45 +01:00
iucv
kcm
key af_key: pfkey_dump needs parameter validation 2020-09-26 18:03:10 +02:00
l2tp
l3mdev
lapb
llc net: silence data-races on sk_backlog.tail 2020-10-01 13:17:15 +02:00
mac80211 mac80211: handle lack of sband->bitrates in rates 2020-10-29 09:58:04 +01:00
mac802154 mac802154: tx: fix use-after-free 2020-10-01 13:18:17 +02:00
mpls
ncsi
netfilter netfilter: nftables_offload: KASAN slab-out-of-bounds Read in nft_flow_rule_create 2020-11-01 12:01:01 +01:00
netlabel netlabel: fix problems with mapping removal 2020-09-12 14:18:55 +02:00
netlink
netrom
nfc nfc: Ensure presence of NFC_ATTR_FIRMWARE_NAME attribute in nfc_genl_fw_download() 2020-10-29 09:57:26 +01:00
nsh
openvswitch openvswitch: handle DNAT tuple collision 2020-10-14 10:33:02 +02:00
packet net/packet: fix overflow in tpacket_rcv 2020-09-09 19:12:29 +02:00
phonet
psample
qrtr net: qrtr: check skb_put_padto() return value 2020-09-26 18:03:15 +02:00
rds rds: Prevent kernel-infoleak in rds_notify_queue_get() 2020-08-05 09:59:44 +02:00
rfkill
rose
rxrpc rxrpc: Fix server keyring leak 2020-10-14 10:33:05 +02:00
sched net/sched: act_mpls: Add softdep on mpls_gso.ko 2020-11-01 12:01:03 +01:00
sctp sctp: fix sctp_auth_init_hmacs() error path 2020-10-14 10:33:01 +02:00
smc net/smc: fix valid DMBE buffer sizes 2020-10-29 09:57:23 +01:00
strparser
sunrpc SUNRPC: fix copying of multiple pages in gss_read_proxy_verf() 2020-10-29 09:57:56 +01:00
switchdev
tipc tipc: fix memory leak caused by tipc_buf_append() 2020-11-01 12:01:04 +01:00
tls net/tls: sendfile fails with ktls offload 2020-10-29 09:57:23 +01:00
unix skbuff: fix a data race in skb_queue_len() 2020-10-01 13:17:31 +02:00
vmw_vsock net: virtio_vsock: Enhance connection semantics 2020-10-07 08:01:24 +02:00
wimax
wireless nl80211: fix non-split wiphy information 2020-10-29 09:57:44 +01:00
x25 net/x25: Fix null-ptr-deref in x25_disconnect 2020-08-05 09:59:44 +02:00
xdp
xfrm xfrm: Use correct address family in xfrm_state_find 2020-10-14 10:33:03 +02:00
Kconfig
Makefile
compat.c net/compat: Add missing sock updates for SCM_RIGHTS 2020-08-21 13:05:25 +02:00
socket.c net: Set fput_needed iff FDPUT_FPUT is set 2020-08-19 08:16:22 +02:00
sysctl_net.c