2021-10-26 11:01:32

by YE Chengfeng

[permalink] [raw]
Subject: drivers/crypto: suspected null-pointer dereference at atmel_sha_init

Hi,

https://github.com/torvalds/linux/blob/master/drivers/crypto/atmel-sha.c#L431

We notice that the return pointer of atmel_sha_find_dev could be null, and it seems that null-check is missing at #line 431. If it returns null pointer, there will be a null pointer dereference problem at #line 437. We check that other call sites of this interface perform null-check, while this doesn't, so we suspect that this could be a problem.

This is detected by our experimental static analysis tool, it could be false positive, so we manually check and report those we think may be true bugs. Would you like to have a look at them?

Thanks so much,
Chengfeng


2021-10-27 16:07:02

by Herbert Xu

[permalink] [raw]
Subject: Re: drivers/crypto: suspected null-pointer dereference at atmel_sha_init

On Tue, Oct 26, 2021 at 09:07:43AM +0000, YE Chengfeng wrote:
> Hi,
>
> https://github.com/torvalds/linux/blob/master/drivers/crypto/atmel-sha.c#L431
>
> We notice that the return pointer of atmel_sha_find_dev could be null, and it seems that null-check is missing at #line 431. If it returns null pointer, there will be a null pointer dereference problem at #line 437. We check that other call sites of this interface perform null-check, while this doesn't, so we suspect that this could be a problem.
>
> This is detected by our experimental static analysis tool, it could be false positive, so we manually check and report those we think may be true bugs. Would you like to have a look at them?

It could be a real issue when the device is hot unplugged.

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2021-10-27 21:31:14

by YE Chengfeng

[permalink] [raw]
Subject: 回复: drivers/crypto: suspected null-pointer dereference at atmel_sha_init

Thanks for your reply!

Do you need us help you to provide a patch to fix it?

Best regards,
Chengfeng

-----?ʼ?ԭ??-----
??????: Herbert Xu <[email protected]>
????ʱ??: 2021??10??27?? 10:56
?ռ???: YE Chengfeng <[email protected]>
????: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
????: Re: drivers/crypto: suspected null-pointer dereference at atmel_sha_init

On Tue, Oct 26, 2021 at 09:07:43AM +0000, YE Chengfeng wrote:
> Hi,
>
> https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> ub.com%2Ftorvalds%2Flinux%2Fblob%2Fmaster%2Fdrivers%2Fcrypto%2Fatmel-s
> ha.c%23L431&amp;data=04%7C01%7Ccyeaa%40connect.ust.hk%7C83edd64969f444
> 64edf608d998f54ac1%7C6c1d415239d044ca88d9b8d6ddca0708%7C1%7C0%7C637709
> 001562266287%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luM
> zIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=5HYshMZFegruxmG%2Bu
> nxw%2F2LF5lrTGFt%2FgTaKbNIKiv8%3D&amp;reserved=0
>
> We notice that the return pointer of atmel_sha_find_dev could be null, and it seems that null-check is missing at #line 431. If it returns null pointer, there will be a null pointer dereference problem at #line 437. We check that other call sites of this interface perform null-check, while this doesn't, so we suspect that this could be a problem.
>
> This is detected by our experimental static analysis tool, it could be false positive, so we manually check and report those we think may be true bugs. Would you like to have a look at them?

It could be a real issue when the device is hot unplugged.

Cheers,
--
Email: Herbert Xu <[email protected]> Home Page: https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgondor.apana.org.au%2F~herbert%2F&amp;data=04%7C01%7Ccyeaa%40connect.ust.hk%7C83edd64969f44464edf608d998f54ac1%7C6c1d415239d044ca88d9b8d6ddca0708%7C1%7C0%7C637709001562266287%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=5h6aT%2FpRjy3GRzb%2FGbGTA3INxe8xsSEENTVa1Jl09Qg%3D&amp;reserved=0
PGP Key: https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgondor.apana.org.au%2F~herbert%2Fpubkey.txt&amp;data=04%7C01%7Ccyeaa%40connect.ust.hk%7C83edd64969f44464edf608d998f54ac1%7C6c1d415239d044ca88d9b8d6ddca0708%7C1%7C0%7C637709001562276244%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=PYlSTQdb0j9gdasnQ0YJq3ktqNlxalxyKetM%2BJCKiFc%3D&amp;reserved=0

2021-10-30 13:42:00

by YE Chengfeng

[permalink] [raw]
Subject: 回复: drivers/crypto: suspected null-pointer dereference at atmel_sha_init

I send a patch for it.

Best regards,
Chengfeng

-----?ʼ?ԭ??-----
??????: YE Chengfeng
????ʱ??: 2021??10??27?? 19:12
?ռ???: Herbert Xu <[email protected]>
????: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
????: ?ظ?: drivers/crypto: suspected null-pointer dereference at atmel_sha_init

Thanks for your reply!

Do you need us help you to provide a patch to fix it?

Best regards,
Chengfeng

-----?ʼ?ԭ??-----
??????: Herbert Xu <[email protected]>
????ʱ??: 2021??10??27?? 10:56
?ռ???: YE Chengfeng <[email protected]>
????: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
????: Re: drivers/crypto: suspected null-pointer dereference at atmel_sha_init

On Tue, Oct 26, 2021 at 09:07:43AM +0000, YE Chengfeng wrote:
> Hi,
>
> https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> ub.com%2Ftorvalds%2Flinux%2Fblob%2Fmaster%2Fdrivers%2Fcrypto%2Fatmel-s
> ha.c%23L431&amp;data=04%7C01%7Ccyeaa%40connect.ust.hk%7C83edd64969f444
> 64edf608d998f54ac1%7C6c1d415239d044ca88d9b8d6ddca0708%7C1%7C0%7C637709
> 001562266287%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luM
> zIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=5HYshMZFegruxmG%2Bu
> nxw%2F2LF5lrTGFt%2FgTaKbNIKiv8%3D&amp;reserved=0
>
> We notice that the return pointer of atmel_sha_find_dev could be null, and it seems that null-check is missing at #line 431. If it returns null pointer, there will be a null pointer dereference problem at #line 437. We check that other call sites of this interface perform null-check, while this doesn't, so we suspect that this could be a problem.
>
> This is detected by our experimental static analysis tool, it could be false positive, so we manually check and report those we think may be true bugs. Would you like to have a look at them?

It could be a real issue when the device is hot unplugged.

Cheers,
--
Email: Herbert Xu <[email protected]> Home Page: https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgondor.apana.org.au%2F~herbert%2F&amp;data=04%7C01%7Ccyeaa%40connect.ust.hk%7C83edd64969f44464edf608d998f54ac1%7C6c1d415239d044ca88d9b8d6ddca0708%7C1%7C0%7C637709001562266287%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=5h6aT%2FpRjy3GRzb%2FGbGTA3INxe8xsSEENTVa1Jl09Qg%3D&amp;reserved=0
PGP Key: https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgondor.apana.org.au%2F~herbert%2Fpubkey.txt&amp;data=04%7C01%7Ccyeaa%40connect.ust.hk%7C83edd64969f44464edf608d998f54ac1%7C6c1d415239d044ca88d9b8d6ddca0708%7C1%7C0%7C637709001562276244%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=PYlSTQdb0j9gdasnQ0YJq3ktqNlxalxyKetM%2BJCKiFc%3D&amp;reserved=0