Commit Graph
77 Commits
Author SHA1 Message Date
Andrei VaginandgVisor bot e2fc34862a proc: add /proc/sys/kernel/cap_last_cap
PiperOrigin-RevId: 559932636
2023-08-24 18:29:31 -07:00
Shambhavi SrivastavaandgVisor bot 76b2713c08 Adding /proc/[pid]/task/[tid]/children
PiperOrigin-RevId: 557888186
2023-08-17 11:41:48 -07:00
gVisor bot d716a5246f Internal change.
PiperOrigin-RevId: 540338096
2023-06-14 11:56:16 -07:00
gVisor bot 014a6b223a Internal change.
PiperOrigin-RevId: 540319250
2023-06-14 10:56:23 -07:00
Andrei Vagin 3445db339d Fix all c++ compile time warnings 2023-03-09 19:01:00 -08:00
gVisor bot 869d2312ec Fix /proc/*/stat parsing in GVisor
The code in GVisor relied on the process name not containing whitespace when
parsing /proc/*/stat. This CL fixes that by moving parsing to its own function,
implemented properly.

PiperOrigin-RevId: 511616209
2023-02-22 15:43:14 -08:00
Nicolas LacasseandgVisor bot f42c179701 Allow setting thread name by writing to /proc/pid/task/tid.
Test that thread can set its own thread, or peer thread in the same thread
group.

PiperOrigin-RevId: 510595880
2023-02-17 21:49:21 -08:00
Jamie LiuandgVisor bot 2a3fb74ffe Fix flakes in tests that use munmap() to create deliberate MM holes.
PiperOrigin-RevId: 479623755
2022-10-07 11:09:09 -07:00
gVisor bot 3138e0d14b Merge pull request #7976 from cedriccchen:proc
PiperOrigin-RevId: 474861876
2022-09-16 11:32:03 -07:00
Chen Hui dbee5ecca5 procfs: support /proc/[pid]/root file
Signed-off-by: Chen Hui <[email protected]>
2022-09-16 12:40:08 +08:00
Sergey MadaminovandgVisor bot 94c40dd35b A procfs file for runtime heap usage information for sentry.
Added a mechanism to query runtime sentry heap usage using procfs from inside
the sandbox. This may help with providing insight regarding sandbox hitting the
memory limit on the host despite reporting a lower application memory usage.
And added a test to `proc.cc`.

PiperOrigin-RevId: 470061488
2022-08-25 12:58:43 -07:00
Ayush RanjanandgVisor bot ceb39c9966 Make anonfs return ENOTDIR for open(O_DIRECTORY) calls.
All anonfs dentries are non-directories. So all FilesystemImpl
methods that would require an anonDentry to be a directory should
return ENOTDIR.

PiperOrigin-RevId: 455271653
2022-06-15 19:07:24 -07:00
Ayush RanjanandgVisor bot f6263c38df Remove VFS1 special handling in tests.
Also clean up usage of GVISOR_VFS environment variable.
Updates #1624

PiperOrigin-RevId: 429100450
2022-02-16 11:41:51 -08:00
Ayush RanjanandgVisor bot 3094195006 Do not check the stability of certain /proc/cpuinfo fields.
PiperOrigin-RevId: 421928736
2022-01-14 15:46:49 -08:00
Adin ScannellandgVisor bot 33a9bf8e30 Refactor CPUID to allow for use in KVM and ring0.
Updates #5039

PiperOrigin-RevId: 421696994
2022-01-13 17:24:28 -08:00
gVisor bot 2184549d77 Merge pull request #6570 from sudo-sturbia:ipc/proc
PiperOrigin-RevId: 398849334
2021-09-24 17:51:25 -07:00
Zyad A. Ali dd1ec58af4 Run proc's static-file tests in a container.
Some /proc files are static in gVisor, but can be updated in native
linux. To test the values of these files, move them to a separate test
and run it using "container" tag to avoid faulty comparisons in native.

Since a separate IPC namespace is used, update shm comparisons to check
the actual value, not an interval.
2021-09-24 14:15:23 +02:00
Jamie LiuandgVisor bot ea5b328b8e Add Uid/Gid/Groups fields to VFS2 /proc/[pid]/status.
For comparison:

```
$ docker run --rm -it ubuntu:focal bash -c 'cat /proc/self/status'
Name:	cat
Umask:	0022
State:	R (running)
Tgid:	1
Ngid:	0
Pid:	1
PPid:	0
TracerPid:	0
Uid:	0	0	0	0
Gid:	0	0	0	0
FDSize:	64
Groups:
NStgid:	1
NSpid:	1
NSpgid:	1
NSsid:	1
VmPeak:	    2660 kB
VmSize:	    2660 kB
VmLck:	       0 kB
VmPin:	       0 kB
VmHWM:	     528 kB
VmRSS:	     528 kB
...

$ docker run --runtime=runsc-vfs2 --rm -it ubuntu:focal bash -c 'cat /proc/self/status'
Name:	cat
State:	R (running)
Tgid:	1
Pid:	1
PPid:	0
TracerPid:	0
Uid:	0	0	0	0
Gid:	0	0	0	0
FDSize:	4
Groups:
VmSize:	10708 kB
VmRSS:	3124 kB
VmData:	316 kB
...
```

Fixes #6374

PiperOrigin-RevId: 387465655
2021-07-28 16:41:35 -07:00
Fabricio VoznikaandgVisor bot 66aefea0c7 Add /proc/sys/vm/max_map_count
Set it to int32 max because gVisor doesn't have a limit.

Fixes #2337

PiperOrigin-RevId: 378722230
2021-06-10 13:36:03 -07:00
Steve SilvaandgVisor bot acc3f657d6 Implement /proc/cmdline
This change implements /proc/cmdline with a basic faux command line
"BOOT_IMAGE=/vmlinuz-[version]-gvisor quiet" so apps that may expect
it do not receive errors.

Also tests for the existence of /proc/cmdline as part of the system
call test suite

PiperOrigin-RevId: 372462070
2021-05-06 18:03:42 -07:00
Fabricio VoznikaandgVisor bot 94bf29345c Fix deadlock in /proc/[pid]/fd/[num]
In order to resolve path names, fsSymlink.Readlink() may need to reenter
kernfs. Change the code so that kernfs.Inode.Readlink() is called without
locks and document the new contract.

PiperOrigin-RevId: 371770222
2021-05-03 13:50:37 -07:00
Fabricio VoznikaandgVisor bot 3fe6a879b2 Remove side effect from test cases
Restore capabilities for tests that need to change them.

PiperOrigin-RevId: 371007047
2021-04-28 16:22:24 -07:00
Rahat MahmoodandgVisor bot 5d7079da00 Also report mount options through /proc/<pid>/mounts.
PiperOrigin-RevId: 369967629
2021-04-22 15:52:24 -07:00
Adin ScannellandgVisor bot ce8ee943e7 Remove _NoRandomSave tests.
We do not currently run random save tests.

PiperOrigin-RevId: 368309921
2021-04-13 15:42:41 -07:00
Fabricio VoznikaandgVisor bot ccebbf4c7f Deflake proc_test_native
Terminating tasks from other tests can mess up with the task
list of the current test. Tests were changed to look for added/removed
tasks, ignoring other tasks that may exist while the test is running.

PiperOrigin-RevId: 363084261
2021-03-15 19:06:03 -07:00
Fabricio VoznikaandgVisor bot d398bfe56f Fix proc test flakiness
Thread from earlier test can show up in `/proc/self/tasks` while the
thread tears down. Account for that when searching for procs for the
first time in the test.

PiperOrigin-RevId: 361689673
2021-03-08 17:01:30 -08:00
Nicolas LacasseandgVisor bot dad54f748f Fix seek on /proc/pid/cmdline when task is zombie.
PiperOrigin-RevId: 348056159
2020-12-17 11:16:06 -08:00
Jing ChenandgVisor bot b82778c4f6 Add /proc/sys/kernel/sem.
PiperOrigin-RevId: 345178956
2020-12-02 00:13:24 -08:00
Adin ScannellandgVisor bot 5f4b0d1995 Ignore permission failures in CheckDuplicatesRecursively.
Not all files are always accessible by the process itself. This
was specifically seen with map_files, but there's no rule that
every entry must be accessible by the process itself.

PiperOrigin-RevId: 343919117
2020-11-23 13:38:41 -08:00
gVisor bot a9e2120a64 Internal change.
PiperOrigin-RevId: 343419851
2020-11-19 20:03:53 -08:00
LennartandgVisor bot cf76182d7e Implement /proc/[pid]/mem
This PR implements /proc/[pid]/mem for `pkg/sentry/fs` (refer to #2716) and `pkg/sentry/fsimpl`.

@majek

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/4060 from lnsp:proc-pid-mem 2caf9021254646f441be618a9bb5528610e44d43
PiperOrigin-RevId: 339369629
2020-10-27 18:07:22 -07:00
Fabricio VoznikaandgVisor bot 64861cca51 Add /proc/[pid]/cwd
PiperOrigin-RevId: 334478850
2020-09-29 15:49:27 -07:00
gVisor bot f0d22776d2 Migrates uses of deprecated map types to recommended types.
PiperOrigin-RevId: 334419854
2020-09-29 11:13:03 -07:00
Jamie LiuandgVisor bot f943ff48de Use a tmpfs file for shared anonymous and /dev/zero mmap on VFS2.
This is more consistent with Linux (see comment on MM.NewSharedAnonMappable()).
We don't do the same thing on VFS1 for reasons documented by the updated
comment.

PiperOrigin-RevId: 332514849
2020-09-18 13:25:35 -07:00
Dean DengandgVisor bot c4e1ded3dd Support setting STATX_SIZE for kernfs.InodeAttrs.
Make setting STATX_SIZE a no-op, if it is valid for the given permissions and
file type.

Also update proc tests, which were overfitted before.

Fixes #3842.
Updates #1193.

PiperOrigin-RevId: 331861087
2020-09-15 14:55:28 -07:00
Tiwei Bie dbd70b048d Fix proc.(*fdDir).IterDirents for VFS2
Currently the returned offset is an index, and we can't
use it to find the next fd to serialize, because getdents
should iterate correctly despite mutation of fds. Instead,
we can return the next fd to serialize plus 2 (which
accounts for "." and "..") as the offset.

Fixes: #3894

Signed-off-by: Tiwei Bie <[email protected]>
2020-09-15 11:12:29 +08:00
Rahat MahmoodandgVisor bot de7cf46f24 Implement StatFS for various VFS2 filesystems.
This mainly involved enabling kernfs' client filesystems to provide a
StatFS implementation.

Fixes #3411, #3515.

PiperOrigin-RevId: 329009864
2020-08-28 14:31:11 -07:00
Dean DengandgVisor bot 33adcb8492 Fix procfs bugs in vfs2.
- Support writing on proc/[pid]/{uid,gid}map
- Return EIO for writing to static files.

Updates #2923.

PiperOrigin-RevId: 318188503
2020-06-24 19:22:12 -07:00
Ting-Yu WangandgVisor bot 11829a48b2 Nit fix: Create and use a std::string object for const char*.
PiperOrigin-RevId: 317973144
2020-06-23 17:44:34 -07:00
Ting-Yu WangandgVisor bot 08e78fa397 Deflake proc test: Don't fail on DT_UNKNOWN.
Per manual page:
"All applications must properly handle a return of DT_UNKNOWN."

PiperOrigin-RevId: 317957013
2020-06-23 16:07:26 -07:00
Nicolas LacasseandgVisor bot d78f787b5f Allow readdir(/proc/[tid]/net) to return EINVAL on a zombie task.
Despite what the man page says, linux will return EINVAL when calling
getdents() an a /proc/[tid]/net file corresponding to a zombie task. This
causes readdir() to return a null pointer AND errno=EINVAL.

See fs/proc/proc_net.c:proc_tgid_net_readdir() for where this occurs.

We have tests that recursively read /proc, and are likely to hit this when
running natively, so we must catch and handle this case.

PiperOrigin-RevId: 317674168
2020-06-22 09:54:22 -07:00
Nicolas LacasseandgVisor bot 6d1821c388 Proc test: Allow root mount pathname to be non-root.
The test was expecting that the root mount pathname was "/", but it doesn't
need to be. Only the mount point actually should be "/" (otherwise it is not
the root).

PiperOrigin-RevId: 316968025
2020-06-17 14:42:41 -07:00
Andrei VaginandgVisor bot e26fdc5e55 Deflake //third_party/gvisor/test/syscalls:proc_test_native
There is the known issue of the linux procfs, that two consequent calls of
readdir can return the same entry twice if between these calls one or more
entries have been removed from this directory.

PiperOrigin-RevId: 309803066
2020-05-04 12:58:24 -07:00
Jamie LiuandgVisor bot 267a72355f Bump proc_test's kRSSTolerance to 10MB.
PiperOrigin-RevId: 305604557
2020-04-08 19:41:43 -07:00
Fabricio VoznikaandgVisor bot 4a84a14a31 Enable SubprocessExited and SubprocessZombie for gVisor
Updates #164

PiperOrigin-RevId: 305544029
2020-04-08 13:34:44 -07:00
Ian LewisandgVisor bot 60f65f3a04 Stub oom_score_adj and oom_score.
Adds an oom_score_adj and oom_score proc file stub. oom_score_adj accepts
writes of values -1000 to 1000 and persists the value with the task. New tasks
inherit the parent's oom_score_adj.

oom_score is a read-only stub that always returns the value '0'.

Issue #202

PiperOrigin-RevId: 299245355
2020-03-05 18:23:01 -08:00
Adin ScannellandCopybara-Service 412a92112f Add basic microbenchmarks.
PiperOrigin-RevId: 296104390
2020-02-19 18:21:54 -08:00
Adin ScannellandgVisor bot 456f4ac3f1 Add notes to relevant tests.
These were out-of-band notes that can help provide additional context
and simplify automated imports.

PiperOrigin-RevId: 293525915
2020-02-05 22:46:35 -08:00
gVisor bot 2667449240 Merge pull request #1471 from xiaobo55x:syscall_test
PiperOrigin-RevId: 292445329
2020-01-30 16:12:25 -08:00
Haibo Xu 3718b509ea Unify the kOLargeFile definition in syscall tests.
Signed-off-by: Haibo Xu <[email protected]>
Change-Id: Id9d6ae98305a4057d55d622ea4c3ac2228fea212
2020-01-23 01:04:02 +00:00