BPF List
 help / color / mirror / Atom feed
* [PATCH] sched-ext: Use correct annotation for strings in kfuncs
@ 2024-10-21 20:11 Kumar Kartikeya Dwivedi
  2024-10-21 20:13 ` Tejun Heo
  2024-10-23 19:06 ` Tejun Heo
  0 siblings, 2 replies; 3+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2024-10-21 20:11 UTC (permalink / raw)
  To: Tejun Heo; +Cc: bpf, linux-kernel

The sched-ext kfuncs with bstr suffix need to take a string, but that
requires annotating the parameters with __str suffix, as right now the
verifier will treat this parameter as a one-byte memory region.

Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
Fixes: 07814a9439a3 ("sched_ext: Print debug dump after an error exit")
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 kernel/sched/ext.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 3cd7c50a51c5..8b8e3c907340 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -6708,7 +6708,7 @@ __bpf_kfunc_start_defs();
  * Indicate that the BPF scheduler wants to exit gracefully, and initiate ops
  * disabling.
  */
-__bpf_kfunc void scx_bpf_exit_bstr(s64 exit_code, char *fmt,
+__bpf_kfunc void scx_bpf_exit_bstr(s64 exit_code, char *fmt__str,
 				   unsigned long long *data, u32 data__sz)
 {
 	unsigned long flags;
@@ -6729,7 +6729,7 @@ __bpf_kfunc void scx_bpf_exit_bstr(s64 exit_code, char *fmt,
  * Indicate that the BPF scheduler encountered a fatal error and initiate ops
  * disabling.
  */
-__bpf_kfunc void scx_bpf_error_bstr(char *fmt, unsigned long long *data,
+__bpf_kfunc void scx_bpf_error_bstr(char *fmt__str, unsigned long long *data,
 				    u32 data__sz)
 {
 	unsigned long flags;
@@ -6753,7 +6753,7 @@ __bpf_kfunc void scx_bpf_error_bstr(char *fmt, unsigned long long *data,
  * The extra dump may be multiple lines. A single line may be split over
  * multiple calls. The last line is automatically terminated.
  */
-__bpf_kfunc void scx_bpf_dump_bstr(char *fmt, unsigned long long *data,
+__bpf_kfunc void scx_bpf_dump_bstr(char *fmt__str, unsigned long long *data,
 				   u32 data__sz)
 {
 	struct scx_dump_data *dd = &scx_dump_data;
--
2.43.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched-ext: Use correct annotation for strings in kfuncs
  2024-10-21 20:11 [PATCH] sched-ext: Use correct annotation for strings in kfuncs Kumar Kartikeya Dwivedi
@ 2024-10-21 20:13 ` Tejun Heo
  2024-10-23 19:06 ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2024-10-21 20:13 UTC (permalink / raw)
  To: Kumar Kartikeya Dwivedi; +Cc: bpf, linux-kernel

On Mon, Oct 21, 2024 at 01:11:43PM -0700, Kumar Kartikeya Dwivedi wrote:
> The sched-ext kfuncs with bstr suffix need to take a string, but that
> requires annotating the parameters with __str suffix, as right now the
> verifier will treat this parameter as a one-byte memory region.
> 
> Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
> Fixes: 07814a9439a3 ("sched_ext: Print debug dump after an error exit")
> Cc: Tejun Heo <tj@kernel.org>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>

Applied to sched_ext/for-6.12-fixes.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched-ext: Use correct annotation for strings in kfuncs
  2024-10-21 20:11 [PATCH] sched-ext: Use correct annotation for strings in kfuncs Kumar Kartikeya Dwivedi
  2024-10-21 20:13 ` Tejun Heo
@ 2024-10-23 19:06 ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2024-10-23 19:06 UTC (permalink / raw)
  To: Kumar Kartikeya Dwivedi; +Cc: bpf, linux-kernel

On Mon, Oct 21, 2024 at 01:11:43PM -0700, Kumar Kartikeya Dwivedi wrote:
> The sched-ext kfuncs with bstr suffix need to take a string, but that
> requires annotating the parameters with __str suffix, as right now the
> verifier will treat this parameter as a one-byte memory region.
> 
> Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
> Fixes: 07814a9439a3 ("sched_ext: Print debug dump after an error exit")
> Cc: Tejun Heo <tj@kernel.org>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>

I popped this patch from sched_ext/for-6.12-fixes along with the follow-up
fix. This breaks compatibility in a way which is difficult to work around.
If we want to do this, I think we should do it by introducing new set of
kfuncs and than phasing out the old ones. Also, it's unclear what the
practical benefits of the change are anyway.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-23 19:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-21 20:11 [PATCH] sched-ext: Use correct annotation for strings in kfuncs Kumar Kartikeya Dwivedi
2024-10-21 20:13 ` Tejun Heo
2024-10-23 19:06 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox