NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/51514: ptrace(2) fails for 32-bit process on 64-bit kernel



The following reply was made to PR kern/51514; it has been noted by GNATS.

From: Rin Okuyama <rokuyama%rk.phys.keio.ac.jp@localhost>
To: Nick Hudson <skrll%netbsd.org@localhost>, gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/51514: ptrace(2) fails for 32-bit process on 64-bit kernel
Date: Tue, 18 Oct 2016 08:37:55 +0900

 On 2016/10/16 17:09, Nick Hudson wrote:
 > Here's what I've got... Some things to nodes are
 >
 > - New compat_netbsd32_ptrace modules is created, but a ptrace module isn't
 
 Thank you so much for your efforts to modularize 32-bit version of
 ptrace. It's also been a good education for me. I've confirmed that
 32-bit version of GDB works well with your patch on amd64, sparc64,
 andevbmips64-eb.
 
 > - Should more be moved into compat32, e.g. PROC_{PTR,REG,FPREG}SZ and
 >   the netbsd32_process_{read,write}_{,fp}regs?
 
 Yes, it should be for the latter. Otherwise, on non-COMPAT_NETBSD32
 kernel, process_{read,write}_{,fp}regs32 are replaced by their 64-bit
 counterparts:
 
    https://nxr.netbsd.org/source/xref/src/sys/sys/ptrace.h#156
 
 And therefore compat_netbsd32_ptrace module may not work properly.
 
 On the other hand, it seems to be harmless for me to have
 PROC_{PTR,REG,FPREG}SZ in the main kernel. Or would it be better to
 protect them by _LP64 like this?
 
 #ifdef _LP64
 #define PROC_PTRSZ(p) (((p)->p_flag & PK_32) ? sizeof(int) : sizeof(void *))
 #define PROC_REGSZ(p) (((p)->p_flag & PK_32) ? \
      sizeof(process_reg32) : sizeof(struct reg))
 #define PROC_FPREGSZ(p) (((p)->p_flag & PK_32) ? \
      sizeof(process_fpreg32) : sizeof(struct fpreg))
 #else
 #define PROC_PTRSZ(p) sizeof(void *)
 #define PROC_REGSZ(p) sizeof(struct reg)
 #define PROC_FPREGSZ(p) sizeof(struct fpreg)
 #endif
 
 For registers of x86, I have no ideas. Sorry but I do not have a
 thorough knowledge of x86 architecture...
 
 Thanks,
 Rin
 


Home | Main Index | Thread Index | Old Index