Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3926716rwi; Sat, 22 Oct 2022 02:21:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM770rz53uGvv5KNBeNgMHsXpCKEwOclbmD2uwPCVa9dJHC1bp0CQ906yVZBHmaHCUliYmLr X-Received: by 2002:a17:902:8c92:b0:178:29d4:600f with SMTP id t18-20020a1709028c9200b0017829d4600fmr23816034plo.40.1666430463938; Sat, 22 Oct 2022 02:21:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666430463; cv=none; d=google.com; s=arc-20160816; b=T2TDKZdw7hXFO2R5ShRuTUg/d1ghOJyUwr1Tt6aULPTkZ76xv94cnSwdkV5qGne+o6 iC2dqnTKrnjiyvAu+7PYiOdK+2mmMFRThBO8RA1j1DQzocfHKf+XIWqj6YLHn8c3Ei89 HiBFv43tixOrcupz8afpygFq1ICTIETx/98jG5FEPFMNLytbXosP9U9JoziYvH7oAgdi SCPnNUwcFQ+7B5g4OKYkzF9YhXYv30TaFPsStV/a4St3Zv8B8Mb9fOiqheM0X/O/hpDt DUqk94z0H1BxujNiRfmaqSiAYJA01/HXjZPa7fYHpxOSDq2fdu86AnIcgP04IHG5Hjpu kSsw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp8-20020a056a00348800b00565de49c23dsi23983293pfb.105.2022.10.22.02.20.26; Sat, 22 Oct 2022 02:21:03 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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); -- 2.35.1