From patchwork Thu Jun 20 16:23:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 805997 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp378053wrt; Thu, 20 Jun 2024 09:25:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWZY0NhEfWGWM8twK1epWKPPPMIQYralDq3j6qJhezwDYVKnkkhKfI0wV7Mtvqr1Cz2C+0JPJpdrZcE51rvSxx2 X-Google-Smtp-Source: AGHT+IGnnbIz9B2juEU4Rk+DidJcFbKFfZFP51+2icA70B7TujC+5TgDsZIEVzoCalTquumnh3FE X-Received: by 2002:a0c:f58d:0:b0:6b2:ca8f:b7ec with SMTP id 6a1803df08f44-6b501eaad72mr68603036d6.50.1718900719837; Thu, 20 Jun 2024 09:25:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718900719; cv=pass; d=google.com; s=arc-20160816; b=zvaI2glr7mexuiH1k2cc7wJVxl4jfLlZOBL2sXsx/SPzG4e7GghbI37qnhc2xulJ7v Ly/6XcVCygegvQcT5vKptAyOjoY9guyUioFb+KKmx4LVfU9QatUDhYtjsCHNQqoorycN 1G8DtUX6TLuTDhYm1UWQalTkeqMBvel2ko4o78v73b6kt+m5sgXU0mpXp0SiErI1b1cs RYnRKa21BVMYHMK8vteC+NGG6Bdm1DTZowwOKshcX9SL3n2mj6O+fB4PUnn/ETQOU5aj ygpO7ByJTirYlq2uyqgflgvu1gZ6sPH0RlIDauj8X2ly8+F6dHCuRTZr+dKELKHtQCkd uZ/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=io3xwGs2zNvfg9zpzpqICE1Npf/qKP3jgPnNgyd6HIc=; fh=8vZR4BMhSp2MKx3u9RvxuJYVlivuNEVatVHlQEAq0t4=; b=XYJEwjn86+H8sS//rIILQ9sS3SE53RLTEUhAnRwWYYB3HEWH8EWQ+MW0VHYLriAqmJ Ja6RntjFpHrkrXQw+d+GYR2eO+WxPtgkC4FpSnYFaTFyuTE7fCtNwUvksMcF3r9OIodo JUpFcGlJQlZ6lWOTlTfKujiPSccYFAhkrYMNBvOHvTpjxAv2LlsEd0v9KMN40hdmFbDq BXJJsyBlxeTnlgavv2kgSDhsNIKLE2NaYOsPsO5QetKxFZetFyro7qvFP9uI3t9W9gBY h0nEp4WBqoHG0xPdi72nYNrBmTbLtIyJqZljgS1FtVgFLJocbeuZVV80g9SpyoxOoEIg wyIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cRy1c8+g; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 6a1803df08f44-6b382523705si69704496d6.441.2024.06.20.09.25.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 09:25:19 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cRy1c8+g; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6B9053894C1E for ; Thu, 20 Jun 2024 16:25:19 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by sourceware.org (Postfix) with ESMTPS id 5FE2B3894C28 for ; Thu, 20 Jun 2024 16:24:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5FE2B3894C28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5FE2B3894C28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2604:1380:4641:c500::1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718900666; cv=none; b=fOttYARrXQ4YEbkPn9v4vtcvgngfQEUveZaXhKJIsCWQ2pk6K51rWndZwWNte0/l4CFaM9SvccQU3Z/ZcyuoGSlD2BKyQGLfPqCFOBvz/L6fg7Uy6KU1q2XW0nCMqz1SrQyFb6ITlSMuPlw8xzZ+HM8WYsr9bCbfoAJZ/ZqLS/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718900666; c=relaxed/simple; bh=CXrlszEDPUQiYKtZ0u7pc0WChHdomqG0bc13oHOMYk8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=pG5QY5K/B/wwndNurWj4OsLDJVXhcQQqcSLhifHL0jDjZEfudeyGUPuAYEyHRIacA+4AJ/Wiuw0qr7xUraOO8TPvb33RhKTO+8nigE3ZqSOjRKRDDgviIgKj6NKn4gDHxQ51/MgBURR9wp4vVbMebk9fgpWnpj+x5jvL60GjaRo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0238C621F8; Thu, 20 Jun 2024 16:24:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B740C2BD10; Thu, 20 Jun 2024 16:24:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718900663; bh=CXrlszEDPUQiYKtZ0u7pc0WChHdomqG0bc13oHOMYk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRy1c8+gzgzO1YmNYFn0xlU4/jPNcn/9MvwsPvAoPe7+0ERWB1jp/4Eg4SrYPfKQW dCxbOu/gXMIqE1WRrm6G4NMNz7t3JWJ57na8ewDl991homE91hY2Y3XJ7fjtxJecwP Z0ls7gy7/0cQaCVR+BfSxUjtZnsLGGh7q+ak0mQ9D7/e8CgHOIX2YIujd0ZuwccdAK qgOlMp7UfU6xdGU8tsWYALGF509s2RqwNwr01W8ehfFbKfshH6UmIb9yP7CLjjIEtf yU4JI3Alw+R/eT/X5xu84FD4G1b2AZ9URmrAprLqK37tETc9Dr0PtHUNggRkNu9Op0 cJXFcVyYlM6ng== From: Arnd Bergmann To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Thomas Bogendoerfer , linux-mips@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, "David S. Miller" , Andreas Larsson , sparclinux@vger.kernel.org, Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N . Rao" , linuxppc-dev@lists.ozlabs.org, Brian Cain , linux-hexagon@vger.kernel.org, Guo Ren , linux-csky@vger.kernel.org, Heiko Carstens , linux-s390@vger.kernel.org, Rich Felker , John Paul Adrian Glaubitz , linux-sh@vger.kernel.org, "H. Peter Anvin" , Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, libc-alpha@sourceware.org, musl@lists.openwall.com, ltp@lists.linux.it, Adhemerval Zanella Subject: [PATCH 07/15] parisc: use generic sys_fanotify_mark implementation Date: Thu, 20 Jun 2024 18:23:08 +0200 Message-Id: <20240620162316.3674955-8-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620162316.3674955-1-arnd@kernel.org> References: <20240620162316.3674955-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org From: Arnd Bergmann The sys_fanotify_mark() syscall on parisc uses the reverse word order for the two halves of the 64-bit argument compared to all syscalls on all 32-bit architectures. As far as I can tell, the problem is that the function arguments on parisc are sorted backwards (26, 25, 24, 23, ...) compared to everyone else, so the calling conventions of using an even/odd register pair in native word order result in the lower word coming first in function arguments, matching the expected behavior on little-endian architectures. The system call conventions however ended up matching what the other 32-bit architectures do. A glibc cleanup in 2020 changed the userspace behavior in a way that handles all architectures consistently, but this inadvertently broke parisc32 by changing to the same method as everyone else. The change made it into glibc-2.35 and subsequently into debian 12 (bookworm), which is the latest stable release. This means we need to choose between reverting the glibc change or changing the kernel to match it again, but either hange will leave some systems broken. Pick the option that is more likely to help current and future users and change the kernel to match current glibc. This also means the behavior is now consistent across architectures, but it breaks running new kernels with old glibc builds before 2.35. Link: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=d150181d73d9 Link: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/arch/parisc/kernel/sys_parisc.c?h=57b1dfbd5b4a39d Cc: Adhemerval Zanella Signed-off-by: Arnd Bergmann Tested-by: Helge Deller Acked-by: Helge Deller --- I found this through code inspection, please double-check to make sure I got the bug and the fix right. The alternative is to fix this by reverting glibc back to the unusual behavior. --- arch/parisc/Kconfig | 1 + arch/parisc/kernel/sys_parisc32.c | 9 --------- arch/parisc/kernel/syscalls/syscall.tbl | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index daafeb20f993..dc9b902de8ea 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -16,6 +16,7 @@ config PARISC select ARCH_HAS_UBSAN select ARCH_HAS_PTE_SPECIAL select ARCH_NO_SG_CHAIN + select ARCH_SPLIT_ARG64 if !64BIT select ARCH_SUPPORTS_HUGETLBFS if PA20 select ARCH_SUPPORTS_MEMORY_FAILURE select ARCH_STACKWALK diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c index 2a12a547b447..826c8e51b585 100644 --- a/arch/parisc/kernel/sys_parisc32.c +++ b/arch/parisc/kernel/sys_parisc32.c @@ -23,12 +23,3 @@ asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23, current->comm, current->pid, r20); return -ENOSYS; } - -asmlinkage long sys32_fanotify_mark(compat_int_t fanotify_fd, compat_uint_t flags, - compat_uint_t mask0, compat_uint_t mask1, compat_int_t dfd, - const char __user * pathname) -{ - return sys_fanotify_mark(fanotify_fd, flags, - ((__u64)mask1 << 32) | mask0, - dfd, pathname); -} diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl index 39e67fab7515..66dc406b12e4 100644 --- a/arch/parisc/kernel/syscalls/syscall.tbl +++ b/arch/parisc/kernel/syscalls/syscall.tbl @@ -364,7 +364,7 @@ 320 common accept4 sys_accept4 321 common prlimit64 sys_prlimit64 322 common fanotify_init sys_fanotify_init -323 common fanotify_mark sys_fanotify_mark sys32_fanotify_mark +323 common fanotify_mark sys_fanotify_mark compat_sys_fanotify_mark 324 32 clock_adjtime sys_clock_adjtime32 324 64 clock_adjtime sys_clock_adjtime 325 common name_to_handle_at sys_name_to_handle_at