diff mbox series

[v2,1/8] unicode: Fix utf8_load() error path

Message ID 20240902225511.757831-2-andrealmeid@igalia.com (mailing list archive)
State New
Headers show
Series tmpfs: Add case-insesitive support for tmpfs | expand

Commit Message

André Almeida Sept. 2, 2024, 10:55 p.m. UTC
utf8_load() requests the symbol "utf8_data_table" and then checks if the
requested UTF-8 version is supported. If it's unsupported, it tries to
put the data table using symbol_put(). If an unsupported version is
requested, symbol_put() fails like this:

 kernel BUG at kernel/module/main.c:786!
 RIP: 0010:__symbol_put+0x93/0xb0
 Call Trace:
  <TASK>
  ? __die_body.cold+0x19/0x27
  ? die+0x2e/0x50
  ? do_trap+0xca/0x110
  ? do_error_trap+0x65/0x80
  ? __symbol_put+0x93/0xb0
  ? exc_invalid_op+0x51/0x70
  ? __symbol_put+0x93/0xb0
  ? asm_exc_invalid_op+0x1a/0x20
  ? __pfx_cmp_name+0x10/0x10
  ? __symbol_put+0x93/0xb0
  ? __symbol_put+0x62/0xb0
  utf8_load+0xf8/0x150

That happens because symbol_put() expects the unique string that
identify the symbol, instead of a pointer to the loaded symbol. Fix that
by using such string.

Fixes: 2b3d04787012 ("unicode: Add utf8-data module")
Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 fs/unicode/utf8-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Theodore Ts'o Sept. 3, 2024, 11:40 a.m. UTC | #1
On Mon, Sep 02, 2024 at 07:55:03PM -0300, André Almeida wrote:
> utf8_load() requests the symbol "utf8_data_table" and then checks if the
> requested UTF-8 version is supported. If it's unsupported, it tries to
> put the data table using symbol_put(). If an unsupported version is
> requested, symbol_put() fails like this:
> 
>  kernel BUG at kernel/module/main.c:786!
>  RIP: 0010:__symbol_put+0x93/0xb0
>  Call Trace:
>   <TASK>
>   ? __die_body.cold+0x19/0x27
>   ? die+0x2e/0x50
>   ? do_trap+0xca/0x110
>   ? do_error_trap+0x65/0x80
>   ? __symbol_put+0x93/0xb0
>   ? exc_invalid_op+0x51/0x70
>   ? __symbol_put+0x93/0xb0
>   ? asm_exc_invalid_op+0x1a/0x20
>   ? __pfx_cmp_name+0x10/0x10
>   ? __symbol_put+0x93/0xb0
>   ? __symbol_put+0x62/0xb0
>   utf8_load+0xf8/0x150
> 
> That happens because symbol_put() expects the unique string that
> identify the symbol, instead of a pointer to the loaded symbol. Fix that
> by using such string.
> 
> Fixes: 2b3d04787012 ("unicode: Add utf8-data module")
> Signed-off-by: André Almeida <andrealmeid@igalia.com>

Nice catch!

Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Gabriel Krisman Bertazi Sept. 3, 2024, 4:48 p.m. UTC | #2
André Almeida <andrealmeid@igalia.com> writes:

> utf8_load() requests the symbol "utf8_data_table" and then checks if the
> requested UTF-8 version is supported. If it's unsupported, it tries to
> put the data table using symbol_put(). If an unsupported version is
> requested, symbol_put() fails like this:
>
>  kernel BUG at kernel/module/main.c:786!
>  RIP: 0010:__symbol_put+0x93/0xb0
>  Call Trace:
>   <TASK>
>   ? __die_body.cold+0x19/0x27
>   ? die+0x2e/0x50
>   ? do_trap+0xca/0x110
>   ? do_error_trap+0x65/0x80
>   ? __symbol_put+0x93/0xb0
>   ? exc_invalid_op+0x51/0x70
>   ? __symbol_put+0x93/0xb0
>   ? asm_exc_invalid_op+0x1a/0x20
>   ? __pfx_cmp_name+0x10/0x10
>   ? __symbol_put+0x93/0xb0
>   ? __symbol_put+0x62/0xb0
>   utf8_load+0xf8/0x150
>
> That happens because symbol_put() expects the unique string that
> identify the symbol, instead of a pointer to the loaded symbol. Fix that
> by using such string.
>

Thanks!

I picked only this one via the for-next branch of the unicode tree.  No need to resubmit
this one with the rest of the series.
diff mbox series

Patch

diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c
index 8395066341a4..0400824ef493 100644
--- a/fs/unicode/utf8-core.c
+++ b/fs/unicode/utf8-core.c
@@ -198,7 +198,7 @@  struct unicode_map *utf8_load(unsigned int version)
 	return um;
 
 out_symbol_put:
-	symbol_put(um->tables);
+	symbol_put(utf8_data_table);
 out_free_um:
 	kfree(um);
 	return ERR_PTR(-EINVAL);