Sched_ext development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tejun Heo" <tj@kernel.org>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH sched_ext/for-7.4] sched_ext: Clear a sub-scheduler's caps before ops.sub_detach()
Date: Tue, 06 Oct 2026 20:44:21 +0000	[thread overview]
Message-ID: <sashiko-outbox-162439@kernel.org> (raw)
In-Reply-To: <b46300eda6da03d56262fcdcbfc9b4fa@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] cleanup: mixing goto-based error handling with guard() declarations in scx_bpf_sub_grant()
--

commit 289fe25628ccca2188e3c04a46e7f9601f2bbbe1
Author: Tejun Heo <tj@kernel.org>

sched_ext: Clear a sub-scheduler's caps before ops.sub_detach()

This commit clears every capability of a sub-scheduler before calling
ops.sub_detach(). This ensures the dying sub-scheduler cannot modify
state after the parent has cleaned it up.

> diff --git a/kernel/sched/ext/sub.c b/kernel/sched/ext/sub.c
> --- a/kernel/sched/ext/sub.c
> +++ b/kernel/sched/ext/sub.c

[ ... ]

> @@ -2321,6 +2355,12 @@ __bpf_kfunc s32 scx_bpf_sub_grant(u64 cgroup_id, u64 caps,
>  		scoped_guard (raw_spinlock, &pps->lock) {
>  			guard(raw_spinlock_nested)(&cps->lock);
>  
> +			/* the child is being disabled, see clear_all_caps() */
> +			if (unlikely(READ_ONCE(child->aborting))) {
> +				ret = -ENODEV;
> +				goto out;
> +			}

[Severity: Medium]
Does jumping out of the scoped_guard() and guard() scopes using a goto
violate the cleanup subsystem guidelines?

According to the cleanup subsystem documentation, the expectation is that
usage of goto and cleanup helpers should never be mixed in the same
function. This pattern creates confusing ownership semantics.

> +
>  			/*
>  			 * Narrow granted_cids to cids the parent holds every
>  			 * requested cap on. All-or-nothing per cid.
> @@ -2373,9 +2413,10 @@ __bpf_kfunc s32 scx_bpf_sub_grant(u64 cgroup_id, u64 caps,
>  		}
>  	}
>  
> +	ret = any_denied ? -EPERM : 0;
> +out:
>  	caps_updated_deliver(&to_deliver);
> -
> -	return any_denied ? -EPERM : 0;
> +	return ret;
>  }

[Severity: Medium]
Could this goto-based cleanup label be avoided to adhere to the scope-based
cleanup guidelines? Since this function now mixes goto cleanup with guards,
should all resources be converted to scope-based cleanups, or should the
goto be refactored?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/b46300eda6da03d56262fcdcbfc9b4fa@kernel.org?part=1

  reply	other threads:[~2026-10-06 20:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 20:31 [PATCH sched_ext/for-7.4] sched_ext: Clear a sub-scheduler's caps before ops.sub_detach() Tejun Heo
2026-10-06 20:44 ` sashiko-bot [this message]
2026-10-06 22:14 ` Tejun Heo
2026-10-08  4:39 ` Tao Cui

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=sashiko-outbox-162439@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    /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