Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5046840pxb; Mon, 15 Feb 2021 08:09:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFeIw4eGGPIkxQCpu02EYK/pwazGDhoR5zP2pCAVp0Ipg3qPx4f4+LV6h4df5lSObNW3EN X-Received: by 2002:a17:906:25c4:: with SMTP id n4mr16496132ejb.359.1613405392681; Mon, 15 Feb 2021 08:09:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613405392; cv=none; d=google.com; s=arc-20160816; b=TxGdfduhAly92W/Uf7UoBhmYN/dPz0xC4SVN4FG0kFEA/54vD8Y2pmyqBygZxLHFZC cjkHvlTUCENxjD+ntwpysoYRsDG7ak1ZDr9su8dXU3GjkNNxAUzXREUrzFS0aIgbYkK1 R6Ycaf3himwzIoLGnJ0IH9puntbqOc+S5sJ/POGLTHUb/INhr5ggGDojDjjorOSq6pKU JBC7rdClYM3kWzYhsOcuYCiqG85vQIn39cPhn6HM1jKmEorvz6l+s869+Uv4M7kB3Ext T1e6UpkA/jeZHq35j8XajEbGAW6sPTKboOtq8IdMpnSej1scXr2znIIsl9lGXDBpvos+ M5CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PH1iVG1TLZglHQ7fK0NO7FIRdJffoh+k7WszmD58q0Q=; b=a0EvDw4ZmEtncLWxRS1tr9ZnXEDgpN/8pxMA1gsoccxRze5o6sjFhClwzdI+/cEBo5 jKcOp3uLhT2xpyMgMQVjinAru03qjXgn6s3aabTgNRRYSE8vMXnDiqlxrs5W5Q5CV0Dr obkG1uAZXgDu16QRWlx9shta0z1vg3DxEUH/4jBrMomRR9NQNPYMBM2GZPqwjt7Uy63F ZsGRX43I9ISJsga30A5L+gunAiT43w1Ut4Hci69onNSSE+UMCgw7ixdMvZWe/FjYMNyX 9aR0Fs0RiXJIht9YEsEY0EjVq0nKK57m8wVpS7S2NE9wsDtAUfO/mQLBm0hG9sGEw4yD LvAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YmmUA2Nn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p18si12436570ejy.191.2021.02.15.08.09.29; Mon, 15 Feb 2021 08:09:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YmmUA2Nn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231553AbhBOQGU (ORCPT + 99 others); Mon, 15 Feb 2021 11:06:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:45572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231373AbhBOPdG (ORCPT ); Mon, 15 Feb 2021 10:33:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5C40A64E51; Mon, 15 Feb 2021 15:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613403040; bh=Z6RFs8Me67B4sK8KIuAnCOPl1Ow0W+abCs+UwuYJBec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YmmUA2Nngz8FEv0i04ipEZxwkA/ibJTCE0TOdbnm1yhcZIzHc1N+73TPFxYTJ1g24 N9UZOFakq1wxzra9d/DXb19Lz7m1UJF8zNC1ap/l7a2JbCrt+g/KpFSlL9j4Q/L2R5 pvycR0ZyTqVXptwCuT37gUh7+5QXL+LDuGRgz3MY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefano Garzarella , "Michael S. Tsirkin" , Jakub Kicinski Subject: [PATCH 5.4 56/60] vsock/virtio: update credit only if socket is not closed Date: Mon, 15 Feb 2021 16:27:44 +0100 Message-Id: <20210215152717.172203374@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210215152715.401453874@linuxfoundation.org> References: <20210215152715.401453874@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefano Garzarella commit ce7536bc7398e2ae552d2fabb7e0e371a9f1fe46 upstream. If the socket is closed or is being released, some resources used by virtio_transport_space_update() such as 'vsk->trans' may be released. To avoid a use after free bug we should only update the available credit when we are sure the socket is still open and we have the lock held. Fixes: 06a8fc78367d ("VSOCK: Introduce virtio_vsock_common.ko") Signed-off-by: Stefano Garzarella Acked-by: Michael S. Tsirkin Link: https://lore.kernel.org/r/20210208144454.84438-1-sgarzare@redhat.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/vmw_vsock/virtio_transport_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -1100,10 +1100,10 @@ void virtio_transport_recv_pkt(struct vi vsk = vsock_sk(sk); - space_available = virtio_transport_space_update(sk, pkt); - lock_sock(sk); + space_available = virtio_transport_space_update(sk, pkt); + /* Update CID in case it has changed after a transport reset event */ vsk->local_addr.svm_cid = dst.svm_cid;