Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3009934ybi; Mon, 17 Jun 2019 14:36:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxk9VkBoqyEWkx54pBdSj/DbmGYA/beSsDlS+kvDDYXuuyCXG6bfZz62/M3pumdXgQofEfk X-Received: by 2002:a17:902:2f84:: with SMTP id t4mr66799557plb.57.1560807396933; Mon, 17 Jun 2019 14:36:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807396; cv=none; d=google.com; s=arc-20160816; b=Y2f+L6H/dKbNgTYt/vQDIl+u8ETSScIymmJPkyRvC/MteKPGDZzEcU542IBZz8YL9M vaj3HHxSAiAvZ4G3IM6RHMMUwnT1vs5MbrmLKTXULb2WTWp/CSYOUiQ+xw2XnLAqvhbT FvW8QfPjmlt+PzW1QvVqPkZHznjQ7mN20CcmUVtS6+imRFOAXrK7DQtz1EmMAGsoCnul I+eB+HCPidY4iKPzI55uGkmApI8eYBaMpjhEyPBl6ihAA7PgTpqNx4XcvZ5uOb3+eLID eT1zDcHttcnFiRnM5TZMIjHbINZdAoG3yOVKqU0Khxu+8zBXoFx58u/FRV7m71R2k2zi shng== 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=6CXtod5K7ZVW+OuNgnzmFajaXD/2+fTuNu/RFKKayzE=; b=s5KTtCLh4j+5oY3ab6S4x/HRELSEGGyYR4gKIyIWTjPLu0bsXiESt+YgA4O137g44M rsDd8CqD7n+194gSSi2Oql3ixzN48fR0qAF9VZrRodT0CawFmSH8QsMzIQBp2jsUClzA Mtj5Doing6GldwuKm7xMC/gajqJ0jJ+nN/JYSwdxOz3OLc7zEE9KuRUGHDHSdkbPBcEf n9FvLNnaS1EDLp0WBYhWCKBuC3DM0yEVFJ2YKXPLOJzf+bVTiFFfaaXTlVYeCJu9jmz+ DY97E7dtDed8/5ShY4vCoaQYZRStMwIfUxvpqy+G5GoBMDBd/cDxp9zuG64y+rjLPkcx 37Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="KxYtrX1/"; 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 q19si332538pjp.24.2019.06.17.14.36.21; Mon, 17 Jun 2019 14:36:36 -0700 (PDT) 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="KxYtrX1/"; 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 S1728765AbfFQVfc (ORCPT + 99 others); Mon, 17 Jun 2019 17:35:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:47506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729173AbfFQVWn (ORCPT ); Mon, 17 Jun 2019 17:22:43 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 68E2D20673; Mon, 17 Jun 2019 21:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806562; bh=xAd0l4WamYl1Zv3TSZdd9NxnwWlSdcbYomFJUMpZK8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KxYtrX1/veFlF4SKzVAVvK+bBYECEAUk9KmM1IHKNvG+xDgDjNoJDq1VQxj+jGu3j R11KMZrjx3rc1BZibk4XH2GcuOEZIahQ+wI1EIWPPwmXjcGF+DPElf9S7CfYA0d4tE wcWbzFypJFwx5E7KPcSN6apz2xeVn/3CDqMtOqKU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Fastabend , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.1 050/115] bpf: sockmap remove duplicate queue free Date: Mon, 17 Jun 2019 23:09:10 +0200 Message-Id: <20190617210803.036791634@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210759.929316339@linuxfoundation.org> References: <20190617210759.929316339@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 [ Upstream commit c42253cc88206fd0e9868c8b2fd7f9e79f9e0e03 ] In tcp bpf remove we free the cork list and purge the ingress msg list. However we do this before the ref count reaches zero so it could be possible some other access is in progress. In this case (tcp close and/or tcp_unhash) we happen to also hold the sock lock so no path exists but lets fix it otherwise it is extremely fragile and breaks the reference counting rules. Also we already check the cork list and ingress msg queue and free them once the ref count reaches zero so its wasteful to check twice. Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface") Signed-off-by: John Fastabend Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- net/ipv4/tcp_bpf.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index 1bb7321a256d..4a619c85daed 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -528,8 +528,6 @@ static void tcp_bpf_remove(struct sock *sk, struct sk_psock *psock) { struct sk_psock_link *link; - sk_psock_cork_free(psock); - __sk_psock_purge_ingress_msg(psock); while ((link = sk_psock_link_pop(psock))) { sk_psock_unlink(sk, link); sk_psock_free_link(link); -- 2.20.1