From patchwork Mon Dec 16 17:49:21 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: 181775 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp4661792ile; Mon, 16 Dec 2019 10:13:45 -0800 (PST) X-Google-Smtp-Source: APXvYqy99m6T6nFGg173yS3RdlYlPKzsvU/czdQzkQiPU/19Lok9XbqkUiSIjUzVUWc2wMu3qRC7 X-Received: by 2002:a05:6830:2110:: with SMTP id i16mr32219878otc.337.1576520025058; Mon, 16 Dec 2019 10:13:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576520025; cv=none; d=google.com; s=arc-20160816; b=0anK0CY+i7vxFs4YxCbKOAM4TSbT76IZB+9AWrh4ODLS68ZpYfwl5ZRG2HFqF1+rBb 4w9W1BuOshYhg6bCcbHCZqwF9xkX0yfya2mF/I/6of5iD/jIVg4uTIq9awRGDctfxLu+ Pcy6Yzon2Sn/pXyPXdkQXwWYblhYAQpBxyJbhbP2jJHWbcIreldtc6YbHYBu8Hw4TfD+ 0g4zCeFvE8clIK8BHBAbhK5IgAfmML25U0Xz7pI86wxRGSJp7uRiIjbivmqqAQhzp21r NJmgWD2wtYOxprzxNmzrhITNjJhTWpCmGl78XV0vKaBV2R5EaV/d8krj8yLtRjwltDkd ykrg== 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=zTyrguqsXmWRPGO3wrcuhjs/K3/GCOdsDBlBGIszC58Mk2QUEaOwbmDjTeIWK6hYPz 42jW9iWd3/CvhWSdd7EBavu7gHfgl3k8GiesLpmppeejbw8Wh7e7yNtbDhX4tVy0G8AQ c/wXEeFCKfu/JmT1/mJb33cRqvxgR1gkVUH1CzKzWBo3fYSFK21dBhijZDZ8vGuvjS23 utP+wleibwt94O3dk4LmkVk6K4CJYcH9D/RkGG5WXKA+8xQUpMxTuQFoIxLkg7a4ZGvY XT0UyIXUo4n+74bYK7+QsNTwY+o0LcSfwx0da29vD6XvWcz1INfR/bpNa0HJYv7dDgZ8 L0FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RbHy3TSn; 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 f60si11380774otf.119.2019.12.16.10.13.44; Mon, 16 Dec 2019 10:13: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=RbHy3TSn; 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 S1730917AbfLPSNm (ORCPT + 27 others); Mon, 16 Dec 2019 13:13:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:59868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731109AbfLPSNb (ORCPT ); Mon, 16 Dec 2019 13:13:31 -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 73E9D20CC7; Mon, 16 Dec 2019 18:13:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576520010; bh=pDM9YgV4ACQyf4D8/DQYrmhcjDCqeiLjgwAC5zEHwIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RbHy3TSnvJL/B/CN6nk36TF1v8ZXw0ssCthZmQyRlNAJ/U2z7uBnogG5MyQX0/g0k alHh5XAyiCVukj6VrleaGYzhEzGXQ8XkwZ7+L6hlbSVg8lRMKulAUQzhOn+4j4moFa AXHOz9R6xQuTjRA+bhGF6plpSa6lt0vfTCIZAcmU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann Subject: [PATCH 5.3 121/180] ppdev: fix PPGETTIME/PPSETTIME ioctls Date: Mon, 16 Dec 2019 18:49:21 +0100 Message-Id: <20191216174840.925017381@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174806.018988360@linuxfoundation.org> References: <20191216174806.018988360@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;