Follow the outline of the open syscall
Thoughts?
inode
struct files_struct
->files in task_struct
SYSCALL_DEFINE3(open,...
openat(2) is preferred
openat(2)
force_o_largefile()
Do we have ARCH_32_BIT_OFF_T
ARCH_32_BIT_OFF_T
strace ./hello_world
open becomes openat
open
openat
SYSCALL_CANCEL()
list of syscalls
AT_FDCWD
struct open_how
int flags
umode_t mode
do_sys_open()
flags
Follow symlinks in each component of patch
By default, follow for last component, unless O_NOFOLLOW
O_NOFOLLOW
O_PATH
RESOLVE_BENEATH
RESOLVE_NO_ROOT
RESOLVE_NO_SYMLINKS
Like O_NOFOLLOW
build_open_how()
openat2
-EINVAL
S_IALLUGO: permission bits
S_IALLUGO
permission bits
read, write, exec for user, group, and other
build_open_flags()
struct open_how => struct open_flags
struct open_flags
getname called => getname_flags
getname called
getname_flags
copy_from_user()
What the heck is "omirr"
Important enough for fundamental changes to pathname lookup
In and out of the kernel
SYSCALL_DEFINE0(fork)
kernel_clone() calls copy_process()
kernel_clone()
copy_process()
copy_process() calls copy_files()
copy_files()
dup_fd()
alloc_fdtable()
get_unused_fd_flags()
do_filp_open()
path_openat()
do_open()
vfs_open()
struct dentry
struct path
call to fops_get
call to fops->open()
fd_install()
sudo bpftrace -e 'k:kkey_open { printf("%s\n", kstack); }'
Open resolves a path into an inode
An open file descriptor refers to a struct file in the current->files structure
struct file
current->files
The newer openat2 provides useful symlink resolution options
Everything is a file descriptor in Linux, and open is the first step