Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1031580pxx; Tue, 27 Oct 2020 06:46:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1J9vrJi6pIJ0R7pRTIDoNQl+QP58Nb6u09M1y4NvERStBi5I5PlFP3iXz3LgIH+2sCf0e X-Received: by 2002:aa7:cd42:: with SMTP id v2mr2288931edw.151.1603806362837; Tue, 27 Oct 2020 06:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603806362; cv=none; d=google.com; s=arc-20160816; b=MkXXZByKaqFgJHJKzEXyUNx8UnTg2HUO34XaiwUi5PYazmLmi1C4IH5Cj2+Tx84YoG zt8euUJ/E8w/NUtkBgp2vKQPOu7yNOTLV2Dka3QIDO0UAUSncpgdS+PJSafpb+Tq4Dsb 28pfP8+y6OEce8YYVD/42hpxZrJuYsznokW6E6y+2GtrIQ9X3ITAmc68IScDp7N1Zfuk gJNq+LCeYQyU8jOU/0Ra+71ILlPOE7tTAUAPNomIWVPnBAGCASZXZqqC1expSmxOcvt2 5pNJFNoIw95O5r8QT6Qqf7Fq9SvDU3K2QUFrZdNnP/ztLJ8AnY2LFjSpG95zKbDKLg0s UJmA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nLycV5Kgdnj+HIzAowIxDQcz3aBIDnHEq9PE08fQ9dY=; b=QlJiJBX6YeS2E6PAHuaWzbRZEXygznk/Dl/qGcLGRawIP/aioT0qs71brlrhtktwau A2nc7oO3LjqdGx1beAs6kdbjcGY6/J3d4BAt8sat4XeKcFw4bJHk1YktzRR0gS0dipMz sWqjK8vjN0crv4oQ4eS5UocDjd4I2/5lTYPEQwymcy7+5wp+mx1/E1BtoAJLKniA+trx tEapnVIZ7WBrT/n8FwBUDlKNSdSK99BOstDVc9X+N19CvV79l5l4EYEKa2voZ8mE326Z MVi0YZAu9rZOKDbB/D7JvXCuVNjqVWbEK753PHDz2caePNccyTJeAACFtQRhUr4/0QKh iSgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WzOsG6cg; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g16si935855edm.68.2020.10.27.06.45.39; Tue, 27 Oct 2020 06:46:02 -0700 (PDT) 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=@kernel.org header.s=default header.b=WzOsG6cg; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2444617AbgJ0AjA (ORCPT + 99 others); Mon, 26 Oct 2020 20:39:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:49976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409124AbgJZXub (ORCPT ); Mon, 26 Oct 2020 19:50:31 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7F1CC20874; Mon, 26 Oct 2020 23:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756231; bh=BIP6Ywvq2AJS2Oz7ARKJM4JshElUyl/dKPhlquHf2qM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WzOsG6cgwPxLccrZ4c9etEyFX/B4h6PUNc+1cxzoCxWx3k5MWAeCL13sgn9Q3lmZ+ BhSYspZIqenfRcvXH3ga/vNIiYsODz/D2o/nM5iy/YziK0nkmz7ODcufiWHN+SVNnC PqmFgn7kDfNVQ6ts0NTIgXacgIL4ExsFraGvv37k= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Magnus Karlsson , Alexei Starovoitov , Sasha Levin , netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.9 069/147] samples/bpf: Fix possible deadlock in xdpsock Date: Mon, 26 Oct 2020 19:47:47 -0400 Message-Id: <20201026234905.1022767-69-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Magnus Karlsson [ Upstream commit 5a2a0dd88f0f267ac5953acd81050ae43a82201f ] Fix a possible deadlock in the l2fwd application in xdpsock that can occur when there is no space in the Tx ring. There are two ways to get the kernel to consume entries in the Tx ring: calling sendto() to make it send packets and freeing entries from the completion ring, as the kernel will not send a packet if there is no space for it to add a completion entry in the completion ring. The Tx loop in l2fwd only used to call sendto(). This patches adds cleaning the completion ring in that loop. Signed-off-by: Magnus Karlsson Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/1599726666-8431-3-git-send-email-magnus.karlsson@gmail.com Signed-off-by: Sasha Levin --- samples/bpf/xdpsock_user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c index 19c679456a0e2..ffb61d4bb93e9 100644 --- a/samples/bpf/xdpsock_user.c +++ b/samples/bpf/xdpsock_user.c @@ -1111,6 +1111,7 @@ static void l2fwd(struct xsk_socket_info *xsk, struct pollfd *fds) while (ret != rcvd) { if (ret < 0) exit_with_error(-ret); + complete_tx_l2fwd(xsk, fds); if (xsk_ring_prod__needs_wakeup(&xsk->tx)) kick_tx(xsk); ret = xsk_ring_prod__reserve(&xsk->tx, rcvd, &idx_tx); -- 2.25.1