From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BA2234BA42 for ; Fri, 29 May 2026 04:51:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780030301; cv=none; b=GYDHIkjivElGsUO/4r9bQk0x1wr+/pbJb0qiUvzU06MEovSv/iDG9prSF3VKhAMjjVOqttYu0LGWuqb1PSsuf9e3C21P9xg+JX0zouw59Ya8OSya2haXWun0tQG3BiKGAFnOkMM2j6Dj7bxPy+jHIP+Dd0NKNfA9JqTDnpzH6Mc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780030301; c=relaxed/simple; bh=csXtqmfNt7VlKqy5YrQQzRdfzgTn5uRyKAcFEOYoWP0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Had4AUTIzG5TeofmZNjJKZqJrLvR+24I6Fr88T6NLNT3SX09j/5Jyg6GYZU/0l+gD/sS2ouRNHjDFAS9e5cJSvN81QtwbFLorNLSrBWTnwGgHjc45skE2V/Mdt78ftwxqN3waONZHNjSS1aPlo/j+G0FEvRcN45mkbFo3eGcAcA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Fc9tjiNr; arc=none smtp.client-ip=91.218.175.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Fc9tjiNr" Message-ID: <5e74168a-5a54-4ad3-8b1d-d4c2cc941de4@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780030288; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J9uleFF/SNpzQuaSDmEBCmTqADcd4XvDfxCE6oEFePQ=; b=Fc9tjiNr6lUrTySRdLPSGoVKTjdBNZ4y0PFqegzYwRB148YEHXemsvt2E6xI2cEC44NbNl C30QKmyxyKQJRIo0UoH7fi4Th8HCrNwXJtoc8ce94tsiHWYEkNDDrfT81O8wgLZQJmXW4o CViCJKU+1pjNhrK49C9Zoj2zcFA942w= Date: Fri, 29 May 2026 12:51:08 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v2 3/3] bpf: cgroup: restore sysctl new-value replacement To: Dawei Feng , martin.lau@linux.dev Cc: emil@etsalapatis.com, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, kees@kernel.org, joel.granados@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, jianhao.xu@seu.edu.cn, stable@vger.kernel.org, Zilin Guan References: <20260529031026.2716641-1-dawei.feng@seu.edu.cn> <20260529031026.2716641-4-dawei.feng@seu.edu.cn> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Jiayuan Chen In-Reply-To: <20260529031026.2716641-4-dawei.feng@seu.edu.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 5/29/26 11:10 AM, Dawei Feng wrote: > Commit 4e63acdff864 ("bpf: Introduce bpf_sysctl_{get,set}_new_value > helpers") changed the success return value to 0, but failed to update the > corresponding check in __cgroup_bpf_run_filter_sysctl(). Since > bpf_prog_run_array_cg() now returns 0 on success, the legacy ret == 1 > condition is never satisfied. As a result, the modified value is ignored, > and bpf_sysctl_set_new_value() fails to replace the write buffer. > > Fix this by checking for a return value of 0 instead, so cgroup/sysctl > programs can correctly replace the pending sysctl buffer. > > This bug was discovered during a manual code review. Tested via a > cgroup/sysctl BPF reproducer overriding writes to a target sysctl. > Pre-fix, bpf_sysctl_set_new_value("foo") was silently ignored: the write > returned 8192 and the value remained "600". Post-fix, the BPF replacement > buffer properly propagates: the write returns 3 and the value updates to > "foo". > > Fixes: 4e63acdff864 ("bpf: Introduce bpf_sysctl_{get,set}_new_value helpers") Change is fine but fixes tag is wrong like the bot said. > Cc: stable@vger.kernel.org > > Signed-off-by: Zilin Guan > Signed-off-by: Dawei Feng I saw a reviewed-by tag given by EmilĀ in previous thread. Pls carry it when sending new verson. > --- > kernel/bpf/cgroup.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c > index a0b5f8cd8b10..3f06e2270f5c 100644 > --- a/kernel/bpf/cgroup.c > +++ b/kernel/bpf/cgroup.c > @@ -1935,7 +1935,7 @@ int __cgroup_bpf_run_filter_sysctl(struct ctl_table_header *head, > > kfree(ctx.cur_val); > > - if (ret == 1 && ctx.new_updated) { > + if (!ret && ctx.new_updated) { > kvfree(*buf); > *buf = ctx.new_val; > *pcount = ctx.new_len;