From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eugene Syromiatnikov Subject: [PATCH net 1/2] ptp: check that rsv field is zero in struct ptp_sys_offset_extended Date: Mon, 7 Jan 2019 16:22:29 +0100 Message-ID: <20190107152229.GA17925@asgard.redhat.com> References: <20181109101449.15398-4-mlichvar@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Richard Cochran , Jacob Keller , Marcelo Tosatti To: Miroslav Lichvar , "David S. Miller" , netdev@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:47588 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727670AbfAGPW0 (ORCPT ); Mon, 7 Jan 2019 10:22:26 -0500 Content-Disposition: inline In-Reply-To: <20181109101449.15398-4-mlichvar@redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: 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 --- drivers/ptp/ptp_chardev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c index 797fab3..7cbea79 100644 --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -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; } -- 2.1.4