From patchwork Fri Nov 8 20:34:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178959 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3246541ilf; Fri, 8 Nov 2019 12:37:30 -0800 (PST) X-Google-Smtp-Source: APXvYqz2P258EkiZUPrkaRo+xBkABjA75AUZfrtG48jTMM3hE+zbU1Jy4B8gf3l8Z7v8y9Y1iJ7Y X-Received: by 2002:a50:8a88:: with SMTP id j8mr13036410edj.35.1573245450034; Fri, 08 Nov 2019 12:37:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573245450; cv=none; d=google.com; s=arc-20160816; b=0T08xyWQNpmfOnG5uem1mFWL68NYBUbJOxi9qrEEQpHuzaGj2so+6JmIaW38CHerAH kfxIM8lfeJ19qiEqWcAqTiUumCw11Nsbz3BIxQ1gu6iRQpQ0/sHUo3lcb2Zln+BpuUbI CBIH4MdPzMK6YRnJ6VxzFBnQisXBWDxk61b2csE/4lNC2zyD/jYfaKCDSHjn8C5y4846 6SJB8WgSk1CnBdajEpHex9Hro457vdPhqNMi4ijDIP1r1ZXE7G8s7X3RNPkQ8pDYORa4 uzhqLe1AkBE01fnwqJQgSz0GrqRhNZbTMWC0ZdOkRyKdV/Sok++8xgmeM+AtCgsLKi+L 3wUw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TaIq8R7Bkuv+GQo/80AQt5TDsV5gTLgIBfEA/uJWyyY=; b=BiP4NOqtFK0SJDakkwnnP5ir7F4FVnA8YatrkMFXhtrmnelBSLpzBk4sgAd2hHJl/m 9L+fdsnkiMJcDxWK9NLKS7hQMFWhD7gmXN/IWnYugdYzOJ1GUsegoDwOorXrnaw/BcUH 9LmLZgjja8K2LzfrWPbOcLRRSC2RoCnEUe/1zzFK0bzpM4jI2KNFG8wtcBaY5ob/WZkW 8v31jkNjlsDNltAUn9GVpOxk+hn2AMk5uTAZTP+fZ1F7OSmtFH0+XIeZxk/zwbuoHfou 1eCyrfPEyavVZZC5j9Dw48TVy7o4nC+mwAF+kAZTbNNAX1Rp/IKjoS8RIwafSyMw27+U c3yg== ARC-Authentication-Results: i=1; mx.google.com; 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 d30si5383717edj.289.2019.11.08.12.37.29; Fri, 08 Nov 2019 12:37:30 -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; 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 S1729683AbfKHUh3 (ORCPT + 14 others); Fri, 8 Nov 2019 15:37:29 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:43475 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729617AbfKHUh3 (ORCPT ); Fri, 8 Nov 2019 15:37:29 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1MJW5G-1iDiWE2fua-00Jr4T; Fri, 08 Nov 2019 21:37:18 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Sudip Mukherjee , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , stable@vger.kernel.org, Bamvor Jian Zhang , "Michael S. Tsirkin" , Thomas Gleixner Subject: [PATCH 7/8] ppdev: fix PPGETTIME/PPSETTIME ioctls Date: Fri, 8 Nov 2019 21:34:30 +0100 Message-Id: <20191108203435.112759-8-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108203435.112759-1-arnd@arndb.de> References: <20191108203435.112759-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:qYLl7Lv1RPZHuaMmx5Y4HTBUG3IUIT6OHrwxfxk1rYIY9q0J5mB ID3W+2I3bIRJN9pb9/4We7gDyPXbqHtuj1j4jbHZqPHOQssbaXzIS5oG4kS2fmZvcPatud4 28UbJl9c5SgBe7fdAKp7oJ+CbG/oBp2vCDyjiOe+T82VoBh+JiGWqcuzcRbpDWbUGG9ilIT oXkl6SZaCeu/b9K9+rWgA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:27jegMmATLs=:NTdMdmiXmyy5b2BfGtixk+ QSkp4BY2cue8C4JNNeidfsutKRhw3wMg3l/slepabQusaphf9a2XzM/Xib4pCK19c/jh6uVYw qgoqRcope7ZcvaczaCTqwuVEOQ19cb1yCth63skQddVaME5+3q0OiGk14MCUEu+SyPOElob9b Qn/YeUBZAR3oXA2iHAYPA7mROXI3Bn7dgaIShyHnylMLGP2uqmZMOllngsqQHKIWE89EWnRug 18W44axbZpxj22LSrEmOeVvaa4iJIkOdHDnXjF6hx8fT24K5b1x9XnNBqnzPwuOG0bYWl8D3+ tDSlHep+MWILVxEz0z2VBYIFRb/gqAtqd0edvpKxcnv4Q6auK3yIGRJayQS962j4gNgOndn77 0fXWlAP0cS3hrK6+4LrfRAdwDWQEM2OYpI5pP7j/hi8Wm+jrmvLn9PYgU68KOKoPMCa1q2Yhj h9nfnueEp5sP8Y6GnRXHD51s4wdw6vjhs9M6W5j4NodYDU1pyZiWYbKIAlPNRF6eH7l5AQjsS ogCgJxDmRvlDQ1MdM2xC0EnxSzjPcLA7GGrAWgVfNevSn0DIwiUxCtGZIiFgo/HG/2reHnWw2 2cMlV1d4OLUq6tEx14Z8gWn5FdQBJpS3h1RQDXv5keY2Lbz/EBwscpvG+QqeHjF2SXoz/OBpH T4vEyyqnuyq1z4hRmUI0mYY+hNztZI18aZDDo+/iy9qlGDbIc0PCwp1/RHEdM5Xjfoy9+7Jmm MTgQ64hTlGXkXWvKrIp/7yenLu4c9AKDQqLC42HchjLAPJ6crLFiylBhIItSCnYqCWe8Tyle3 mNAzDqk5r3RJ1GgTpL4QW8DP8nhhYfuSFLqdmsNXGmvrPVtcClQZK5bb+XFwFrqMAehuhAUZN BhhYhfG6EkYlzncjY87g== Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 --- drivers/char/ppdev.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) -- 2.20.0 diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index c86f18aa8985..34bb88fe0b0a 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -619,20 +619,27 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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, unsigned int cmd, unsigned long arg) 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;