Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2074448yba; Sat, 27 Apr 2019 13:48:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRPmp0xfnb5SBkN7lM561rdWTTu/f4KzTyiK9XS6d4nn+qDbkyQZRl9WpxFs+jtjAe0aum X-Received: by 2002:a63:6fcd:: with SMTP id k196mr50361179pgc.238.1556398120580; Sat, 27 Apr 2019 13:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556398120; cv=none; d=google.com; s=arc-20160816; b=z9tomh60V1F6PSvHCZ5A/IESQWGV51jbPdEkIprMH++0DqzYc33ayodfLg3j87CRGy UoEs53X/tzfXHnIpmuy6RRGqRIys5DopH368u9yA49sg3/TdsnRTV/oOowWOVN6rvAjL Bp6uSw+fZ9ezYkfgcUSCJJ+MTCndehlM2jlpz89YeuW0TX8H644detCgIXsEYjQo1hgm dYx33M6xJUx8eCdwd4U7dHNrdrHXCCiP7DLJMERJVWycW7rOjOOsCvcxtltGsvaAMitw YpHWO+lnRPki6j+W6vQuZk8vuJTPg8Y2kCSFq2sPHSwwca2y8BmcVOOEJUws0zdexJNB DaRg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=oJZwi5HKm66cnYcamtByOPnY4QsInX+mRk+q0/LOasI=; b=gHIVeS7FyNBSJNLeg8DY9+bPf62TF7ruUaXcgg+UWWkBpzbhRVKkSkEs3NFeNeASkw XFQyaAVhNf/YO/buJKCT1EFslyGkxfL2U01b8NPqE+NdYFgwED+5OtcmXdXWhH8VCYop jtEPXwNznSkPNbB/6McNJ7mtpsNYxY1YldUV8iMclJpHJrXh65R4LEp0zmDVc5jDMKUl aenZG13vIW7FQg2b6xLHykSEw4o4WG8E7wxzqqNw7o1Vc4vALxu2ymAAkrMHef1gUw3n xF6MNWjk1XSuMNOiDw6gykBTEO2IF8s6erdyxa560nrrVEh842kHo8WTo5HYX/FQN8gt Makg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d17si28256029pgg.367.2019.04.27.13.48.24; Sat, 27 Apr 2019 13:48:40 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726385AbfD0Urg convert rfc822-to-8bit (ORCPT + 99 others); Sat, 27 Apr 2019 16:47:36 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:37392 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726088AbfD0Urf (ORCPT ); Sat, 27 Apr 2019 16:47:35 -0400 Received: by mail-qk1-f194.google.com with SMTP id c1so3918750qkk.4; Sat, 27 Apr 2019 13:47:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=bkiA6cWFfvKZGfeD6fCJT7YhaAu5sHw91dR8QStbhuQ=; b=LDE0SHiX98Km4YGVNloqIind++Yoh89hFfM70RMOi/qpQknHSHdva5cT23YWB65pkz 92PFO1+S82PHxpOTD5K7X/xuF2znlF5M1ovc2mQjKdj5J+V8jyvQeQOA+5z2nlWwaWgq 3cH19PI8IzQETlOnA14eSbs+10W4QL48+i4rJH5zhrawnIQWXeCNzLwho9pdB6NgruMm cfDkKCW96pj3g2tF06CPT34swosBh/nQBSj7iWYjJhaFou/0f4LeebWtg9Fy6XVvd1fl 9u9r2dYn8qbuZ5m97afmsNoCVCHdnyv0t70oFebNpV5YD+Cb26Wfd0Aeg1Lffy5EdBOj tuXg== X-Gm-Message-State: APjAAAVCcF9h79/i1nPb6/EX/3+fJ/waaLFtCHR/MhYsUiyHOyqgj+C2 fpc9GFanFkNnSxJkarC4+IGfggstwzxHxS0voS0= X-Received: by 2002:ae9:ee15:: with SMTP id i21mr38217586qkg.107.1556398054542; Sat, 27 Apr 2019 13:47:34 -0700 (PDT) MIME-Version: 1.0 References: <20190426142531.1378357-1-arnd@arndb.de> <20190427004653.3cecd1cb@jawa> <20190427095418.344yoomf5nwznatd@sghpc.golosunov.pp.ru> <20190427170613.38bdfbbd@jawa> In-Reply-To: <20190427170613.38bdfbbd@jawa> From: Arnd Bergmann Date: Sat, 27 Apr 2019 22:47:17 +0200 Message-ID: Subject: Re: [PATCH 1/2] y2038: make CONFIG_64BIT_TIME unconditional To: Lukasz Majewski Cc: Stepan Golosunov , Thomas Gleixner , Joseph Myers , GNU C Library , Linux API , Linux Kernel Mailing List , Deepa Dinamani Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 27, 2019 at 5:06 PM Lukasz Majewski wrote: > > 27.04.2019 в 00:46:53 +0200 Lukasz Majewski написал: > > (I am wondering whether such trucation is undefined behaviour in C > > According to [1] - Chapter 6.3.1.3 - Point 3 it is > implementation-defined. The kernel relies on the sane behavior for integer overflow in many places already, and it is built with -fno-strict-overflow to also make sure gcc doesn't optimize cases that would be undefined otherwise. > > and > > whether there should be sign-extension instead of zeroing-out for the > > in_compat_syscall() case though.) > > What I've found is that "typically" the high order bits are discarded. > > However, it is still "implementation dependent". I think the question was whether we should use kts.tv_nsec = (int)kts.tv_nsec; instead of kts.tv_nsec &= 0xfffffffful; Both have a clearly defined meaning in the C dialect we use in the kernel, but differ in the upper 32 bits for negative input values. I would say that using sign-extension indeed makes more sense here, but we don't need to change it for linux-5.1, since none of the callers of get_timespec64() care -- any negative 32-bit tv_nsec value results in -EINVAL, including the utimensat() syscall that has two special cases outside of the 0...999999999 range. Arnd