From patchwork Sat Oct 22 07:22:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7366 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1095875wrr; Sat, 22 Oct 2022 01:03:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM532/YFP0EN73po509bfZse/JJ7cGcqoPmo8JeJDbjmEgI4GrnRioJTeRyHOXPE5e/u3LbU X-Received: by 2002:a17:903:1251:b0:17f:7f78:e71c with SMTP id u17-20020a170903125100b0017f7f78e71cmr23474226plh.147.1666425820669; Sat, 22 Oct 2022 01:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425820; cv=none; d=google.com; s=arc-20160816; b=Q+Jyw7xO3OoFxQ0FY52OOXKW6aaQnEU/15gFPbdrgL1+bdY0baotiwa3HOcSpfCDYu aBI9+OC07Cz/ayrW3AMGwNZ6NyE06OJeytiLSAfK241puiqM1/abJAPgbg8uB1yLnTAe 9kRoYpGDWfvxaOpddGJyE3e4D5q7srv7W2SYA5/hdL6Rhq2rxi2UaLeMC4gPR091C8Eb rpWVzDPwmg3bUX1R0w1Fu11SOoGI4t063qyMoBS0ZsXigKoJAJNRwZ1r8lswFigRDkWJ c5YLz4mkzwiYRZXE8uO4ylngalBEBuKgKAc9HzlJ8A4cB/F7kAMReCZfkan3qN67cZqM 9U6A== 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=MSGZVNZxL0wYGC+mLfDT+kNbW6LhrFDWYy/nsUpMvSY=; b=dV3um3bCJBRD4A8Bh8+kwcLc5lwbkuA/mb/F8bj0I3fiZx7c0ntcsgUt7V7bYe3DY0 JaWx8z/rM+YrkdeGrsLcqmiP7pUdjTOzDFQuH3T30S8dSSLER5d91lkBIRPQp5sluFZL TOs7WLZSrrSd0Z/miLWoE3LwvcGOIgJkhAavl7sbsWYCb2zllF/V5MrEMYwo/il4CmNK qqlVB/rZD9SPfoaDa45UGF/oA1W+guPJoY9XAuyz3hZl7qusu9i+dLk+CnGgO+BgWVSW mW6yLXWvnoJ0wNeR5uSQPgMPSP4RlNN24u8ClJL358KOrGBi2NgGrwNeoduoe6FNr114 PWbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jJ6MgLhB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r124-20020a632b82000000b00434d8692854si28156514pgr.541.2022.10.22.01.03.27; Sat, 22 Oct 2022 01:03:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jJ6MgLhB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232473AbiJVIDI (ORCPT + 99 others); Sat, 22 Oct 2022 04:03:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232387AbiJVHyx (ORCPT ); Sat, 22 Oct 2022 03:54:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD36B3FA07; Sat, 22 Oct 2022 00:48:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 15D99B82E04; Sat, 22 Oct 2022 07:47:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84152C433D6; Sat, 22 Oct 2022 07:47:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424846; bh=ipVy3jWeRp0xJbTVsGRKB0dSH6uQrgwCt2Ovp5+8Yww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jJ6MgLhBB5rbAHpwm2ru9lSu6+Wlc2zDqJdqzA34omWHBkvfxRYgxlmvjTztalDwz BkufMn0PLCo4luzUIC++bTt382ZK6vlIlKogx/JKoTgosUrordSJQM/sNWhfmrBOlA g+NxZOOTxeblC2A39RX3TihY7F/e1C3lq20pjGkE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liu Jian , Daniel Borkmann , John Fastabend , Sasha Levin Subject: [PATCH 5.19 268/717] skmsg: Schedule psock work if the cached skb exists on the psock Date: Sat, 22 Oct 2022 09:22:27 +0200 Message-Id: <20221022072501.806164079@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747374121301994273?= X-GMAIL-MSGID: =?utf-8?q?1747374121301994273?= From: Liu Jian [ Upstream commit bec217197b412d74168c6a42fc0f76d0cc9cad00 ] In sk_psock_backlog function, for ingress direction skb, if no new data packet arrives after the skb is cached, the cached skb does not have a chance to be added to the receive queue of psock. As a result, the cached skb cannot be received by the upper-layer application. Fix this by reschedule the psock work to dispose the cached skb in sk_msg_recvmsg function. Fixes: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface") Signed-off-by: Liu Jian Signed-off-by: Daniel Borkmann Acked-by: John Fastabend Link: https://lore.kernel.org/bpf/20220907071311.60534-1-liujian56@huawei.com Signed-off-by: Sasha Levin --- net/core/skmsg.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/core/skmsg.c b/net/core/skmsg.c index 69ac686c7cae..864cd7ded2ca 100644 --- a/net/core/skmsg.c +++ b/net/core/skmsg.c @@ -435,8 +435,10 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg, if (copied + copy > len) copy = len - copied; copy = copy_page_to_iter(page, sge->offset, copy, iter); - if (!copy) - return copied ? copied : -EFAULT; + if (!copy) { + copied = copied ? copied : -EFAULT; + goto out; + } copied += copy; if (likely(!peek)) { @@ -456,7 +458,7 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg, * didn't copy the entire length lets just break. */ if (copy != sge->length) - return copied; + goto out; sk_msg_iter_var_next(i); } @@ -478,7 +480,9 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg, } msg_rx = sk_psock_peek_msg(psock); } - +out: + if (psock->work_state.skb && copied > 0) + schedule_work(&psock->work); return copied; } EXPORT_SYMBOL_GPL(sk_msg_recvmsg);