From patchwork Thu Jun 20 16:23:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 806006 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp379666wrt; Thu, 20 Jun 2024 09:28:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXVHiNZaaS6nVEtitZ8ypRdKZdWDQyK2Zm0wEv2hpJOKX89mmc1hs9yIimgYIQw0zlLYliUWo1flMZAzK02u/K X-Google-Smtp-Source: AGHT+IGf1Ug3VMy8AwajhoUfqFECCLYtCHAeRryxZ1uUveoXInkce/acMbbGasb4DkMmn4KyZW6R X-Received: by 2002:ad4:5bae:0:b0:6b2:a36f:3118 with SMTP id 6a1803df08f44-6b2e23826dcmr167392886d6.22.1718900916228; Thu, 20 Jun 2024 09:28:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718900916; cv=pass; d=google.com; s=arc-20160816; b=Ogz8Z6ZLwIEQNq+SLGj6YsXmMr2HgaovQbH0PYuxITFfKT8pFDeK0hUmZNc2jAU2OM JQfjUEEW0t7TduFifG5/cKySx7E+QwQ+I1hXenFK9fT1G1fz8mfIw/qzQAAzQX5oe+kg Apms5F6PRigyHmCOWKHcBwHxbg+cFLiw5rMe3AtXjK5SE7o0XCUVyaS7X4B3s10YxK8e gP/V4iRJR0VLtJvhkPyEZpsw8iZaRmebRQixc9OtbK23FDAhu/9RZ189LfaaFUYAEK6c mRUmIISq03o2C/GfyBpkcdbI8P4seidVkiord+81elrk8iONnscTxcfloGKk0MJr8jEU EeNQ== 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=2hu5UhjwC1eLUsRyhRoY0VbfG7QceNiHQECI0lI9G38=; fh=xSIq547Z/8+2mwrThk5NmWwnmadq1eVmQ35PeXz4rpA=; b=c4aY6E8+ZjsDIkGByO4B8j/3L1UqeonriG7Ml0BrEesG2xSqQxDe6DVha50grDAy9v Dw6MYwj+dwEwPhbyZkJKgAIoX9eBVPqMmLRfk5RpTyKGK3+gVGY8inhOG8gbaoiBSkNU fxmKKHa+2oRFtGzzf7Tx6oAVB5z+D9kJFcJgxIUjPRHh6d2I18Zio9PnyiadZ7cj0p5a 37HJ0/8vcU7Z4RZrECbzyOZwwwQo/VYGABovZhvPX64W78mFU1jvWJYbrmkCdUIw3Oaa /tv6WSqQhlIc51ylpeH6QaH6sovUkZak7VlBdkaHzu47peexg2/kV+mNK2z7sJTlGhiv uD2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L4I6Oy4U; 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-6b2a5b7553esi1870626d6.519.2024.06.20.09.28.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 09:28:36 -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=L4I6Oy4U; 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 D522F389000C for ; Thu, 20 Jun 2024 16:28:35 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by sourceware.org (Postfix) with ESMTPS id 23F403894C3C for ; Thu, 20 Jun 2024 16:25:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23F403894C3C 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 23F403894C3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=145.40.73.55 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718900711; cv=none; b=x/lWirnB2hXcN0qFw+spvRP4Z2PBATv6msi+dKZHQvsaln60XY81Eqj2fJ3ByoeXaDGkujiMVho4ionIgnjCuc7Jx44wJIVhhyPQ9cmHz60FB0W/218zHEB60P+0hG3yh+WQeN+27gFAgckap6i4sQYjmGC/Zwx0xpYloPZJ7o8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718900711; c=relaxed/simple; bh=cPi0ZjnBV1CIKlXBkpBvG5fVNflJ/ABQ595U6A2fdNY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Q0AsOB3MM215O740OBOH1KV8pJJ5mG8LpovYtqNkTx3ylhGkSBZTY/p+S4kcjTSl7Oob/GakY2sBGn/Y67Y9K1iXqP+QI1mQdtP56Q12JNZ9sBUZ0uNKOt4RwuaKTmBQ8POjQYEqE5kTNmM49exJ3wMYrVlNH56kZYacmUVFyMg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 29220CE2429; Thu, 20 Jun 2024 16:25:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3633C32786; Thu, 20 Jun 2024 16:24:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718900705; bh=cPi0ZjnBV1CIKlXBkpBvG5fVNflJ/ABQ595U6A2fdNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L4I6Oy4U9Tj4R13eiK7pqNG2CXsWUIjkycJBnYKwfQOrvpBUldFWwHt5fforf8qGO W7ImwPMXiKO8CaPCzUM0SFq2R8ogOIYhE4DzW2jwybln/I37fOpfNvMxVAVrrdaDoS WUi8sCz8As8NoYFsujUNcySYE3BhqLiI+fdifQAzyfs9GESJFzoOrwAaRenVvMUVkG XnNmh77sKBmccGcKyq697GncV2zjKoPPWOKYtfbRLPaDFIGaZyswOD5mh9kmoEczBR MmqXf5vABoIwXanfGd9nvrIo6xDYMJfqhkmt6FUeNA/P7TOQqjAij0rew7x9s74LHq xobiBExDOIVlg== 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 Subject: [PATCH 13/15] syscalls: mmap(): use unsigned offset type consistently Date: Thu, 20 Jun 2024 18:23:14 +0200 Message-Id: <20240620162316.3674955-14-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.3 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 Most architectures that implement the old-style mmap() with byte offset use 'unsigned long' as the type for that offset, but microblaze and riscv have the off_t type that is shared with userspace, matching the prototype in include/asm-generic/syscalls.h. Make this consistent by using an unsigned argument everywhere. This changes the behavior slightly, as the argument is shifted to a page number, and an user input with the top bit set would result in a negative page offset rather than a large one as we use elsewhere. For riscv, the 32-bit sys_mmap2() definition actually used a custom type that is different from the global declaration, but this was missed due to an incorrect type check. Signed-off-by: Arnd Bergmann --- arch/csky/kernel/syscall.c | 2 +- arch/loongarch/kernel/syscall.c | 2 +- arch/microblaze/kernel/sys_microblaze.c | 2 +- arch/riscv/kernel/sys_riscv.c | 4 ++-- include/asm-generic/syscalls.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/csky/kernel/syscall.c b/arch/csky/kernel/syscall.c index 3d30e58a45d2..4540a271ee39 100644 --- a/arch/csky/kernel/syscall.c +++ b/arch/csky/kernel/syscall.c @@ -20,7 +20,7 @@ SYSCALL_DEFINE6(mmap2, unsigned long, prot, unsigned long, flags, unsigned long, fd, - off_t, offset) + unsigned long, offset) { if (unlikely(offset & (~PAGE_MASK >> 12))) return -EINVAL; diff --git a/arch/loongarch/kernel/syscall.c b/arch/loongarch/kernel/syscall.c index b4c5acd7aa3b..8801611143ab 100644 --- a/arch/loongarch/kernel/syscall.c +++ b/arch/loongarch/kernel/syscall.c @@ -22,7 +22,7 @@ #define __SYSCALL(nr, call) [nr] = (call), SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, unsigned long, - prot, unsigned long, flags, unsigned long, fd, off_t, offset) + prot, unsigned long, flags, unsigned long, fd, unsigned long, offset) { if (offset & ~PAGE_MASK) return -EINVAL; diff --git a/arch/microblaze/kernel/sys_microblaze.c b/arch/microblaze/kernel/sys_microblaze.c index ed9f34da1a2a..0850b099f300 100644 --- a/arch/microblaze/kernel/sys_microblaze.c +++ b/arch/microblaze/kernel/sys_microblaze.c @@ -35,7 +35,7 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, unsigned long, prot, unsigned long, flags, unsigned long, fd, - off_t, pgoff) + unsigned long, pgoff) { if (pgoff & ~PAGE_MASK) return -EINVAL; diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c index 64155323cc92..d77afe05578f 100644 --- a/arch/riscv/kernel/sys_riscv.c +++ b/arch/riscv/kernel/sys_riscv.c @@ -23,7 +23,7 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len, #ifdef CONFIG_64BIT SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, unsigned long, prot, unsigned long, flags, - unsigned long, fd, off_t, offset) + unsigned long, fd, unsigned long, offset) { return riscv_sys_mmap(addr, len, prot, flags, fd, offset, 0); } @@ -32,7 +32,7 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, #if defined(CONFIG_32BIT) || defined(CONFIG_COMPAT) SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, unsigned long, prot, unsigned long, flags, - unsigned long, fd, off_t, offset) + unsigned long, fd, unsigned long, offset) { /* * Note that the shift for mmap2 is constant (12), diff --git a/include/asm-generic/syscalls.h b/include/asm-generic/syscalls.h index 933ca6581aba..fabcefe8a80a 100644 --- a/include/asm-generic/syscalls.h +++ b/include/asm-generic/syscalls.h @@ -19,7 +19,7 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, #ifndef sys_mmap asmlinkage long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, - unsigned long fd, off_t pgoff); + unsigned long fd, unsigned long off); #endif #ifndef sys_rt_sigreturn