From patchwork Wed Apr 25 16:02:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 134348 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1050092lji; Wed, 25 Apr 2018 09:04:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/2ekGig+jiOwwUZU1FEg2xYGSPNQeFjv3ndMdrTlOgXArxTY4fWpjscmTp3ufAOkOwirB2 X-Received: by 10.99.178.83 with SMTP id t19mr24654163pgo.212.1524672280192; Wed, 25 Apr 2018 09:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524672280; cv=none; d=google.com; s=arc-20160816; b=sG1XZafZmzXI0FQwFFRqkxLhHIKgQ6oy2rVeQ93blRVjdsMeWFqnXqikG/lmjSM+zE uqqGLQMDY/xgxhAoPqk2oTw9AeOjV1nu/XBdToa5Do66JEnbsCD2wUSK0Bk4hclw7+rf gn8t3dvdcJDGmdRZCJsBVWkurfQ2U7DmqSqvtjox1HLUXa+K4ZsULLD9CmprzWyZ/LLg Wu1ugqFqO0lGkCJPA9cnbLPsRPMM7zzcudXdRq8iD+3DL/yaa/dZSUtKL82ayPKB9CG4 QV5j2xZqEwTKeFkMi+gw+ZXxwFg5DKAnkz441KKwi54u0CEreUsxMqVHXot/HRFCk/Cn z1uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=T4Vg73iJqa43fgAAzk4HBFJySPiVT+uMtLfqGj3WTaM=; b=wcjRBIKQDuY5cuMMSnw1ge274hF45WusUTLttMq5rB6xnI7XkQRnfPo5cQ/Z16581z 3ey1h3GtqjHn6YuHDopLOVeVTa0cZIPCsBq24KpDEhZfL9XOGyCuE7hqCvYSfvoUQACy TIweZ09M4dGuwYbbmsyIrquzx6Hh7PSrg8ACfI88Bw05CutUbd0+Ky0+TKAg5wd2xpXy cCtpaaxoK92DLNfbfPuwDdilOoftKSbiz+kMxGkc9dMaxtHBIK2C83GmWkufhtVzuAW4 HMPU2RWQVLgU0QaQFdF9QBroGWUxwzLAzh0RraBQ4JbIwZTVK2K+Vez0V2k/x0pMSnrs 9umg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=jOKmGiyH; spf=pass (google.com: domain of libc-alpha-return-91840-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91840-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id x10-v6si17194204plm.5.2018.04.25.09.04.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 09:04:40 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-91840-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=jOKmGiyH; spf=pass (google.com: domain of libc-alpha-return-91840-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91840-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=tPwW7h9XC0dWIJtIqs3kzXzLQ/1Lb9r L+TUBuQ8dIEhk7z/CFHYME7Nx2uGmnhZ/1dNMVVbjqsNKVNhnVSQ93Me4aq9Cm8J liWUpkwxZHvqVek5gq1WvxHH4HeZCf/6VK8wsqiR/asVg46XdPN8oc6YXKTrBf6M pE554oajaWck= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=WCxhSSVUZJ1vI9TfIrdbQIQZaB8=; b=jOKmG iyHsIdhfo4VhLLqABKJ6l0XCfincIh891M3DEksM7RnNOXC9jcn0p0rFQVtmz3Ar liS5PqQTSIcwtLruKVYqQppnbHkvuj0A8DeoFUgyoYgBuLvOaeBiL07j2VLT+1om UR0MmcNHyrj8htAxmS7MKVMZBcyHIfItHmBc1w= Received: (qmail 56320 invoked by alias); 25 Apr 2018 16:04:28 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 56116 invoked by uid 89); 25 Apr 2018 16:04:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=backwards X-HELO: mout.kundenserver.de From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, libc-alpha@sourceware.org, tglx@linutronix.de, netdev@vger.kernel.org, deepa.kernel@gmail.com, viro@zeniv.linux.org.uk, albert.aribaud@3adev.fr, Peter Zijlstra , Darren Hart , "Eric W. Biederman" , Dominik Brodowski Subject: [PATCH 03/17] y2038: Remove stat64 family from default syscall set Date: Wed, 25 Apr 2018 18:02:57 +0200 Message-Id: <20180425160311.2718314-4-arnd@arndb.de> In-Reply-To: <20180425160311.2718314-1-arnd@arndb.de> References: <20180425160311.2718314-1-arnd@arndb.de> X-UI-Out-Filterresults: notjunk:1; V01:K0:7uiQpXHC848=:mBxjrN0EXu38QOlmHaaN7a NxwMLu/9I44+PdkuAPpu1/d7A0UOFxHkDv0eA5PH64E87aGsknKcPulT0Sd7DDU7j8Dz7IN+x O5e3KM0YB4+oCzDfbxCj8gUfJhyuP284y2ay3Qt4UR4gpq92onmcjlkZ5HM4HqG+nqSVspSUY DVHr2ABKX8niumES+QCMbnWthIUJOpOOh67jdrgYUZDe7eH9E2CaBZ4RF7+2UY88B4ZEhWLmf rnreuerQX5jpScKnXcOUCCpd8Oqo89/4cvsD9EZOr/n2Skg3bK9LANzAZ/4Y9UHs77Ed8eOGJ /aAbKsKY8bXgMxU6IfIL+n0F8vsaXnp7wqPMhj6lPy7O8sb4CXAZAuGnOLxags7kcA3ayCwae KyXUiQuNl0nOTfJzFCyoGa+jiIYL9CWEKSRF+4jWc6DIFMLzkLP/hR/z22oX0EjeTCGLSYKms KhNXjWGaPuFwheoio1/W2X/uF9AgJ8xTAm7vURlwp6NryYcYm9bFXeKik2uKBe3S9yIc1YLZz 5R7tWbnMZ5BQMrKSNkcpceNp75WNX9bIrR5fljpN29dBBT5BuhrFL5Kf/bFgUZsu+yY2QoISy eUynAlXAuIctili0Kn3PS7uja87S7dUDzF9XuGw0CVvxkoruF0DF5e3EFZ+rHsZQ0BWyiFUmu DlnD1VwC/aQOxZFJkRsNa5VE6xvAwfEaUNDFVtDMuL2DE3zavONviF0fohv+wGATqdew= New architectures should no longer need stat64, which is not y2038 safe and has been replaced by statx(). This removes the 'select __ARCH_WANT_STAT64' statement from asm-generic/unistd.h and instead moves it into the respective asm/unistd.h UAPI header files for each architecture that uses it today. In the generic file, the system call number and entry points are now made conditional, so newly added architectures (e.g. riscv32 or csky) will never need to carry backwards compatiblity for it. arm64 is the only 64-bit architecture using the asm-generic/unistd.h file, and it already sets __ARCH_WANT_NEW_STAT in its headers, and I use the same #ifdef here: future 64-bit architectures therefore won't see newstat or stat64 any more. They don't suffer from the y2038 time_t overflow, but for consistency it seems best to also let them use statx(). Signed-off-by: Arnd Bergmann --- arch/arc/include/uapi/asm/unistd.h | 1 + arch/c6x/include/uapi/asm/unistd.h | 1 + arch/h8300/include/uapi/asm/unistd.h | 1 + arch/hexagon/include/uapi/asm/unistd.h | 1 + arch/nds32/include/uapi/asm/unistd.h | 1 + arch/nios2/include/uapi/asm/unistd.h | 1 + arch/openrisc/include/uapi/asm/unistd.h | 1 + arch/unicore32/include/uapi/asm/unistd.h | 1 + include/asm-generic/unistd.h | 1 - include/uapi/asm-generic/unistd.h | 2 ++ 10 files changed, 10 insertions(+), 1 deletion(-) -- 2.9.0 diff --git a/arch/arc/include/uapi/asm/unistd.h b/arch/arc/include/uapi/asm/unistd.h index 517178b1daef..3b3543fd151c 100644 --- a/arch/arc/include/uapi/asm/unistd.h +++ b/arch/arc/include/uapi/asm/unistd.h @@ -17,6 +17,7 @@ #define _UAPI_ASM_ARC_UNISTD_H #define __ARCH_WANT_RENAMEAT +#define __ARCH_WANT_STAT64 #define __ARCH_WANT_SYS_EXECVE #define __ARCH_WANT_SYS_CLONE #define __ARCH_WANT_SYS_VFORK diff --git a/arch/c6x/include/uapi/asm/unistd.h b/arch/c6x/include/uapi/asm/unistd.h index 0d2daf7f9809..6b2fe792de9d 100644 --- a/arch/c6x/include/uapi/asm/unistd.h +++ b/arch/c6x/include/uapi/asm/unistd.h @@ -16,6 +16,7 @@ */ #define __ARCH_WANT_RENAMEAT +#define __ARCH_WANT_STAT64 #define __ARCH_WANT_SYS_CLONE /* Use the standard ABI for syscalls. */ diff --git a/arch/h8300/include/uapi/asm/unistd.h b/arch/h8300/include/uapi/asm/unistd.h index 7dd20ef7625a..628195823816 100644 --- a/arch/h8300/include/uapi/asm/unistd.h +++ b/arch/h8300/include/uapi/asm/unistd.h @@ -1,5 +1,6 @@ #define __ARCH_NOMMU #define __ARCH_WANT_RENAMEAT +#define __ARCH_WANT_STAT64 #include diff --git a/arch/hexagon/include/uapi/asm/unistd.h b/arch/hexagon/include/uapi/asm/unistd.h index ea181e79162e..c91ca7d02461 100644 --- a/arch/hexagon/include/uapi/asm/unistd.h +++ b/arch/hexagon/include/uapi/asm/unistd.h @@ -29,6 +29,7 @@ #define sys_mmap2 sys_mmap_pgoff #define __ARCH_WANT_RENAMEAT +#define __ARCH_WANT_STAT64 #define __ARCH_WANT_SYS_EXECVE #define __ARCH_WANT_SYS_CLONE #define __ARCH_WANT_SYS_VFORK diff --git a/arch/nds32/include/uapi/asm/unistd.h b/arch/nds32/include/uapi/asm/unistd.h index 6e95901cabe3..603e826e0449 100644 --- a/arch/nds32/include/uapi/asm/unistd.h +++ b/arch/nds32/include/uapi/asm/unistd.h @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (C) 2005-2017 Andes Technology Corporation +#define __ARCH_WANT_STAT64 #define __ARCH_WANT_SYNC_FILE_RANGE2 /* Use the standard ABI for syscalls */ diff --git a/arch/nios2/include/uapi/asm/unistd.h b/arch/nios2/include/uapi/asm/unistd.h index b6bdae04bc84..d9948d88790b 100644 --- a/arch/nios2/include/uapi/asm/unistd.h +++ b/arch/nios2/include/uapi/asm/unistd.h @@ -19,6 +19,7 @@ #define sys_mmap2 sys_mmap_pgoff #define __ARCH_WANT_RENAMEAT +#define __ARCH_WANT_STAT64 /* Use the standard ABI for syscalls */ #include diff --git a/arch/openrisc/include/uapi/asm/unistd.h b/arch/openrisc/include/uapi/asm/unistd.h index 11c5a58ab333..ec37df18d8ed 100644 --- a/arch/openrisc/include/uapi/asm/unistd.h +++ b/arch/openrisc/include/uapi/asm/unistd.h @@ -20,6 +20,7 @@ #define sys_mmap2 sys_mmap_pgoff #define __ARCH_WANT_RENAMEAT +#define __ARCH_WANT_STAT64 #define __ARCH_WANT_SYS_FORK #define __ARCH_WANT_SYS_CLONE diff --git a/arch/unicore32/include/uapi/asm/unistd.h b/arch/unicore32/include/uapi/asm/unistd.h index 65856eaab163..1e8fe5941b8a 100644 --- a/arch/unicore32/include/uapi/asm/unistd.h +++ b/arch/unicore32/include/uapi/asm/unistd.h @@ -15,4 +15,5 @@ /* Use the standard ABI for syscalls. */ #include +#define __ARCH_WANT_STAT64 #define __ARCH_WANT_SYS_CLONE diff --git a/include/asm-generic/unistd.h b/include/asm-generic/unistd.h index cdf904265caf..ea74eca8463f 100644 --- a/include/asm-generic/unistd.h +++ b/include/asm-generic/unistd.h @@ -8,6 +8,5 @@ * be selected by default. */ #if __BITS_PER_LONG == 32 -#define __ARCH_WANT_STAT64 #define __ARCH_WANT_SYS_LLSEEK #endif diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index 8bcb186c6f67..ce6a26c596e8 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -242,10 +242,12 @@ __SYSCALL(__NR_tee, sys_tee) /* fs/stat.c */ #define __NR_readlinkat 78 __SYSCALL(__NR_readlinkat, sys_readlinkat) +#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64) #define __NR3264_fstatat 79 __SC_3264(__NR3264_fstatat, sys_fstatat64, sys_newfstatat) #define __NR3264_fstat 80 __SC_3264(__NR3264_fstat, sys_fstat64, sys_newfstat) +#endif /* fs/sync.c */ #define __NR_sync 81 From patchwork Wed Apr 25 16:02:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 134349 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1050295lji; Wed, 25 Apr 2018 09:04:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx49XBRzuIV72KZLpIHTLqxcXEEpjVM+w7KG09yBHy11nFLUSu6ypJi6I5L2YwmLpUUWbQmP8 X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr29601723pla.205.1524672288751; Wed, 25 Apr 2018 09:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524672288; cv=none; d=google.com; s=arc-20160816; b=inJj257r322rW2zrMwCr6aJ6teFC5CNGkI5R23u3eB+TmMRU4D2wDIe1UG/gFFK3Ef ZR0zX7AIa5iLEYge9lrrJxrwBF/qdbnW9hjrrOBVZDiqNaU38QC21b8dBG5E8PZtKwNq 6WMcRwUEtPt7ocRMjU+6A0lCPleGwI5dFOWSV/ERKjD+F1PE+tkDZDJqiXPTShClD0If UPlbzeWp6maIfk9EXQv9Czozi6teNdNqQF4fszGR7jVC94k7Dbde2jH/oyBSHqt7B3iv 99SGLTsqc0B7N10QIfdlcRNXeFcWdhk70bK1n6VnEgdCc41fJQHY6k7+AY/iyQEjqXvO 94kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=6PCetevrWYZvGNLi2gm6bBVctHkkolEnb0pEIoemcAk=; b=oa2+ppw6H9Etexk+6i6nFPc08PUYP8+Fh8fCI9s3gE6CDZmpJf74pPQqMY8Di7zUes pQq6rAYiSziD1EA/ZpMXe+khscrKGHLy2hkxvaJDFBBJ2Ur4iVUeHWcYvXfUeR7G/SMx Hec983WGzoC2JrNSMOyg2hhP9WnxMeAe3lNj3Hz4NjRKVV0NB49QVRTlBsqCQCS/HmiC iaZFNidAvH1jtDUOQLDqji1ZoDX9BvsX7OMl+/21l1HLzglhKjRJGsIEi1nbz+dfj8Ie OKOutdpw2zNmfSo+GmKdw3IXQAif6+excmoo5t7zBZydtmuqya2eydysO9MjE7t3ofGO JQkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=AIQa09Xf; spf=pass (google.com: domain of libc-alpha-return-91841-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91841-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id o12-v6si16546021plk.264.2018.04.25.09.04.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 09:04:48 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-91841-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=AIQa09Xf; spf=pass (google.com: domain of libc-alpha-return-91841-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91841-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=DWyKV1ycrfdcQzL3q8/DOcMk79kkAxy uxjMUVOIpSNnoiGYNSGrLkjOif8QSG9S8l/RgvC8o/002VjESw5KV450P08KSmUb RbbTDy6YYq6OxmM6g2g7a+itQMTt/fHbZtqSNRVIW57czgZZ4eR8a2AJ1QtHdseT 6qrTZrVvLHsY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=0LuP8i29z2PajWUENs1smYBUzd4=; b=AIQa0 9XfF9cGlBVJI5b3uiP/YrvKx8yfoGxLjK2aOq7i4O2rLpulU87gRDJu2vFNLYv82 RP+Kt9jlYgQZks8wRjC/u0uayoM+kflDrUj/UOlGsaNzsC0q2z+xHPfWAeyl6FPZ aOrGPTcNFwhnCYQew8VrPQ8wPeVSCgfMdCVumo= Received: (qmail 57327 invoked by alias); 25 Apr 2018 16:04:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 57142 invoked by uid 89); 25 Apr 2018 16:04:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:ESMTPA X-HELO: mout.kundenserver.de From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, libc-alpha@sourceware.org, tglx@linutronix.de, netdev@vger.kernel.org, deepa.kernel@gmail.com, viro@zeniv.linux.org.uk, albert.aribaud@3adev.fr, Peter Zijlstra , Darren Hart , "Eric W. Biederman" , Dominik Brodowski Subject: [PATCH 05/17] asm-generic: Remove empty asm/unistd.h Date: Wed, 25 Apr 2018 18:02:59 +0200 Message-Id: <20180425160311.2718314-6-arnd@arndb.de> In-Reply-To: <20180425160311.2718314-1-arnd@arndb.de> References: <20180425160311.2718314-1-arnd@arndb.de> X-UI-Out-Filterresults: notjunk:1; V01:K0:cF4Rt6VqImo=:f3kBY75BnxBLFdMCi7joox Xno79JNaZnwmHHYiwVC1c3mOXlc0G+lh06h8jEK1q262qXk/n3CfiBg3darvN9+b5we4Rg5s8 Fp/mZA1eRdAerXkaoO4onnsPifzfR4DIgu4WYti5r3679GodnYTr/QEIxw8P5/ZW5q6ecV+NK wgQwIBSpdcLeBFYjmS4EYZYBnIoDZQ/9ZyTcHAA3JHFnQrsB3F+/EVLBc+mo0E9nYe3O+92Rg bBRZgdfeBjplkQ8cHA3SPzM7rTO5oQfg3cwPqkHyZ0+6ib+UCPWqTZP5dOdEgZUGJcrrlFU3+ d9KgIJ5cXM8Cco5WL06KImVKghavfRwKYEj8OGD0gZTyfJOhFBVOPzFIem2ioc/MMKqV2LelP 7MienlBWF1u9LefrRZFHaY9G0P20Vr04DMimcoj3kJKsKlS5BdtvG16VqKKxnydMSICtl2C2L N3XbtWsXKSW6A7wTcKTyzTXj8meOXyFLEHWSr1eOoJoExWWemdbB3FnlEkVUkF8OrIlDJTJJq eLyiEiMCFSjJ4QqOfrf81q1Jqxe3fmNwpvuiD9aPMkc9pOlTVAp5VgcXe3Rj+2TudcuKxfr+C QcHuXYS0mHd81Ibit10duOpmbdcJk+DARRU+CfysM9lXg7C+tHRFE3ispwhhR2Z7C+q3qvmkb I3aoh8TbcK4QpDigmZU92oTJxeyum2nu8lePuxRUnuGNVQqslQxJmNYeO8EAU2ibroXw= Nothing is left in asm/unistd.h except for the redirect to uapi/asm/unistd.h, so removing the file simply leads to that one being used directly. The linux/export.h inclusion is a leftover from commit e1b5bb6d1236 ("consolidate cond_syscall and SYSCALL_ALIAS declarations") and should not be used anyway. Signed-off-by: Arnd Bergmann --- include/asm-generic/unistd.h | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 include/asm-generic/unistd.h -- 2.9.0 diff --git a/include/asm-generic/unistd.h b/include/asm-generic/unistd.h deleted file mode 100644 index 71d2fcf9dbcd..000000000000 --- a/include/asm-generic/unistd.h +++ /dev/null @@ -1,3 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include -#include From patchwork Wed Apr 25 16:03:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 134355 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1051312lji; Wed, 25 Apr 2018 09:05:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx49BpgqmELXmvMv59a8japkyas1Qrv0TOJ6y2pUMGUNoh+vp22LFC1QsU1vPrDtM5eBkHwh/ X-Received: by 10.101.69.194 with SMTP id m2mr24235318pgr.433.1524672329336; Wed, 25 Apr 2018 09:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524672329; cv=none; d=google.com; s=arc-20160816; b=QEUxzoSJL4jz3DxK2zXEx39uYA2FTL5UtfJlJub4nITuWSsIDRznzE0U0CKufg1QMc qELQzR6E4bXTjd8HCxQnJSPugGjzfNZGPVyRzWralL2l3HueCE4q0/lCOryPwzYsSMmf /z2qqf0aaJw/UIWfpMEfUI10IqJ7QkyF8INy3gzfAA27wo5Y6GXi6yS3Q4nH75LXzDEn /6/OmScGY3gErE/YEmbdEv29a0FP9yBYOATptRkPIGZOqzRyuOVpuOkANuGVTHdeKc6x CyZ5YyLR/UB4umzARUOZpY2sd9Ataftl8sOb3tKuCkjWSHUtUCMbfJRir1+8zOqFCLSW HQPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=pY/unc05HR9/U7jR5JfwojOFiWBaI42qEBvPClQK8Xk=; b=G0NHVAc2ZcyRd2aA7CqQQj892zJmKijBVQo4DsJ/TwJFwvt04f8nsXtqec5QJjy06N agq0hMU7PfizHWBQPVBHKxBq26u1sa+RsyRlZt3Nb1bQ2gAktKL0d0cSwDdMt7wcBorr P9z59x5lJeLMkaRoDLLwhMzsmStztHam8gZowzuvF+D/GMHHtUwk4SgXl6drjS2OZf7w r1TgOcdfl/FIj4G8IAjLRZ4oYwFv74+ZxZRZdk3MQs+2F4sSegdc4RF2ZlKi/3gpfnzT UO6LxaO/00Bm2gBjJfPXppICL/J5FiR1T8pDkA4srAFkM9kbsBX/enTlzDU4/Q8ik21R poxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PZmcCqQI; spf=pass (google.com: domain of libc-alpha-return-91845-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91845-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l3si3151362pfa.368.2018.04.25.09.05.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 09:05:29 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-91845-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PZmcCqQI; spf=pass (google.com: domain of libc-alpha-return-91845-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91845-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=J3nrdifvjvN/LzLDybG2c17UieH5npA qzNbuwZ2RvMPj47jSwjagYPuha6utbFZRRtR8S8FIpiG3kybz/prtJOS1JgIj8HL e10KUY6OjLV8XggQFxscARhAhixl0k1iwTo8BR+w9YqlTlPvOezdiysOPwR0+AtL Tzl3YFyzZEBw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=eaeJ49lw/AiCj55lffGBYsQ70g0=; b=PZmcC qQIzXDu5KcFIQbln0Cu48HqZQa/soBTP0TeqPlg2QrrZVWyeu1ginqYlDMSPTA4J EROZYFGe5CsU1xhl4tjaaanRKJBn6L+J6M0NLVTN/EWF+B4A/m85jSsm4hClleJB BPFA578dMwKk7PQBd/oQnR4aUVdNsfn2t6nQnU= Received: (qmail 59248 invoked by alias); 25 Apr 2018 16:04:50 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 59142 invoked by uid 89); 25 Apr 2018 16:04:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=dfd X-HELO: mout.kundenserver.de From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, libc-alpha@sourceware.org, tglx@linutronix.de, netdev@vger.kernel.org, deepa.kernel@gmail.com, viro@zeniv.linux.org.uk, albert.aribaud@3adev.fr, Peter Zijlstra , Darren Hart , "Eric W. Biederman" , Dominik Brodowski Subject: [PATCH 06/17] y2038: Change sys_utimensat() to use __kernel_timespec Date: Wed, 25 Apr 2018 18:03:00 +0200 Message-Id: <20180425160311.2718314-7-arnd@arndb.de> In-Reply-To: <20180425160311.2718314-1-arnd@arndb.de> References: <20180425160311.2718314-1-arnd@arndb.de> X-UI-Out-Filterresults: notjunk:1; V01:K0:WRcSPk41H4s=:aRIUhRdxQKZsyYruZo61Qz yha/TdFPz0PVepEvJd5TQhRAevY+c1N01Ji2yOk0+yUssbPv+G2rebscubmHDcpAKdo7LRR3x uH6JQMzocysQcTFw2atL4Gd4ocljp6MZg592pUf26ByCH+bllIef8M9hoSS6SamXwVnob9TSJ Vay/2cVtNXwNRzXDlneBzcKep9yGP0b42dBL6cXs7NT4TqiLHaHfuOdjnt2t5TqdmviK/78P2 Pm2cJMVu5bHS04h75RXWUBR6uOVLXK8fO1oyX0kN39l4V9yEz4cASHxoJS7fiPVlJANjUf9hd L/H1fIHgBeJMhzGSf9v2NvfAH7lF8h9/u8zNY84Kbsr4K6K1qBlfrVWPANmGEH5EM/QApjxMx RMamj4XL7ycsgZ9iUr0hz9eQKgzhuLBbWFqX+9wobIEqJab0r6GvP97dKHqsJE+UpDJBK5mA3 O3oH2g76bWmezZOIpUUTsgGY85bb1NBceok9TNHBKwrCa/pWggR8RY1DCOMb7qNHTv8nYaNhS MSPGZxUnyJeKhQ2StHBSZlrdORy4F748954B9MwpLsa/1bYzyA2bt5+Ydr3DMMG8v60vh5BTn go9gZdX8C9f1VIx4eSZV59CffAkpz/QtMtHeROvw52w7yqP6jiyGRJuoSyM1NgaYr4XnxlfUd vnBBxA4zxIsLQmB4O5yPFKVkmFZsWU+pgN4PH/cpvUa+/w9/E1anufQirX3rlQnL38Ls= When 32-bit architectures get changed to support 64-bit time_t, utimensat() needs to use the new __kernel_timespec structure as its argument. The older utime(), utimes() and futimesat() system calls don't need a corresponding change as they are no longer used on C libraries that have 64-bit time support. As we do for the other syscalls that have timespec arguments, we reuse the 'compat' syscall entry points to implement the traditional four interfaces, and only leave the new utimensat() as a native handler, so that the same code gets used on both 32-bit and 64-bit kernels on each syscall. Signed-off-by: Arnd Bergmann --- fs/utimes.c | 2 +- include/linux/syscalls.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) -- 2.9.0 diff --git a/fs/utimes.c b/fs/utimes.c index 69d4b6ba1bfb..ca2c02a7985c 100644 --- a/fs/utimes.c +++ b/fs/utimes.c @@ -166,7 +166,7 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, } SYSCALL_DEFINE4(utimensat, int, dfd, const char __user *, filename, - struct timespec __user *, utimes, int, flags) + struct __kernel_timespec __user *, utimes, int, flags) { struct timespec64 tstimes[2]; diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index b92cb79d38c3..3d7dd665cdeb 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -500,7 +500,8 @@ asmlinkage long sys_timerfd_gettime(int ufd, struct itimerspec __user *otmr); /* fs/utimes.c */ asmlinkage long sys_utimensat(int dfd, const char __user *filename, - struct timespec __user *utimes, int flags); + struct __kernel_timespec __user *utimes, + int flags); /* kernel/acct.c */ asmlinkage long sys_acct(const char __user *name); From patchwork Wed Apr 25 16:03:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 134361 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1052182lji; Wed, 25 Apr 2018 09:06:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx49G11Ul3p68TIhOp+gJlx4OlEkaNvoVZ7ENldP+O/UQHNb7nfj5vMlKE2b1lpSGmvWMtK7x X-Received: by 10.101.102.3 with SMTP id w3mr24203073pgv.151.1524672367786; Wed, 25 Apr 2018 09:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524672367; cv=none; d=google.com; s=arc-20160816; b=cbZOBvQX+o3jtIjjEry9VGcXPWz08AWH7IkEt5zSckGlkYVyQv+37jhmQXxH2TwGjN JiVrX/KrHlQvXF8i2nZessjJ58FOWUr9qcUPv4ZWfy6YXmjhwkide4F6XWXnIt1VO0os G5fi7H7m7FeRd4x7RmP6GN61WtQyE8HTKN0fXg1hXIaOzZQ/TG0QPRkqsYTzKFXlcDi3 0p6zgbZi0qfb2EnQ8Xh/CXMHZcwaCTRebI24KlaDdHBY+/DWwH+4zfcHMUDDdRU2veBE vQkL26PqZqdCl6oNfAE78g9K7KeJHN8c5zI7tk3BkIzFe8QZQby2QXvH/eNfytaN27/L 1BTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=QYvG25EBr+BcYrVa7BmxH338CoSrjJxFKYJsX9Z0Onw=; b=dCPOznn4/iub2DFkBQzpJqLgNhiKKHZdDi0EadNytaAruWq/EKA34SBOQsbNolkFKc XmkcN14nn4huMOjAtT9h2JVTeyNciNBojzV/tbG1bCEH3IxWKMVS2cqe8EitlGrFHyDa pVcM+pK+x84/RiuezoM0OU6Lb2rRq6fgCJJq2uPjdK2Pu3+drJu5vvsCZX7AIjcxEWcb WVO5xqqk+LEJPMI682cma3suXvalC2Nmp564R/7maD/M2WT/Lk6WZbufZfNgKf9dWEHa G4BYz1hsx/LmxxhIQKQeN4zScpw9d9QZ8vVqm54iS1yCc0oqzE80uAgcFSMEZ0gP9NVI Pupw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=UOCPJm/3; spf=pass (google.com: domain of libc-alpha-return-91849-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91849-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id t11si13674934pgn.337.2018.04.25.09.06.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 09:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-91849-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=UOCPJm/3; spf=pass (google.com: domain of libc-alpha-return-91849-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91849-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=kD7uwJRsqTKEt19H2BvPKexX9tPItei SEl7qsvcPQ+nZpcA+VshaMnPOtCAs773x3zriKPVOZCvBvwPBK72WKRFrhA7jc79 Ej70/1JsPpOppLZv/Cw6wHu8Cp8R4abhcXrvXd3l6y0HiWRP+vFb59xh7vKpYDNJ j4RjUTYGPVww= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=7yiP1SOnd12fYLdP3eE8UGGY5nU=; b=UOCPJ m/35oZ+IiVGTIFcpPjtg5BiP4mYZaX+mTWNUyyNBRKw9FLqRoc4hUwgz6YeXmq4K E+/X3Cibtj12UzKTRRx6K/2bkMNqGpcLJz91iUg5j3cA4pU9M3zMPB3t+qu6SFz8 ASULvq1x3do/QCOGFiWvZ0NjuSsPb98Yt3RR6k= Received: (qmail 61923 invoked by alias); 25 Apr 2018 16:05:10 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 61791 invoked by uid 89); 25 Apr 2018 16:05:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=tiny X-HELO: mout.kundenserver.de From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, libc-alpha@sourceware.org, tglx@linutronix.de, netdev@vger.kernel.org, deepa.kernel@gmail.com, viro@zeniv.linux.org.uk, albert.aribaud@3adev.fr, Peter Zijlstra , Darren Hart , "Eric W. Biederman" , Dominik Brodowski Subject: [PATCH 07/17] y2038: Compile utimes()/futimesat() conditionally Date: Wed, 25 Apr 2018 18:03:01 +0200 Message-Id: <20180425160311.2718314-8-arnd@arndb.de> In-Reply-To: <20180425160311.2718314-1-arnd@arndb.de> References: <20180425160311.2718314-1-arnd@arndb.de> X-UI-Out-Filterresults: notjunk:1; V01:K0:EqAKw0UipvY=:bh0EjLUZlrGjZePSwrEraC pXuI3LV4tJc7TDgS1LCwPm9w035dG07j/RWR+JJK4g/o1Dp0R5QwpqTJqsJeOIX0kM270AXXB r9lgJkrpSs+GRXDIYMmsVNeiyQOf5c5x4W18WL8hN8Uoc+K6U2b+xy9+MO+BpJDvBgca3gtTU gdLlRdhRBdn6ndbJBUbWlNrm99l80M5gLC4Yan22jRX04aRUJDH94qb314G6SypV9vg7qXOs3 MgLdqU5qPmZvxKthTyEQRA3jxFHYsDI7aClKdoL4nK0FeIO4Zj/4fJ2tcPJyAsI/CPGNv+tln r4zNprUfNoJmjnlV0evn+PNr/xN+8AyDg0ZCE3v0oSkSvKSj3bZZx0sl78wJT7/+X4lGpUtfs cExJEgezuiJPsn6IH/GFgmFlMNB9qJNpz9WgyYiuV6Df2SifCDPwU6qYZNotU2svFxnfEJL+k w8MZxjeQvUlLDGjW41uRBYi+cXy7/rX5kuNQ8UmyKQ7k1mK5TBaUK2jTvSfG70Rpo+TB/GRKQ 5P15OGVy6I6nPBGCPU06WAmwANTTOuf1VVQTNwSMW8fUqOr/YiiFYxeU3aq37J+3fjAneQ0DB MWBDhgDrLT1cRJY4Wsh94qVDXYjmheIy8mE2LMjMOYqa8Dfy55KtTJZ+iJwpBnRLsGIHBEKph RBNJFOdRTXAHpc5SX0I1SZBWvGcMTYTUc0N56dCGilp0MX5WSOehJm+vvunrXXQalWt0= There are four generations of utimes() syscalls: utime(), utimes(), futimesat() and utimensat(), each one being a superset of the previous one. For y2038 support, we have to add another one, which is the same as the existing utimensat() but always passes 64-bit times_t based timespec values. There are currently 10 architectures that only use utimensat(), two that use utimes(), futimesat() and utimensat() but not utime(), and 11 architectures that have all four, and those define __ARCH_WANT_SYS_UTIME in order to get a sys_utime implementation. Since all the new architectures only want utimensat(), moving all the legacy entry points into a common __ARCH_WANT_SYS_UTIME guard simplifies the logic. Only alpha and ia64 grow a tiny bit as they now also get an unused sys_utime(), but it didn't seem worth the extra complexity of adding yet another ifdef for those. Signed-off-by: Arnd Bergmann --- arch/alpha/include/asm/unistd.h | 1 + arch/arm/include/asm/unistd.h | 2 +- arch/ia64/include/asm/unistd.h | 1 + fs/utimes.c | 51 ++++++++++++++++++----------------------- include/linux/syscalls.h | 10 ++++---- 5 files changed, 31 insertions(+), 34 deletions(-) -- 2.9.0 diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h index edc090470023..9ff37aa1165f 100644 --- a/arch/alpha/include/asm/unistd.h +++ b/arch/alpha/include/asm/unistd.h @@ -14,6 +14,7 @@ #define __ARCH_WANT_SYS_GETPGRP #define __ARCH_WANT_SYS_OLDUMOUNT #define __ARCH_WANT_SYS_SIGPENDING +#define __ARCH_WANT_SYS_UTIME #define __ARCH_WANT_SYS_FORK #define __ARCH_WANT_SYS_VFORK #define __ARCH_WANT_SYS_CLONE diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h index 8f1159c26f20..88ef2ce1f69a 100644 --- a/arch/arm/include/asm/unistd.h +++ b/arch/arm/include/asm/unistd.h @@ -26,13 +26,13 @@ #define __ARCH_WANT_SYS_SIGPROCMASK #define __ARCH_WANT_SYS_OLD_MMAP #define __ARCH_WANT_SYS_OLD_SELECT +#define __ARCH_WANT_SYS_UTIME #if !defined(CONFIG_AEABI) || defined(CONFIG_OABI_COMPAT) #define __ARCH_WANT_SYS_TIME #define __ARCH_WANT_SYS_IPC #define __ARCH_WANT_SYS_OLDUMOUNT #define __ARCH_WANT_SYS_ALARM -#define __ARCH_WANT_SYS_UTIME #define __ARCH_WANT_SYS_OLD_GETRLIMIT #define __ARCH_WANT_OLD_READDIR #define __ARCH_WANT_SYS_SOCKETCALL diff --git a/arch/ia64/include/asm/unistd.h b/arch/ia64/include/asm/unistd.h index c5b2620c4a4c..49e34db2529c 100644 --- a/arch/ia64/include/asm/unistd.h +++ b/arch/ia64/include/asm/unistd.h @@ -29,6 +29,7 @@ #define __IGNORE_umount2 /* umount() */ #define __ARCH_WANT_NEW_STAT +#define __ARCH_WANT_SYS_UTIME #if !defined(__ASSEMBLY__) && !defined(ASSEMBLER) diff --git a/fs/utimes.c b/fs/utimes.c index ca2c02a7985c..ebc7fb713d91 100644 --- a/fs/utimes.c +++ b/fs/utimes.c @@ -8,35 +8,6 @@ #include #include -#ifdef __ARCH_WANT_SYS_UTIME - -/* - * sys_utime() can be implemented in user-level using sys_utimes(). - * Is this for backwards compatibility? If so, why not move it - * into the appropriate arch directory (for those architectures that - * need it). - */ - -/* If times==NULL, set access and modification to current time, - * must be owner or have write permission. - * Else, update from *times, must be owner or super user. - */ -SYSCALL_DEFINE2(utime, char __user *, filename, struct utimbuf __user *, times) -{ - struct timespec64 tv[2]; - - if (times) { - if (get_user(tv[0].tv_sec, ×->actime) || - get_user(tv[1].tv_sec, ×->modtime)) - return -EFAULT; - tv[0].tv_nsec = 0; - tv[1].tv_nsec = 0; - } - return do_utimes(AT_FDCWD, filename, times ? tv : NULL, 0); -} - -#endif - static bool nsec_valid(long nsec) { if (nsec == UTIME_OMIT || nsec == UTIME_NOW) @@ -184,6 +155,13 @@ SYSCALL_DEFINE4(utimensat, int, dfd, const char __user *, filename, return do_utimes(dfd, filename, utimes ? tstimes : NULL, flags); } +#ifdef __ARCH_WANT_SYS_UTIME +/* + * futimesat(), utimes() and utime() are older versions of utimensat() + * that are provided for compatibility with traditional C libraries. + * On modern architectures, we always use libc wrappers around + * utimensat() instead. + */ static long do_futimesat(int dfd, const char __user *filename, struct timeval __user *utimes) { @@ -225,6 +203,21 @@ SYSCALL_DEFINE2(utimes, char __user *, filename, return do_futimesat(AT_FDCWD, filename, utimes); } +SYSCALL_DEFINE2(utime, char __user *, filename, struct utimbuf __user *, times) +{ + struct timespec64 tv[2]; + + if (times) { + if (get_user(tv[0].tv_sec, ×->actime) || + get_user(tv[1].tv_sec, ×->modtime)) + return -EFAULT; + tv[0].tv_nsec = 0; + tv[1].tv_nsec = 0; + } + return do_utimes(AT_FDCWD, filename, times ? tv : NULL, 0); +} +#endif + #ifdef CONFIG_COMPAT /* * Not all architectures have sys_utime, so implement this in terms diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 3d7dd665cdeb..d2b19e814218 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -941,8 +941,6 @@ asmlinkage long sys_access(const char __user *filename, int mode); asmlinkage long sys_rename(const char __user *oldname, const char __user *newname); asmlinkage long sys_symlink(const char __user *old, const char __user *new); -asmlinkage long sys_utimes(char __user *filename, - struct timeval __user *utimes); #if defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_COMPAT_STAT64) asmlinkage long sys_stat64(const char __user *filename, struct stat64 __user *statbuf); @@ -972,14 +970,18 @@ asmlinkage long sys_alarm(unsigned int seconds); asmlinkage long sys_getpgrp(void); asmlinkage long sys_pause(void); asmlinkage long sys_time(time_t __user *tloc); +#ifdef __ARCH_WANT_SYS_UTIME asmlinkage long sys_utime(char __user *filename, struct utimbuf __user *times); +asmlinkage long sys_utimes(char __user *filename, + struct timeval __user *utimes); +asmlinkage long sys_futimesat(int dfd, const char __user *filename, + struct timeval __user *utimes); +#endif asmlinkage long sys_creat(const char __user *pathname, umode_t mode); asmlinkage long sys_getdents(unsigned int fd, struct linux_dirent __user *dirent, unsigned int count); -asmlinkage long sys_futimesat(int dfd, const char __user *filename, - struct timeval __user *utimes); asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, struct timeval __user *tvp); asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds, From patchwork Wed Apr 25 16:03:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 134356 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1051500lji; Wed, 25 Apr 2018 09:05:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+QuJHZcbMQkdntDErRtMRqTdYE730IwRioBDJTp2htFKWzQB1kHj4ZsMznxMOusS8HfYsP X-Received: by 10.99.112.91 with SMTP id a27mr24124630pgn.432.1524672339229; Wed, 25 Apr 2018 09:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524672339; cv=none; d=google.com; s=arc-20160816; b=S+95VGwuL1lVWv/N+Q+dsmkBEyKlQVNtMlqOuYMDv28Z8EpO06gHPVVTWhwbmiIFJo qYT1sFBt3dj1jmHrsCgYR+y5Yzjlr5kl4DRSN02rOMBhZc9rjp1Csk88IhV0Bb1+TbEU TG556hfCmi205RnKSKs+OswvOp2srtSnR432u8u+xKFjymgHVRKwTww/Yg18WPZKHghI TDEFWBRiEK2rFUZBwRXng+yzy1rZ+9qo386s4nt3u3b3ycmMl76xtcitnHHdHRpcV5QV drhXR5zZHBjNzDA+oAjs7Khh31YO87r/hO9745spM89987P9yl+O+smmWW5EiNiuaDzz AXDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=84ch6/287E5PDHPJcklCuUJwEN0xB+a/v40XRHNymJI=; b=eH6lbn2TCWzr/xHxtgN5caqrvYOblocpQz85TK/N+pPSKB5QA7RYMG+bO32CY61ajv NPmUk8Hn7CliEy4jxYa+EQy1R92uX4qFjzLqTVXcFD1liapU4AXle8k3LD3giLw7xyzD HLbVaRspro8z7xuV715DQL01lulsSNYqCpKxBgjFqh2Y49SRV7GCCPOCGGHC6XzH9O9z BrOfJOlU2VyN1/33ghcg5ktrFYS48FO4QAJsMU4pRz9aKWmPVFZDrmRGNkdeKpTBzPec EdPT+dSe0aOG3/mbkCfnsA5LnsmWDaneq0nTus0mu5pci1tcmr2UTNA96NRBTj7cxIv+ 4GoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lUzDbomA; spf=pass (google.com: domain of libc-alpha-return-91846-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91846-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id m77si16660181pfk.56.2018.04.25.09.05.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 09:05:39 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-91846-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lUzDbomA; spf=pass (google.com: domain of libc-alpha-return-91846-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91846-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Q3TVLFq8kLoVsqfv0B0bejzf4sFA2S0 AapMzBya5t8plXNSslt8TJZHmLOmFd15CasxvlPTu7ZSLCwX+bI7URBSQ4k+arCI IGx3AVlbSh0V6zhV87L58rvx262w8lUWEs81rph2YCZY4nj7gQb1GpF87AWeJeU9 IVjx1wJz4bOE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=q5GWY2e2Hanqlf8fee3CdVxu9oU=; b=lUzDb omAnX8bahEf/yA9y4k/oXKzVr+84gdtruyn74B+d/OLWzEpc9dmMtehBm3/kENil Xw7v2gyvRraNlwCQP6QelDW9XIfytOaumv/C5kmEvG6Uu7kR2iPaOPqINDbxcmYu DU2q+RK4hhKq4HvCgkHdm00eqVnOAooGR+dJjg= Received: (qmail 59428 invoked by alias); 25 Apr 2018 16:04:51 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 59254 invoked by uid 89); 25 Apr 2018 16:04:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, UNSUBSCRIBE_BODY autolearn=ham version=3.3.2 spammy=locks, trend X-HELO: mout.kundenserver.de From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, libc-alpha@sourceware.org, tglx@linutronix.de, netdev@vger.kernel.org, deepa.kernel@gmail.com, viro@zeniv.linux.org.uk, albert.aribaud@3adev.fr, Peter Zijlstra , Darren Hart , "Eric W. Biederman" , Dominik Brodowski Subject: [PATCH 09/17] y2038: futex: Move compat implementation into futex.c Date: Wed, 25 Apr 2018 18:03:03 +0200 Message-Id: <20180425160311.2718314-10-arnd@arndb.de> In-Reply-To: <20180425160311.2718314-1-arnd@arndb.de> References: <20180425160311.2718314-1-arnd@arndb.de> X-UI-Out-Filterresults: notjunk:1; V01:K0:2Dx9tbvNdcU=:DLKJ34fO+EkEFrcIMVIGDQ bhXFlMCmb4f/q5mgw0a0CDSh4kpRejCxRO33JxaV42xJBSIz7qfEZK5TTc0uW3TMuU4A9sifQ ZnVU2L2q3eMu2o8L5Hfx+1c3KaIpVpAGWU3biqkyOuWgSzoaDVHw79qFWz4nDgf9xSefdhxpo pem2We4WsloY/hE5dEYmYEsaq53Om9y59eqArQEE1XoXGfuPndfvFIX4zqQIZXxKPBg7TrBgY AcE1SbeLBg8pO7BJ+CpI6fv9V7WoKKGxUBF11q1vh1TpQZCCkAuORJYMRoBRaJkDHB4KQyhfQ 131F1Bz268UI0hIgPGBstaRWlv6w2naTYJ+w2y3PYQ2G9bTenLppQyjW5isGY4tTbjj1MCqYy w21SQPmay3gRpk3caSKdF3kBKjA8cdVKWkNk10eOsKhlZxx7eST5fos4Y/4YFWnvEG/zu9Cw2 RkuWQuV9cafbxoePkVXSxUBZs7nTeFP7ruQZTjps+zz95svIrvezOq9ywdgKyopxbfzuk19YH gaafOWTd4FqHgzcIORUUMgfN+Et9dPm7VRxtzKXTeuyOXTtN8DKLwLOeVbA/4FpScelDGvVbB om1BfUhzbipz6WYFzJ0bT4z/SnR14hirIcnIoxQ5m4OoqnZen/I0yiR9uyqEktK1OezX4v7qu wF+8C7IdbLzxuVKn2aS/pXkP3/Fwf2rYi+XbTPF77NI7hwPDIQVaXOKEk8jwY45DCRyI= We are going to share the compat_sys_futex() handler between 64-bit architectures and 32-bit architectures that need to deal with both 32-bit and 64-bit time_t, and this is easier if both entry points are in the same file. In fact, most other system call handlers do the same thing these days, so let's follow the trend here and merge all of futex_compat.c into futex.c. In the process, a few minor changes have to be done to make sure everything still makes sense: handle_futex_death() and futex_cmpxchg_enabled() become local symbol, and the compat version of the fetch_robust_entry() function gets renamed to compat_fetch_robust_entry() to avoid a symbol clash. This is intended as a purely cosmetic patch, no behavior should change. Signed-off-by: Arnd Bergmann --- include/linux/futex.h | 8 -- kernel/Makefile | 3 - kernel/futex.c | 195 +++++++++++++++++++++++++++++++++++++++++++++++- kernel/futex_compat.c | 202 -------------------------------------------------- 4 files changed, 192 insertions(+), 216 deletions(-) delete mode 100644 kernel/futex_compat.c -- 2.9.0 diff --git a/include/linux/futex.h b/include/linux/futex.h index 821ae502d3d8..ccaef0097785 100644 --- a/include/linux/futex.h +++ b/include/linux/futex.h @@ -9,9 +9,6 @@ struct inode; struct mm_struct; struct task_struct; -extern int -handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi); - /* * Futexes are matched on equal values of this key. * The key type depends on whether it's a shared or private mapping. @@ -55,11 +52,6 @@ extern void exit_robust_list(struct task_struct *curr); long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, u32 __user *uaddr2, u32 val2, u32 val3); -#ifdef CONFIG_HAVE_FUTEX_CMPXCHG -#define futex_cmpxchg_enabled 1 -#else -extern int futex_cmpxchg_enabled; -#endif #else static inline void exit_robust_list(struct task_struct *curr) { diff --git a/kernel/Makefile b/kernel/Makefile index f85ae5dfa474..fbebd38cef8f 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -48,9 +48,6 @@ obj-$(CONFIG_PROFILING) += profile.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-y += time/ obj-$(CONFIG_FUTEX) += futex.o -ifeq ($(CONFIG_COMPAT),y) -obj-$(CONFIG_FUTEX) += futex_compat.o -endif obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o obj-$(CONFIG_SMP) += smp.o ifneq ($(CONFIG_SMP),y) diff --git a/kernel/futex.c b/kernel/futex.c index 1f450e092c74..e9013d1e65a1 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -44,6 +44,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include #include @@ -173,8 +174,10 @@ * double_lock_hb() and double_unlock_hb(), respectively. */ -#ifndef CONFIG_HAVE_FUTEX_CMPXCHG -int __read_mostly futex_cmpxchg_enabled; +#ifdef CONFIG_HAVE_FUTEX_CMPXCHG +#define futex_cmpxchg_enabled 1 +#else +static int __read_mostly futex_cmpxchg_enabled; #endif /* @@ -3360,7 +3363,7 @@ SYSCALL_DEFINE3(get_robust_list, int, pid, * Process a futex-list entry, check whether it's owned by the * dying task, and do notification if so: */ -int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi) +static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi) { u32 uval, uninitialized_var(nval), mval; @@ -3587,6 +3590,192 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); } +#ifdef CONFIG_COMPAT +/* + * Fetch a robust-list pointer. Bit 0 signals PI futexes: + */ +static inline int +compat_fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry, + compat_uptr_t __user *head, unsigned int *pi) +{ + if (get_user(*uentry, head)) + return -EFAULT; + + *entry = compat_ptr((*uentry) & ~1); + *pi = (unsigned int)(*uentry) & 1; + + return 0; +} + +static void __user *futex_uaddr(struct robust_list __user *entry, + compat_long_t futex_offset) +{ + compat_uptr_t base = ptr_to_compat(entry); + void __user *uaddr = compat_ptr(base + futex_offset); + + return uaddr; +} + +/* + * Walk curr->robust_list (very carefully, it's a userspace list!) + * and mark any locks found there dead, and notify any waiters. + * + * We silently return on any sign of list-walking problem. + */ +void compat_exit_robust_list(struct task_struct *curr) +{ + struct compat_robust_list_head __user *head = curr->compat_robust_list; + struct robust_list __user *entry, *next_entry, *pending; + unsigned int limit = ROBUST_LIST_LIMIT, pi, pip; + unsigned int uninitialized_var(next_pi); + compat_uptr_t uentry, next_uentry, upending; + compat_long_t futex_offset; + int rc; + + if (!futex_cmpxchg_enabled) + return; + + /* + * Fetch the list head (which was registered earlier, via + * sys_set_robust_list()): + */ + if (compat_fetch_robust_entry(&uentry, &entry, &head->list.next, &pi)) + return; + /* + * Fetch the relative futex offset: + */ + if (get_user(futex_offset, &head->futex_offset)) + return; + /* + * Fetch any possibly pending lock-add first, and handle it + * if it exists: + */ + if (compat_fetch_robust_entry(&upending, &pending, + &head->list_op_pending, &pip)) + return; + + next_entry = NULL; /* avoid warning with gcc */ + while (entry != (struct robust_list __user *) &head->list) { + /* + * Fetch the next entry in the list before calling + * handle_futex_death: + */ + rc = compat_fetch_robust_entry(&next_uentry, &next_entry, + (compat_uptr_t __user *)&entry->next, &next_pi); + /* + * A pending lock might already be on the list, so + * dont process it twice: + */ + if (entry != pending) { + void __user *uaddr = futex_uaddr(entry, futex_offset); + + if (handle_futex_death(uaddr, curr, pi)) + return; + } + if (rc) + return; + uentry = next_uentry; + entry = next_entry; + pi = next_pi; + /* + * Avoid excessively long or circular lists: + */ + if (!--limit) + break; + + cond_resched(); + } + if (pending) { + void __user *uaddr = futex_uaddr(pending, futex_offset); + + handle_futex_death(uaddr, curr, pip); + } +} + +COMPAT_SYSCALL_DEFINE2(set_robust_list, + struct compat_robust_list_head __user *, head, + compat_size_t, len) +{ + if (!futex_cmpxchg_enabled) + return -ENOSYS; + + if (unlikely(len != sizeof(*head))) + return -EINVAL; + + current->compat_robust_list = head; + + return 0; +} + +COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid, + compat_uptr_t __user *, head_ptr, + compat_size_t __user *, len_ptr) +{ + struct compat_robust_list_head __user *head; + unsigned long ret; + struct task_struct *p; + + if (!futex_cmpxchg_enabled) + return -ENOSYS; + + rcu_read_lock(); + + ret = -ESRCH; + if (!pid) + p = current; + else { + p = find_task_by_vpid(pid); + if (!p) + goto err_unlock; + } + + ret = -EPERM; + if (!ptrace_may_access(p, PTRACE_MODE_READ_REALCREDS)) + goto err_unlock; + + head = p->compat_robust_list; + rcu_read_unlock(); + + if (put_user(sizeof(*head), len_ptr)) + return -EFAULT; + return put_user(ptr_to_compat(head), head_ptr); + +err_unlock: + rcu_read_unlock(); + + return ret; +} + +COMPAT_SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, + struct compat_timespec __user *, utime, u32 __user *, uaddr2, + u32, val3) +{ + struct timespec ts; + ktime_t t, *tp = NULL; + int val2 = 0; + int cmd = op & FUTEX_CMD_MASK; + + if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI || + cmd == FUTEX_WAIT_BITSET || + cmd == FUTEX_WAIT_REQUEUE_PI)) { + if (compat_get_timespec(&ts, utime)) + return -EFAULT; + if (!timespec_valid(&ts)) + return -EINVAL; + + t = timespec_to_ktime(ts); + if (cmd == FUTEX_WAIT) + t = ktime_add_safe(ktime_get(), t); + tp = &t; + } + if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || + cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP) + val2 = (int) (unsigned long) utime; + + return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); +} +#endif /* CONFIG_COMPAT */ + static void __init futex_detect_cmpxchg(void) { #ifndef CONFIG_HAVE_FUTEX_CMPXCHG diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c deleted file mode 100644 index 83f830acbb5f..000000000000 --- a/kernel/futex_compat.c +++ /dev/null @@ -1,202 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * linux/kernel/futex_compat.c - * - * Futex compatibililty routines. - * - * Copyright 2006, Red Hat, Inc., Ingo Molnar - */ - -#include -#include -#include -#include -#include -#include - -#include - - -/* - * Fetch a robust-list pointer. Bit 0 signals PI futexes: - */ -static inline int -fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry, - compat_uptr_t __user *head, unsigned int *pi) -{ - if (get_user(*uentry, head)) - return -EFAULT; - - *entry = compat_ptr((*uentry) & ~1); - *pi = (unsigned int)(*uentry) & 1; - - return 0; -} - -static void __user *futex_uaddr(struct robust_list __user *entry, - compat_long_t futex_offset) -{ - compat_uptr_t base = ptr_to_compat(entry); - void __user *uaddr = compat_ptr(base + futex_offset); - - return uaddr; -} - -/* - * Walk curr->robust_list (very carefully, it's a userspace list!) - * and mark any locks found there dead, and notify any waiters. - * - * We silently return on any sign of list-walking problem. - */ -void compat_exit_robust_list(struct task_struct *curr) -{ - struct compat_robust_list_head __user *head = curr->compat_robust_list; - struct robust_list __user *entry, *next_entry, *pending; - unsigned int limit = ROBUST_LIST_LIMIT, pi, pip; - unsigned int uninitialized_var(next_pi); - compat_uptr_t uentry, next_uentry, upending; - compat_long_t futex_offset; - int rc; - - if (!futex_cmpxchg_enabled) - return; - - /* - * Fetch the list head (which was registered earlier, via - * sys_set_robust_list()): - */ - if (fetch_robust_entry(&uentry, &entry, &head->list.next, &pi)) - return; - /* - * Fetch the relative futex offset: - */ - if (get_user(futex_offset, &head->futex_offset)) - return; - /* - * Fetch any possibly pending lock-add first, and handle it - * if it exists: - */ - if (fetch_robust_entry(&upending, &pending, - &head->list_op_pending, &pip)) - return; - - next_entry = NULL; /* avoid warning with gcc */ - while (entry != (struct robust_list __user *) &head->list) { - /* - * Fetch the next entry in the list before calling - * handle_futex_death: - */ - rc = fetch_robust_entry(&next_uentry, &next_entry, - (compat_uptr_t __user *)&entry->next, &next_pi); - /* - * A pending lock might already be on the list, so - * dont process it twice: - */ - if (entry != pending) { - void __user *uaddr = futex_uaddr(entry, futex_offset); - - if (handle_futex_death(uaddr, curr, pi)) - return; - } - if (rc) - return; - uentry = next_uentry; - entry = next_entry; - pi = next_pi; - /* - * Avoid excessively long or circular lists: - */ - if (!--limit) - break; - - cond_resched(); - } - if (pending) { - void __user *uaddr = futex_uaddr(pending, futex_offset); - - handle_futex_death(uaddr, curr, pip); - } -} - -COMPAT_SYSCALL_DEFINE2(set_robust_list, - struct compat_robust_list_head __user *, head, - compat_size_t, len) -{ - if (!futex_cmpxchg_enabled) - return -ENOSYS; - - if (unlikely(len != sizeof(*head))) - return -EINVAL; - - current->compat_robust_list = head; - - return 0; -} - -COMPAT_SYSCALL_DEFINE3(get_robust_list, int, pid, - compat_uptr_t __user *, head_ptr, - compat_size_t __user *, len_ptr) -{ - struct compat_robust_list_head __user *head; - unsigned long ret; - struct task_struct *p; - - if (!futex_cmpxchg_enabled) - return -ENOSYS; - - rcu_read_lock(); - - ret = -ESRCH; - if (!pid) - p = current; - else { - p = find_task_by_vpid(pid); - if (!p) - goto err_unlock; - } - - ret = -EPERM; - if (!ptrace_may_access(p, PTRACE_MODE_READ_REALCREDS)) - goto err_unlock; - - head = p->compat_robust_list; - rcu_read_unlock(); - - if (put_user(sizeof(*head), len_ptr)) - return -EFAULT; - return put_user(ptr_to_compat(head), head_ptr); - -err_unlock: - rcu_read_unlock(); - - return ret; -} - -COMPAT_SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, - struct compat_timespec __user *, utime, u32 __user *, uaddr2, - u32, val3) -{ - struct timespec ts; - ktime_t t, *tp = NULL; - int val2 = 0; - int cmd = op & FUTEX_CMD_MASK; - - if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI || - cmd == FUTEX_WAIT_BITSET || - cmd == FUTEX_WAIT_REQUEUE_PI)) { - if (compat_get_timespec(&ts, utime)) - return -EFAULT; - if (!timespec_valid(&ts)) - return -EINVAL; - - t = timespec_to_ktime(ts); - if (cmd == FUTEX_WAIT) - t = ktime_add_safe(ktime_get(), t); - tp = &t; - } - if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || - cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP) - val2 = (int) (unsigned long) utime; - - return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); -} From patchwork Wed Apr 25 16:03:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 134352 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1050759lji; Wed, 25 Apr 2018 09:05:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+zRlfngU90GMh4fIfjVIyw/+dKJa0uvDrZe06Z6SO0y1gljhlp7d/OmphbOdyKAtE6H+JI X-Received: by 2002:a17:902:9886:: with SMTP id s6-v6mr29514280plp.380.1524672307159; Wed, 25 Apr 2018 09:05:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524672307; cv=none; d=google.com; s=arc-20160816; b=YcDdYC3XdW+E6aMciDTqBnX6jh6Kqauwd1YpZ9duys53JHe/dx/0I4/1XEh9JUVPqp Wf8vsL+DeCay2/fJeP4MHjq4BaUP2s/G41LSZSLTMDWn2fprPuDT8jdYIVK4OMStsGU0 AVi5LFTCKL2NK9yu/TEr8j13xUYQi2dqWCrwQNcRdvDmWyyC6AmI85sl2IfXUpKM2GVA XaQqiYivPiyxP4u5spHaXYPm7TLQ5oDRgLy7A6D2upuyhhLRNz3TdEnbpDRZ4yN8ICyH Tnne1iM7/iSGpBfohagiaIlTFKOJLWyVRH/vCe/JDHcJcPTEfKZaPlFZE3NoyO6nJxDr jzCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=Xi6M927Wn09aZe2xh41/BbO68+oKSE1kgE/shZ6GWv0=; b=qtMILGdbG1vdlhkvdoEyOxDnheRkARziawZQBnSuzqIWCmnESLTRAKHzPy/d+oR5UQ Yo2UuivKnZeFdbvL4C3WY7aFdk2H/1QpYRfyjwXvu7ArRKVQtbHPEzHh6fwN4nqcfhK4 C77CYi8ZpjAUNIbANcRxdduqWeYJ8JOUHiFvIEKITF0/NEVav2MbuEOmti/s1q13bGFm WCrsyhwkwk1IRwFLgBYmDqyFt8/qu36GEpPS8fWPVKlUx7ZKOQ1FS3E0TX4cU4YtcOBW LOJfPD9Cwp9ZI0vvlscNXC0fkon6Zvw6xYLE/DUWHsNIRYukTk4rtjFaZJ+Lg0FBElBz 5Szg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=WKpnPtJ7; spf=pass (google.com: domain of libc-alpha-return-91843-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91843-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s85si16365004pfi.32.2018.04.25.09.05.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 09:05:07 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-91843-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=WKpnPtJ7; spf=pass (google.com: domain of libc-alpha-return-91843-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91843-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=YcqtKTTSUNBCtkbdj3F14mY2ezi4YKx +YU0l3F82UvkpHWnM0jOIolacqv4F0hbTgqJ881lM0JHPfySE5CNvE9nJZj/2GyA l8IBa/JhyzVywqFlTJShb5jjpAOspIVGURaIg074hj3BbXY46yxJYdSP2MmMhAWe M+jLipQpwhqo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=YK32kMQ/JLGi9Jn1A4xYDNEWLBY=; b=WKpnP tJ7TWXWHwNuLOS5NgC/vt8sBKS8qHFiR3D7ajeYBLCxUOeDTEaTvF2xZ1zDf+h4e DlKMHoJfhAq0zIAPS+AA4ARVgH2iD0qeyQOCgypMnZ9kIdmtPg89S8FzaAImExyi BJKGcLV2eyM52A4G8091qtB5CISkIRRRuMiJEU= Received: (qmail 57807 invoked by alias); 25 Apr 2018 16:04:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 57688 invoked by uid 89); 25 Apr 2018 16:04:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=iff X-HELO: mout.kundenserver.de From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, libc-alpha@sourceware.org, tglx@linutronix.de, netdev@vger.kernel.org, deepa.kernel@gmail.com, viro@zeniv.linux.org.uk, albert.aribaud@3adev.fr, Peter Zijlstra , Darren Hart , "Eric W. Biederman" , Dominik Brodowski Subject: [PATCH 13/17] y2038: socket: Convert recvmmsg to __kernel_timespec Date: Wed, 25 Apr 2018 18:03:07 +0200 Message-Id: <20180425160311.2718314-14-arnd@arndb.de> In-Reply-To: <20180425160311.2718314-1-arnd@arndb.de> References: <20180425160311.2718314-1-arnd@arndb.de> X-UI-Out-Filterresults: notjunk:1; V01:K0:sglwVHXxeSY=:vNscQiXXHEevXWKGq26INQ JlvCBlREy160DQwhPUWb9YmHwtXKjUguqzxLKj5iFVXuua4KbKrB0OFD9F3FxqmdjOoqMfrMj equvKsFysjIEYWngTZlAWR8qK5oAOLYwup6gVx6HhYq/LdxEPkWjjD268zrDspzFoj4yrCOCS 9uoA7tAHoz3IBvkqyFQ7g7Nk4NMwFCkV/eUK3hETxkryhmYHa83GHVSQdmnFvI+T7T6rXLzgd IUj+I0G8zVipJ7bCPPxohsGnPXbc9Otf9bhzw8xgL59xynnK6WV4VtTl+V/9wQMpDZLn0IyQu 0XlK1b18QQDYuk9Hm0Ypn/pPGnbVNWU1LOoNzStl6MvNDNeM6ShlvxnSrdZI5bThO1HOUvfOr 9lJLsl2nxtziFbfH1TwtFxfD5USK3WwyK/THEKylBNFt8HwhVcjH+lq5wTaNLF7D5w3He/GEH suyKD+65UEowYTuxaGAEUSjXt0rK0u7SmekmPP69NsWfw1QrLzGW+HHjzHP10jdnVXzqcjWsy tg71DCyMJa5rBtyrE3z5W09pCGJRjBINNVhBeOzxE3LCU2WOJDaNXrOLWRuQVnUBglbZYwcro LAJczieX1mL6TbXSAtQ2T3kiNeQPbgveo8u5gF7UKPPCN/jZrVAjsHJOmkz8W9hXjIukJqch4 ExNRUtr/p/Dfq/FWCx3Bb3C0+Js0bt/DM/38FcxsAeS32guXjGYZANLHAopOkTeQ/xQg= This converts the recvmmsg() system call in all its variations to use 'timespec64' internally for its timeout, and have a __kernel_timespec64 argument in the native entry point. This lets us change the type to use 64-bit time_t at a later point while using the 32-bit compat system call emulation for existing user space. Signed-off-by: Arnd Bergmann --- include/linux/socket.h | 4 ++-- include/linux/syscalls.h | 2 +- net/compat.c | 6 +++--- net/socket.c | 18 ++++++++---------- 4 files changed, 14 insertions(+), 16 deletions(-) -- 2.9.0 diff --git a/include/linux/socket.h b/include/linux/socket.h index ea50f4a65816..d36a6c1bdbaf 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -345,7 +345,7 @@ struct ucred { extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr); extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data); -struct timespec; +struct timespec64; /* The __sys_...msg variants allow MSG_CMSG_COMPAT iff * forbid_cmsg_compat==false @@ -355,7 +355,7 @@ extern long __sys_recvmsg(int fd, struct user_msghdr __user *msg, extern long __sys_sendmsg(int fd, struct user_msghdr __user *msg, unsigned int flags, bool forbid_cmsg_compat); extern int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, - unsigned int flags, struct timespec *timeout); + unsigned int flags, struct timespec64 *timeout); extern int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, unsigned int flags, bool forbid_cmsg_compat); diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index ffd8674e9df7..eaa32317f573 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -817,7 +817,7 @@ asmlinkage long sys_perf_event_open( asmlinkage long sys_accept4(int, struct sockaddr __user *, int __user *, int); asmlinkage long sys_recvmmsg(int fd, struct mmsghdr __user *msg, unsigned int vlen, unsigned flags, - struct timespec __user *timeout); + struct __kernel_timespec __user *timeout); asmlinkage long sys_wait4(pid_t pid, int __user *stat_addr, int options, struct rusage __user *ru); diff --git a/net/compat.c b/net/compat.c index 5ae7437d3853..93b80a3d967c 100644 --- a/net/compat.c +++ b/net/compat.c @@ -815,18 +815,18 @@ static int __compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg, struct compat_timespec __user *timeout) { int datagrams; - struct timespec ktspec; + struct timespec64 ktspec; if (timeout == NULL) return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, flags | MSG_CMSG_COMPAT, NULL); - if (compat_get_timespec(&ktspec, timeout)) + if (compat_get_timespec64(&ktspec, timeout)) return -EFAULT; datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, flags | MSG_CMSG_COMPAT, &ktspec); - if (datagrams > 0 && compat_put_timespec(&ktspec, timeout)) + if (datagrams > 0 && compat_put_timespec64(&ktspec, timeout)) datagrams = -EFAULT; return datagrams; diff --git a/net/socket.c b/net/socket.c index f10f1d947c78..4510e6269764 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2343,7 +2343,7 @@ SYSCALL_DEFINE3(recvmsg, int, fd, struct user_msghdr __user *, msg, */ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, - unsigned int flags, struct timespec *timeout) + unsigned int flags, struct timespec64 *timeout) { int fput_needed, err, datagrams; struct socket *sock; @@ -2408,8 +2408,7 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, if (timeout) { ktime_get_ts64(&timeout64); - *timeout = timespec64_to_timespec( - timespec64_sub(end_time, timeout64)); + *timeout = timespec64_sub(end_time, timeout64); if (timeout->tv_sec < 0) { timeout->tv_sec = timeout->tv_nsec = 0; break; @@ -2455,10 +2454,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, static int do_sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, unsigned int flags, - struct timespec __user *timeout) + struct __kernel_timespec __user *timeout) { int datagrams; - struct timespec timeout_sys; + struct timespec64 timeout_sys; if (flags & MSG_CMSG_COMPAT) return -EINVAL; @@ -2466,13 +2465,12 @@ static int do_sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, if (!timeout) return __sys_recvmmsg(fd, mmsg, vlen, flags, NULL); - if (copy_from_user(&timeout_sys, timeout, sizeof(timeout_sys))) + if (get_timespec64(&timeout_sys, timeout)) return -EFAULT; datagrams = __sys_recvmmsg(fd, mmsg, vlen, flags, &timeout_sys); - if (datagrams > 0 && - copy_to_user(timeout, &timeout_sys, sizeof(timeout_sys))) + if (datagrams > 0 && put_timespec64(&timeout_sys, timeout)) datagrams = -EFAULT; return datagrams; @@ -2480,7 +2478,7 @@ static int do_sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, SYSCALL_DEFINE5(recvmmsg, int, fd, struct mmsghdr __user *, mmsg, unsigned int, vlen, unsigned int, flags, - struct timespec __user *, timeout) + struct __kernel_timespec __user *, timeout) { return do_sys_recvmmsg(fd, mmsg, vlen, flags, timeout); } @@ -2603,7 +2601,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args) break; case SYS_RECVMMSG: err = do_sys_recvmmsg(a0, (struct mmsghdr __user *)a1, a[2], - a[3], (struct timespec __user *)a[4]); + a[3], (struct __kernel_timespec __user *)a[4]); break; case SYS_ACCEPT4: err = __sys_accept4(a0, (struct sockaddr __user *)a1, From patchwork Wed Apr 25 16:03:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 134358 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1051912lji; Wed, 25 Apr 2018 09:05:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx48PdZv89IXPu1m1Q+n+0ucxRTnsTvC+YSxrumcsggp1QbJ67gTp89thcax+sOaCeLsKW1cP X-Received: by 2002:a17:902:aa94:: with SMTP id d20-v6mr30705882plr.323.1524672356477; Wed, 25 Apr 2018 09:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524672356; cv=none; d=google.com; s=arc-20160816; b=wJV1PQ9ogvXjSTT2PiEYe7Bjvj09L0Vq9kWvXhw0rRb73SystEtTa9dpNvoWI++Ms3 P6XaBoMipynkP0E83v+dAeYyx+1qkmcvWqXKByGFSRVnE15uvaGyZ55I/JGGDOqPjrVw ep3pq6/2Ds7Xgmm8fMvgWjZf7dM6Ez/vxJkQmf315PBV5AqJICAs2q6iTSjw/Uuu6NzW eLAZZcQOqddKRrM+hbyjPVwYebqUJG63ToEq0fgmSpIYCXKB0/ISCAKbk9X8+gHA7sEL ZxXekyYrlx5IKIr6gQL66lor+1sxYhybq3Xd3myl2VETcxTc1Mia+jJRMxbq/vt8hyOb /jYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=egcI5QX9cF6aF69pSWTBzGBhElnQuCGDbXZFRtMJYSA=; b=ndnFS31YegaXDnUsu1dMeACzHob/Xsjr5Ga3wQ0kJt1wvKLA7+bU9Dj8IDk2g7Ks3L t+kaWS3VcsK7uVwVx1ghz6w8AdMAvqEsl8tjnnHMGoDN7p/0UPjxRxXhw63BczigaClW F67YSRnBbI4plJFnuW0+uEGZpoppZQcEQTihMl/sI/9Tzde+dCmT3mmPnBV/wGRZem3O kxmAKX5VXJrQX4h6tVys/03+waYgPhZcHbd7fhEFWRG5juPTwTMqeJkjA7R9AzfsGEE4 i4/XAmylVgZ0kbR6c7YihciDsxj6BKZ+obH4H5czkxu/pn52qH1oY1wVszxFPxdb0vZz G9fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=EA2N3UYm; spf=pass (google.com: domain of libc-alpha-return-91848-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91848-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z196si13894429pgz.349.2018.04.25.09.05.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 09:05:56 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-91848-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=EA2N3UYm; spf=pass (google.com: domain of libc-alpha-return-91848-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-91848-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=fZPSm9qS/lLNpV8S7TaMuOCzvkZdLg4 FK7LK555KglXhcg5wCfDQAV3eqnQPG1elbvyCKgiSOQUM2UJdP5R5iWYyE7mZ+cp bKMLDY1Q/DAY63whMTxx2Ls0PlTT6suNnLlifjAEdJwnNm4uBA6ZSJlllWce1pFU lfYOCG0iJpgA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=uxX7cPbonYGZXvt6XiTDUBefwF4=; b=EA2N3 UYmV+7clC9tFnFYtI1pYCx/cgN8s3UxQcR+TtQOgagCZLjBaQcUgRzoodJG/EHH+ vhZ3rbmYKGw0Ki6NERc18bEyVBshNnZPfJpVpLapljXakR/NJlzJsckSPjM5ly4e hF9cWcV/x1apd6grk4hsM9pfjC21dbtdhn1XhA= Received: (qmail 61179 invoked by alias); 25 Apr 2018 16:05:05 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 61045 invoked by uid 89); 25 Apr 2018 16:05:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mout.kundenserver.de From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, libc-alpha@sourceware.org, tglx@linutronix.de, netdev@vger.kernel.org, deepa.kernel@gmail.com, viro@zeniv.linux.org.uk, albert.aribaud@3adev.fr, Peter Zijlstra , Darren Hart , "Eric W. Biederman" , Dominik Brodowski Subject: [PATCH 14/17] y2038: socket: Add compat_sys_recvmmsg_time64 Date: Wed, 25 Apr 2018 18:03:08 +0200 Message-Id: <20180425160311.2718314-15-arnd@arndb.de> In-Reply-To: <20180425160311.2718314-1-arnd@arndb.de> References: <20180425160311.2718314-1-arnd@arndb.de> X-UI-Out-Filterresults: notjunk:1; V01:K0:hsOUounq7to=:uBmn6NOvgVy5KCUbgV6WyK 2CQPwZgE6lIv32HwyOMHt4pNl5RTjNwCjIPNIpBkChqAEwFVXybyE67DFtyE42rXAn41tLxSi M37s4LR3JPdaibYA60OIgH6HXD4P8yvZEt5ryLycKAPgSOBuWI9+sNIv7eF9Frnf2tGETSn57 SXUnRne4yRq1ZEk7PD3KcYvrD72aHgc0jLqACxkc0gHOUeWi9aaLlq4cd6uW8hE8rzIIas5BP wi6EZXawItA5UYe5+QxyaZnbJRQ2eRyauqWc57bN7elZZG72NNDzUuS89Nujc/vIZIJmmUGsH mmKi5jdVpLIIphAYGprZMt72j+4wpXwN2AEQ/l4OflA1CAm9P3ZvsTLdUU8snFx8cCydWl0xe cCCu28tHMFMm2k+d88iAo8cYhhvSEznWdHqDgF+N6pX+0C5w9bW1b+AimgHHa4r5IqHIqevZd J42gJgQL5QbCskMEWCEVezOexhJxgB2vKg9P2rnP32FWz6WJiub093eAk2BoFMQRESR3uo24/ Cwejs/CKOlVjQqgrVoUQJ/VEsN2NyuydKL36VKubnMa2YvWyQTEEHFEpidpF+3iVekJM5Akau LZ4PMwGlj1EuoWuSy3Z7EiZjWiot3RllhttLuo9efPhx65rc3tE/5f0H2jJcsTAL4IDn45Okf I/Cq24X4YTYf0WxsQiZvdG3cTrliFJVxTzIKiqbm38gswfvB7OZfqm+41mYVMryNtVW8= recvmmsg() takes two arguments to pointers of structures that differ between 32-bit and 64-bit architectures: mmsghdr and timespec. For y2038 compatbility, we are changing the native system call from timespec to __kernel_timespec with a 64-bit time_t (in another patch), and use the existing compat system call on both 32-bit and 64-bit architectures for compatibility with traditional 32-bit user space. As we now have two variants of recvmmsg() for 32-bit tasks that are both different from the variant that we use on 64-bit tasks, this means we also require two compat system calls! The solution I picked is to flip things around: The existing compat_sys_recvmmsg() call gets moved from net/compat.c into net/socket.c and now handles the case for old user space on all architectures that have set CONFIG_COMPAT_32BIT_TIME. A new compat_sys_recvmmsg_time64() call gets added in the old place for 64-bit architectures only, this one handles the case of a compat mmsghdr structure combined with __kernel_timespec. In the indirect sys_socketcall(), we now need to call either do_sys_recvmmsg() or __compat_sys_recvmmsg(), depending on what kind of architecture we are on. For compat_sys_socketcall(), no such change is needed, we always call __compat_sys_recvmmsg(). I decided to not add a new SYS_RECVMMSG_TIME64 socketcall: Any libc implementation for 64-bit time_t will need significant changes including an updated asm/unistd.h, and it seems better to consistently use the separate syscalls that configuration, leaving the socketcall only for backward compatibility with 32-bit time_t based libc. Signed-off-by: Arnd Bergmann --- include/linux/compat.h | 5 ++++- include/linux/socket.h | 15 ++++++++++++++- kernel/sys_ni.c | 1 + net/compat.c | 14 +++++++------- net/socket.c | 39 +++++++++++++++++++++++++++++++++++++-- 5 files changed, 63 insertions(+), 11 deletions(-) -- 2.9.0 diff --git a/include/linux/compat.h b/include/linux/compat.h index 7887b0a54c1e..f9423bbf7e7c 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -863,7 +863,10 @@ asmlinkage long compat_sys_move_pages(pid_t pid, compat_ulong_t nr_pages, asmlinkage long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig, struct compat_siginfo __user *uinfo); -asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg, +asmlinkage long compat_sys_recvmmsg_time64(int fd, struct compat_mmsghdr __user *mmsg, + unsigned vlen, unsigned int flags, + struct __kernel_timespec __user *timeout); +asmlinkage long compat_sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned vlen, unsigned int flags, struct compat_timespec __user *timeout); asmlinkage long compat_sys_wait4(compat_pid_t pid, diff --git a/include/linux/socket.h b/include/linux/socket.h index d36a6c1bdbaf..22358e0e1288 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -2,8 +2,8 @@ #ifndef _LINUX_SOCKET_H #define _LINUX_SOCKET_H - #include /* arch-dependent defines */ +#include #include /* the SIOCxxx I/O controls */ #include /* iovec support */ #include /* pid_t */ @@ -346,6 +346,7 @@ extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_sto extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data); struct timespec64; +struct compat_timespec; /* The __sys_...msg variants allow MSG_CMSG_COMPAT iff * forbid_cmsg_compat==false @@ -356,6 +357,18 @@ extern long __sys_sendmsg(int fd, struct user_msghdr __user *msg, unsigned int flags, bool forbid_cmsg_compat); extern int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, unsigned int flags, struct timespec64 *timeout); +#ifdef CONFIG_COMPAT_32BIT_TIME +extern int __compat_sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, + unsigned int vlen, unsigned int flags, + struct compat_timespec __user *timeout); +#else +static inline int __compat_sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, + unsigned int vlen, unsigned int flags, + struct compat_timespec __user *timeout) +{ + return -EINVAL; +} +#endif extern int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, unsigned int flags, bool forbid_cmsg_compat); diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index 9791364925dc..61fc9babe6ce 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c @@ -283,6 +283,7 @@ COND_SYSCALL(perf_event_open); COND_SYSCALL(accept4); COND_SYSCALL(recvmmsg); COND_SYSCALL_COMPAT(recvmmsg); +COND_SYSCALL_COMPAT(recvmmsg_time64); /* * Architecture specific syscalls: see further below diff --git a/net/compat.c b/net/compat.c index 93b80a3d967c..7521a0afe18d 100644 --- a/net/compat.c +++ b/net/compat.c @@ -810,9 +810,9 @@ COMPAT_SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, buf, compat_size_t, len return __compat_sys_recvfrom(fd, buf, len, flags, addr, addrlen); } -static int __compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg, +static int __compat_sys_recvmmsg_time64(int fd, struct compat_mmsghdr __user *mmsg, unsigned int vlen, unsigned int flags, - struct compat_timespec __user *timeout) + struct __kernel_timespec __user *timeout) { int datagrams; struct timespec64 ktspec; @@ -821,22 +821,22 @@ static int __compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg, return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, flags | MSG_CMSG_COMPAT, NULL); - if (compat_get_timespec64(&ktspec, timeout)) + if (get_timespec64(&ktspec, timeout)) return -EFAULT; datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, flags | MSG_CMSG_COMPAT, &ktspec); - if (datagrams > 0 && compat_put_timespec64(&ktspec, timeout)) + if (datagrams > 0 && put_timespec64(&ktspec, timeout)) datagrams = -EFAULT; return datagrams; } -COMPAT_SYSCALL_DEFINE5(recvmmsg, int, fd, struct compat_mmsghdr __user *, mmsg, +COMPAT_SYSCALL_DEFINE5(recvmmsg_time64, int, fd, struct compat_mmsghdr __user *, mmsg, unsigned int, vlen, unsigned int, flags, - struct compat_timespec __user *, timeout) + struct __kernel_timespec __user *, timeout) { - return __compat_sys_recvmmsg(fd, mmsg, vlen, flags, timeout); + return __compat_sys_recvmmsg_time64(fd, mmsg, vlen, flags, timeout); } COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args) diff --git a/net/socket.c b/net/socket.c index 4510e6269764..5e97b645bfee 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2483,6 +2483,37 @@ SYSCALL_DEFINE5(recvmmsg, int, fd, struct mmsghdr __user *, mmsg, return do_sys_recvmmsg(fd, mmsg, vlen, flags, timeout); } +#ifdef CONFIG_COMPAT_32BIT_TIME +int __compat_sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, + unsigned int vlen, unsigned int flags, + struct compat_timespec __user *timeout) +{ + int datagrams; + struct timespec64 ktspec; + + if (timeout == NULL) + return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, + flags | MSG_CMSG_COMPAT, NULL); + + if (compat_get_timespec64(&ktspec, timeout)) + return -EFAULT; + + datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen, + flags | MSG_CMSG_COMPAT, &ktspec); + if (datagrams > 0 && compat_put_timespec64(&ktspec, timeout)) + datagrams = -EFAULT; + + return datagrams; +} + +COMPAT_SYSCALL_DEFINE5(recvmmsg, int, fd, struct mmsghdr __user *, mmsg, + unsigned int, vlen, unsigned int, flags, + struct compat_timespec __user *, timeout) +{ + return __compat_sys_recvmmsg(fd, mmsg, vlen, flags, timeout); +} +#endif + #ifdef __ARCH_WANT_SYS_SOCKETCALL /* Argument list sizes for sys_socketcall */ #define AL(x) ((x) * sizeof(unsigned long)) @@ -2600,8 +2631,12 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args) a[2], true); break; case SYS_RECVMMSG: - err = do_sys_recvmmsg(a0, (struct mmsghdr __user *)a1, a[2], - a[3], (struct __kernel_timespec __user *)a[4]); + if (IS_ENABLED(CONFIG_64BIT) || !IS_ENABLED(CONFIG_64BIT_TIME)) + err = do_sys_recvmmsg(a0, (struct mmsghdr __user *)a1, a[2], + a[3], (struct __kernel_timespec __user *)a[4]); + else + err = __compat_sys_recvmmsg(a0, (struct mmsghdr __user *)a1, a[2], + a[3], (struct compat_timespec __user *)a[4]); break; case SYS_ACCEPT4: err = __sys_accept4(a0, (struct sockaddr __user *)a1,