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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C20F8CE79D3 for ; Wed, 20 Sep 2023 11:55:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234810AbjITLzO (ORCPT ); Wed, 20 Sep 2023 07:55:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234898AbjITLyq (ORCPT ); Wed, 20 Sep 2023 07:54:46 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B676E6 for ; Wed, 20 Sep 2023 04:54:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E188C433C7; Wed, 20 Sep 2023 11:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695210876; bh=K4F6w3moKzrDdO8MimPL343JntuHz2AVOriPM4kyhyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kRn4XwQValN0Hr8mSAwvqAyweqiWA2C5NgvnZPt6/oRoAYVKX/BqCWUYTvXrsPTNa WO8up9GeJ4hkt//tSZ9iP7I4wXUwMz9Bwk8mk1tvE6Y0C81GYBeNab1GtyhILKiYE3 o2HBeXv/OA/exoRxQ4JROpl9D/827GUWRtVBRj8I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, xu xin , Yang Yang , Si Hao , Kuniyuki Iwashima , Vadim Fedorenko , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 025/139] net/ipv4: return the real errno instead of -EINVAL Date: Wed, 20 Sep 2023 13:29:19 +0200 Message-ID: <20230920112836.534785001@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112835.549467415@linuxfoundation.org> References: <20230920112835.549467415@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: xu xin [ Upstream commit c67180efc507e04a87f22aa68bd7dd832db006b7 ] For now, No matter what error pointer ip_neigh_for_gw() returns, ip_finish_output2() always return -EINVAL, which may mislead the upper users. For exemple, an application uses sendto to send an UDP packet, but when the neighbor table overflows, sendto() will get a value of -EINVAL, and it will cause users to waste a lot of time checking parameters for errors. Return the real errno instead of -EINVAL. Signed-off-by: xu xin Reviewed-by: Yang Yang Cc: Si Hao Reviewed-by: Kuniyuki Iwashima Reviewed-by: Vadim Fedorenko Link: https://lore.kernel.org/r/20230807015408.248237-1-xu.xin16@zte.com.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/ip_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index ebd2cea5b7d7a..66908ce2dd116 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -234,7 +234,7 @@ static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *s net_dbg_ratelimited("%s: No header cache and no neighbour!\n", __func__); kfree_skb_reason(skb, SKB_DROP_REASON_NEIGH_CREATEFAIL); - return -EINVAL; + return PTR_ERR(neigh); } static int ip_finish_output_gso(struct net *net, struct sock *sk, -- 2.40.1