-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
lib/vfscore: Fix create through broken symlink #998
Conversation
81d6352
to
494b0eb
Compare
int | ||
namei(const char *path, struct dentry **dpp) |
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.
int | |
namei(const char *path, struct dentry **dpp) | |
int namei(const char *path, struct dentry **dpp) |
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.
You can leave it on the same line, as mentioned in the coding - conventions PR: unikraft/docs#248
Prefer the Linux style with the return type on the same line as the function name.
In case of long functions + first argument, you can break after the return type.
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.
All of lookup.c uses this format, and I believe maintaining consistency is important.
If we however believe this style actively harms readability, we can address it for the entire file in a style change PR.
In vfs.h: sure, there it makes sense, and the rest of the file follows suit as well.
lib/vfscore/vfs.h
Outdated
* - (0): Completed successfully | ||
* - (<0): Negative value with error code | ||
*/ | ||
int |
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.
Same here
return error; | ||
} | ||
/* | ||
* Convert a pathname into a pointer to a dentry |
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.
I think the commentary is not needed, since it's very similar in vfs.h
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.
Indeed the comments are duplicates of the docstrings in vfs.h, however the file already has this style for exported functions and I don't want to break it without good reason.
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.
Thanks @andreittr. See my few comments below. Other than that I wasn't able to reproduce the issue with the example you provided, though the changes make sense.
lib/vfscore/lookup.c
Outdated
*/ | ||
int | ||
namei(const char *path, struct dentry **dpp) | ||
namei_resolve(const char *path, struct dentry **dpp, char realpath[PATH_MAX]) |
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.
namei_resolve(const char *path, struct dentry **dpp, char realpath[PATH_MAX]) | |
namei_resolve(const char *path, struct dentry **dpp, char *realpath) |
Let's have this without the specified size, just like it happens for the other argument.
lib/vfscore/lookup.c
Outdated
return 0; | ||
out: | ||
if (realpath) | ||
strcpy(realpath, fp); |
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.
strcpy(realpath, fp); | |
strlcpy(realpath, fp, PATH_MAX); |
We can use strlcpy()
in order to keep the consistency within the file and for better security.
What behavior are you getting when trying to reproduce? If the symlink call fails you might need to apply this PR: #952. |
I had already applied that PR since I also reviewed it.
The bug is not reproducible on @andreittr I'll approve the PR after you apply the suggestions, thank you for this! |
Previously a vfs syscall on a broken symlink would fail with ENOENT instead of attempting the syscall on the symlink target. This would make open(O_CREAT) to fail instead of creating the missing target file. This change fixes this behavior, bringing it in line with expectations. Signed-off-by: Andrei Tatar <andrei@unikraft.io>
494b0eb
to
257ccba
Compare
Pushed changes addressing comments.
That's really odd that 9pfs isn't affected, as the code paths are common between filesystems 🤷 . |
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.
All good on my side now, thanks a lot for the fixes @andreittr!
Reviewed-by: Maria Sfiraiala maria.sfiraiala@gmail.com
✅ Checkpatch passed Beep boop! I ran Unikraft's
|
All good also from my side. As @mariasfiraiala, I have only managed to reproduce the bug on ramfs, not 9pfs. Reviewed-by: Radu Nichita radunichita99@gmail.com |
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.
Approved-by: Razvan Deaconescu razvand@unikraft.io
Description of changes
Previously a vfs syscall on a broken symlink would fail with ENOENT instead of attempting the syscall on the symlink target. This would make open(O_CREAT) to fail instead of creating the missing target file. This change fixes this behavior, bringing it in line with expectations.
Prerequisite checklist
checkpatch.uk
on your commit series before opening this PR;Base target
Additional configuration
Test with: