* [PATCH] module: release codetag section when module load fails
@ 2025-05-18 10:12 David Wang
2025-05-19 16:03 ` Suren Baghdasaryan
2025-05-19 16:38 ` [PATCH v2] " David Wang
0 siblings, 2 replies; 6+ messages in thread
From: David Wang @ 2025-05-18 10:12 UTC (permalink / raw)
To: surenb, mcgrof, petr.pavlu; +Cc: linux-modules, linux-kernel, David Wang
When module load failed after memory for codetag sections ready,
codetag section memory was not properly released. This
causes memory leak, and if next module load happens to got the
same module address, codetag may pick the uninitialized section
when manipulating tags during module unload, and lead to
"unable to handle page fault" BUG.
Closes: https://lore.kernel.org/all/20250516131246.6244-1-00107082@163.com/
Signed-off-by: David Wang <00107082@163.com>
---
kernel/module/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/module/main.c b/kernel/module/main.c
index a2859dc3eea6..5c6ab20240a6 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -2829,6 +2829,7 @@ static void module_deallocate(struct module *mod, struct load_info *info)
{
percpu_modfree(mod);
module_arch_freeing_init(mod);
+ codetag_free_module_sections(mod);
free_mod_mem(mod);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] module: release codetag section when module load fails
2025-05-18 10:12 [PATCH] module: release codetag section when module load fails David Wang
@ 2025-05-19 16:03 ` Suren Baghdasaryan
2025-05-19 16:30 ` David Wang
2025-05-19 16:38 ` [PATCH v2] " David Wang
1 sibling, 1 reply; 6+ messages in thread
From: Suren Baghdasaryan @ 2025-05-19 16:03 UTC (permalink / raw)
To: David Wang; +Cc: mcgrof, petr.pavlu, linux-modules, linux-kernel
On Sun, May 18, 2025 at 3:12 AM David Wang <00107082@163.com> wrote:
>
> When module load failed after memory for codetag sections ready,
nit: s/ready/is ready
> codetag section memory was not properly released. This
> causes memory leak, and if next module load happens to got the
nit: s/happens to got/happens to get
> same module address, codetag may pick the uninitialized section
> when manipulating tags during module unload, and lead to
> "unable to handle page fault" BUG.
>
> Closes: https://lore.kernel.org/all/20250516131246.6244-1-00107082@163.com/
> Signed-off-by: David Wang <00107082@163.com>
Acked-by: Suren Baghdasaryan <surenb@google.com>
> ---
> kernel/module/main.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/module/main.c b/kernel/module/main.c
> index a2859dc3eea6..5c6ab20240a6 100644
> --- a/kernel/module/main.c
> +++ b/kernel/module/main.c
> @@ -2829,6 +2829,7 @@ static void module_deallocate(struct module *mod, struct load_info *info)
> {
> percpu_modfree(mod);
> module_arch_freeing_init(mod);
> + codetag_free_module_sections(mod);
>
> free_mod_mem(mod);
> }
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] module: release codetag section when module load fails
2025-05-19 16:03 ` Suren Baghdasaryan
@ 2025-05-19 16:30 ` David Wang
0 siblings, 0 replies; 6+ messages in thread
From: David Wang @ 2025-05-19 16:30 UTC (permalink / raw)
To: Suren Baghdasaryan; +Cc: mcgrof, petr.pavlu, linux-modules, linux-kernel
At 2025-05-20 00:03:16, "Suren Baghdasaryan" <surenb@google.com> wrote:
>On Sun, May 18, 2025 at 3:12 AM David Wang <00107082@163.com> wrote:
>>
>> When module load failed after memory for codetag sections ready,
>
>nit: s/ready/is ready
>
>> codetag section memory was not properly released. This
>> causes memory leak, and if next module load happens to got the
>
>nit: s/happens to got/happens to get
>
Thanks, I will send new version.
>
>> same module address, codetag may pick the uninitialized section
>> when manipulating tags during module unload, and lead to
>> "unable to handle page fault" BUG.
>>
>> Closes: https://lore.kernel.org/all/20250516131246.6244-1-00107082@163.com/
>> Signed-off-by: David Wang <00107082@163.com>
>
>Acked-by: Suren Baghdasaryan <surenb@google.com>
>
>> ---
>> kernel/module/main.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/kernel/module/main.c b/kernel/module/main.c
>> index a2859dc3eea6..5c6ab20240a6 100644
>> --- a/kernel/module/main.c
>> +++ b/kernel/module/main.c
>> @@ -2829,6 +2829,7 @@ static void module_deallocate(struct module *mod, struct load_info *info)
>> {
>> percpu_modfree(mod);
>> module_arch_freeing_init(mod);
>> + codetag_free_module_sections(mod);
>>
>> free_mod_mem(mod);
>> }
>> --
>> 2.39.2
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] module: release codetag section when module load fails
2025-05-18 10:12 [PATCH] module: release codetag section when module load fails David Wang
2025-05-19 16:03 ` Suren Baghdasaryan
@ 2025-05-19 16:38 ` David Wang
2025-05-19 16:46 ` Suren Baghdasaryan
1 sibling, 1 reply; 6+ messages in thread
From: David Wang @ 2025-05-19 16:38 UTC (permalink / raw)
To: surenb, petr.pavlu, mcgrof; +Cc: linux-modules, linux-kernel, David Wang
When module load fails after memory for codetag section is ready,
codetag section memory will not be properly released. This
causes memory leak, and if next module load happens to get the
same module address, codetag may pick the uninitialized section
when manipulating tags during module unload, and leads to
"unable to handle page fault" BUG.
Closes: https://lore.kernel.org/all/20250516131246.6244-1-00107082@163.com/
Signed-off-by: David Wang <00107082@163.com>
Acked-by: Suren Baghdasaryan <surenb@google.com>
---
kernel/module/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/module/main.c b/kernel/module/main.c
index a2859dc3eea6..5c6ab20240a6 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -2829,6 +2829,7 @@ static void module_deallocate(struct module *mod, struct load_info *info)
{
percpu_modfree(mod);
module_arch_freeing_init(mod);
+ codetag_free_module_sections(mod);
free_mod_mem(mod);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] module: release codetag section when module load fails
2025-05-19 16:38 ` [PATCH v2] " David Wang
@ 2025-05-19 16:46 ` Suren Baghdasaryan
2025-05-19 16:57 ` Suren Baghdasaryan
0 siblings, 1 reply; 6+ messages in thread
From: Suren Baghdasaryan @ 2025-05-19 16:46 UTC (permalink / raw)
To: Andrew Morton; +Cc: petr.pavlu, mcgrof, linux-modules, linux-kernel, David Wang
On Mon, May 19, 2025 at 9:38 AM David Wang <00107082@163.com> wrote:
>
> When module load fails after memory for codetag section is ready,
> codetag section memory will not be properly released. This
> causes memory leak, and if next module load happens to get the
> same module address, codetag may pick the uninitialized section
> when manipulating tags during module unload, and leads to
> "unable to handle page fault" BUG.
>
> Closes: https://lore.kernel.org/all/20250516131246.6244-1-00107082@163.com/
> Signed-off-by: David Wang <00107082@163.com>
> Acked-by: Suren Baghdasaryan <surenb@google.com>
Sending to Andrew for adding into the mm tree.
> ---
> kernel/module/main.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/module/main.c b/kernel/module/main.c
> index a2859dc3eea6..5c6ab20240a6 100644
> --- a/kernel/module/main.c
> +++ b/kernel/module/main.c
> @@ -2829,6 +2829,7 @@ static void module_deallocate(struct module *mod, struct load_info *info)
> {
> percpu_modfree(mod);
> module_arch_freeing_init(mod);
> + codetag_free_module_sections(mod);
>
> free_mod_mem(mod);
> }
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] module: release codetag section when module load fails
2025-05-19 16:46 ` Suren Baghdasaryan
@ 2025-05-19 16:57 ` Suren Baghdasaryan
0 siblings, 0 replies; 6+ messages in thread
From: Suren Baghdasaryan @ 2025-05-19 16:57 UTC (permalink / raw)
To: Andrew Morton; +Cc: petr.pavlu, mcgrof, linux-modules, linux-kernel, David Wang
On Mon, May 19, 2025 at 9:46 AM Suren Baghdasaryan <surenb@google.com> wrote:
>
> On Mon, May 19, 2025 at 9:38 AM David Wang <00107082@163.com> wrote:
> >
> > When module load fails after memory for codetag section is ready,
> > codetag section memory will not be properly released. This
> > causes memory leak, and if next module load happens to get the
> > same module address, codetag may pick the uninitialized section
> > when manipulating tags during module unload, and leads to
> > "unable to handle page fault" BUG.
> >
Fixes: 0db6f8d7820a ("alloc_tag: load module tags into separate
contiguous memory")
> > Closes: https://lore.kernel.org/all/20250516131246.6244-1-00107082@163.com/
> > Signed-off-by: David Wang <00107082@163.com>
> > Acked-by: Suren Baghdasaryan <surenb@google.com>
>
> Sending to Andrew for adding into the mm tree.
>
> > ---
> > kernel/module/main.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/kernel/module/main.c b/kernel/module/main.c
> > index a2859dc3eea6..5c6ab20240a6 100644
> > --- a/kernel/module/main.c
> > +++ b/kernel/module/main.c
> > @@ -2829,6 +2829,7 @@ static void module_deallocate(struct module *mod, struct load_info *info)
> > {
> > percpu_modfree(mod);
> > module_arch_freeing_init(mod);
> > + codetag_free_module_sections(mod);
> >
> > free_mod_mem(mod);
> > }
> > --
> > 2.39.2
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-05-19 16:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-18 10:12 [PATCH] module: release codetag section when module load fails David Wang
2025-05-19 16:03 ` Suren Baghdasaryan
2025-05-19 16:30 ` David Wang
2025-05-19 16:38 ` [PATCH v2] " David Wang
2025-05-19 16:46 ` Suren Baghdasaryan
2025-05-19 16:57 ` Suren Baghdasaryan
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).