Adam,
I saw an example with problems where a 31-bit sshd2 application was being
run on a SLES9 64 bit system. Accessing a utmp entry for a db2fmcd entry
caused a SIGSEGV due to an invalid timestamp in the utmp file. We noticed
that the 1st 6 utmp entries, written by init, are 400 bytes in length. We
noticed that subsequent entries, written by sshd2, are 384 bytes in length.
We saw that the 1st sshd2 entry would skip 6 * 384 = 2304 bytes to write
the 7th record. The db2fmcd entry, being the 6th entry written by init
occupied bytes 2000 thru 2399. We noticed an sshd2 entry starting 304 bytes
(2304 - 2000) into the db2fmcd record. This landed on the timestamp,
leaving the value that caused the segmentation fault.
Mike O'Reilly
IBM Linux Change Team
Adam Thornton
<[EMAIL PROTECTED]
mine.net> To
Sent by: Linux on [email protected]
390 Port cc
<[EMAIL PROTECTED]
IST.EDU> Subject
SLES 10 utmpx/utmp function
problems in 31-bit mode
05/23/2008 03:20
PM
Please respond to
Linux on 390 Port
<[EMAIL PROTECTED]
IST.EDU>
So, it seems as if the functions that depend on utmp.h and utmpx.h
*should* run in 31-bit mode, even on a 64-bit host.
They don't.
I'm going to post the test code I've got with utmpx.h, which is the
more modern interface (I have a suspicion utmp.h really *IS* utmpx.h
under the hood anyway). All it does it walk through the utmp entries
and print what it finds.
***begin source code***
#include <utmpx.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
struct utmpx *utp;
setutxent();
while ((utp = getutxent()) != NULL) {
printf("getutxent: utp at 0x%0x: ut_type: 0x%0x, pid 0x%x,\
device name \"%s\" (0x%0x), inittab id \"%s\" (0x%0x),\
username \"%s\" (0x%0x), hostname \"%s\" (0x%0x),\
session ID 0x%0x, raddr 0x%0x\n",\
utp,\
utp->ut_type,\
utp->ut_pid,\
utp->ut_line,\
utp->ut_line,\
utp->ut_id,\
utp->ut_id,\
utp->ut_user,\
utp->ut_user,\
utp->ut_host,\
utp->ut_host,\
utp->ut_session,\
utp->ut_addr_v6
);
}
return(0);
}
***end source code***
I'm using a SLES10SP2 system, but this also happens on SP1. I no
longer have a GA SLES10 system to test against.
Now if I just compile and run it, everything is cool:
[EMAIL PROTECTED]:~/src/utmpxtester> gcc test.c
[EMAIL PROTECTED]:~/src/utmpxtester> ./a.out
getutxent: utp at 0x80002010: ut_type: 0x2, pid 0x0, device
name "~" (0x80002018), inittab id "~~" (0x80002038), username
"reboot" (0x8000203c), hostname "" (0x8000205c), session ID
0x0, raddr 0x80002178
getutxent: utp at 0x80002010: ut_type: 0x8, pid 0x12d, device
name "" (0x80002018), inittab id "si" (0x80002038), username
"" (0x8000203c), hostname "" (0x8000205c), session ID 0x0,
raddr 0x80002178
getutxent: utp at 0x80002010: ut_type: 0x7, pid 0x3ec5, device
name "pts/0" (0x80002018), inittab id "ts/
0root" (0x80002038), username "root" (0x8000203c), hostname
"quicksilver.fsf.net" (0x8000205c), session ID 0x0, raddr
0x80002178
getutxent: utp at 0x80002010: ut_type: 0x7, pid 0x3fc8, device
name "pts/1" (0x80002018), inittab id "ts/
1root" (0x80002038), username "root" (0x8000203c), hostname
"quicksilver.fsf.net" (0x8000205c), session ID 0x0, raddr
0x80002178
getutxent: utp at 0x80002010: ut_type: 0x1, pid 0x4e33, device
name "~" (0x80002018), inittab id "~~" (0x80002038), username
"runlevel" (0x8000203c), hostname "" (0x8000205c), session ID
0x0, raddr 0x80002178
getutxent: utp at 0x80002010: ut_type: 0x8, pid 0x1bbe, device
name "" (0x80002018), inittab id "l3" (0x80002038), username
"" (0x8000203c), hostname "" (0x8000205c), session ID 0x0,
raddr 0x80002178
getutxent: utp at 0x80002010: ut_type: 0x6, pid 0x1dde, device
name "ttyS0" (0x80002018), inittab id "1" (0x80002038),
username "LOGIN" (0x8000203c), hostname "" (0x8000205c),
session ID 0x1dde, raddr 0x80002178
getutxent: utp at 0x80002010: ut_type: 0x7, pid 0x4066, device
name "pts/2" (0x80002018), inittab id "ts/
2adam" (0x80002038), username "adam" (0x8000203c), hostname
"quicksilver.fsf.net" (0x8000205c), session ID 0x0, raddr
0x80002178
getutxent: utp at 0x80002010: ut_type: 0x7, pid 0x6e82, device
name "pts/3" (0x80002018), inittab id "ts/
3root" (0x80002038), username "root" (0x8000203c), hostname
"nealemac.sinenomine.net" (0x8000205c), session ID 0x0, raddr
0x80002178
getutxent: utp at 0x80002010: ut_type: 0x7, pid 0x5c0f, device
name "pts/4" (0x80002018), inittab id "ts/
4adam" (0x80002038), username "adam" (0x8000203c), hostname
"quicksilver.fsf.net" (0x8000205c), session ID 0x0, raddr
0x80002178
getutxent: utp at 0x80002010: ut_type: 0x7, pid 0x3215, device
name "pts/5" (0x80002018), inittab id "ts/
5root" (0x80002038), username "root" (0x8000203c), hostname
"quicksilver.fsf.net" (0x8000205c), session ID 0x0, raddr
0x80002178
getutxent: utp at 0x80002010: ut_type: 0x7, pid 0x65e0, device
name "pts/6" (0x80002018), inittab id "ts/
6root" (0x80002038), username "root" (0x8000203c), hostname
"quicksilver.fsf.net" (0x8000205c), session ID 0x0, raddr
0x80002178
getutxent: utp at 0x80002010: ut_type: 0x7, pid 0x7d18, device
name "pts/7" (0x80002018), inittab id "ts/
7adam" (0x80002038), username "adam" (0x8000203c), hostname
"quicksilver.fsf.net" (0x8000205c), session ID 0x0, raddr
0x80002178
However, if I try to build and run it in 31-bit mode, everything is
NOT cool:
[EMAIL PROTECTED]:~/src/utmpxtester> gcc -m31 test.c
[EMAIL PROTECTED]:~/src/utmpxtester> ./a.out
getutxent: utp at 0x402008: ut_type: 0x2, pid 0x0, device name
"~" (0x402010), inittab id "~~" (0x402030), username
"reboot" (0x402034), hostname "" (0x402054), session ID 0x0,
raddr 0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0x0, device name
"" (0x402010), inittab id "" (0x402030), username
"" (0x402034), hostname "" (0x402054), session ID 0x0, raddr
0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0x0, device name
"" (0x402010), inittab id "pts/0" (0x402030), username
"0" (0x402034), hostname "root" (0x402054), session ID 0x0,
raddr 0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0xc69fe, device
name "??O" (0x402010), inittab id "" (0x402030), username
"" (0x402034), hostname "" (0x402054), session ID 0x0, raddr
0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0x0, device name
"" (0x402010), inittab id "" (0x402030), username
"" (0x402034), hostname "" (0x402054), session ID 0x0, raddr
0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0x0, device name
"" (0x402010), inittab id "" (0x402030), username
"" (0x402034), hostname "" (0x402054), session ID 0x0, raddr
0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0x0, device name
"" (0x402010), inittab id "" (0x402030), username
"H.]g" (0x402034), hostname "" (0x402054), session ID 0x0,
raddr 0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0x0, device name
"" (0x402010), inittab id "" (0x402030), username
"" (0x402034), hostname "" (0x402054), session ID 0x0, raddr
0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0x0, device name
"" (0x402010), inittab id "" (0x402030), username
"" (0x402034), hostname "H6??" (0x402054), session ID 0x0,
raddr 0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0x0, device name
"" (0x402010), inittab id "" (0x402030), username
"" (0x402034), hostname "" (0x402054), session ID 0x0, raddr
0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0x0, device name
"" (0x402010), inittab id "" (0x402030), username
"" (0x402034), hostname "" (0x402054), session ID 0x0, raddr
0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0x0, device name
"" (0x402010), inittab id "" (0x402030), username
"" (0x402034), hostname "" (0x402054), session ID 0x0, raddr
0x402164
getutxent: utp at 0x402008: ut_type: 0x0, pid 0x0, device name
"" (0x402010), inittab id "" (0x402030), username
"" (0x402034), hostname "" (0x402054), session ID 0x0, raddr
0x402164
This is a problem, because it means that 31-bit executables that use
getutxent() break on SLES10.
Any advice? I've tried faking out the compiler by explicitly defining
__s390x__ even though I'm also doing -m31, and by defining
__WORDSIZE=64 and also __WORDSIZE_COMPAT32, but it doesn't help: I
can't get -m31 to play nice with getutxent().
Adam
----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or
visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
<<inline: ecblank.gif>>
<<inline: graycol.gif>>
<<inline: pic27342.gif>>
