From patchwork Mon Dec 16 17:49:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 181769 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp4630623och; Mon, 16 Dec 2019 10:04:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzbNt+sp9Z3uHyuC6GI+bypRGXBgNdYi6WO3k5YB8wXKCuaj6hwk9H/tL4pXxGlO8POQwGR X-Received: by 2002:a05:6830:1d6a:: with SMTP id l10mr34289297oti.233.1576519492962; Mon, 16 Dec 2019 10:04:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576519492; cv=none; d=google.com; s=arc-20160816; b=nHhRHyxdX2eTshdGvf75O+7meyCHxFL0TlmpSIHqFiuRTg7ra2p84aCfnvD1UhnaGj sFQxOtruRxjGmut6aItmUN/ryfiwof/T/VrAf8FOhaaIfIu2zfQAgsp4715d+KhRLLi/ pyygarWq9ayJPr56mtmOZJbJ1r3rMoSkyYR8vSokRFFUA8XsqQhEoywuAOJ1Q+/PmTtZ 6LX03Ay9hFXXjGbfEI3KXCweENLjGXkcLUGDz3Waj5uQN0/dOMBZt2EwgU67SYonuscg tAyVasulCayT14v1DYeyfn2kfqrVFNkiQWO9NPKWFzxOsxi1eFsAfTPmUA5En6gE6OWu HfNA== 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=PsR4hPJ5HY47X5XorNKgQoG+MTUiGgnRNWuEVlmTQpfS8DErDFO1Yyl8+pV+kM1Br8 nt18uqGMoUt4Yv4dsjiUZvSnH/adrIppQe+R1X0xvaKxUnrinAhY3ejP4YvpPAdzs3F4 fqhk15m0q5nAMYE2woxy3yKALIVW6P2PnH+zX86N6f1WPuxgWpMfrEO6y46SxdlMyObJ ik8QaYbQUWBzGnNVeRSg2kRSp22Vs9tVTgxFGuwV47h/4DWLazZ+ORj5wtSuu1oioO1/ yR7tPoXJi1wKxFjFiAeZnztDpMeUgKZOkm4553WGwZnp3OsXLvkJiP5k3+alnl0M7Mai I1vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NAzByhfi; 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 c2si10431707otn.311.2019.12.16.10.04.52; Mon, 16 Dec 2019 10:04:52 -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=NAzByhfi; 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 S1729352AbfLPSEv (ORCPT + 27 others); Mon, 16 Dec 2019 13:04:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:42328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729713AbfLPSEs (ORCPT ); Mon, 16 Dec 2019 13:04:48 -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 1346720700; Mon, 16 Dec 2019 18:04:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576519487; bh=F4vKAhEQ4KlxcVKJdkavRAZ3Pz5qXOCTJJxmKXUdaDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NAzByhfiWas7vCgCAdXNa4pgc8CfIdI6GpE+p8DjscYdBZbJKGgVsoiNRiNY1Aumk BqjsOC/HIgQMJGtR+S/pU5J35IvOVwuyIQfGIqYdm7y+QZQEoAEMqdHkft3HY+bQXb 0nh0Du2CLpf+Jvx0jQHyngZg7RQwToGGnz3/BcKg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann Subject: [PATCH 4.19 085/140] ppdev: fix PPGETTIME/PPSETTIME ioctls Date: Mon, 16 Dec 2019 18:49:13 +0100 Message-Id: <20191216174810.427565881@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174747.111154704@linuxfoundation.org> References: <20191216174747.111154704@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;