* [PATCH next] liveupdate: luo_file: don't use invalid list iterator
@ 2025-11-28 7:17 Dan Carpenter
2025-11-28 10:49 ` Mike Rapoport
2025-11-28 14:38 ` Pasha Tatashin
0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-11-28 7:17 UTC (permalink / raw)
To: Pasha Tatashin
Cc: Mike Rapoport, Pratyush Yadav, Andrew Morton, linux-kernel,
kernel-janitors
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@intel.com>
Closes: https://lore.kernel.org/r/202511280420.y9O4fyhX-lkp@intel.com/
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH next] liveupdate: luo_file: don't use invalid list iterator
2025-11-28 7:17 [PATCH next] liveupdate: luo_file: don't use invalid list iterator Dan Carpenter
@ 2025-11-28 10:49 ` Mike Rapoport
2025-11-28 14:38 ` Pasha Tatashin
1 sibling, 0 replies; 4+ messages in thread
From: Mike Rapoport @ 2025-11-28 10:49 UTC (permalink / raw)
To: Dan Carpenter
Cc: Pasha Tatashin, Pratyush Yadav, Andrew Morton, linux-kernel,
kernel-janitors
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@intel.com>
> Closes: https://lore.kernel.org/r/202511280420.y9O4fyhX-lkp@intel.com/
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH next] liveupdate: luo_file: don't use invalid list iterator
2025-11-28 7:17 [PATCH next] liveupdate: luo_file: don't use invalid list iterator Dan Carpenter
2025-11-28 10:49 ` Mike Rapoport
@ 2025-11-28 14:38 ` Pasha Tatashin
2025-11-28 16:01 ` Pasha Tatashin
1 sibling, 1 reply; 4+ messages in thread
From: Pasha Tatashin @ 2025-11-28 14:38 UTC (permalink / raw)
To: Dan Carpenter
Cc: Mike Rapoport, Pratyush Yadav, Andrew Morton, linux-kernel,
kernel-janitors
> Fixes: 3ee1d673194e ("liveupdate: luo_file: implement file systems callbacks")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/r/202511280420.y9O4fyhX-lkp@intel.com/
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Thank you,
Pasha
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH next] liveupdate: luo_file: don't use invalid list iterator
2025-11-28 14:38 ` Pasha Tatashin
@ 2025-11-28 16:01 ` Pasha Tatashin
0 siblings, 0 replies; 4+ messages in thread
From: Pasha Tatashin @ 2025-11-28 16:01 UTC (permalink / raw)
To: Dan Carpenter
Cc: Mike Rapoport, Pratyush Yadav, Andrew Morton, linux-kernel,
kernel-janitors
On Fri, Nov 28, 2025 at 9:38 AM Pasha Tatashin
<pasha.tatashin@soleen.com> wrote:
>
> > Fixes: 3ee1d673194e ("liveupdate: luo_file: implement file systems callbacks")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/r/202511280420.y9O4fyhX-lkp@intel.com/
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
>
> Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Given that this patch is already in nonmm-stable, it should be OK to
apply this fix in one of the RCs.
>
> Thank you,
> Pasha
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-28 16:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-28 7:17 [PATCH next] liveupdate: luo_file: don't use invalid list iterator Dan Carpenter
2025-11-28 10:49 ` Mike Rapoport
2025-11-28 14:38 ` Pasha Tatashin
2025-11-28 16:01 ` Pasha Tatashin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).