All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bence Csokas" <bence.csokas@arm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] eventfd: Add scope-based cleanup capability
Date: Wed, 09 Sep 2026 12:42:49 +0000	[thread overview]
Message-ID: <20260909124249.A84301F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909-efd-autofree-v1-1-c6c3c19cc702@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The DEFINE_FREE wrapper for eventfd lacks an IS_ERR_OR_NULL check. When used with eventfd_ctx_fdget() or eventfd_ctx_fileget() (which return ERR_PTR on failure), the cleanup routine will pass the error pointer to eventfd_ctx_put(), bypassing its NULL check and causing a kernel panic when dereferenced.
--

commit f893599e482de1bd276a121a5c34c8f30a6546ce
Author: Bence Csokas <bence.csokas@arm.com>

eventfd: Add scope-based cleanup capability

This commit introduces a scope-based cleanup capability for eventfd contexts,
allowing eventfd_ctx_put() to be used with the RAII-inspired __free() API.

> diff --git a/fs/eventfd.c b/fs/eventfd.c
> index 9d33a02757d52..24111a16284f1 100644
> --- a/fs/eventfd.c
> +++ b/fs/eventfd.c
> @@ -102,6 +102,9 @@ static void eventfd_free(struct kref *kref)
>   */
>  void eventfd_ctx_put(struct eventfd_ctx *ctx)
>  {
> +	if (!ctx)
> +		return;
> +
>  	kref_put(&ctx->kref, eventfd_free);

[Severity: High]
Does this release function adequately protect against error pointers?

It appears to only guard against NULL, so if the __free wrapper invokes this
function with an ERR_PTR, it seems like it will bypass this check and
cause a kernel panic when dereferencing ctx->kref.

>  }
>  EXPORT_SYMBOL_GPL(eventfd_ctx_put);
> diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h
> index e32bee4345fb9..689358c2b0ae7 100644
> --- a/include/linux/eventfd.h
> +++ b/include/linux/eventfd.h
[ ... ]
> @@ -89,5 +90,7 @@ static inline void eventfd_signal(struct eventfd_ctx *ctx)
>  	eventfd_signal_mask(ctx, 0);
>  }
>  
> +DEFINE_FREE(eventfd, struct eventfd_ctx *, eventfd_ctx_put(_T))

[Severity: High]
Is this cleanup wrapper safe to use with functions like eventfd_ctx_fdget()
or eventfd_ctx_fileget() that return ERR_PTR on failure?

Because this wrapper lacks an IS_ERR_OR_NULL check, if a getter fails and
returns an ERR_PTR, the early return path will pass the error pointer to
eventfd_ctx_put(), bypassing its NULL check. This seems to violate the
cleanup function compatibility guidelines and could lead to a crash.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260909-efd-autofree-v1-0-c6c3c19cc702@arm.com?part=1

  reply	other threads:[~2026-09-09 12:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 12:36 [PATCH 0/2] Add scope-based cleanup capability to eventfd_ctx Bence Csokas
2026-09-09 12:36 ` [PATCH 1/2] eventfd: Add scope-based cleanup capability Bence Csokas
2026-09-09 12:42   ` sashiko-bot [this message]
2026-09-09 12:36 ` [PATCH 2/2] drm/syncobj: Use scope-based cleanup for eventfd_ctx Bence Csokas
2026-09-09 12:43   ` sashiko-bot

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=20260909124249.A84301F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bence.csokas@arm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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 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.