Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4486405ybx; Mon, 4 Nov 2019 14:13:39 -0800 (PST) X-Google-Smtp-Source: APXvYqzNcL7TOgnHxECZydEdvgdZllFV6copeLV4zl0kKIDJXbEs8oq9Bk5J0XSqgRxEWpt7zGWg X-Received: by 2002:a17:906:c08:: with SMTP id s8mr26468370ejf.73.1572905619165; Mon, 04 Nov 2019 14:13:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905619; cv=none; d=google.com; s=arc-20160816; b=Go67NmP3TV7hMbbWKQdRzypwgC8gk9F4jlM+GeHRnbW3q+yeuUrKH16YF4cto/ihWd MpXGTjH8OlRJmDvU/AbiNfi9lNhvGeTjDxUaXtK82kZbIRMdnE7ky91yfLn9V9b4bHC7 dnyUANaZYmSNPbesFxAGona+an2PTkXQYBx0AICbgf2dX3M3NhGl2kFIzctglX3F4Zfk HTdXIv7XAtaSSEOzHS8IkB26ma+nycSuCInJIc+bAMr0kF+hivFSk6bASGN76FcqutZE xVXahn1r6nSFxSwHhxuEzrq6E5Au4UJg5e7yKFMCZq5+FSf+7DRj8K1imMmwkd9foSmd d46A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Hs3a88XVAOhBN2Jpvyxr1MMG7hfsiEx6P73pDZnuVG0=; b=ZeJwaHiOI6i1s5z9ZVTVjhlhkCxf60miiIqW7zyuOKAuxNUmuHw+A/F27wNw9/EYoA HnLw+5XWovN/db5aZ9NGnzzM1ofqSwrOjbL3inWMTzvwbO3cElXE7oAeofYDqdio8Jo/ iSIMqy2Wuez2fscw2s5pRHhsJ5viGxFwmy1t12pCsnm3cB2KR8mAVGBePo7Xuwky64uD l/53orm+Qm7oLt5jIhgYgzuujGe1OZvC16F2LKzhzKE0KybyMBF2zeDcAm8fAqbMI+7p 4JXEIv6PXKW5nf7K6xahxD8WbNw6/GhjFIyjs9Vsbb5mn/mNQTi2NqLBP4u8d3OL6NvZ rOJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NMiqffWC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d15si9014998edn.49.2019.11.04.14.13.15; Mon, 04 Nov 2019 14:13:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NMiqffWC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389337AbfKDWMr (ORCPT + 99 others); Mon, 4 Nov 2019 17:12:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:43958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390142AbfKDWKn (ORCPT ); Mon, 4 Nov 2019 17:10:43 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 87F8F205C9; Mon, 4 Nov 2019 22:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905442; bh=k9jy+lx+shuuvnVRszCf8uaiSUPr42VBGyRwNfbn6ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NMiqffWCyelQNQ9SDa0IJ8+jbwFl3dqPGbXoXEfJUQ9oHAJrcZMnB65DHWg4g/TAF NKsHiFQQmL16H2+O9a9PMNZtvRIkbdgaCdmLmaBtIvcBn0FnJOZ3TWYmZi0cvH1n/C EFSHppZLImI9IkN9NS6LfQoPVVLYBIjVpvOf/eyI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+d850c266e3df14da1d31@syzkaller.appspotmail.com, David Howells Subject: [PATCH 5.3 148/163] rxrpc: Fix call ref leak Date: Mon, 4 Nov 2019 22:45:38 +0100 Message-Id: <20191104212151.036425778@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells commit c48fc11b69e95007109206311b0187a3090591f3 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- net/rxrpc/sendmsg.c | 1 + 1 file changed, 1 insertion(+) --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -661,6 +661,7 @@ int rxrpc_do_sendmsg(struct rxrpc_sock * 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: