public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>,
	syzbot+d850c266e3df14da1d31@syzkaller.appspotmail.com,
	Sasha Levin <sashal@kernel.org>,
	linux-afs@lists.infradead.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 13/25] rxrpc: Fix call ref leak
Date: Fri, 25 Oct 2019 09:57:01 -0400	[thread overview]
Message-ID: <20191025135715.25468-13-sashal@kernel.org> (raw)
In-Reply-To: <20191025135715.25468-1-sashal@kernel.org>

From: David Howells <dhowells@redhat.com>

[ Upstream commit c48fc11b69e95007109206311b0187a3090591f3 ]

When sendmsg() finds a call to continue on with, if the call is in an
inappropriate state, it doesn't release the ref it just got on that call
before returning an error.

This causes the following symptom to show up with kasan:

	BUG: KASAN: use-after-free in rxrpc_send_keepalive+0x8a2/0x940
	net/rxrpc/output.c:635
	Read of size 8 at addr ffff888064219698 by task kworker/0:3/11077

where line 635 is:

	whdr.epoch	= htonl(peer->local->rxnet->epoch);

The local endpoint (which cannot be pinned by the call) has been released,
but not the peer (which is pinned by the call).

Fix this by releasing the call in the error path.

Fixes: 37411cad633f ("rxrpc: Fix potential NULL-pointer exception")
Reported-by: syzbot+d850c266e3df14da1d31@syzkaller.appspotmail.com
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/rxrpc/sendmsg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index 016e293681b8c..a980b49d7a4f8 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -586,6 +586,7 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
 		case RXRPC_CALL_SERVER_PREALLOC:
 		case RXRPC_CALL_SERVER_SECURING:
 		case RXRPC_CALL_SERVER_ACCEPTING:
+			rxrpc_put_call(call, rxrpc_call_put);
 			ret = -EBUSY;
 			goto error_release_sock;
 		default:
-- 
2.20.1


  parent reply	other threads:[~2019-10-25 13:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25 13:56 [PATCH AUTOSEL 4.14 01/25] PCI/ASPM: Do not initialize link state when aspm_disabled is set Sasha Levin
2019-10-25 13:56 ` [PATCH AUTOSEL 4.14 02/25] HID: i2c-hid: Add Odys Winbook 13 to descriptor override Sasha Levin
2019-10-25 13:56 ` [PATCH AUTOSEL 4.14 03/25] ACPI: video: Use vendor backlight on Sony VPCEH3U1E Sasha Levin
2019-10-25 13:56 ` [PATCH AUTOSEL 4.14 04/25] Fixed https://bugzilla.kernel.org/show_bug.cgi?id=202935 allow write on the same file Sasha Levin
2019-10-25 13:56 ` [PATCH AUTOSEL 4.14 05/25] nvme-pci: fix conflicting p2p resource adds Sasha Levin
2019-10-25 13:56 ` [PATCH AUTOSEL 4.14 06/25] scsi: qedf: Do not retry ELS request if qedf_alloc_cmd fails Sasha Levin
2019-10-25 13:56 ` [PATCH AUTOSEL 4.14 07/25] driver core: platform: Fix the usage of platform device name(pdev->name) Sasha Levin
2019-10-25 13:56 ` [PATCH AUTOSEL 4.14 08/25] powerpc/pseries/hvconsole: Fix stack overread via udbg Sasha Levin
2019-10-25 13:56 ` [PATCH AUTOSEL 4.14 09/25] scsi: RDMA/srp: Fix a sleep-in-invalid-context bug Sasha Levin
2019-10-25 13:56 ` [PATCH AUTOSEL 4.14 10/25] drm/msm: stop abusing dma_map/unmap for cache Sasha Levin
2019-10-25 13:56 ` [PATCH AUTOSEL 4.14 11/25] drm/msm: Use the correct dma_sync calls in msm_gem Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 12/25] sch_netem: fix rcu splat in netem_enqueue() Sasha Levin
2019-10-25 13:57 ` Sasha Levin [this message]
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 14/25] llc: fix sk_buff leak in llc_sap_state_process() Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 15/25] llc: fix sk_buff leak in llc_conn_service() Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 16/25] NFC: pn533: fix use-after-free and memleaks Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 17/25] bonding: fix potential NULL deref in bond_update_slave_arr Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 18/25] net: usb: sr9800: fix uninitialized local variable Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 19/25] jbd2: flush_descriptor(): Do not decrease buffer head's ref count Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 20/25] ath9k: dynack: fix possible deadlock in ath_dynack_node_{de}init Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 21/25] Btrfs: fix hang when loading existing inode cache off disk Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 22/25] ubi: ubi_wl_get_peb: Increase the number of attempts while getting PEB Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 23/25] RDMA/iwcm: Fix a lock inversion issue Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 24/25] ipv6: Handle race in addrconf_dad_work Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 25/25] bdi: Do not use freezable workqueue Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191025135715.25468-13-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+d850c266e3df14da1d31@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox