Stable Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] sparc32: fix struct ipc64_perm type definition
@ 2020-01-14 13:26 Arnd Bergmann
  2020-01-14 22:10 ` Dmitry V. Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2020-01-14 13:26 UTC (permalink / raw)
  To: David S. Miller, Sam Ravnborg
  Cc: Arnd Bergmann, stable, Dmitry V . Levin, Rich Felker, libc-alpha,
	sparclinux, linux-kernel

As discussed in the strace issue tracker, it appears that the sparc32
sysvipc support has been broken for the past 11 years. It was however
working in compat mode, which is how it must have escaped most of the
regular testing.

The problem is that a cleanup patch inadvertently changed the uid/gid
fields in struct ipc64_perm from 32-bit types to 16-bit types in uapi
headers.

Both glibc and uclibc-ng still use the original types, so they should
work fine with compat mode, but not natively.  Change the definitions
to use __kernel_uid32_t and __kernel_gid32_t again.

Fixes: 83c86984bff2 ("sparc: unify ipcbuf.h")
Link: https://github.com/strace/strace/issues/116
Cc: <stable@vger.kernel.org> # v2.6.29
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: "Dmitry V . Levin" <ldv@altlinux.org>
Cc: Rich Felker <dalias@libc.org>
Cc: libc-alpha@sourceware.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/sparc/include/uapi/asm/ipcbuf.h | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/sparc/include/uapi/asm/ipcbuf.h b/arch/sparc/include/uapi/asm/ipcbuf.h
index 5b933a598a33..0ea1240d2ea1 100644
--- a/arch/sparc/include/uapi/asm/ipcbuf.h
+++ b/arch/sparc/include/uapi/asm/ipcbuf.h
@@ -17,19 +17,19 @@
 
 struct ipc64_perm
 {
-	__kernel_key_t	key;
-	__kernel_uid_t	uid;
-	__kernel_gid_t	gid;
-	__kernel_uid_t	cuid;
-	__kernel_gid_t	cgid;
+	__kernel_key_t		key;
+	__kernel_uid32_t	uid;
+	__kernel_gid32_t	gid;
+	__kernel_uid32_t	cuid;
+	__kernel_gid32_t	cgid;
 #ifndef __arch64__
-	unsigned short	__pad0;
+	unsigned short		__pad0;
 #endif
-	__kernel_mode_t	mode;
-	unsigned short	__pad1;
-	unsigned short	seq;
-	unsigned long long __unused1;
-	unsigned long long __unused2;
+	__kernel_mode_t		mode;
+	unsigned short		__pad1;
+	unsigned short		seq;
+	unsigned long long	__unused1;
+	unsigned long long	__unused2;
 };
 
 #endif /* __SPARC_IPCBUF_H */
-- 
2.20.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] sparc32: fix struct ipc64_perm type definition
  2020-01-14 13:26 [PATCH] sparc32: fix struct ipc64_perm type definition Arnd Bergmann
@ 2020-01-14 22:10 ` Dmitry V. Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry V. Levin @ 2020-01-14 22:10 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: David S. Miller, Sam Ravnborg, stable, Rich Felker, libc-alpha,
	sparclinux, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2495 bytes --]

On Tue, Jan 14, 2020 at 02:26:14PM +0100, Arnd Bergmann wrote:
> As discussed in the strace issue tracker, it appears that the sparc32
> sysvipc support has been broken for the past 11 years. It was however
> working in compat mode, which is how it must have escaped most of the
> regular testing.
> 
> The problem is that a cleanup patch inadvertently changed the uid/gid
> fields in struct ipc64_perm from 32-bit types to 16-bit types in uapi
> headers.
> 
> Both glibc and uclibc-ng still use the original types, so they should
> work fine with compat mode, but not natively.  Change the definitions
> to use __kernel_uid32_t and __kernel_gid32_t again.
> 
> Fixes: 83c86984bff2 ("sparc: unify ipcbuf.h")
> Link: https://github.com/strace/strace/issues/116
> Cc: <stable@vger.kernel.org> # v2.6.29
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: "Dmitry V . Levin" <ldv@altlinux.org>
> Cc: Rich Felker <dalias@libc.org>
> Cc: libc-alpha@sourceware.org
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/sparc/include/uapi/asm/ipcbuf.h | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/sparc/include/uapi/asm/ipcbuf.h b/arch/sparc/include/uapi/asm/ipcbuf.h
> index 5b933a598a33..0ea1240d2ea1 100644
> --- a/arch/sparc/include/uapi/asm/ipcbuf.h
> +++ b/arch/sparc/include/uapi/asm/ipcbuf.h
> @@ -17,19 +17,19 @@
>  
>  struct ipc64_perm
>  {
> -	__kernel_key_t	key;
> -	__kernel_uid_t	uid;
> -	__kernel_gid_t	gid;
> -	__kernel_uid_t	cuid;
> -	__kernel_gid_t	cgid;
> +	__kernel_key_t		key;
> +	__kernel_uid32_t	uid;
> +	__kernel_gid32_t	gid;
> +	__kernel_uid32_t	cuid;
> +	__kernel_gid32_t	cgid;
>  #ifndef __arch64__
> -	unsigned short	__pad0;
> +	unsigned short		__pad0;
>  #endif
> -	__kernel_mode_t	mode;
> -	unsigned short	__pad1;
> -	unsigned short	seq;
> -	unsigned long long __unused1;
> -	unsigned long long __unused2;
> +	__kernel_mode_t		mode;
> +	unsigned short		__pad1;
> +	unsigned short		seq;
> +	unsigned long long	__unused1;
> +	unsigned long long	__unused2;
>  };
>  
>  #endif /* __SPARC_IPCBUF_H */

I think the fix is correct, I also confirm that the part of strace
test suite that checks tracing of 32-bit tracees on sparc64 turns green
again when this patch is applied.

Please add to the commit message that
this bug was found by strace test suite.

Feel free to add
Reported-and-tested-by: Dmitry V. Levin <ldv@altlinux.org>


-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 13:26 [PATCH] sparc32: fix struct ipc64_perm type definition Arnd Bergmann
2020-01-14 22:10 ` Dmitry V. Levin

Stable Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://lore.kernel.org/stable \
		stable@vger.kernel.org
	public-inbox-index stable

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git