-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Linux] procfs file reads and UnauthorizedAccessException handling #62513
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsIn restricted environments such as a container with limited access, shared hosting, chroot and other forms of sandbox, .NET process may not have read permissions on procfs files, while the file may exist. This can lead to While most of the managed code reading procfs files in the runtime repo found by Line 38 in c8ede5c
runtime/src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs Line 149 in c8ede5c
runtime/src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.ParseMapModules.cs Lines 26 to 27 in c8ede5c
Line 36 in c8ede5c
and then there are cases in
|
this would be nice to fix for consistency. |
Triage: It would be nice clean up. Should not be that difficult to do. |
In restricted environments such as a container with limited access, shared hosting, chroot and other forms of sandbox, .NET process may not have read permissions on procfs files, while the file may exist. This can lead to
UnauthorizedAccessException
.While most of the managed code reading procfs files in the runtime repo found by
git grep /proc ':/*.cs' ':/!*[tT]est*'
seem to handle unauhorized access case, we should try to make the user-experience consistent and align varied styles where possible. A few examples:runtime/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.cs
Line 38 in c8ede5c
runtime/src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
Line 149 in c8ede5c
runtime/src/libraries/Common/src/Interop/Linux/procfs/Interop.ProcFsStat.ParseMapModules.cs
Lines 26 to 27 in c8ede5c
runtime/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/StringParsingHelpers.Connections.cs
Line 36 in c8ede5c
and then there are cases in
NetworkInformation
, which do not handle the exception at all. Majority of procfs files listed inNetworkInformation/NetworkFiles.cs
are read viaStringParsingHelpers
. Some call sites catchIOException
andUnauthorizedAccessException
, others don't and it seems unintentional. For instance,GetIcmpV4Statistics
andGetTcpIPv4Statistics
docs do not mentionPlatformNotSupportedException
,IOException
orUnauthorizedAccessException
are the possible exceptions which these APIs can throw, onlyNetworkInformationException
is noted.The text was updated successfully, but these errors were encountered: