summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2021-06-16 18:20:25 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-18 10:15:14 +0200
commit9559ac9dd63c7d4ef40b964cbf341612b4d60ab6 (patch)
treee99bcab1f3501cc8cdc1b890afdfd935d0d07ce9 /Kernel/FileSystem
parent8cd96f031d5f826a5f5b67ef3dcf6a9d4341ed95 (diff)
downloadserenity-9559ac9dd63c7d4ef40b964cbf341612b4d60ab6.zip
Kernel: Correctly decode proc_file_type from identifier
inode identifiers in ProcFS are encoded in a way that the parent ID is shifted 12 bits to the left and the PID is shifted by 16 bits. This means that the rightmost 12 bits are reserved for the file type or the fd. Since the to_fd and to_proc_file_type decoders only decoded the rightmost 8 bits, decoded values would wrap around beyond values of 255, resulting in a different value compared to what was originally encoded.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/ProcFS.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index 76bad8a63a..0bc78c51fe 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -126,13 +126,13 @@ static inline ProcParentDirectory to_proc_parent_directory(const InodeIdentifier
static inline ProcFileType to_proc_file_type(const InodeIdentifier& identifier)
{
- return (ProcFileType)(identifier.index().value() & 0xff);
+ return (ProcFileType)(identifier.index().value() & 0xfff);
}
static inline int to_fd(const InodeIdentifier& identifier)
{
VERIFY(to_proc_parent_directory(identifier) == PDI_PID_fd);
- return (identifier.index().value() & 0xff) - FI_MaxStaticFileIndex;
+ return (identifier.index().value() & 0xfff) - FI_MaxStaticFileIndex;
}
static inline size_t to_sys_index(const InodeIdentifier& identifier)