All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steffen Klassert <steffen.klassert@secunet.com>
To: Yasuaki Torimaru <yasuakitorimaru@gmail.com>
Cc: <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
	<edumazet@kernel.org>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<horms@kernel.org>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH ipsec] xfrm: account XFRMA_MARK in xfrm_sa_len()
Date: Fri, 20 Nov 2026 07:44:06 +0100	[thread overview]
Message-ID: <av_sNleLx4XJ_bLf@gauss4> (raw)
In-Reply-To: <20261110114623.2659197-1-yasuakitorimaru@gmail.com>

On Tue, Nov 10, 2026 at 08:46:23PM +0900, Yasuaki Torimaru wrote:
> xfrm_notify_sa() sizes its netlink message with xfrm_sa_len(), while
> copy_to_user_state_extra() appends XFRMA_MARK whenever the state carries
> a mark.  xfrm_sa_len() does not count that attribute.  Only the
> XFRM_MSG_DELSA path adds it to the length separately, so for a marked
> state the XFRM_MSG_NEWSA and XFRM_MSG_UPDSA messages are sized short by
> nla_total_size(sizeof(struct xfrm_mark)), 12 bytes.  The other length
> calculations in this file already account for the mark; xfrm_sa_len() is
> the only one that does not.
> 
> Instrumenting xfrm_notify_sa() on an x86-64 KASAN build under qemu to
> print the accounted length while adding a marked state confirms the gap:
> accounting the mark raises the computed length by exactly 12 bytes
> (348 -> 360), matching nla_total_size(sizeof(struct xfrm_mark)).
> 
> Whether the shortfall is reached depends on the skb allocation, which is
> rounded up: xfrm_notify_sa() fails with -EMSGSIZE only when that slack is
> exhausted.  km_state_notify() discards the return value, so such a
> failure would be silent.  This was not reproduced.
> 
> Count the mark in xfrm_sa_len() for every event and drop the now
> redundant addition in the DELSA path.  The message content is unchanged;
> only the computed length changes.
> 
> Fixes: 6f26b61e177e ("xfrm: Allow user space config of SAD mark")
> Signed-off-by: Yasuaki Torimaru <yasuakitorimaru@gmail.com>

Applied, thanks a lot!

      parent reply	other threads:[~2026-11-20  6:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 11:46 [PATCH ipsec] xfrm: account XFRMA_MARK in xfrm_sa_len() Yasuaki Torimaru
2026-11-10 11:52 ` netdev-bot+sinfo
2026-11-12  5:40   ` Yasuaki Torimaru
2026-11-20  6:44 ` Steffen Klassert [this message]

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=av_sNleLx4XJ_bLf@gauss4 \
    --to=steffen.klassert@secunet.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=yasuakitorimaru@gmail.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.