-
-
Notifications
You must be signed in to change notification settings - Fork 168
fix(open): 修复open系统调用在gvisor下的异常表现 #1417
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
base: master
Are you sure you want to change the base?
Conversation
OpenTest.OTrunc OpenTest.OTruncAndReadOnlyDir OpenTest.OCreateDirectory OpenTest.MustCreateExisting OpenTest.CreateWithAppend OpenTest.AppendOnly OpenTest.AppendConcurrentWrite OpenTest.DirectoryWritableFails OpenTest.DirectoryDirectFails OpenTest.Null OpenTest.CanTruncateReadOnly OpenTest.OpenNonDirectoryWithTrailingSlash OpenTest.OpenWithStrangeFlags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes open syscall test failures by implementing proper POSIX semantics for various file open flags and adding boundary condition checks. The changes address O_NOFOLLOW, O_APPEND, O_TRUNC, O_EXCL, and directory-specific validations.
Key changes:
- Corrects O_APPEND semantics to move file offset to EOF only during write operations, not at open time
- Moves O_TRUNC truncation to occur before File object creation at the inode level
- Changes error codes from EPERM to EBADF for file access mode validation to align with POSIX standards
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| user/apps/tests/syscall/gvisor/blocklists/open_test | Adds blocklist for 8 symlink and permission tests that are not yet implemented |
| kernel/src/filesystem/vfs/open.rs | Implements O_NOFOLLOW flag handling, path validation (empty paths, trailing slashes), O_EXCL/O_CREAT/O_TRUNC semantics, and directory-specific flag checks |
| kernel/src/filesystem/vfs/file.rs | Refactors O_APPEND write logic to append at file end on each write, updates readable/writeable to return EBADF instead of EPERM, and adds unused set_offset method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
|
这里有些AI的review还没回应 @Vitus213 |
|
@claude review,审查功能、性能、安全、linux一致性的问题 |
|
Claude finished @fslongjin's task —— View job PR Review for #1417: fix(open): 修复open系统调用在gvisor下的异常表现I've completed a comprehensive review of the PR changes for functionality, performance, security, and Linux consistency. Here's my detailed feedback: Current Progress:
SummaryOverall, this PR makes significant improvements to open syscall semantics, fixing several test failures. The changes generally align with POSIX/Linux behavior, but there are some important issues that need to be addressed. Detailed Review✅ Positive Changes
|
| Behavior | DragonOS | Linux | Notes |
|---|---|---|---|
| `O_RDONLY | O_TRUNC` | ✅ Allowed with write perm | ✅ Allowed with write perm |
O_APPEND offset after open |
✅ 0 | ✅ 0 | lseek(fd, 0, SEEK_CUR) |
Directory with O_TRUNC |
✅ EISDIR |
✅ EISDIR |
|
Directory with O_DIRECT |
✅ EINVAL |
✅ EINVAL |
|
| Empty path | ✅ ENOENT |
AT_EMPTY_PATH special case |
|
| Trailing slash non-dir | ✅ ENOTDIR |
✅ ENOTDIR |
Recommendations
High Priority
- Fix O_APPEND race condition (
file.rs:630-635):- Implement atomic append or re-read size before write
- Consider inode-level locking for concurrent writes
Medium Priority
- Verify O_NOFOLLOW behavior: Ensure
lookup_follow_symlink2()returns symlink inode whenfollow_symlink=false - Standardize permission checks: Consider adding
can_write()check inwriteable()for consistency
Low Priority
- Translate blocklist comment to English
- Add debug assertion for unreachable symlink check (as suggested by Copilot)
Conclusion
This PR significantly improves open syscall compliance with POSIX/Linux standards. The functional changes are mostly correct, but the O_APPEND race condition is a critical issue that must be fixed before merging. Addressing this will prevent data corruption in concurrent write scenarios.
The PR is mostly ready but requires the race condition fix for production readiness.
Review complete - All aspects (functionality, performance, security, Linux consistency) have been evaluated.
symlink和权限检查的测试屏蔽了,补充了边界测试,其他点都过了