Linkat(2) should sanity check flags.

PiperOrigin-RevId: 224047765
Change-Id: I6f3c75b33c32bf8f8910ea3fab35406d7d672d87
This commit is contained in:
Brian Geffon
2018-12-04 14:34:19 -08:00
committed by Shentubot
parent 82719be42e
commit 2cab0e82ad
+6
View File
@@ -1251,6 +1251,12 @@ func Linkat(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Syscal
// AT_SYMLINK_FOLLOW can be specified in flags to cause oldpath to be
// dereferenced if it is a symbolic link.
flags := args[4].Int()
// Sanity check flags.
if flags&^(linux.AT_SYMLINK_FOLLOW|linux.AT_EMPTY_PATH) != 0 {
return 0, nil, syserror.EINVAL
}
resolve := flags&linux.AT_SYMLINK_FOLLOW == linux.AT_SYMLINK_FOLLOW
allowEmpty := flags&linux.AT_EMPTY_PATH == linux.AT_EMPTY_PATH