From: sashiko-bot@kernel.org
To: "Ratheesh Kannoth" <rkannoth@marvell.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v18 net-next 1/2] octeontx2: use atomic bitops for PF/VF and rep flags
Date: Wed, 30 Sep 2026 02:30:15 +0000 [thread overview]
Message-ID: <20260930023016.21A551F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929022915.2704627-2-rkannoth@marvell.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: octeontx2: non-atomic flags sync clobbers concurrent atomic bitops
--
commit 7297391279ac6b1794cb03ec3bcedc49fd752258
Author: Ratheesh Kannoth <rkannoth@marvell.com>
octeontx2: use atomic bitops for PF/VF and rep flags
This commit switches PF/VF and representor flags from non-atomic masks to
unsigned long bitmaps using atomic bit operations. It also relocates
representor VF initialization bits and introduces a helper to locklessly
sync representor flags onto the PF mailbox context.
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
[ ... ]
> @@ -593,6 +607,32 @@ struct otx2_nic {
> unsigned long *af_xdp_zc_qidx;
> };
>
> +static inline void otx2_set_flag(struct otx2_nic *nic, unsigned int flag)
> +{
> + set_bit(flag, &nic->flags);
> +}
> +
[ ... ]
> +static inline void otx2_sync_flags_from_rep(struct otx2_nic *dst,
> + unsigned long *src_flags)
> +{
> + unsigned long src = READ_ONCE(*src_flags);
> + unsigned long new_flags;
> +
> + new_flags = (READ_ONCE(dst->flags) & ~OTX2_REP_SYNC_FLAGS_MASK) |
> + (src & OTX2_REP_SYNC_FLAGS_MASK);
> + WRITE_ONCE(dst->flags, new_flags);
> +}
[Severity: High]
Can this cause lost atomic updates? The patch converts flags to be modified
by atomic bitops like set_bit() and clear_bit(). However, this helper
performs a non-atomic read-modify-write (READ_ONCE followed by WRITE_ONCE)
over the entire dst->flags word.
If a concurrent path atomically sets a flag (such as OTX2_FLAG_INTF_DOWN or
OTX2_FLAG_PORT_UP) right between the READ_ONCE and WRITE_ONCE, the
WRITE_ONCE will overwrite the memory with the stale value, silently erasing
the concurrent atomic bit operation. This is reachable from the TC flower
offload setup path which calls rvu_rep_setup_tc_cb().
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
[ ... ]
> @@ -599,11 +599,11 @@ int otx2_napi_handler(struct napi_struct *napi, int budget)
>
> if (workdone < budget && napi_complete_done(napi, workdone)) {
> /* If interface is going down, don't re-enable IRQ */
> - if (pfvf->flags & OTX2_FLAG_INTF_DOWN)
> + if (otx2_test_flag(pfvf, OTX2_FLAG_INTF_DOWN))
> return workdone;
[Severity: High]
Because the NAPI handler heavily relies on OTX2_FLAG_INTF_DOWN to halt
processing and prevent use-after-free scenarios during teardown, erasing
this flag via the race condition in otx2_sync_flags_from_rep() could result
in otx2_napi_handler() continuously polling freed resources.
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
[ ... ]
> @@ -632,7 +632,7 @@ void rvu_rep_destroy(struct otx2_nic *priv)
> int rep_id;
>
> rvu_eswitch_config(priv, false);
> - priv->flags |= OTX2_FLAG_INTF_DOWN;
> + otx2_set_flag(priv, OTX2_FLAG_INTF_DOWN);
> rvu_rep_free_cq_rsrc(priv);
[Severity: High]
If the OTX2_FLAG_INTF_DOWN flag set here is immediately overwritten by the
non-atomic flag sync mentioned above, NAPI polling can continue executing
concurrently while rvu_rep_free_cq_rsrc() tears down the queues, leading to
a use-after-free crash on teardown.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260929022915.2704627-1-rkannoth@marvell.com?part=1
next prev parent reply other threads:[~2026-09-30 2:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 2:29 [PATCH v18 net-next 0/2] octeontx2: mqprio bandwidth offload for NIX TX schedulers Ratheesh Kannoth
2026-09-29 2:29 ` [PATCH v18 net-next 1/2] octeontx2: use atomic bitops for PF/VF and rep flags Ratheesh Kannoth
2026-09-30 2:30 ` sashiko-bot [this message]
2026-10-02 8:31 ` netdev-bot+sashiko
2026-10-05 4:16 ` Ratheesh Kannoth
2026-09-29 2:29 ` [PATCH v18 net-next 2/2] octeontx2: add mqprio bandwidth offload for NIX TX schedulers Ratheesh Kannoth
2026-09-30 2:30 ` sashiko-bot
2026-10-02 8:31 ` netdev-bot+sashiko
2026-10-02 1:22 ` [PATCH v18 net-next 0/2] octeontx2: " Jakub Kicinski
2026-10-02 9:37 ` David Laight
2026-10-05 2:58 ` Ratheesh Kannoth
2026-10-05 8:14 ` David Laight
2026-10-05 9:49 ` Ratheesh Kannoth
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=20260930023016.21A551F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=rkannoth@marvell.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox