NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/52352: /proc/cpuinfo includes NULL character when large results.
>Number: 52352
>Category: kern
>Synopsis: /proc/cpuinfo includes NULL character when large results.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jul 01 01:55:00 +0000 2017
>Originator: Yasushi Oshima
>Release: NetBSD/amd64 8.0_BETA
>Organization:
>Environment:
NetBSD sudachi 8.0_BETA NetBSD 8.0_BETA (GENERIC.201706291900Z) amd64
>Description:
/proc/cpuinfo results strings with NULL character when the size is large than 8192,
This will appear in the case of the machine which has many core cpu. My machine is AMD Ryzen7-8core/SMT(16cpus).
% cat /proc/cpuinfo | grep stepping
Binary file (standard input) matches
% cat /proc/cpuinfo | hexdump -C | tail -3
00002da0 63 6c 66 6c 75 73 68 20 73 69 7a 65 09 3a 20 36 |clflush size.: 6|
00002db0 34 0a 00 |4..|
00002db3
The last byte is '00'.
When running on another machine (which has 4-logical core)
% cat /proc/cpuinfo | grep stepping
stepping : 7
stepping : 7
stepping : 7
stepping : 7
% cat /proc/cpuinfo | hexdump -C | tail -3
000007f0 65 5f 74 69 6d 65 72 20 78 73 61 76 65 20 61 76 |e_timer xsave av|
00000800 78 20 6c 61 68 66 5f 6c 6d 20 0a 0a |x lahf_lm ..|
0000080c
The last byte is '\n'.
Maybe this is caused by:
-sys/miscfs/procfs/procfs_linux.c#procfs_docpuinfo()
Re-allocate output buffer larger than LBFSZ to 'JUST' size when required.
-sys/arch/x86/x86/procfs_machdep.c#procfs_getcpuinfstr()
Add '\n' only when less than 'size'. When 'used' == 'size', does not set any character, so it will unknown byte - in my case is NULL.
>How-To-Repeat:
1. Boot netbsd/amd64 with many core cpu(Ryzen7, Xeon 8 core/HT, or qemu -smp 20, etc...)
2. mount procfs (enable linux option)
3. cat /proc/cpuinfo | grep stepping
>Fix:
none.
Perhaps add the case of 'used' == 'size' in procfs_machdep.c#procfs_getcpuinfstr(), for manage length and last byte.
Home |
Main Index |
Thread Index |
Old Index