From patchwork Mon Dec 16 17:49:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 181785 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp4673437ile; Mon, 16 Dec 2019 10:23:37 -0800 (PST) X-Google-Smtp-Source: APXvYqydaiDo7a60RJfmS3vej0UL4XJGtknx/iyee0eIaeaxmayf8CTHUZAbQP1NlpMScaVSknoM X-Received: by 2002:a9d:175:: with SMTP id 108mr32768147otu.325.1576520615283; Mon, 16 Dec 2019 10:23:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576520615; cv=none; d=google.com; s=arc-20160816; b=DiUJqiROSaGKL+dPjo0n5rsO+E/Z4c42bLIMpscnrTtjv6zc89vimBONrXphgsqHJd MJHw+G24mJkB/VYEtiHQdVZJbpdBEtLrtFZkVdOED+2OehhnnqizIAVfxtUDjlom6J55 a/wf2YzweqdbYtcoLHx5+yZQWPKg1Hl5GsVyMax2eIRoVGa7bj0On89gcuW1axfiWpWv bwoIRuXUdPRQqx+3Ir6DCHSLGo/84SFqJ7pvQkcAt0u9TJ0ccdQFqKmfD1t7FGQR/BwZ ChbcbSmJrmCZg65c8c2ku3UiOIIdkyUFDDZRVATGoF2LI/+Uu4AKIY0tC403ueJoIBcq aeTA== 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=6gzpBaurV2pbGYeo4dbaffg7HecLjR3Mkpt2ajvxTsQ=; b=f/W4nXaIwUl0A4B+1guOr4Z98atUIb0qTxzzsVh9JD/+EFhIrNWfM5t3YzUHxI+M8u e6uro+AeRiNyBsbQml9q61zt75p2IOcSegdN3s18bp/YpSiTHVygsVx7cdRaiRyZ4rCb QLtwqGB2XF09GQw9ibRO2ZNWGpBKaMJglA+xhN6wVJh1Rp2IfioQa+swdbLmqIO1DDfz hzTe8CHhNK7yDYCtBP+iPyiJjLt5I1dhVPNXckGn0oAS95gWU/fyC2AKGBCkjC5/jvXd StzrApfqbYjiVOHyN5+XpaOClbqWF/JDAjDHrsX3H6fsf4mLvAGjMYC1wZhqBoh1z4oW ZWWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mybrmzor; 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 u12si10938116otq.51.2019.12.16.10.23.34; Mon, 16 Dec 2019 10:23:35 -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=Mybrmzor; 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 S1732035AbfLPSUL (ORCPT + 27 others); Mon, 16 Dec 2019 13:20:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:49252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732012AbfLPSUD (ORCPT ); Mon, 16 Dec 2019 13:20:03 -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 7158221739; Mon, 16 Dec 2019 18:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576520402; bh=pDM9YgV4ACQyf4D8/DQYrmhcjDCqeiLjgwAC5zEHwIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MybrmzorL1vVGDsDwQ3Un/sxWHr5cmaFovWq3aDR/lt3IuiL1fRx/4qOANhAuM/pJ wsb9iSyq+vsd1S2wg+63xySKT5kQ1i+XB+n5bGFdhG77ijacH5jodfJyrGLqCmwvic mDhwnL44h/GFGfRpFWl0sI/Fx+CNNlbdZ4OOwX1o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann Subject: [PATCH 5.4 141/177] ppdev: fix PPGETTIME/PPSETTIME ioctls Date: Mon, 16 Dec 2019 18:49:57 +0100 Message-Id: <20191216174846.834159741@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174811.158424118@linuxfoundation.org> References: <20191216174811.158424118@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 @@ -619,20 +619,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; @@ -643,8 +650,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;