RE: how to tell if a process is 64-bit

2017-09-08 Thread Terry Moore
Hi, > In a cross-platform process utility tool the question came up how to decide if a process is 64-bit. > > https://github.com/giampaolo/psutil/issues/1102 > > What's the best answer for NetBSD? If I understand correctly, you want psutil-based scripts -- which seem to be written in Python --

re: how to tell if a process is 64-bit

2017-09-08 Thread matthew green
> > In addition to amd64/i386, it occurs to me that sparc64/sparc32 is > > another case; IIRC it's possible to take sparc64 hardware and build a > > (special? not sure) kernel that runs sparc32 userland. I've never > > tried it; I don't know whether sparc32 and sparc64 are as freely > > mixable

Re: how to tell if a process is 64-bit

2017-09-08 Thread Mouse
> That's why I asked "what does 'is 64-bit' mean". Your previous reference to$ Any particular reason for the paragraph-length line? Manually repairing it (and trimming to the part I'm replying to), > [...] the question "does this program use 64 bit addresses". There > are at least two other

Re: how to tell if a process is 64-bit

2017-09-08 Thread Eduardo Horvath
On Fri, 8 Sep 2017, Mouse wrote: > >> ([...] on most "64-bit" ports, a real question on amd64 (and others, > >> if any) which support 32-bit userland.) > > actually -- our mips64 ports largely use N32 userland, which is 64 > > bit registers and 32 bit addresses. > > Oh! Thank you. Yes, that's

Re: how to tell if a process is 64-bit

2017-09-08 Thread Mouse
>> ([...] on most "64-bit" ports, a real question on amd64 (and others, >> if any) which support 32-bit userland.) > actually -- our mips64 ports largely use N32 userland, which is 64 > bit registers and 32 bit addresses. Oh! Thank you. Yes, that's an interesting case. In addition to

Re: how to tell if a process is 64-bit

2017-09-08 Thread Paul.Koning
> On Sep 8, 2017, at 4:00 PM, matthew green wrote: > >> Is the answer "it's using an ISA with 64-bit registers and addresses"? >> This actually can be broken down into the "registers" and "addresses" >> portion, but, in practice, the two tend to go together. (Always true >>

re: how to tell if a process is 64-bit

2017-09-08 Thread matthew green
> Is the answer "it's using an ISA with 64-bit registers and addresses"? > This actually can be broken down into the "registers" and "addresses" > portion, but, in practice, the two tend to go together. (Always true > on most "64-bit" ports, a real question on amd64 (and others, if any) > which

re: how to tell if a process is 64-bit

2017-09-08 Thread matthew green
> In a cross-platform process utility tool the question came up how to > decide if a process is 64-bit. > > https://github.com/giampaolo/psutil/issues/1102 > > What's the best answer for NetBSD? in C: internally, just check #ifdef _LP64. externally, kvm_getprocs() with KERN_PROC_PID. in other

Re: fork1 use-after-free of the child process

2017-09-08 Thread Kamil Rytarowski
On 08.09.2017 04:32, Mateusz Guzik wrote: > The fork1 routine can wait for the child to exit (if vforked) and/or > return the pointer to the child. > > Neither case guarantees the safety of said operation. The key is that > the parent can be ignoring SIGCHLD, which results in autoreaping the >

unsafe ->p_cwdi access in mount_checkdirs

2017-09-08 Thread Mateusz Guzik
In mount_checkdirs you can find a loop: mutex_enter(proc_lock); PROCLIST_FOREACH(p, ) { if ((cwdi = p->p_cwdi) == NULL) continue; if (cwdi->cwdi_cdir != olddp && cwdi->cwdi_rdir != olddp) continue; retry = true; rele1 =

Re: how to tell if a process is 64-bit

2017-09-08 Thread Martin Husemann
On Fri, Sep 08, 2017 at 01:13:44PM +, Christos Zoulas wrote: > If you can attach to it with ktrace, the first record is an emul record. > If you have procfs cat /proc//emul Yeah, but it would be interesting to see in something like kprocinfo2 (easily fetchable via sysctl or the kvm wrapper).

Re: how to tell if a process is 64-bit

2017-09-08 Thread Christos Zoulas
In article <20170908115647.ga29...@mail.duskware.de>, Martin Husemann wrote: >On Fri, Sep 08, 2017 at 12:55:37PM +0200, Thomas Klausner wrote: >> What's the best answer for NetBSD? > >If the kernel is 64bit: >kvm_getproc2() and check the process flags for P_32. > >If not: all

Re: how to tell if a process is 64-bit

2017-09-08 Thread Mouse
>> First, I have to ask: what does it mean to say that a particular >> process is - or isn't - 64-bit? > Many 64-bit ports support running 32-bit applications > (compat_netbsd32, compat_linux32). Exactly. Is the answer "it can do arithmetic on 64-bit values"? (Most - all, I think - NetBSD ports

Re: how to tell if a process is 64-bit

2017-09-08 Thread Thomas Klausner
On Fri, Sep 08, 2017 at 07:38:24AM -0400, Mouse wrote: > First, I have to ask: what does it mean to say that a particular > process is - or isn't - 64-bit? Many 64-bit ports support running 32-bit applications (compat_netbsd32, compat_linux32). Thomas

Re: how to tell if a process is 64-bit

2017-09-08 Thread Martin Husemann
On Fri, Sep 08, 2017 at 12:55:37PM +0200, Thomas Klausner wrote: > What's the best answer for NetBSD? If the kernel is 64bit: kvm_getproc2() and check the process flags for P_32. If not: all of them ;-} I would find it more interesting to answer "what is the emulation it runs under", so you

Re: how to tell if a process is 64-bit

2017-09-08 Thread coypu
At the risk of making people angry, this answer works for linux and netbsd: $ file -L /proc/self/exe /proc/self/exe: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /usr/libexec/ld.elf_so, for NetBSD 8.99.2, not stripped

Re: how to tell if a process is 64-bit

2017-09-08 Thread Mouse
> In a cross-platform process utility tool the question came up how to > decide if a process is 64-bit. First, I have to ask: what does it mean to say that a particular process is - or isn't - 64-bit? I started to write that on most of the 64-bit-supporting ports there isn't even any question,

how to tell if a process is 64-bit

2017-09-08 Thread Thomas Klausner
Hi! In a cross-platform process utility tool the question came up how to decide if a process is 64-bit. https://github.com/giampaolo/psutil/issues/1102 What's the best answer for NetBSD? Thomas

fork1 use-after-free of the child process

2017-09-08 Thread Mateusz Guzik
The fork1 routine can wait for the child to exit (if vforked) and/or return the pointer to the child. Neither case guarantees the safety of said operation. The key is that the parent can be ignoring SIGCHLD, which results in autoreaping the child and the child itself is made runnable. Thus in