From patchwork Mon Dec 16 17:49:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 181766 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp4623596och; Mon, 16 Dec 2019 09:59:46 -0800 (PST) X-Google-Smtp-Source: APXvYqwUeZscIVvJP+q3E63z+USoCnxxgIKvGmqO1lTSnvNNfV/lZnZXUiXxxLqOH0hJ3aWrRDne X-Received: by 2002:a54:4f8e:: with SMTP id g14mr205988oiy.8.1576519185941; Mon, 16 Dec 2019 09:59:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576519185; cv=none; d=google.com; s=arc-20160816; b=bYeQJkfv9rgscNSWF96Yn85ZlbZFl0Z/bxM2VYDyfDjekfFBjHzYQxBEkZh+9ZfrZg qdZYtqRy0u3ooNcTzZwajTMzfNDV8Fp/+RoocCXw6c/3MFCIAYWnDGAxDwLNnCgUhGyn q5NnZH6joGWMCB3jo744UA2komoGxd8lf7L7M+uZy4+r9CnyslNR2QG3zRcQ4T3eFsMH PZTvrKOprhQNdU/cYlGX8ebEw/IiYCuMlvW/nBhVWWWt22dtXTOi9fNzAi7EquHtTf9b GoS26qeN+HNko/GUOrYxFxeiyeRezomaVzD/Hf/IUaFn8vwxUWp5pBA4tpZBrXMtTb82 ZEyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=amH9+2+fpxCl9fj2YOBKpsqozFaURg+4Cpyt3Uha9B4=; b=tUJ47N92/lKJzLtBZXT1AQhP6g0BwHh7MFuUQfvlwIStYDdGz9T+e9uzhDjnPfCx41 LXBRN+8+lZJEJPnavtolJYGIYFW3bHOnwjCEUewO6d6Y8KKl7SeqVDtzBSXmCajQOxKJ NKal35BKzqD3rWEAZdNS97bRpKhcqTO+fLx2AzfShYPcO5WBmAM8AcKFt6i9ZXj94ZDm tQa3r0bxAYUyePFxpRGkpPmI3LXyuVY8rdUrR75ajrT+jvJHLDYW2+hA/ow7Zqx0Wqmk n4HYWQ2aKokcnYIZH1tnvaSK0duc/poGM32piiLaZ7S5VWC+Cxciucz0tMorzyZ5LpbD C6zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mr2INVhi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si10652444oih.186.2019.12.16.09.59.45; Mon, 16 Dec 2019 09:59:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mr2INVhi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727862AbfLPR7o (ORCPT + 27 others); Mon, 16 Dec 2019 12:59:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:32798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728806AbfLPR7l (ORCPT ); Mon, 16 Dec 2019 12:59:41 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C3BD020700; Mon, 16 Dec 2019 17:59:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576519180; bh=F4vKAhEQ4KlxcVKJdkavRAZ3Pz5qXOCTJJxmKXUdaDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mr2INVhi34wZlob0IneQyr1bZIgHntvrdEUAyfbix+rq/737TA6sSe/n3tebFJCnO C/uttmr1Wg7IeTHTOL58ziUGnIW8v3ft2V2MWJsjcXHcs17Yj+wGwOvmOV6m8VVskB XNO97sEaT3G7vbV7xWiEg+hxWegKPmaPUCst59ho= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann Subject: [PATCH 4.14 226/267] ppdev: fix PPGETTIME/PPSETTIME ioctls Date: Mon, 16 Dec 2019 18:49:12 +0100 Message-Id: <20191216174914.938862823@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174848.701533383@linuxfoundation.org> References: <20191216174848.701533383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann commit 998174042da229e2cf5841f574aba4a743e69650 upstream. Going through the uses of timeval in the user space API, I noticed two bugs in ppdev that were introduced in the y2038 conversion: * The range check was accidentally moved from ppsettime to ppgettime * On sparc64, the microseconds are in the other half of the 64-bit word. Fix both, and mark the fix for stable backports. Cc: stable@vger.kernel.org Fixes: 3b9ab374a1e6 ("ppdev: convert to y2038 safe") Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20191108203435.112759-8-arnd@arndb.de Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/char/ppdev.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -623,20 +623,27 @@ static int pp_do_ioctl(struct file *file if (copy_from_user(time32, argp, sizeof(time32))) return -EFAULT; + if ((time32[0] < 0) || (time32[1] < 0)) + return -EINVAL; + return pp_set_timeout(pp->pdev, time32[0], time32[1]); case PPSETTIME64: if (copy_from_user(time64, argp, sizeof(time64))) return -EFAULT; + if ((time64[0] < 0) || (time64[1] < 0)) + return -EINVAL; + + if (IS_ENABLED(CONFIG_SPARC64) && !in_compat_syscall()) + time64[1] >>= 32; + return pp_set_timeout(pp->pdev, time64[0], time64[1]); case PPGETTIME32: jiffies_to_timespec64(pp->pdev->timeout, &ts); time32[0] = ts.tv_sec; time32[1] = ts.tv_nsec / NSEC_PER_USEC; - if ((time32[0] < 0) || (time32[1] < 0)) - return -EINVAL; if (copy_to_user(argp, time32, sizeof(time32))) return -EFAULT; @@ -647,8 +654,9 @@ static int pp_do_ioctl(struct file *file jiffies_to_timespec64(pp->pdev->timeout, &ts); time64[0] = ts.tv_sec; time64[1] = ts.tv_nsec / NSEC_PER_USEC; - if ((time64[0] < 0) || (time64[1] < 0)) - return -EINVAL; + + if (IS_ENABLED(CONFIG_SPARC64) && !in_compat_syscall()) + time64[1] <<= 32; if (copy_to_user(argp, time64, sizeof(time64))) return -EFAULT;