Convert another tmpfs assert into runtime check.
The offset of the directory file, passed to getdirentries(2) syscall, is user-controllable. The value of the offset must not be asserted, instead the invalid value should be checked and rejected if invalid. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
3cd77f5416
commit
15ad3e51c5
@ -819,10 +819,13 @@ tmpfs_dir_lookup_cookie(struct tmpfs_node *node, off_t cookie,
|
||||
goto out;
|
||||
}
|
||||
|
||||
MPASS((cookie & TMPFS_DIRCOOKIE_MASK) == cookie);
|
||||
dekey.td_hash = cookie;
|
||||
/* Recover if direntry for cookie was removed */
|
||||
de = RB_NFIND(tmpfs_dir, dirhead, &dekey);
|
||||
if ((cookie & TMPFS_DIRCOOKIE_MASK) != cookie) {
|
||||
de = NULL;
|
||||
} else {
|
||||
dekey.td_hash = cookie;
|
||||
/* Recover if direntry for cookie was removed */
|
||||
de = RB_NFIND(tmpfs_dir, dirhead, &dekey);
|
||||
}
|
||||
dc->tdc_tree = de;
|
||||
dc->tdc_current = de;
|
||||
if (de != NULL && tmpfs_dirent_duphead(de)) {
|
||||
|
Loading…
Reference in New Issue
Block a user