From patchwork Thu Dec 19 18:33:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 182172 Delivered-To: patch@linaro.org Received: by 2002:a92:d0a:0:0:0:0:0 with SMTP id 10csp862479iln; Thu, 19 Dec 2019 10:47:26 -0800 (PST) X-Google-Smtp-Source: APXvYqycE3I/2EBqCavwYMyA20QQpRn4BvvxyBEVnbnP6VZq7fEYQflcONb0hP2s9A32Q/GpdP4d X-Received: by 2002:a05:6830:139a:: with SMTP id d26mr10462002otq.75.1576781246160; Thu, 19 Dec 2019 10:47:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576781246; cv=none; d=google.com; s=arc-20160816; b=L2Bl7YfLTYyCf5tntogaxJhCNtretdd0czZpISy/gR+nrKo2CDf9CmVAOjll9NrFK+ 1p6dUcIEZIQrUsDS/IfP9NHLsKg9fgLkjq5X8I3hgUciLvFyJ15rwWPD37LZq2kl6Tri P2sqTIHv5VOejjX8SXW/aymBA8fw0sF1P5jE0yRt5GZi+3/VEkU9V2xChetGGMOjSzxb W8HE4TO4BlbUS1BrucZaMFGG2/H5TEw5gJc78Fi01pslrDkLVbdkBlyAV6XbSGi1QzK0 Q1ervy7F7x3QvjDroi761GVno7N2HSddkM2oI+5JmbgI8TGSBPftHWUmhzgfmLbPR9MQ cPLw== 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=qmM1xz1rlgYKunlUzZoqQyaxeRX8Zncdljj95HA4Noc=; b=Q6D+UZ1DaJixduXKzCW4AkTF06k5yOo5/KO+ULZlEq4aKXd57mkUC08altYud+YuFv wZ4oEoYahZq1cLbPJYaoAz34uKXMY5r+JqzoWlAzKoeaw79d7rzlBtbGmYNU/mKs7Sqp FNx+uTvyGwXmhZm4bzpE2bZd0DZ64l5cAw1/QXHwEBPHrCPCP6hJ9MDsPmZlUeFawQaH B+8bcUBlmwFSsJNtGTjkPT4CLZjWTZcEcSo8BruQ3dpB4XzKViHLCpgZl/QrLDbn/rif RaOcxRuRGPbwjdYvUOUWkFGvYjbEkLhXmeQ/vyE5NCBJLod6QC5k0Gu55wDhdts8ykKP E5ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YBcyH0zN; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 m5si3496152ote.187.2019.12.19.10.47.25; Thu, 19 Dec 2019 10:47:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=YBcyH0zN; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729254AbfLSSrY (ORCPT + 14 others); Thu, 19 Dec 2019 13:47:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:40254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729229AbfLSSrX (ORCPT ); Thu, 19 Dec 2019 13:47:23 -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 8A9E1206D7; Thu, 19 Dec 2019 18:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781243; bh=nuHAsepJtngeuassJ0DTBPKJvjsLu9vQprBq1cI/L3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YBcyH0zNZTphoEgz7OHafA+krKDksNRg3wiEhi/jIULlvwbShb5bzeiSe34Mgl4EB Y0eFJHDsvOPP19KzMij5fY5FaW36STrb38RYvgM/6SUtU5b4RQVRNFEn4VC9uN+vQN SfxdntyNSawSR1eZLFgP/MqiJ59jA9qlsqC/5UR8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann Subject: [PATCH 4.9 141/199] ppdev: fix PPGETTIME/PPSETTIME ioctls Date: Thu, 19 Dec 2019 19:33:43 +0100 Message-Id: <20191219183222.973502841@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183214.629503389@linuxfoundation.org> References: <20191219183214.629503389@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -624,20 +624,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; @@ -648,8 +655,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;