From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8ABC98465 for ; Wed, 20 Sep 2023 11:45:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 050EAC433C7; Wed, 20 Sep 2023 11:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695210330; bh=J61lUdGXu7LgeUX9BMTlUKoeFIUbL6UTZJQGCi9A0cI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XpasHRMW+jUQ8eH+6he5SInjALC5FuYgkwFBkamnNArECfCX+h+zBEiLetg5N52+E lzXhaY7vDGCt1twYdrR4RU58mxeo9DdhoVeFw3LYf0EGcoxBq1RNlObiI1JUXWn4pf 5K4sMYHnQVaYUBzqPUD/BIu5BkWP4hLALEV3kY5U= 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.5 038/211] net/ipv4: return the real errno instead of -EINVAL Date: Wed, 20 Sep 2023 13:28:02 +0200 Message-ID: <20230920112846.973958706@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112845.859868994@linuxfoundation.org> References: <20230920112845.859868994@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.5-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 6935d07a60c35..a8d2e8b1ff415 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -236,7 +236,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