From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 70C8C3FDBFD; Thu, 16 Jul 2026 13:48:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784209725; cv=none; b=sYNQfvLDG2+G5LVjQzl5KMZ3y2rFADCHfRuTgpPPY3S8SKf1tn9kZsVEwwa4/1oOOF9fiSmlVvB4u539u50C3Wa2X/7MFw7wBXl5o+AERLOtoyebrXHP1YJrE9HgVkXsFhf2uRrle2WcVbAOQHOYR5B41SbQ5Dny5XAtt6lTiuE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784209725; c=relaxed/simple; bh=UILTVJIYM1lb4xzmIcqkrCTxzuKHOVIdkaO1J5+lGYs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hDoVehE1txxcwncAEPlDLZhZgnRS9W3+oQZGEMK3ZT5xG0vghRCpJTSdrnoq4l/Hjy1UHv8tGbw1YmE9ZILV3QNZpq6AS/5FwyHPw9kOQSweigJy6sC/9WLWv908tvG2IRjo5dJniUWSk1SXpkTkG7hGDkJe4RiA9m1F4jL/hx0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=q7dzpvO0; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="q7dzpvO0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 401061F00A3F; Thu, 16 Jul 2026 13:48:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784209720; bh=ni0kSQZ+MsvNRxmhnheRmNUrY6aDZvQFNaiBMbOgzEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=q7dzpvO04892XZ7YNqB2Z74+ZcNzLfN7BvUMVX2XXHlLnf/AEjQXq7DxbPsNchtHG 6uQL4BjpcAGyDbeHmzpjYwFwSBHjrbWURosrCQZLapwtgoK6P7Xb+4zKZ+qAALIYDv Bzf96MyfkgAuYMOyARuwqFLxAuG4DStofUyR5Dks= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yonghong Song , Zilin Guan , Dawei Feng , Jiayuan Chen , Xu Kuohai , Alexei Starovoitov Subject: [PATCH 7.1 292/518] bpf: Restore sysctl new-value from 1 to 0 Date: Thu, 16 Jul 2026 15:29:20 +0200 Message-ID: <20260716133054.207528997@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260716133047.772246337@linuxfoundation.org> References: <20260716133047.772246337@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dawei Feng commit 2566c3b24219c5b30e35205cba029ff34ff7c78b upstream. 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: f10d05966196 ("bpf: Make BPF_PROG_RUN_ARRAY return -err instead of allow boolean") Cc: stable@vger.kernel.org Acked-by: Yonghong Song Signed-off-by: Zilin Guan Signed-off-by: Dawei Feng Reviewed-by: Jiayuan Chen Acked-by: Xu Kuohai Link: https://lore.kernel.org/r/20260603105317.944304-4-dawei.feng@seu.edu.cn Signed-off-by: Alexei Starovoitov Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -1935,7 +1935,7 @@ int __cgroup_bpf_run_filter_sysctl(struc 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;