diff mbox series

unicode: add s_encoding null ptr check in utf8ncursor

Message ID 20230920112015.829124-2-twuufnxlz@gmail.com
State Rejected
Headers show
Series unicode: add s_encoding null ptr check in utf8ncursor | expand

Commit Message

Edward AD Sept. 20, 2023, 11:20 a.m. UTC
When init struct utf8cursor *u8c in utf8ncursor(), we need check um is
valid.

Reported-and-tested-by: syzbot+9cf75dc581fb4307d6dd@syzkaller.appspotmail.com
Fixes: b81427939590 ("ext4: remove redundant checks of s_encoding")
Signed-off-by: Edward AD <twuufnxlz@gmail.com>
---
 fs/unicode/utf8-norm.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Eric Biggers Sept. 20, 2023, 7:37 p.m. UTC | #1
On Wed, Sep 20, 2023 at 07:20:16PM +0800, Edward AD wrote:
> When init struct utf8cursor *u8c in utf8ncursor(), we need check um is
> valid.
> 
> Reported-and-tested-by: syzbot+9cf75dc581fb4307d6dd@syzkaller.appspotmail.com
> Fixes: b81427939590 ("ext4: remove redundant checks of s_encoding")
> Signed-off-by: Edward AD <twuufnxlz@gmail.com>
> ---
>  fs/unicode/utf8-norm.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fs/unicode/utf8-norm.c b/fs/unicode/utf8-norm.c
> index 768f8ab448b8..906b639b2f38 100644
> --- a/fs/unicode/utf8-norm.c
> +++ b/fs/unicode/utf8-norm.c
> @@ -422,6 +422,10 @@ int utf8ncursor(struct utf8cursor *u8c, const struct unicode_map *um,
>  {
>  	if (!s)
>  		return -1;
> +
> +	if (IS_ERR_OR_NULL(um))
> +		return -1;
> +
>  	u8c->um = um;
>  	u8c->n = n;
>  	u8c->s = s;
> -- 

See https://lore.kernel.org/linux-fsdevel/20230920073659.GC2739@sol.localdomain/

- Eric
diff mbox series

Patch

diff --git a/fs/unicode/utf8-norm.c b/fs/unicode/utf8-norm.c
index 768f8ab448b8..906b639b2f38 100644
--- a/fs/unicode/utf8-norm.c
+++ b/fs/unicode/utf8-norm.c
@@ -422,6 +422,10 @@  int utf8ncursor(struct utf8cursor *u8c, const struct unicode_map *um,
 {
 	if (!s)
 		return -1;
+
+	if (IS_ERR_OR_NULL(um))
+		return -1;
+
 	u8c->um = um;
 	u8c->n = n;
 	u8c->s = s;