ptp: check that rsv field is zero in struct ptp_sys_offset_extended

Otherwise it is impossible to use it for something else, as it will break
userspace that puts garbage there.

The same check should be done in other structures, but the fact that
data in reserved fields is ignored is already part of the kernel ABI.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eugene Syromiatnikov 2019-01-07 16:22:29 +01:00 коммит произвёл David S. Miller
Родитель 977e4899c9
Коммит 895ac1376d
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -224,7 +224,8 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
extoff = NULL;
break;
}
if (extoff->n_samples > PTP_MAX_SAMPLES) {
if (extoff->n_samples > PTP_MAX_SAMPLES
|| extoff->rsv[0] || extoff->rsv[1] || extoff->rsv[2]) {
err = -EINVAL;
break;
}