Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android](CryptoNative_HmacUpdate): Parameter 'data' must be a valid pointer' #61783

Closed
MaximLipnin opened this issue Nov 18, 2021 · 11 comments · Fixed by #61827
Closed

[Android](CryptoNative_HmacUpdate): Parameter 'data' must be a valid pointer' #61783

MaximLipnin opened this issue Nov 18, 2021 · 11 comments · Fixed by #61827
Labels
area-System.Security os-android untriaged New issue has not been triaged by the area owner

Comments

@MaximLipnin
Copy link
Contributor

System.Security.Cryptography.Tests failed on Android due to a crash with the following message:

Abort message: '/__w/1/s/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/pal_hmac.c:88 (CryptoNative_HmacUpdate): Parameter 'data' must be a valid pointer'

https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-61670-merge-3d266bcf337a4ffe92/System.Security.Cryptography.Tests/1/adb-logcat-net.dot.System.Security.Cryptography.Tests-net.dot.MonoRunner.log?sv=2019-07-07&se=2021-12-08T15%3A07%3A31Z&sr=c&sp=rl&sig=McQh8mbdRtBm%2FUFGKVsx7BoxJQ6bKhUkvsFldClN2iI%3D

cc @steveisok @akoeplinger

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Security untriaged New issue has not been triaged by the area owner labels Nov 18, 2021
@ghost
Copy link

ghost commented Nov 18, 2021

Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq, @GrabYourPitchforks
See info in area-owners.md if you want to be subscribed.

Issue Details

System.Security.Cryptography.Tests failed on Android due to a crash with the following message:

Abort message: '/__w/1/s/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/pal_hmac.c:88 (CryptoNative_HmacUpdate): Parameter 'data' must be a valid pointer'

https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-61670-merge-3d266bcf337a4ffe92/System.Security.Cryptography.Tests/1/adb-logcat-net.dot.System.Security.Cryptography.Tests-net.dot.MonoRunner.log?sv=2019-07-07&se=2021-12-08T15%3A07%3A31Z&sr=c&sp=rl&sig=McQh8mbdRtBm%2FUFGKVsx7BoxJQ6bKhUkvsFldClN2iI%3D

cc @steveisok @akoeplinger

Author: MaximLipnin
Assignees: -
Labels:

area-System.Security, untriaged

Milestone: -

@MaximLipnin
Copy link
Contributor Author

It might be related to #61742 @AaronRobinsonMSFT

@marek-safar
Copy link
Contributor

I'm curious to know we got into this state

@ghost
Copy link

ghost commented Nov 18, 2021

Tagging subscribers to 'arch-android': @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Issue Details

System.Security.Cryptography.Tests failed on Android due to a crash with the following message:

Abort message: '/__w/1/s/src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/pal_hmac.c:88 (CryptoNative_HmacUpdate): Parameter 'data' must be a valid pointer'

https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-61670-merge-3d266bcf337a4ffe92/System.Security.Cryptography.Tests/1/adb-logcat-net.dot.System.Security.Cryptography.Tests-net.dot.MonoRunner.log?sv=2019-07-07&se=2021-12-08T15%3A07%3A31Z&sr=c&sp=rl&sig=McQh8mbdRtBm%2FUFGKVsx7BoxJQ6bKhUkvsFldClN2iI%3D

cc @steveisok @akoeplinger

Author: MaximLipnin
Assignees: -
Labels:

area-System.Security, os-android, untriaged

Milestone: -

@steveisok
Copy link
Member

I confirmed it started happening at least from the last rolling build.

@AaronRobinsonMSFT
Copy link
Member

I'll take a look.

@AaronRobinsonMSFT
Copy link
Member

/cc @jkoritzinsky @elinor-fung

@marek-safar
Copy link
Contributor

@steveisok could we ensure if there is CI hole that it's closed?

@AaronRobinsonMSFT
Copy link
Member

I think this is a slight semantic change that is handled properly but validates earlier than needed on Android.

int32_t CryptoNative_EvpDigestOneShot(const EVP_MD* type, const void* source, int32_t sourceSize, uint8_t* md, uint32_t* mdSize)
{
if (type == NULL || sourceSize < 0 || md == NULL || mdSize == NULL)
return 0;
EVP_MD_CTX* ctx = CryptoNative_EvpMdCtxCreate(type);

My plan is to move the NULL check after the case where length is 0.

int32_t CryptoNative_EvpDigestOneShot(intptr_t type, void* source, int32_t sourceSize, uint8_t* md, uint32_t* mdSize)
{
abort_if_invalid_pointer_argument (source);
if (!type || !md || !mdSize || sourceSize < 0)
return FAIL;

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Nov 18, 2021
@elinor-fung
Copy link
Member

The signature of EvpDigentOneShot is blittable, so the semantic change should not be in how we are handling arguments for that function though.

[GeneratedDllImport(Libraries.AndroidCryptoNative, EntryPoint = "CryptoNative_EvpDigestOneShot")]
internal static unsafe partial int EvpDigestOneShot(IntPtr type, byte* source, int sourceSize, byte* md, uint* mdSize);

Something must have caused inputs to change so that it is being passed null.

@AaronRobinsonMSFT
Copy link
Member

@elinor-fung Agreed. I confirmed we are simply creating a DllImport anyways so I'm unclear how we got here. I am putting up a commit reverting only that change to confirm in the CI.

@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Nov 19, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Nov 19, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Nov 24, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Dec 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Security os-android untriaged New issue has not been triaged by the area owner
Projects
None yet
5 participants