Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2585152lqp; Mon, 25 Mar 2024 03:35:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWxQxmqwLXFY3FPLEPRDzSrxOE0nSfZHm5BUNoQlI1q8JNaucrropJHvq0EFjGeZt/mcGn3rSQRjzO2pV9OtO8DuN9IJELu9rsNmLi1Xw== X-Google-Smtp-Source: AGHT+IFaQXZnIsM/sLTLSVyXREntr28VGErK618BxZns0UALX2fVEQslHR8UID7+x3IsnXThTkhG X-Received: by 2002:a19:ca19:0:b0:515:9ce3:daa3 with SMTP id a25-20020a19ca19000000b005159ce3daa3mr4860622lfg.37.1711362903125; Mon, 25 Mar 2024 03:35:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711362903; cv=pass; d=google.com; s=arc-20160816; b=z5PtYxy5qP2gZ9y/bbN0psPT/VT6bGRcV8gkint2wTEJ+0FmcKtQYiIu+wCAH8uG1t tjBigjPlVTfiFoXX+r0pFz5GdYkvHQ33QZN6VCiwz+y2ID4YNKaPYDIlunGUTx8Bb6/Q DAW3dxylTn7gwZJctin6rw00WWFN8pQoEsoRwKlZnL/Chq+hmcjwYYHa3NlLfMTiLzek AMv+GTE5K8/j3soM+m3R0QUgv3zEh2G/rlb5ZRh0RPzsM3UlYVEfNRhk64aH7qpWWi93 NUua3GPRqV2+8gHjnXgA5QU7UbPQES2euORdOp5yCNzGtJC0PpZ3cXR/EvgBCyFdjOtt 7k8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nB5SsrLN24c+C5H7Ad2wm3tgcEIMRbTPEBDYtzyRmY8=; fh=Nw5cgJ1qEuaHUM5eOUejOW/x18eA+gsen5dMLgcBFVY=; b=GxuWjLU8g1P1ockejE9yd0r9HDY2Za6YM9yqjRHPT1PZO7i0TNQaLtRWdFzo0cyCQK ruQ3fVQ6xjnTa9QmTkSfm/2djvP4n1XSPx9IJImFGKeUQkih5pQV4DIk+6USKFYOreom csytXFbc37Y6l4KsCUS2VfUspzc2z34JBYyC56Zu/ziuRtI47/Mq9slO3GyAFdgVK5gQ nbzhbVxzOwTECZd1NQgiTNja0L47E+5VTnLATmyKd40d1Vcimv5PVespLloRo2aC1BtJ FPYBrl4wTipnMSeowqQZBra68VD5sJhXza8dNC9VlFy65wbCNJo+9MQlG7jLXVABlutK ryrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kRL6akHw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115318-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115318-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ly2-20020a170906af4200b00a46cedcac6bsi2352957ejb.1004.2024.03.25.03.35.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:35:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115318-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kRL6akHw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115318-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115318-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D10621F3461D for ; Mon, 25 Mar 2024 10:35:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E46B41DEA1E; Mon, 25 Mar 2024 02:32:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kRL6akHw" 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 D550C80C00; Sun, 24 Mar 2024 22:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320514; cv=none; b=fQfS5fui8YtwwLiLPb4eKkx9/Wk6oMhiP8F+0jxSni1Rakdgd3LEsQhc80FHzEK8BZuzYqDL4EUD50OcEf1wzuFCI8uXuZiblqCIzGBbemGbbZ9k78qH01TVxzUJnZpds0S4240/JCtzj/8CvaUSE7DFy2kgkkSV1MBxQgPWYew= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320514; c=relaxed/simple; bh=O9V6/TN435gODXHOlwJPy0OeVZD6dXtAzOUmJleT3mQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RzAMKD+ufvwcWbIxkQs3uY4rjV+BqZTYshoIh/62FbA4s4yi2KcSy69Z8mzDy4wXQpnig3n2EFAWncPooRhLXqPPRvV9i1aIp1Wav5RGasktu9Ij4CaANv4VmI++Wlvo6BC9IRX0bazY8vBz+du7LYWUHqpsH8CB2kSmRaj6TSY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kRL6akHw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22CECC43394; Sun, 24 Mar 2024 22:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320514; bh=O9V6/TN435gODXHOlwJPy0OeVZD6dXtAzOUmJleT3mQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kRL6akHwTf0eHYDm0T8Oof6S+hsD2PIl5EWYA1CQrbaaIc5QcCeD7O6SFTlR3NNJS QvJW01Y7WnsETqaeEuM2e8jC8HdAcTVB4nP9GCBaqLrpntqNScCxcpPVu9nBud6+fn /puFVIbm89nowG341m0vuRLnHFTHOtONWuAklp5YctEFkmUysypi4smYeyZZhZxLT8 NgR3CVakmlJ87pEqU8Yxd6Z64YJrwjFrS7bSDVV2ISFFLSrkZvxrQ4I3bVxaefQkYf B3Z64Fhm+mxnCvHQ3LtQNiEPompe58Ks/CdDaOYTi2IRlMppF1L/jFSuFA22yPJpt4 ghoIVNCnidnZQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mike Yu , Steffen Klassert , Sasha Levin Subject: [PATCH 6.7 075/713] xfrm: fix xfrm child route lookup for packet offload Date: Sun, 24 Mar 2024 18:36:41 -0400 Message-ID: <20240324224720.1345309-76-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Mike Yu [ Upstream commit d4872d70fc6feabfc8e897edad993a81096ade9f ] In current code, xfrm_bundle_create() always uses the matched SA's family type to look up a xfrm child route for the skb. The route returned by xfrm_dst_lookup() will eventually be used in xfrm_output_resume() (skb_dst(skb)->ops->local_out()). If packet offload is used, the above behavior can lead to calling ip_local_out() for an IPv6 packet or calling ip6_local_out() for an IPv4 packet, which is likely to fail. This change fixes the behavior by checking if the matched SA has packet offload enabled. If not, keep the same behavior; if yes, use the matched SP's family type for the lookup. Test: verified IPv6-in-IPv4 packets on Android device with IPsec packet offload enabled Signed-off-by: Mike Yu Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/xfrm/xfrm_policy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index e69d588caa0c6..9c5f2efed3333 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -2694,7 +2694,9 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, if (xfrm[i]->props.smark.v || xfrm[i]->props.smark.m) mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]); - family = xfrm[i]->props.family; + if (xfrm[i]->xso.type != XFRM_DEV_OFFLOAD_PACKET) + family = xfrm[i]->props.family; + oif = fl->flowi_oif ? : fl->flowi_l3mdev; dst = xfrm_dst_lookup(xfrm[i], tos, oif, &saddr, &daddr, family, mark); -- 2.43.0