[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aSl-HhDCCjax-XrF@kernel.org>
Date: Fri, 28 Nov 2025 12:49:02 +0200
From: Mike Rapoport <rppt@...nel.org>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Pasha Tatashin <pasha.tatashin@...een.com>,
Pratyush Yadav <pratyush@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH next] liveupdate: luo_file: don't use invalid list
iterator
On Fri, Nov 28, 2025 at 10:17:07AM +0300, Dan Carpenter wrote:
> If we exit a list_for_each_entry() without hitting a break then the
> list iterator points to an offset from the list_head. It's a
> non-NULL but invalid pointer and dereferencing it isn't allowed.
>
> Introduce a new "found" variable to test instead.
>
> Fixes: 3ee1d673194e ("liveupdate: luo_file: implement file systems callbacks")
> Reported-by: kernel test robot <lkp@...el.com>
> Closes: https://lore.kernel.org/r/202511280420.y9O4fyhX-lkp@intel.com/
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@...nel.org>
> ---
> Presumably, this going to be folded into the original patch. I just
> added the tags because they are harmless.
>
> kernel/liveupdate/luo_file.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c
> index fca3806dae28..86b4d274d9aa 100644
> --- a/kernel/liveupdate/luo_file.c
> +++ b/kernel/liveupdate/luo_file.c
> @@ -561,17 +561,20 @@ int luo_retrieve_file(struct luo_file_set *file_set, u64 token,
> {
> struct liveupdate_file_op_args args = {0};
> struct luo_file *luo_file;
> + bool found = false;
> int err;
>
> if (list_empty(&file_set->files_list))
> return -ENOENT;
>
> list_for_each_entry(luo_file, &file_set->files_list, list) {
> - if (luo_file->token == token)
> + if (luo_file->token == token) {
> + found = true;
> break;
> + }
> }
>
> - if (luo_file->token != token)
> + if (!found)
> return -ENOENT;
>
> guard(mutex)(&luo_file->mutex);
> --
> 2.51.0
>
--
Sincerely yours,
Mike.
Powered by blists - more mailing lists