1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:18:11 +00:00

Kernel: Dump backtrace when denying a path because of a veil

This will make it much easier to see why a process wants to open the file.
This commit is contained in:
Sergey Bugaev 2020-01-30 14:05:36 +03:00 committed by Andreas Kling
parent a27c5d2fb7
commit 3ffdff5c02

View file

@ -729,18 +729,21 @@ KResult VFS::validate_path_against_process_veil(StringView path, int options)
auto* unveiled_path = find_matching_unveiled_path(path); auto* unveiled_path = find_matching_unveiled_path(path);
if (!unveiled_path) { if (!unveiled_path) {
dbg() << "Rejecting path '" << path << "' since it hasn't been unveiled."; dbg() << "Rejecting path '" << path << "' since it hasn't been unveiled.";
dump_backtrace();
return KResult(-ENOENT); return KResult(-ENOENT);
} }
if (options & O_CREAT) { if (options & O_CREAT) {
if (!(unveiled_path->permissions & UnveiledPath::Access::CreateOrRemove)) { if (!(unveiled_path->permissions & UnveiledPath::Access::CreateOrRemove)) {
dbg() << "Rejecting path '" << path << "' since it hasn't been unveiled with 'c' permission."; dbg() << "Rejecting path '" << path << "' since it hasn't been unveiled with 'c' permission.";
dump_backtrace();
return KResult(-EACCES); return KResult(-EACCES);
} }
} }
if (options & O_UNLINK_INTERNAL) { if (options & O_UNLINK_INTERNAL) {
if (!(unveiled_path->permissions & UnveiledPath::Access::CreateOrRemove)) { if (!(unveiled_path->permissions & UnveiledPath::Access::CreateOrRemove)) {
dbg() << "Rejecting path '" << path << "' for unlink since it hasn't been unveiled with 'c' permission."; dbg() << "Rejecting path '" << path << "' for unlink since it hasn't been unveiled with 'c' permission.";
dump_backtrace();
return KResult(-EACCES); return KResult(-EACCES);
} }
return KSuccess; return KSuccess;
@ -748,18 +751,21 @@ KResult VFS::validate_path_against_process_veil(StringView path, int options)
if (options & O_RDONLY) { if (options & O_RDONLY) {
if (!(unveiled_path->permissions & UnveiledPath::Access::Read)) { if (!(unveiled_path->permissions & UnveiledPath::Access::Read)) {
dbg() << "Rejecting path '" << path << "' since it hasn't been unveiled with 'r' permission."; dbg() << "Rejecting path '" << path << "' since it hasn't been unveiled with 'r' permission.";
dump_backtrace();
return KResult(-EACCES); return KResult(-EACCES);
} }
} }
if (options & O_WRONLY) { if (options & O_WRONLY) {
if (!(unveiled_path->permissions & UnveiledPath::Access::Write)) { if (!(unveiled_path->permissions & UnveiledPath::Access::Write)) {
dbg() << "Rejecting path '" << path << "' since it hasn't been unveiled with 'w' permission."; dbg() << "Rejecting path '" << path << "' since it hasn't been unveiled with 'w' permission.";
dump_backtrace();
return KResult(-EACCES); return KResult(-EACCES);
} }
} }
if (options & O_EXEC) { if (options & O_EXEC) {
if (!(unveiled_path->permissions & UnveiledPath::Access::Execute)) { if (!(unveiled_path->permissions & UnveiledPath::Access::Execute)) {
dbg() << "Rejecting path '" << path << "' since it hasn't been unveiled with 'x' permission."; dbg() << "Rejecting path '" << path << "' since it hasn't been unveiled with 'x' permission.";
dump_backtrace();
return KResult(-EACCES); return KResult(-EACCES);
} }
} }