From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7849FC31E5B for ; Mon, 17 Jun 2019 21:35:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C41C20657 for ; Mon, 17 Jun 2019 21:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560807333; bh=xAd0l4WamYl1Zv3TSZdd9NxnwWlSdcbYomFJUMpZK8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=To3oW34t/AkpE2sbgRsta/kuaCLp4e4maSzlERn6Xwym9GqegpSyA7vIXj6MTBI7V pOWtZQoRx4b7j/0BDrn2YxjXYEVCnOzSb+u11ZUYsqLiKjz6wvP2Ojl1oQwU1dph2T dbQlmuhqir/r6XVXBs9/S5OM+lHiswksGbR1J4Ig= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728943AbfFQVfc (ORCPT ); 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