dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.28k stars 4.73k forks source link

Extract_HardLinkEntry_TargetInsideDirectory test from System.Formats.Tar.Tests fails on Android/iOS/tvOS #68360

Open akoeplinger opened 2 years ago

akoeplinger commented 2 years ago

Newly added test from https://github.com/dotnet/runtime/pull/67883 fails on runtime-extra-platfroms. I haven't investigated whether it is expected, just filing this so I can disable the test with ActiveIssue.

Android fails with

System.UnauthorizedAccessException : Access to the path '/data/user/0/net.dot.System.Formats.Tar.Tests/cache/qtsmyi3v.nmj/link' is denied.
---- System.IO.IOException : Permission denied

Stack trace
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Interop.CheckIo(Int64 result, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Interop.CheckIo(Int32 result, String path, Boolean isDirectory, Func`2 errorRewriter)
   at System.Formats.Tar.TarEntry.ExtractAsHardLink(String targetFilePath, String hardLinkFilePath)
   at System.Formats.Tar.TarEntry.ExtractToFileInternal(String filePath, String linkTargetPath, Boolean overwrite)
   at System.Formats.Tar.TarEntry.ExtractRelativeToDirectory(String destinationDirectoryPath, Boolean overwrite)
   at System.Formats.Tar.TarFile.ExtractToDirectoryInternal(Stream source, String destinationDirectoryPath, Boolean overwriteFiles, Boolean leaveOpen)
   at System.Formats.Tar.TarFile.ExtractToDirectory(Stream source, String destinationDirectoryName, Boolean overwriteFiles)
   at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_LinkEntry_TargetInsideDirectory_Internal(TarEntryType entryType) in /_/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs:line 123
   at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_HardLinkEntry_TargetInsideDirectory() in /_/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs:line 101
   at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(Object obj, IntPtr* byrefParameters, Span`1 argsForTemporaryMonoSupport, BindingFlags invokeAttr)
----- Inner Stack Trace -----

iOS/tvOS Simulators fail with

System.IO.IOException : Extracting the Tar entry '/Users/helix-runner/Library/Developer/CoreSimulator/Devices/11416593-2690-443B-964F-E9F6694BA19A/dat' would have resulted in a link target outside the specified destination directory: '/Users/helix-runner/Library/Developer/CoreSimulator/Devices/11416593-2690-443B-964F-E9F6694BA19A/data/Containers/Data/Application/1BD07C3B-0285-4EAB-943A-2BBFDD9E63A5/tmp/f2gsvib5.4m4/'

Stack trace
   at System.Formats.Tar.TarEntry.<ExtractRelativeToDirectory>g__GetSanitizedFullPath|34_0(String destinationDirectoryFullPath, String path, String exceptionMessage)
   at System.Formats.Tar.TarEntry.ExtractRelativeToDirectory(String destinationDirectoryPath, Boolean overwrite)
   at System.Formats.Tar.TarFile.ExtractToDirectoryInternal(Stream source, String destinationDirectoryPath, Boolean overwriteFiles, Boolean leaveOpen)
   at System.Formats.Tar.TarFile.ExtractToDirectory(Stream source, String destinationDirectoryName, Boolean overwriteFiles)
   at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_LinkEntry_TargetInsideDirectory_Internal(TarEntryType entryType)
   at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_HardLinkEntry_TargetInsideDirectory()
   at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(Object obj, IntPtr* byrefParameters, Span`1 argsForTemporaryMonoSupport, BindingFlags invokeAttr)

FYI @carlossanlop

ghost commented 2 years ago

Tagging subscribers to this area: @dotnet/area-system-io See info in area-owners.md if you want to be subscribed.

Issue Details
Newly added test from https://github.com/dotnet/runtime/pull/67883 fails on runtime-extra-platfroms. I haven't investigated whether it is expected, just filing this so I can disable the test with ActiveIssue. Android fails with ``` System.UnauthorizedAccessException : Access to the path '/data/user/0/net.dot.System.Formats.Tar.Tests/cache/qtsmyi3v.nmj/link' is denied. ---- System.IO.IOException : Permission denied Stack trace at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) at Interop.CheckIo(Int64 result, String path, Boolean isDirectory, Func`2 errorRewriter) at Interop.CheckIo(Int32 result, String path, Boolean isDirectory, Func`2 errorRewriter) at System.Formats.Tar.TarEntry.ExtractAsHardLink(String targetFilePath, String hardLinkFilePath) at System.Formats.Tar.TarEntry.ExtractToFileInternal(String filePath, String linkTargetPath, Boolean overwrite) at System.Formats.Tar.TarEntry.ExtractRelativeToDirectory(String destinationDirectoryPath, Boolean overwrite) at System.Formats.Tar.TarFile.ExtractToDirectoryInternal(Stream source, String destinationDirectoryPath, Boolean overwriteFiles, Boolean leaveOpen) at System.Formats.Tar.TarFile.ExtractToDirectory(Stream source, String destinationDirectoryName, Boolean overwriteFiles) at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_LinkEntry_TargetInsideDirectory_Internal(TarEntryType entryType) in /_/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs:line 123 at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_HardLinkEntry_TargetInsideDirectory() in /_/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs:line 101 at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(Object obj, IntPtr* byrefParameters, Span`1 argsForTemporaryMonoSupport, BindingFlags invokeAttr) ----- Inner Stack Trace ----- ``` iOS/tvOS Simulators fail with ``` System.IO.IOException : Extracting the Tar entry '/Users/helix-runner/Library/Developer/CoreSimulator/Devices/11416593-2690-443B-964F-E9F6694BA19A/dat' would have resulted in a link target outside the specified destination directory: '/Users/helix-runner/Library/Developer/CoreSimulator/Devices/11416593-2690-443B-964F-E9F6694BA19A/data/Containers/Data/Application/1BD07C3B-0285-4EAB-943A-2BBFDD9E63A5/tmp/f2gsvib5.4m4/' Stack trace at System.Formats.Tar.TarEntry.g__GetSanitizedFullPath|34_0(String destinationDirectoryFullPath, String path, String exceptionMessage) at System.Formats.Tar.TarEntry.ExtractRelativeToDirectory(String destinationDirectoryPath, Boolean overwrite) at System.Formats.Tar.TarFile.ExtractToDirectoryInternal(Stream source, String destinationDirectoryPath, Boolean overwriteFiles, Boolean leaveOpen) at System.Formats.Tar.TarFile.ExtractToDirectory(Stream source, String destinationDirectoryName, Boolean overwriteFiles) at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_LinkEntry_TargetInsideDirectory_Internal(TarEntryType entryType) at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_HardLinkEntry_TargetInsideDirectory() at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(Object obj, IntPtr* byrefParameters, Span`1 argsForTemporaryMonoSupport, BindingFlags invokeAttr) ``` FYI @carlossanlop
Author: akoeplinger
Assignees: -
Labels: `area-System.IO`
Milestone: -
stephentoub commented 2 years ago

Same root cause as what's being fixed in https://github.com/dotnet/runtime/pull/68361?

akoeplinger commented 2 years ago

I don't think it's the same issue.

ghost commented 2 years ago

Tagging subscribers to this area: @dotnet/area-system-io-compression See info in area-owners.md if you want to be subscribed.

Issue Details
Newly added test from https://github.com/dotnet/runtime/pull/67883 fails on runtime-extra-platfroms. I haven't investigated whether it is expected, just filing this so I can disable the test with ActiveIssue. Android fails with ``` System.UnauthorizedAccessException : Access to the path '/data/user/0/net.dot.System.Formats.Tar.Tests/cache/qtsmyi3v.nmj/link' is denied. ---- System.IO.IOException : Permission denied Stack trace at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) at Interop.CheckIo(Int64 result, String path, Boolean isDirectory, Func`2 errorRewriter) at Interop.CheckIo(Int32 result, String path, Boolean isDirectory, Func`2 errorRewriter) at System.Formats.Tar.TarEntry.ExtractAsHardLink(String targetFilePath, String hardLinkFilePath) at System.Formats.Tar.TarEntry.ExtractToFileInternal(String filePath, String linkTargetPath, Boolean overwrite) at System.Formats.Tar.TarEntry.ExtractRelativeToDirectory(String destinationDirectoryPath, Boolean overwrite) at System.Formats.Tar.TarFile.ExtractToDirectoryInternal(Stream source, String destinationDirectoryPath, Boolean overwriteFiles, Boolean leaveOpen) at System.Formats.Tar.TarFile.ExtractToDirectory(Stream source, String destinationDirectoryName, Boolean overwriteFiles) at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_LinkEntry_TargetInsideDirectory_Internal(TarEntryType entryType) in /_/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs:line 123 at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_HardLinkEntry_TargetInsideDirectory() in /_/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs:line 101 at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(Object obj, IntPtr* byrefParameters, Span`1 argsForTemporaryMonoSupport, BindingFlags invokeAttr) ----- Inner Stack Trace ----- ``` iOS/tvOS Simulators fail with ``` System.IO.IOException : Extracting the Tar entry '/Users/helix-runner/Library/Developer/CoreSimulator/Devices/11416593-2690-443B-964F-E9F6694BA19A/dat' would have resulted in a link target outside the specified destination directory: '/Users/helix-runner/Library/Developer/CoreSimulator/Devices/11416593-2690-443B-964F-E9F6694BA19A/data/Containers/Data/Application/1BD07C3B-0285-4EAB-943A-2BBFDD9E63A5/tmp/f2gsvib5.4m4/' Stack trace at System.Formats.Tar.TarEntry.g__GetSanitizedFullPath|34_0(String destinationDirectoryFullPath, String path, String exceptionMessage) at System.Formats.Tar.TarEntry.ExtractRelativeToDirectory(String destinationDirectoryPath, Boolean overwrite) at System.Formats.Tar.TarFile.ExtractToDirectoryInternal(Stream source, String destinationDirectoryPath, Boolean overwriteFiles, Boolean leaveOpen) at System.Formats.Tar.TarFile.ExtractToDirectory(Stream source, String destinationDirectoryName, Boolean overwriteFiles) at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_LinkEntry_TargetInsideDirectory_Internal(TarEntryType entryType) at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_HardLinkEntry_TargetInsideDirectory() at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(Object obj, IntPtr* byrefParameters, Span`1 argsForTemporaryMonoSupport, BindingFlags invokeAttr) ``` FYI @carlossanlop
Author: akoeplinger
Assignees: -
Labels: `area-System.IO.Compression`, `untriaged`
Milestone: -
danmoseley commented 2 years ago

@carlossanlop

carlossanlop commented 2 years ago

I think the user we use to execute tests in Android/iOS/tvOS does not have permission to create symbolic links in those operating systems. I will have to use elevation in those OS.

carlossanlop commented 2 years ago

Test failure has been fixed, and the test method has been reenabled.

karelz commented 2 years ago

The test is failing again -- @carlossanlop can you please disable it again and take a look?

Failures since 6/17 - query in runfo

Rolling builds:

Test output example:

System.IO.IOException : Extracting the Tar entry '/Users/helix-runner/Library/Developer/CoreSimulator/Devices/B689B860-E125-4467-80B3-E8073029AB31/dat' would have resulted in a link target outside the specified destination directory: '/Users/helix-runner/Library/Developer/CoreSimulator/Devices/B689B860-E125-4467-80B3-E8073029AB31/data/Containers/Data/Application/34807FE3-9761-4A8D-95A4-38EDB198D1E0/tmp/5jyza0jc.ucf'

   at System.Formats.Tar.TarEntry.ExtractRelativeToDirectory(String destinationDirectoryPath, Boolean overwrite)
   at System.Formats.Tar.TarFile.ExtractToDirectoryInternal(Stream source, String destinationDirectoryPath, Boolean overwriteFiles, Boolean leaveOpen)
   at System.Formats.Tar.TarFile.ExtractToDirectory(Stream source, String destinationDirectoryName, Boolean overwriteFiles)
   at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_LinkEntry_TargetInsideDirectory_Internal(TarEntryType entryType)
   at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_HardLinkEntry_TargetInsideDirectory()
   at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
karelz commented 2 years ago

Also, test System.Formats.Tar.Tests.TarReader_ExtractToFile_Tests.ExtractToFile_SpecialFile_Unelevated_Throws fails as well with similar error to the 1st one report in the top post:

System.UnauthorizedAccessException : Access to the path '/private/var/mobile/Containers/Data/Application/607B5A9D-8D94-42C4-8CCD-54BCE7B1B2E9/tmp/j2osgcp1.kpt/output' is denied.
---- System.IO.IOException : Operation not permitted

  at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at System.Formats.Tar.TarEntry.ExtractAsFifo(String destinationFileName)
   at System.Formats.Tar.TarEntry.ExtractToFileInternal(String filePath, String linkTargetPath, Boolean overwrite)
   at System.Formats.Tar.TarEntry.ExtractToFile(String destinationFileName, Boolean overwrite)
   at System.Formats.Tar.Tests.TarReader_ExtractToFile_Tests.ExtractToFile_SpecialFile_Unelevated_Throws()
   at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)

Failures since 6/17 - query in runfo

Rolling builds:

ghost commented 2 years ago

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

Issue Details
Newly added test from https://github.com/dotnet/runtime/pull/67883 fails on runtime-extra-platfroms. I haven't investigated whether it is expected, just filing this so I can disable the test with ActiveIssue. Android fails with ``` System.UnauthorizedAccessException : Access to the path '/data/user/0/net.dot.System.Formats.Tar.Tests/cache/qtsmyi3v.nmj/link' is denied. ---- System.IO.IOException : Permission denied Stack trace at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) at Interop.CheckIo(Int64 result, String path, Boolean isDirectory, Func`2 errorRewriter) at Interop.CheckIo(Int32 result, String path, Boolean isDirectory, Func`2 errorRewriter) at System.Formats.Tar.TarEntry.ExtractAsHardLink(String targetFilePath, String hardLinkFilePath) at System.Formats.Tar.TarEntry.ExtractToFileInternal(String filePath, String linkTargetPath, Boolean overwrite) at System.Formats.Tar.TarEntry.ExtractRelativeToDirectory(String destinationDirectoryPath, Boolean overwrite) at System.Formats.Tar.TarFile.ExtractToDirectoryInternal(Stream source, String destinationDirectoryPath, Boolean overwriteFiles, Boolean leaveOpen) at System.Formats.Tar.TarFile.ExtractToDirectory(Stream source, String destinationDirectoryName, Boolean overwriteFiles) at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_LinkEntry_TargetInsideDirectory_Internal(TarEntryType entryType) in /_/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs:line 123 at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_HardLinkEntry_TargetInsideDirectory() in /_/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs:line 101 at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(Object obj, IntPtr* byrefParameters, Span`1 argsForTemporaryMonoSupport, BindingFlags invokeAttr) ----- Inner Stack Trace ----- ``` iOS/tvOS Simulators fail with ``` System.IO.IOException : Extracting the Tar entry '/Users/helix-runner/Library/Developer/CoreSimulator/Devices/11416593-2690-443B-964F-E9F6694BA19A/dat' would have resulted in a link target outside the specified destination directory: '/Users/helix-runner/Library/Developer/CoreSimulator/Devices/11416593-2690-443B-964F-E9F6694BA19A/data/Containers/Data/Application/1BD07C3B-0285-4EAB-943A-2BBFDD9E63A5/tmp/f2gsvib5.4m4/' Stack trace at System.Formats.Tar.TarEntry.g__GetSanitizedFullPath|34_0(String destinationDirectoryFullPath, String path, String exceptionMessage) at System.Formats.Tar.TarEntry.ExtractRelativeToDirectory(String destinationDirectoryPath, Boolean overwrite) at System.Formats.Tar.TarFile.ExtractToDirectoryInternal(Stream source, String destinationDirectoryPath, Boolean overwriteFiles, Boolean leaveOpen) at System.Formats.Tar.TarFile.ExtractToDirectory(Stream source, String destinationDirectoryName, Boolean overwriteFiles) at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_LinkEntry_TargetInsideDirectory_Internal(TarEntryType entryType) at System.Formats.Tar.Tests.TarFile_ExtractToDirectory_Stream_Tests.Extract_HardLinkEntry_TargetInsideDirectory() at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(Object obj, IntPtr* byrefParameters, Span`1 argsForTemporaryMonoSupport, BindingFlags invokeAttr) ``` FYI @carlossanlop
Author: akoeplinger
Assignees: carlossanlop
Labels: `area-System.IO.Compression`, `os-ios`, `os-tvos`
Milestone: 7.0.0
karelz commented 2 years ago

@carlossanlop the main issue with test Extract_HardLinkEntry_TargetInsideDirectory was addressed. Thanks!

However, the second similar issue with test ExtractToFile_SpecialFile_Unelevated_Throws is still happening -- see above https://github.com/dotnet/runtime/issues/68360#issuecomment-1159654910

Reopening to keep tracking it. Feel free to split it into another issue if it is more convenient for you.

karelz commented 2 years ago

@carlossanlop given that it fails in each CI run, please disable the test ASAP unless you have high confidence fix. Thanks!

adamsitnik commented 2 years ago

I've opened #71258 to disable this test for tvOS

ilonatommy commented 2 years ago

I'm facing a very similar issue on unconnected PRs (Run) on:

karelz commented 2 years ago

Test is disabled, not blocking CI anymore -> removing blocking-clean-ci label.