kernel-fxtec-pro1x/net
Tuong Lien 6b3ea3aa6c tipc: fix memory leak in service subscripting
[ Upstream commit 0771d7df819284d46cf5cfb57698621b503ec17f ]

Upon receipt of a service subscription request from user via a topology
connection, one 'sub' object will be allocated in kernel, so it will be
able to send an event of the service if any to the user correspondingly
then. Also, in case of any failure, the connection will be shutdown and
all the pertaining 'sub' objects will be freed.

However, there is a race condition as follows resulting in memory leak:

       receive-work       connection        send-work
              |                |                |
        sub-1 |<------//-------|                |
        sub-2 |<------//-------|                |
              |                |<---------------| evt for sub-x
        sub-3 |<------//-------|                |
              :                :                :
              :                :                :
              |       /--------|                |
              |       |        * peer closed    |
              |       |        |                |
              |       |        |<-------X-------| evt for sub-y
              |       |        |<===============|
        sub-n |<------/        X    shutdown    |
    -> orphan |                                 |

That is, the 'receive-work' may get the last subscription request while
the 'send-work' is shutting down the connection due to peer close.

We had a 'lock' on the connection, so the two actions cannot be carried
out simultaneously. If the last subscription is allocated e.g. 'sub-n',
before the 'send-work' closes the connection, there will be no issue at
all, the 'sub' objects will be freed. In contrast the last subscription
will become orphan since the connection was closed, and we released all
references.

This commit fixes the issue by simply adding one test if the connection
remains in 'connected' state right after we obtain the connection lock,
then a subscription object can be created as usual, otherwise we ignore
it.

Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jmaloy@redhat.com>
Reported-by: Thang Ngo <thang.h.ngo@dektech.com.au>
Signed-off-by: Tuong Lien <tuong.t.lien@dektech.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-01 13:14:44 +02:00
..
6lowpan
9p net/9p: validate fds in p9_fd_open 2020-08-11 15:32:32 +02:00
802
8021q
appletalk
atm atm: fix a memory leak of vcc->user_back 2020-10-01 13:14:43 +02:00
ax25 AX.25: Prevent integer overflows in connect and sendmsg 2020-07-31 18:37:48 +02:00
batman-adv batman-adv: bla: use netif_rx_ni when not in interrupt context 2020-09-09 19:04:24 +02:00
bluetooth Bluetooth: Handle Inquiry Cancel error after Inquiry Complete 2020-10-01 13:14:44 +02:00
bpf
bpfilter
bridge net: bridge: enfore alignment for ethernet address 2020-06-30 23:17:03 -04:00
caif
can
ceph libceph: don't omit recovery_deletes in target_copy() 2020-07-22 09:32:13 +02:00
core neigh_stat_seq_next() should increase position index 2020-10-01 13:14:29 +02:00
dcb net: DCB: Validate DCB_ATTR_DCB_BUFFER argument 2020-09-26 18:01:29 +02:00
dccp net: ipv6: add net argument to ip6_dst_lookup_flow 2020-04-29 16:31:16 +02:00
decnet
dns_resolver KEYS: Don't write out to userspace while holding key semaphore 2020-04-23 10:30:24 +02:00
dsa dsa: Allow forwarding of redirected IGMP traffic 2020-09-23 12:10:56 +02:00
ethernet
hsr
ieee802154
ife
ipv4 rt_cpu_seq_next should increase position index 2020-10-01 13:14:29 +02:00
ipv6 ipv6_route_seq_next should increase position index 2020-10-01 13:14:29 +02:00
iucv
kcm
key af_key: pfkey_dump needs parameter validation 2020-09-26 18:01:28 +02:00
l2tp l2tp: remove skb_dst_set() from l2tp_xmit_skb() 2020-07-22 09:31:59 +02:00
l3mdev
lapb
llc net: silence data-races on sk_backlog.tail 2020-10-01 13:14:26 +02:00
mac80211 mac80211: fix misplaced while instead of if 2020-08-21 11:05:32 +02:00
mac802154
mpls net: ipv6_stub: use ip6_dst_lookup_flow instead of ip6_dst_lookup 2020-04-29 16:31:17 +02:00
ncsi
netfilter netfilter: conntrack: allow sctp hearbeat after connection re-use 2020-09-17 13:45:24 +02:00
netlabel netlabel: fix problems with mapping removal 2020-09-12 13:40:22 +02:00
netlink genetlink: remove genl_bind 2020-07-22 09:31:58 +02:00
netrom net: netrom: Fix potential nr_neigh refcnt leak in nr_add_node 2020-04-29 16:31:21 +02:00
nfc net/nfc/rawsock.c: add CAP_NET_RAW check. 2020-08-19 08:15:03 +02:00
nsh
openvswitch net: openvswitch: use u64 for meter bucket 2020-10-01 13:14:42 +02:00
packet af_packet: TPACKET_V3: fix fill status rwlock imbalance 2020-08-19 08:15:03 +02:00
phonet
psample
qrtr net: qrtr: check skb_put_padto() return value 2020-09-26 18:01:30 +02:00
rds rds: Prevent kernel-infoleak in rds_notify_queue_get() 2020-08-05 10:06:01 +02:00
rfkill
rose
rxrpc rxrpc: Fix race between recvmsg and sendmsg on immediate call failure 2020-08-11 15:32:35 +02:00
sched net: sch_generic: aviod concurrent reset and enqueue op for lockless qdisc 2020-09-26 18:01:30 +02:00
sctp sctp: move trace_sctp_probe_path into sctp_outq_sack 2020-10-01 13:14:30 +02:00
smc net/smc: Prevent kernel-infoleak in __smc_diag_dump() 2020-09-03 11:24:17 +02:00
strparser
sunrpc svcrdma: Fix leak of transport addresses 2020-10-01 13:14:40 +02:00
switchdev
tipc tipc: fix memory leak in service subscripting 2020-10-01 13:14:44 +02:00
tls net/tls: Fix kmap usage 2020-08-19 08:15:03 +02:00
unix skbuff: fix a data race in skb_queue_len() 2020-10-01 13:14:32 +02:00
vmw_vsock vsock: fix timeout in vsock_accept() 2020-06-10 21:34:59 +02:00
wimax
wireless cfg80211: regulatory: reject invalid hints 2020-09-09 19:04:32 +02:00
x25 net/x25: Fix null-ptr-deref in x25_disconnect 2020-08-05 10:06:02 +02:00
xdp xdp: Fix xsk_generic_xmit errno 2020-06-25 15:33:05 +02:00
xfrm xfrm: Fix double ESP trailer insertion in IPsec crypto offload. 2020-06-30 23:17:10 -04:00
compat.c net/compat: Add missing sock updates for SCM_RIGHTS 2020-08-21 11:05:32 +02:00
Kconfig
Makefile
socket.c net: Set fput_needed iff FDPUT_FPUT is set 2020-08-19 08:15:03 +02:00
sysctl_net.c