NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/56121: struct kinfo_lwp is inconsistent in NUL-termination of its char arrays, ps assumes all are NUL-terminated!
The following reply was made to PR kern/56121; it has been noted by GNATS.
From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: kern/56121: struct kinfo_lwp is inconsistent in NUL-termination
of its char arrays, ps assumes all are NUL-terminated!
Date: Sat, 1 May 2021 20:34:46 +0000
The following response got misfiled by gnats:
From: Simon Burge <simonb%NetBSD.org@localhost>
To: "Greg A. Woods" <woods%planix.ca@localhost>
Cc: gnats-bugs%NetBSD.org@localhost
Subject: Re: struct kinfo_lwp is inconsistent in NUL-termination of its char arrays, ps assumes all are NUL-terminated!
Hi Greg,
"Greg A. Woods" wrote:
> >Number: 56121
> >Category: kern
> >Synopsis: struct kinfo_lwp is inconsistent in NUL-termination of =
its char arrays, ps assumes all are NUL-terminated!
> --- sys/sys/sysctl.h.~1.231.~ 2021-03-07 17:24:18.000000000 -0800
> +++ sys/sys/sysctl.h 2021-04-21 17:41:09.797635650 -0700
> @@ -373,7 +373,7 @@
> */
> #define KI_NGROUPS 16
> #define KI_MAXCOMLEN 24 /* extra for 8 byte alignment */
> -#define KI_WMESGLEN 8
> +#define KI_WMESGLEN 12 /* extra for NUL and 8 byte alignment */
> #define KI_MAXLOGNAME 24 /* extra for 8 byte alignment */
> #define KI_MAXEMULLEN 16
> #define KI_LNAMELEN 20 /* extra 4 for alignment */
> @@ -566,8 +566,7 @@
> uint8_t l_usrpri; /* U_CHAR: User-priority based on l_cpu and p_nic
e. */
> int8_t l_stat; /* CHAR: S* process status. */
> int8_t l_pad1; /* fill out to 4-byte boundary */
> - int32_t l_pad2; /* .. and then to an 8-byte boundary */
> - char l_wmesg[KI_WMESGLEN]; /* wchan message */
> + char l_wmesg[KI_WMESGLEN]; /* wchan message (with NUL) */
> uint64_t l_wchan; /* PTR: sleep address. */
> uint64_t l_cpuid; /* LONG: CPU id */
> uint32_t l_rtime_sec; /* STRUCT TIMEVAL: Real time. */
This part changes the structure of kinfo_proc2 in a non-backwards
compatible way by moving the offset of l_wmesg[*]. I think we just need
to handle the fixed sized buffer directly in ps(1). I'll look a bit
more.
Cheers,
Simon.
[*] For example you should be able to use any ps(1) binary from amd64
or i386 from NetBSD 1.5 onwards on today's -current amd64 kernel.
Home |
Main Index |
Thread Index |
Old Index