All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiayuan Chen" <jiayuan.chen@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf] net/sched: cls_bpf: prevent unbounded recursion in offload rollback
Date: Fri, 22 May 2026 03:13:09 +0000	[thread overview]
Message-ID: <20260522031309.A2AC61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260522025854.341647-1-jiayuan.chen@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The function silently swallows error codes during a rollback, returning success (0) instead of the actual error.
--

commit ed592986d69e913d97df2ff4e0394a1bcd8686ac
Author: Jiayuan Chen <jiayuan.chen@linux.dev>
net/sched: cls_bpf: prevent unbounded recursion in offload rollback

This commit adds an is_rollback flag to cls_bpf_offload_cmd() to prevent
infinite recursion when a driver's tc_setup_cb_replace callback repeatedly
fails during a rollback operation.

Link: https://lore.kernel.org/bpf/ce5a6005-3c5e-4696-9e05-eba9461dc860@std.uestc.edu.cn/T/#u

> diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
> index 9a346b6221b35..d71fbf7cb407e 100644
> --- a/net/sched/cls_bpf.c
> +++ b/net/sched/cls_bpf.c
[ ... ]
> @@ -176,8 +177,8 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,
>  					  skip_sw, &oldprog->gen_flags,
>  					  &oldprog->in_hw_count, true);
>  
> -	if (prog && err) {
> -		cls_bpf_offload_cmd(tp, oldprog, prog, extack);
> +	if (prog && err && !is_rollback) {
> +		cls_bpf_offload_cmd(tp, oldprog, prog, extack, true);
>  		return err;
>  	}
>  

[Severity: Low]
Does this silently swallow the error code and return success during a rollback?

If err is non-zero but is_rollback is true, the entire if condition evaluates
to false. The function then falls through and returns 0 at the end instead of
returning the actual error.

While the only caller that sets is_rollback to true ignores the return value,
this still drops the error code. Should the recursion guard only wrap the
nested call so that the error is always returned?

    if (prog && err) {
        if (!is_rollback)
            cls_bpf_offload_cmd(tp, oldprog, prog, extack, true);
        return err;
    }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260522025854.341647-1-jiayuan.chen@linux.dev?part=1

  reply	other threads:[~2026-05-22  3:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22  2:58 [PATCH bpf] net/sched: cls_bpf: prevent unbounded recursion in offload rollback Jiayuan Chen
2026-05-22  3:13 ` sashiko-bot [this message]
2026-05-25 18:03 ` Jakub Kicinski
2026-05-25 18:56   ` Alexei Starovoitov

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=20260522031309.A2AC61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --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.