mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-12 02:30:30 +09:00
Kernel: Strip SUID+SGID bits from file when written to or chowned
Fixes #1624.
This commit is contained in:
parent
040ba77d44
commit
53d0ca2ad8
Notes:
sideshowbarker
2024-07-19 07:56:12 +09:00
Author: https://github.com/awesomekling
Commit: 53d0ca2ad8
6 changed files with 36 additions and 0 deletions
|
@ -511,6 +511,14 @@ KResult VFS::chown(Inode& inode, uid_t a_uid, gid_t a_gid)
|
|||
}
|
||||
|
||||
dbg() << "VFS::chown(): inode " << inode.identifier() << " <- uid:" << new_uid << " gid:" << new_gid;
|
||||
|
||||
if (metadata.is_setuid() || metadata.is_setgid()) {
|
||||
dbg() << "VFS::chown(): Stripping SUID/SGID bits from " << inode.identifier();
|
||||
auto result = inode.chmod(metadata.mode & ~(04000 | 02000));
|
||||
if (result.is_error())
|
||||
return result;
|
||||
}
|
||||
|
||||
return inode.chown(new_uid, new_gid);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue