From: Simon Horman <horms@kernel.org>
To: Antony Antony <antony.antony@secunet.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
devel@linux-ipsec.org, Leon Romanovsky <leon@kernel.org>,
Eyal Birger <eyal.birger@gmail.com>,
Nicolas Dichtel <nicolas.dichtel@6wind.com>,
Sabrina Dubroca <sd@queasysnail.net>
Subject: Re: [PATCH ipsec-next v10 2/3] xfrm: Add dir validation to "out" data path lookup
Date: Thu, 18 Apr 2024 10:24:21 +0100 [thread overview]
Message-ID: <20240418092421.GA3974194@kernel.org> (raw)
In-Reply-To: <274c82dfea0d656f59f69ccaab46d4319f0ef54c.1712828282.git.antony.antony@secunet.com>
On Thu, Apr 11, 2024 at 11:42:13AM +0200, Antony Antony wrote:
> Introduces validation for the x->dir attribute within the XFRM output
> data lookup path. If the configured direction does not match the expected
> direction, out, increment the XfrmOutDirError counter and drop the packet
> to ensure data integrity and correct flow handling.
>
> grep -vw 0 /proc/net/xfrm_stat
> XfrmOutPolError 2
> XfrmOutDirError 2
>
> Signed-off-by: Antony Antony <antony.antony@secunet.com>
...
> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index 6affe5cd85d8..7deeb21dae15 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -2489,6 +2489,12 @@ xfrm_tmpl_resolve_one(struct xfrm_policy *policy, const struct flowi *fl,
>
> x = xfrm_state_find(remote, local, fl, tmpl, policy, &error,
> family, policy->if_id);
> + if (x->dir && x->dir != XFRM_SA_DIR_OUT) {
> + XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTDIRERROR);
> + xfrm_state_put(x);
> + error = -EINVAL;
> + goto fail;
> + }
Hi Antony,
the line below assumes that x may be NULL,
but the new code above dereferences x unconditionally.
Is this ok?
Flagged by Smatch.
>
> if (x && x->km.state == XFRM_STATE_VALID) {
> xfrm[nx++] = x;
...
next prev parent reply other threads:[~2024-04-18 9:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-11 9:40 [PATCH ipsec-next v10 1/3] xfrm: Add Direction to the SA in or out Antony Antony
2024-04-11 9:42 ` [PATCH ipsec-next v10 2/3] xfrm: Add dir validation to "out" data path lookup Antony Antony
2024-04-12 13:49 ` Nicolas Dichtel
2024-04-12 13:53 ` Nicolas Dichtel
2024-04-18 9:24 ` Simon Horman [this message]
2024-04-21 22:13 ` Antony Antony
2024-04-11 9:42 ` [PATCH ipsec-next v10 3/3] xfrm: Add dir validation to "in" " Antony Antony
2024-04-12 13:54 ` Nicolas Dichtel
2024-04-15 19:54 ` Antony Antony
2024-04-11 11:41 ` [PATCH ipsec-next v10 1/3] xfrm: Add Direction to the SA in or out Leon Romanovsky
2024-04-11 16:20 ` [devel-ipsec] " Paul Wouters
2024-04-11 16:40 ` Christian Hopps
2024-04-11 17:05 ` Leon Romanovsky
2024-04-15 12:21 ` Sabrina Dubroca
2024-04-16 7:10 ` [devel-ipsec] " Antony Antony
2024-04-16 8:36 ` Sabrina Dubroca
2024-04-21 22:04 ` Antony Antony
2024-04-22 9:16 ` Sabrina Dubroca
2024-04-22 9:54 ` Nicolas Dichtel
2024-04-23 12:42 ` Antony Antony
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240418092421.GA3974194@kernel.org \
--to=horms@kernel.org \
--cc=antony.antony@secunet.com \
--cc=davem@davemloft.net \
--cc=devel@linux-ipsec.org \
--cc=edumazet@google.com \
--cc=eyal.birger@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.