Skip to content
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: ERRNO gets wrongly set #849

Closed
flpostolache opened this issue Apr 19, 2023 · 2 comments
Closed

lib/vfscore: ERRNO gets wrongly set #849

flpostolache opened this issue Apr 19, 2023 · 2 comments
Labels
kind/bug Something isn't working

Comments

@flpostolache
Copy link
Contributor

Describe the bug

Currently, the symlink syscall implementation fromvfscore sets the errno variable to some default values that don't correspond to the man pages in case of an error. This might be a problem when some ported apps explicitly check for a specific errno to continue.

Steps to reproduce

For reproduction, you can use this repository to compare errno results across multiple modes. This repo lets you compile and run the testsuite both as a plain linux source and as an Unikraft app. You can use the run.sh script with the plain argument to compile the source file and run it as a linux executable and qemu-root argument to build and run the testsuite as a Unikraft app. When you will run the plain executable, you will see that the errno is set to ELOOP in the eloop test, while on Unikraft side it will return ENOENT.

Expected behavior

The expectation is that Unikraft will set the errno correctly, as per man pages description.

Which architectures were you using or does this bug affect?

x86_64

Which platforms were you using or does this bug affect?

kvm

Relevant log output

Plain testsuite output:

Preparing ELOOP test.                                                                                                                                                                                      
Symlink call returned -1.                                                                                                                                                                                  
ERRNO: 40. Too many levels of symbolic links.                                                                                                                                                              
FINISHING ELOOP test.                                                                                                                                                                                      
--------------------                                                                                                                                                                                       
                                                                                                                                                                                                           
Preparing EEXIST test.                                                                               
Symlink call returned -1.                                                                            
ERRNO: 2. No such file or directory.                                                                 
FINISHING EEXIST test.                            
--------------------                                                                                 
                                                                                                     
Preparing ENOENT test.                                                                               
Symlink call returned -1.                                                                            
ERRNO: 2. No such file or directory.                                                                 
FINISHING ENOENT test.                                                                               
--------------------                                                                                 
                                                                                                     
Preparing WRITE_CONTENT test.                                                                        
Symlink call returned 0                                                                                                                                                                                    
fd=3                                                                                                                                                                                                       
FINISHING WRITE_CONTENT test.                                                                                                                                                                              
--------------------

Unikraft testuite output:

Powered by
o.   .o       _ _               __ _
Oo   Oo  ___ (_) | __ __  __ _ ' _) :_
oO   oO ' _ `| | |/ /  _)' _` | |_|  _)
oOo oOO| | | | |   (| | | (_) |  _) :_
 OoOoO ._, ._:_:_,\_._,  .__,_:_, \___)
             Epimetheus 0.12.0~45d00c7d
[    0.174027] Info: [libukboot] <boot.c @  348> Pre-init table at 0x1e0098 - 0x1e0098
[    0.177254] Info: [libukboot] <boot.c @  359> Constructor table at 0x1e0098 - 0x1e0098
[    0.180522] Info: [libukboot] <boot.c @  369> Calling main(2, ['build/test-symlink_kvm-x86_64', 'console=ttyS0'])

Preparing ELOOP test.
Symlink call returned -1.
ERRNO: 2. No such file or directory. 
FINISHING ELOOP test.
--------------------

Preparing EEXIST test.
Symlink call returned -1.
ERRNO: 2. No such file or directory.
FINISHING EEXIST test.
--------------------

Preparing ENOENT test.
Symlink call returned -1.
ERRNO: 2. No such file or directory.
FINISHING ENOENT test.
--------------------

Preparing WRITE_CONTENT test.
Symlink call returned 0
fd=3
FINISHING WRITE_CONTENT test.
--------------------
@flpostolache flpostolache added the kind/bug Something isn't working label Apr 19, 2023
StefanJum added a commit to unikraft-upb/unikraft that referenced this issue Apr 20, 2023
The `sys_symlink()` function returns `ENOENT` if the lookup failed,
instead of the actual error code `lookup()` exited with.
This may not always be right, since `lookup()` can return other error
codes (for example `ELOOP`).

Fix that by not setting the error code and just jump to the end of the
function.

Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
GitHub-Closes: unikraft#849
@StefanJum
Copy link
Member

@maniatro111 can you check if #851 fixes it for you (in addition with #830)?

@flpostolache
Copy link
Contributor Author

flpostolache commented Apr 22, 2023

Hello, @StefanJum ! Yes, the problem is solved with those two PRs. Sadly, I haven't managed to add more tests to check more ERRNO cases. Will work on adding more and see if any differences appear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

2 participants