[AArch64,BZ,18400] fix elf_prpsinfo in procfs.h

Message ID 5551BE4D.4060308@arm.com
State Committed
Headers

Commit Message

Szabolcs Nagy May 12, 2015, 8:48 a.m. UTC
  Kernel uses int pr_uid, pr_gid, but glibc used unsigned short.

This is an ABI breaking change so I created a bugzilla ticket,
but I guess glibc elf_prpsinfo is not widely used if this
haven't come up yet.

Changelog:

2015-05-12  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	[BZ #18400]
	* sysdeps/unix/sysv/linux/aarch64/sys/procfs.h (struct elf_prpsinfo):
	Fix pr_uid and pr_gid members.
  

Comments

Andreas Schwab May 12, 2015, 9:49 a.m. UTC | #1
Szabolcs Nagy <szabolcs.nagy@arm.com> writes:

> Kernel uses int pr_uid, pr_gid, but glibc used unsigned short.
>
> This is an ABI breaking change so I created a bugzilla ticket,
> but I guess glibc elf_prpsinfo is not widely used if this
> haven't come up yet.

Can you find out where the struct is actually been used?

Andreas.
  
Mike Frysinger May 12, 2015, 10:30 a.m. UTC | #2
On 12 May 2015 11:49, Andreas Schwab wrote:
> Szabolcs Nagy <szabolcs.nagy@arm.com> writes:
> > Kernel uses int pr_uid, pr_gid, but glibc used unsigned short.
> >
> > This is an ABI breaking change so I created a bugzilla ticket,
> > but I guess glibc elf_prpsinfo is not widely used if this
> > haven't come up yet.
> 
> Can you find out where the struct is actually been used?

breakpad uses it, but i wouldn't worry too much about that ... it statically 
links things in general and should be easy to fix it

otherwise, the usual debug culprits like gdb, libunwind, strace, etc... *might* 
use it.  i find these proc headers are fairly uncommon though.

maybe github code search would help ?
-mike
  
Szabolcs Nagy May 12, 2015, 11:06 a.m. UTC | #3
On 12/05/15 10:49, Andreas Schwab wrote:
> Szabolcs Nagy <szabolcs.nagy@arm.com> writes:
> 
>> Kernel uses int pr_uid, pr_gid, but glibc used unsigned short.
>>
>> This is an ABI breaking change so I created a bugzilla ticket,
>> but I guess glibc elf_prpsinfo is not widely used if this
>> haven't come up yet.
> 
> Can you find out where the struct is actually been used?
> 

it should be used by things that look at elf core dumps, but
i cannot find any use of the glibc struct

binutils relies on the struct layout:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elfxx-aarch64.c;h=db9d4fa01924342cbc110877d1ac06c7a389debc;hb=HEAD#l526

note that those parts are not changed here
(the struct is 8 byte aligned so 2*short -> 2*int
does not change the layout for other members)

i've seen various packages defining their own prpsinfo
struct (uclibc, bionic, musl, google-breakpad, valgrind,
binutils, qemu) and some using the kernel definition
(undertaker).

some of the definitions are broken on various platforms
(i haven't seen the pr_uid/pr_gid fields used).
  
Andreas Schwab May 13, 2015, 8:37 a.m. UTC | #4
Szabolcs Nagy <szabolcs.nagy@arm.com> writes:

> note that those parts are not changed here
> (the struct is 8 byte aligned so 2*short -> 2*int
> does not change the layout for other members)

> (i haven't seen the pr_uid/pr_gid fields used).

Given these two statements this change should be pretty safe.

Andreas.
  
Marcus Shawcroft July 7, 2015, 10:01 a.m. UTC | #5
On 12 May 2015 at 09:48, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> Kernel uses int pr_uid, pr_gid, but glibc used unsigned short.
>
> This is an ABI breaking change so I created a bugzilla ticket,
> but I guess glibc elf_prpsinfo is not widely used if this
> haven't come up yet.
>
> Changelog:
>
> 2015-05-12  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
>         [BZ #18400]
>         * sysdeps/unix/sysv/linux/aarch64/sys/procfs.h (struct elf_prpsinfo):
>         Fix pr_uid and pr_gid members.


All of the comments on this thread suggest the change is relatively
safe, go ahead and commit it.
/Marcus
  

Patch

diff --git a/sysdeps/unix/sysv/linux/aarch64/sys/procfs.h b/sysdeps/unix/sysv/linux/aarch64/sys/procfs.h
index cf5e76c..ecc65ab 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sys/procfs.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sys/procfs.h
@@ -91,8 +91,8 @@  struct elf_prpsinfo
     char pr_zomb;			/* Zombie.  */
     char pr_nice;			/* Nice val.  */
     unsigned long int pr_flag;		/* Flags.  */
-    unsigned short int pr_uid;
-    unsigned short int pr_gid;
+    unsigned int pr_uid;
+    unsigned int pr_gid;
     int pr_pid, pr_ppid, pr_pgrp, pr_sid;
     /* Lots missing */
     char pr_fname[16];			/* Filename of executable.  */