fix(sys): handle EACCES from fstat on socketpair fds#30916
Conversation
9528cb9 to
2ecf453
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughOn Linux/Android, Changesfstat EACCES special-case handling
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/sys/lib.rs`:
- Around line 2098-2103: The current fstat error handling swallows Err(e) if e
== libc::EACCES for any Fd and returns a zeroed stat; restrict that fallback to
socket descriptors only by adding a platform-gated helper (e.g.
is_socket_fd(fd)) that uses getsockopt(SOL_SOCKET, SO_TYPE) on linux/android to
detect sockets, then change the Err(e) branch in the fstat handling so that if e
== libc::EACCES you call is_socket_fd(fd) and only return Ok(zeroed stat) when
true, otherwise propagate Err(Error::from_code_int(e, Tag::fstat)); ensure the
helper is inlined and only compiled on the appropriate targets and reference the
existing Tag::fstat and fstat handling code paths when making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7c4ebad3-a34f-463a-b1a3-b579f2200331
📒 Files selected for processing (1)
src/sys/lib.rs
2ecf453 to
112f305
Compare
|
Updated: fstat EACCES fallback is now scoped to socket fds only via getsockopt(SO_TYPE) probe. Non-socket fds will properly propagate the EACCES error. |
On some Linux configurations (notably with SELinux), fstat() on socketpair fds returns EACCES. Fall back to a zeroed stat instead of erroring.