Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] dyndbg: split declaration and assignment of __free() in 
ddebug_proc_write()
--

commit 1bfaabab91de2989a4d10ae03eef349ab77809d6
Author: Christian Brauner <[email protected]>

dyndbg: let procfs copy in writes to /proc/dynamic_debug/control

This commit factors the query execution logic out of ddebug_proc_write() into
ddebug_proc_write_buf() and switches proc_fops to use .proc_write_buf and
.proc_write_size so procfs copies in the user buffer before pinning the entry.

> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index 64a2112908725..1d6012c9eb41f 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
> @@ -1002,11 +1002,28 @@ __setup("dyndbg=", dyndbg_setup);

[ ... ]

>  static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
>                                 size_t len, loff_t *offp)
>  {
> -     char *tmpbuf;
> -     int ret;
> +     char *tmpbuf __free(kfree) = NULL;
>  
>       if (len == 0)
>               return 0;
> @@ -1017,15 +1034,7 @@ static ssize_t ddebug_proc_write(struct file *file, 
> const char __user *ubuf,
>       tmpbuf = memdup_user_nul(ubuf, len);
>       if (IS_ERR(tmpbuf))
>               return PTR_ERR(tmpbuf);
> -     v2pr_info("read %zu bytes from userspace\n", len);
> -
> -     ret = ddebug_exec_queries(tmpbuf, NULL);
> -     kfree(tmpbuf);
> -     if (ret < 0)
> -             return ret;
> -
> -     *offp += len;
> -     return len;
> +     return ddebug_proc_write_buf(file, tmpbuf, len, offp);
>  }

[Severity: Low]
In ddebug_proc_write(), tmpbuf is declared with __free(kfree) = NULL at the
top of the function before the early length checks and then assigned later via
memdup_user_nul().

Per the cleanup.h guidelines, could tmpbuf be defined and initialized in a
single statement at the allocation site instead:

        char *tmpbuf __free(kfree) = memdup_user_nul(ubuf, len);

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=23

Reply via email to