From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934972AbcCJDRo (ORCPT ); Wed, 9 Mar 2016 22:17:44 -0500 Received: from mail5.windriver.com ([192.103.53.11]:36132 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934909AbcCJDRe (ORCPT ); Wed, 9 Mar 2016 22:17:34 -0500 From: Jiang Lu To: , , Subject: [v2] serial_core:recognize invalid pointer from userspace Date: Thu, 10 Mar 2016 11:17:23 +0800 Message-ID: <1457579843-29676-2-git-send-email-lu.jiang@windriver.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1457579843-29676-1-git-send-email-lu.jiang@windriver.com> References: <1457579843-29676-1-git-send-email-lu.jiang@windriver.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org compat_ioctl use 0xffffffff as a magic number to mark invalid pointer for iomem_base in serial_struct when truncating a 64bit pointer into 32bit. Serial driver need recognize this invalid pointer when parsing serial_struct from userspace. Signed-off-by: Jiang Lu --- drivers/tty/serial/serial_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index a5d545e..d293536 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -745,6 +745,9 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, * allocations, we should treat type changes the same as * IO port changes. */ + if ((unsigned long)new_info->iomem_base == 0xffffffff) + new_info->iomem_base = (void *)(unsigned long)uport->mapbase; + change_port = !(uport->flags & UPF_FIXED_PORT) && (new_port != uport->iobase || (unsigned long)new_info->iomem_base != uport->mapbase || -- 1.9.1