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 CD0BA16406 for ; Fri, 8 Sep 2023 18:18:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A01FC43140; Fri, 8 Sep 2023 18:18:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694197123; bh=5IUt5jOw0j/GAMErOaqocmM4IXD72TvXgoHe9eInHFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J7R5Ump92ahHhk8v4HdJdTKKiI7WijaU2+P+K9LY65V+3Hlluk4xD6qha4KYFB2WS pOwxmeGYstHV4F3Gm5cWF5qbZmEvmzfGiT71lozBozZtzbBFe4Vm1WeXT/dHfE4kYx t6BhMKv6E2zgD68yv32LcJL9mfT1h765xdVZVIgZRSt+Rj1v1XdoMvfBgOhmvDXGi3 5MnXd8dCw9/lyLRmrsNMwXRwtqN4dxQkK7Vholfvj91GKcr4miPOfP2i+H72IsPbz7 wBYWVTpvk02k5Q4uLHO0f+DWae4oVFUAqLYd2Iu97IBodarZQoHHPfLn/tM3CeNPEX UwwRaS6Jqdjeg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: xu xin , Yang Yang , Si Hao , Kuniyuki Iwashima , Vadim Fedorenko , Jakub Kicinski , Sasha Levin , davem@davemloft.net, dsahern@kernel.org, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 12/26] net/ipv4: return the real errno instead of -EINVAL Date: Fri, 8 Sep 2023 14:17:50 -0400 Message-Id: <20230908181806.3460164-12-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230908181806.3460164-1-sashal@kernel.org> References: <20230908181806.3460164-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.52 Content-Transfer-Encoding: 8bit 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 acfe58d2f1dd7..831c627e03ff8 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