Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2277588ybc; Wed, 20 Nov 2019 11:33:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwSfU1q+y+XBSHSgmZiyY01S+NT+im6mTYjjqyFroHW7haERMbgu9hmYUAhuFLipEz7i85K X-Received: by 2002:a17:906:f10:: with SMTP id z16mr7513048eji.211.1574278427564; Wed, 20 Nov 2019 11:33:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574278427; cv=none; d=google.com; s=arc-20160816; b=yhtyrx56iZZZxs7QGh8UEvGuFP7uqLdcjyHdPmNezekiKUj19IFabiupQLJ54QmcEz OcByy/xbWl2ITVC09vgjjrmN3WoLPhOuWzLcdAUCkc02KJz2kPdFsmywhrGMnOCDmkvd 9gLDyHAoMn1l23pN5iY7FDprudbShp5q+pgOGiknk/ekcvyJzupL+S11hhIKPrbfsHv0 CI8FMJkDI/zU5mwjFMsMVqchHoQB4F04PDUP72Xg085MliZYEf1pqqDTo/td0frO2EWH wDDu+w5K++pWx784A8wWyI0N2qkc2wNb5s/YYUfzP9fSoi08yQvjAbTbDXGbJViMMaTn KbEQ== 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:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=O3LaVBkHjXniCUG226VMGpgMltGXZOfuYsj2wt9Pl9E=; b=KsjZJ9V3mb6v5qDfsnXEl7Y+kJJonQM045wM40aXYdSl3nr6hhBtxdAcnAswKBJHlf 8lIOXzbOjqoUQKE3cHi2gG+c1oNe0BkqcBX9hfSVDtUtS5DQezbqKD7qtv3gE2aHEP8n OrKMrpxK6L4rMR1HL+DyiOwhiRxDDedwzr6nH39u0UtBdGYz7WymE4j689EKgMdqdsP7 nXYWIk3ytkaPI917xLBQb6OyfRgMn39wUP+bJ7UQvOn2vyRu4xfvGt49GA9DF3NBPPCt tJH7cQoNCRv8Of/0jAidFqENITp+h/aq7qfsIkZ7umQzAfGXPn5uq2V8yNjp7D6mevLL qiZQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t27si281864edd.304.2019.11.20.11.33.23; Wed, 20 Nov 2019 11:33:47 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727771AbfKTT3g (ORCPT + 99 others); Wed, 20 Nov 2019 14:29:36 -0500 Received: from imap1.codethink.co.uk ([176.9.8.82]:34311 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727090AbfKTT3g (ORCPT ); Wed, 20 Nov 2019 14:29:36 -0500 Received: from [167.98.27.226] (helo=xylophone) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1iXVfQ-0002UZ-9S; Wed, 20 Nov 2019 19:29:32 +0000 Message-ID: Subject: Re: [Y2038] [PATCH 7/8] ppdev: fix PPGETTIME/PPSETTIME ioctls From: Ben Hutchings To: Arnd Bergmann , y2038@lists.linaro.org, Sudip Mukherjee , Greg Kroah-Hartman Cc: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Thomas Gleixner , Bamvor Jian Zhang Date: Wed, 20 Nov 2019 19:29:31 +0000 In-Reply-To: <20191108203435.112759-8-arnd@arndb.de> References: <20191108203435.112759-1-arnd@arndb.de> <20191108203435.112759-8-arnd@arndb.de> Organization: Codethink Ltd. Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5-1.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2019-11-08 at 21:34 +0100, Arnd Bergmann wrote: > 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. Like the patch for lpdev, this also doesn't completely fix sparc64. Ben. > 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(-) > > 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; -- Ben Hutchings, Software Developer Codethink Ltd https://www.codethink.co.uk/ Dale House, 35 Dale Street Manchester, M1 2HF, United Kingdom