Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp916967pxx; Tue, 27 Oct 2020 03:57:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpfG07LtvSLMhhKb1PnszepPYmd9XM2k3J+MZM2uQiGyCKh6Fw+S6fBkgJFLDxtNjD7cT8 X-Received: by 2002:a17:906:7254:: with SMTP id n20mr1702168ejk.382.1603796257382; Tue, 27 Oct 2020 03:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603796257; cv=none; d=google.com; s=arc-20160816; b=c3hWyWjBADfXCPIC7fhF4HhvwGNTBgqwBO3QkRFA1QOATudp4D1ldmTlCDJThNcLTZ JDlWxY0VO0j0/+wak0Soo5WZ45YYbWSr5YxqUR31n3mKzkwKFQorEmJgQDuAQC/QG+op JRV15rpMIuG+BIsqVL1FMR/5urYdn7mvklHJkXLSzSgywNOkv+JEWjss1fC6/k9q3FCe iCY4uxbjY+UVfFMkx7ngv/sncDsQwl7XRRKnqXEu2QNCKlGYfU0P/rRDLYJ2BSqQHVdT DkfoCL8uoq+UyGJSvhaKco/rO6iSanbJMzxey0V8QQklNx2c8xnd9KVxyLgZgUcw5Rwj UMZw== 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=2ESt9DLMzU/T24xw11i4knkBsvLkRuOOjUA+V+wi0J0=; b=cjE5uSrwd9ptgSo8mFKYdy3PoDW3zRkzZi4LpPUj4dlc/0I11DfTJDoAMzhVI9trM7 wyFDO8Yyy0AvI2YNcR95+XphsJvKoZUKdj9Eh8aIWfZkgXiou4n4f0HgrlDHiuPSMQ91 rs9xwDpgfLac3LKRtYgL0liJ/2vTxuuK6pbgfapMWL8xMZgWl7hc9U3d6dNzU2FeQJ1w AH2RKJZBhR81JeiWfYdfvRx3YcDTpLN8OoACzVu8Rt4AaEua+AFYX8kbhWL/UzeAP+0Q FRUOCLinXfg5RjJHGzK1qE382mJ6OKss71FMGyfGgQiM4f8VLaaMtFss3uPXB6KROvTR c0mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BlGwyHU8; 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 d21si730414ejr.160.2020.10.27.03.57.15; Tue, 27 Oct 2020 03:57:37 -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=BlGwyHU8; 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 S2437589AbgJ0AEE (ORCPT + 99 others); Mon, 26 Oct 2020 20:04:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:35182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2411017AbgJZX4A (ORCPT ); Mon, 26 Oct 2020 19:56:00 -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 326CA22202; Mon, 26 Oct 2020 23:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756559; bh=xXQCAi1UanTxXmdmTXNwci+zWfS1jsM/sBq4Gzk2pFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BlGwyHU8vUZjhbt0rqJ/G4w4PQpxbbbS60VrFztXa30uOsO2aCw+M4StsHT3giiLt AwCF0AFygKj0kYhJFWoqoefZDvj9w8auNW8AgMXM1rdW6aZyBhxyU5KKSKoFyk205D +jMPl3/BP3cuYluMs/UloOptjyv0QLOOGUkDm0eI= 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.4 35/80] samples/bpf: Fix possible deadlock in xdpsock Date: Mon, 26 Oct 2020 19:54:31 -0400 Message-Id: <20201026235516.1025100-35-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-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 df011ac334022..79d1005ff2ee3 100644 --- a/samples/bpf/xdpsock_user.c +++ b/samples/bpf/xdpsock_user.c @@ -677,6 +677,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