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

utime() fails to assign current time to file #157

Closed
vamsikrishna935 opened this issue May 4, 2020 · 22 comments
Closed

utime() fails to assign current time to file #157

vamsikrishna935 opened this issue May 4, 2020 · 22 comments
Assignees
Labels
area: sgx-lkl Core SGX-LKL functionality bug p1 Medium priority
Milestone

Comments

@vamsikrishna935
Copy link
Contributor

vamsikrishna935 commented May 4, 2020

Utime03 is failing because of this issue. Please find the testcase details below.
https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/utime/utime03.c

utime syscall : http://man7.org/linux/man-pages/man2/utime.2.html

Analysis :
Temporary file is created while setup and test tries to test utime syscall.
TEST(utime(TEMP_FILE, NULL)); This will call utime on temp_file and changes modified and access times to current time (Expected Behavior of utime syscall)
But in actual it is not setting it to current time , because the system time is 00:00:00 UTC on 1 January 1970. Here are some findings.
TEST(utime(TEMP_FILE, NULL)) will return -1 on failure.

  1. Verification step.

    • In the test we are capturing the time stamps before (in the variable curr_time) and after (in the variable pres_time) calling utime to perform validation.
    • We do have sleep for few seconds to get difference in times
    • So we call utime() on temp file , both modifed & access times of files should be greater than curr_time (captured before utime using time() function) and less than pres_time
  2. Actual behavior TEST(utime(TEMP_FILE, NULL))

    • TEST(utime(TEMP_FILE, NULL)) got succeeded.
    • Below are the debugging details
    • (gdb) p access_time
      $1 = 64
      (gdb) p modf_time
      $2 = 64
      (gdb) p user_uid
      $3 = 0
      (gdb) p curr_time
      $4 = 1587997633
      (gdb) p pres_time
      $5 = 1587997644
      (gdb) p stat_buf
      $6 = {st_dev = 65024, st_ino = 169, st_nlink = 1, st_mode = 33270, st_uid = 1, st_gid = 1, __pad0 = 0, st_rdev = 0,
      st_size = 0, st_blksize = 4096, st_blocks = 0, st_atim = {tv_sec = 64, tv_nsec = 120000000}, st_mtim = {tv_sec = 64,
      tv_nsec = 120000000}, st_ctim = {tv_sec = 64, tv_nsec = 120000000}, __unused = {140734238814168, 140734279192000,
      140733199559282}}
    • It didn't set the file modified & access times to current which is not expected.
@vamsikrishna935
Copy link
Contributor Author

#121 is not fixed , cannot able to reopen the issue 121 . So created a new issue to track it.

@prp prp changed the title utime(file, NULL) syscall is not setting current time to the file when "NULL" is passed as arguement. utime() fails to assign current time to file May 4, 2020
@prp prp added area: sgx-lkl Core SGX-LKL functionality bug p1 Medium priority labels May 4, 2020
@prp prp added this to the Milestone 2 milestone May 4, 2020
@SeanTAllen
Copy link
Contributor

This is definitely broken on oe_port and would have been for a while from the looks of it. utime03 and a couple more of the utime tests pass on my ongoing in-enclave-time-source branch. However, at the moment, that branch is breaking a couple of other things.

I'm trying to see if I can get a slightly abbreviated version of the "in-enclave time source" work to pass CI that would include the utime fixes which would, in theory, be mergeable before all the work is done.

@SeanTAllen
Copy link
Contributor

SeanTAllen commented May 4, 2020

This is fixed as part of #134 work.

I'll update this issue when those changes are merged.

@SeanTAllen
Copy link
Contributor

This has been addressed. The utime03 ltp test is now on as part of the changes and will run for CI for everything going forward.

5bb8a20

@SeanTAllen
Copy link
Contributor

@vamsikrishna935 @hukoyu you are good to go.

@vamsikrishna935
Copy link
Contributor Author

@vamsikrishna935 @hukoyu you are good to go.

@SeanTAllen , Verified in latest code in oe_port branch, issue still presents. Please find debugging details below.
(gdb) p modf_time
$3 = 64
(gdb) p access_time
$4 = 64
(gdb) p stat_buf
$5 = {st_dev = 11, st_ino = 612, st_nlink = 1, st_mode = 33270, st_uid = 1, st_gid = 1, __pad0 = 0, st_rdev = 0,
st_size = 0, st_blksize = 4096, st_blocks = 0, st_atim = {tv_sec = 64, tv_nsec = 920000000}, st_mtim = {tv_sec = 64,
tv_nsec = 920000000}, st_ctim = {tv_sec = 64, tv_nsec = 920000000}, __unused = {140734279159656, 140734279151040,
140733199524115}}

@SeanTAllen
Copy link
Contributor

@vamsikrishna935 are you saying that the ltp utime03 test doesn't pass for you? It passes for me both locally and it passes CI.

@vamsikrishna935
Copy link
Contributor Author

@vamsikrishna935 are you saying that the ltp utime03 test doesn't pass for you? It passes for me both locally and it passes CI.

Yes utime03 is failing for me. Just verified with latest code in oe_port branch.
[[ SGX-LKL ]] libc_start_main_stage2(): Calling app main: /ltp/testcases/kernel/syscalls/utime/utime03
utime03 1 TFAIL : utime03.c:196: tmp_file access and modification times not set

@SeanTAllen
Copy link
Contributor

@vamsikrishna935 can you describe how you are building everything and your environment as it passes in CI on oe_port and locally for me.

@SeanTAllen
Copy link
Contributor

SeanTAllen commented May 7, 2020

@vamsikrishna935 here is how I am testing locally:

git clone [email protected]:lsds/sgx-lkl.git
cd sgx-lkl/
git checkout oe_port
make DEBUG=true
cd tests/ltp/ltp-batch1/

then editing ../batch.mk to run off run-hw and run-sw running all tests so i can run one test followed by

make clean && make DEBUG=true && make run
SGXLKL_VERBOSE=1 SGXLKL_KERNEL_VERBOSE=0 ../../../build/sgx-lkl-run-oe --hw-debug  sgxlkl-miniroot-fs.img /ltp/testcases/kernel/syscalls/utime/utime03

I'm able to run the last command that runs the test repeatedly without any failures. I just ran it 10 times in a row without issue.

Each time I get:

utime03     1  TPASS  :  Functionality of utime(tmp_file, NULL) successful

@vamsikrishna935
Copy link
Contributor Author

@SeanTAllen Let me verify with clean repo again and i will update you the status.

@hukoyu
Copy link
Collaborator

hukoyu commented May 7, 2020

@SeanTAllen are you using oe_port branch of sgx-lkl? In your steps you are not checking out oe_port branch, can you double check?

@SeanTAllen
Copy link
Contributor

Sorry, yes, I left that out. I am using that port. I will update the steps, my oversight in writing them up. Sorry for the confusion @hukoyu @vamsikrishna935.

@hukoyu
Copy link
Collaborator

hukoyu commented May 7, 2020

@SeanTAllen I checked utime03 and actually it is timing out and since we were not checking exit code, it was hiding timeouted tests. I submitted this PR : #220
utime03 is also failing in this PR. Per @letmaik 's recommendtaion I will disable utime03 test for now until we understand why it is failing.

@SeanTAllen
Copy link
Contributor

@hukoyu it times out for you locally?

@vamsikrishna935
Copy link
Contributor Author

@hukoyu : for me it is failing , i did not get any time out till now for utime03

@hukoyu
Copy link
Collaborator

hukoyu commented May 7, 2020

@hukoyu
Copy link
Collaborator

hukoyu commented May 7, 2020

@SeanTAllen @vamsikrishna935 I disabled utime03 test in my PR for now. FYI
PR : #220

@hukoyu
Copy link
Collaborator

hukoyu commented May 7, 2020

@SeanTAllen @vamsikrishna935 I got confused between utime03 and times03. I disabled test times03 in my PR not utime03. times03 is timing out after 5 minutes. I enabled back utime03. @vamsikrishna935 please investigate times03 for timeout. Issue with utime03 is not time out issue, it must be something else.

@SeanTAllen
Copy link
Contributor

@vamsikrishna935 I am unable in any environment to produce utime03 failing. If you can provide information on how I can do that, I'd appreciate it. All I get it passing results.

@SeanTAllen
Copy link
Contributor

@hukoyu your times03 problem is probably related to #209.

@vamsikrishna935
Copy link
Contributor Author

@SeanTAllen , Verified in latest repo today, the test is passing.
[[ SGX-LKL ]] libc_start_main_stage2(): Calling app main: /ltp/testcases/kernel/syscalls/utime/utime03
utime03 1 TPASS : Functionality of utime(tmp_file, NULL) successful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: sgx-lkl Core SGX-LKL functionality bug p1 Medium priority
Projects
None yet
Development

No branches or pull requests

4 participants