[PATCH v3 01/10] liveupdate: Pass user argument to file preserve and retrieve
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Tue Nov 3 17:03:21 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] liveupdate: karg __free(kfree) declared as NULL at top of luo_copy_user_arg()
--
commit c4f18d427b088994ba26ccc665552744e8d63e5a
Author: Pasha Tatashin <pasha.tatashin at soleen.com>
liveupdate: Pass user argument to file preserve and retrieve
This commit extends LIVEUPDATE_SESSION_PRESERVE_FD and
LIVEUPDATE_SESSION_RETRIEVE_FD with an optional user-space argument pointer,
allowing file handlers to specify and receive handler-specific argument
structures during file preservation and retrieval.
> diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c
> index a39992da504fb..eeeb3b5ff2faa 100644
> --- a/kernel/liveupdate/luo_file.c
> +++ b/kernel/liveupdate/luo_file.c
[ ... ]
> @@ -202,11 +203,45 @@ static bool luo_token_is_used(struct luo_file_set *file_set, u64 token)
> return false;
> }
>
> +static int luo_copy_user_arg(u64 user_arg, const void **argp,
> + const struct liveupdate_arg_spec *spec)
> +{
> + void *karg __free(kfree) = NULL;
> + void __user *uptr;
> + u32 user_size;
> + int err;
> +
> + if (!user_arg)
> + return 0;
> + if (!spec->size)
> + return -EOPNOTSUPP;
> +
> + uptr = u64_to_user_ptr(user_arg);
> + if (get_user(user_size, (u32 __user *)uptr))
> + return -EFAULT;
> + if (user_size < spec->min_size)
> + return -EINVAL;
> + if (user_size > PAGE_SIZE)
> + return -E2BIG;
> +
> + karg = kmalloc(spec->size, GFP_KERNEL);
> + if (!karg)
> + return -ENOMEM;
[Severity: Low]
This isn't a bug, but in luo_copy_user_arg(), karg is declared with
__free(kfree) = NULL at the top of the function and assigned later after the
early validation checks.
Per the Cleanup API conventions in include/linux/cleanup.h, could karg be
defined and initialized in a single statement at the allocation site instead:
void *karg __free(kfree) = kmalloc(spec->size, GFP_KERNEL);
if (!karg)
return -ENOMEM;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103010216.3447716-1-dmatlack@google.com?part=1
More information about the kexec
mailing list