From: sashiko-bot@kernel.org
To: "Simon Schippers" <simon.schippers@tu-dortmund.de>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH net-next v14 4/5] ptr_ring: move free-space check into separate helper
Date: Wed, 05 Aug 2026 01:57:35 +0000 [thread overview]
Message-ID: <20260805015735.7D6C81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803183641.96882-5-simon.schippers@tu-dortmund.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but `__ptr_ring_full()` lacks a check for a zero-sized ring, leading to a kernel crash (page fault/panic) when it dereferences `ZERO_SIZE_PTR`.
--
--- Patch [4]: [PATCH net-next v14 4/5] ptr_ring: move free-space check into separate helper ---
commit 883e8b9b82d44bf10bcbbae97968cf7b37d933bd
Author: Simon Schippers <simon.schippers@tu-dortmund.de>
ptr_ring: move free-space check into separate helper
This commit moves the available free space check for a new entry into a
separate helper function. It allows callers to determine in advance whether a
subsequent produce call will succeed. Existing callers checking for a
non-zero return value remain unaffected.
> diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
> index d2c3629bbe451..631c43fde4407 100644
> --- a/include/linux/ptr_ring.h
> +++ b/include/linux/ptr_ring.h
> @@ -96,6 +96,26 @@ static inline bool ptr_ring_full_bh(struct ptr_ring *r)
> return ret;
> }
>
> +/* Report whether the next __ptr_ring_produce() has room for one entry:
> + * 0 means the single slot at r->queue[r->producer] is free, -ENOSPC means
> + * the ring is full, which is transient, and -EINVAL means r->size is 0,
> + * which is permanent. A caller that stops producing and waits for space
> + * must therefore do so only for -ENOSPC.
> + *
> + * Note: callers invoking this in a loop must use a compiler barrier,
> + * for example cpu_relax(). Callers must hold producer_lock.
> + */
> +static inline int __ptr_ring_check_produce(struct ptr_ring *r)
> +{
> + if (unlikely(!r->size))
> + return -EINVAL;
> +
> + if (data_race(r->queue[r->producer]))
> + return -ENOSPC;
[Severity: High]
This isn't a bug introduced by this patch, but __ptr_ring_full() in
include/linux/ptr_ring.h lacks a check for a zero-sized ring, unlike the
check added here.
include/linux/ptr_ring.h:__ptr_ring_full() {
return data_race(r->queue[r->producer]);
}
Can this lead to a kernel Oops when it unconditionally dereferences r->queue?
When a ptr_ring is initialized or resized to a size of 0, r->queue becomes
ZERO_SIZE_PTR. Calling __ptr_ring_full() evaluates r->queue[r->producer]
unconditionally without checking if r->size == 0, leading to a page fault
when it dereferences ZERO_SIZE_PTR.
Would it make sense to update __ptr_ring_full() to safely check for
!r->size as well?
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803183641.96882-1-simon.schippers@tu-dortmund.de?part=4
next prev parent reply other threads:[~2026-08-05 1:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 18:36 [PATCH net-next v14 0/5] tun/tap & vhost-net: apply qdisc backpressure on full ptr_ring to reduce TX drops Simon Schippers
2026-08-03 18:36 ` [PATCH net-next v14 1/5] tun/tap: add IFF_BACKPRESSURE flag Simon Schippers
2026-08-05 1:57 ` sashiko-bot
2026-08-03 18:36 ` [PATCH net-next v14 2/5] tun/tap: add ptr_ring consume helper with netdev queue wakeup Simon Schippers
2026-08-05 1:57 ` sashiko-bot
2026-08-03 18:36 ` [PATCH net-next v14 3/5] vhost-net: wake queue of tun/tap after ptr_ring consume Simon Schippers
2026-08-03 18:36 ` [PATCH net-next v14 4/5] ptr_ring: move free-space check into separate helper Simon Schippers
2026-08-05 1:57 ` sashiko-bot [this message]
2026-08-03 18:36 ` [PATCH net-next v14 5/5] tun/tap & vhost-net: stop tail-drop when IFF_BACKPRESSURE is set Simon Schippers
2026-08-05 5:20 ` [PATCH net-next v14 0/5] tun/tap & vhost-net: apply qdisc backpressure on full ptr_ring to reduce TX drops Simon Schippers
2026-08-08 1:10 ` patchwork-bot+netdevbpf
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=20260805015735.7D6C81F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=simon.schippers@tu-dortmund.de \
/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.