NetBSD Problem Report #52352
From www@NetBSD.org Sat Jul 1 01:53:47 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 6AB167A2B3
for <gnats-bugs@gnats.NetBSD.org>; Sat, 1 Jul 2017 01:53:47 +0000 (UTC)
Message-Id: <20170701015346.0445A7A2B8@mollari.NetBSD.org>
Date: Sat, 1 Jul 2017 01:53:45 +0000 (UTC)
From: oshima-ya@yagoto-urayama.jp
Reply-To: oshima-ya@yagoto-urayama.jp
To: gnats-bugs@NetBSD.org
Subject: /proc/cpuinfo includes NULL character when large results.
X-Send-Pr-Version: www-1.0
>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: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jul 01 01:55:00 +0000 2017
>Closed-Date: Tue Sep 12 04:50:52 +0000 2017
>Last-Modified: Tue Sep 12 04:50:52 +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.
>Release-Note:
>Audit-Trail:
From: "SAITOH Masanobu" <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/52352 CVS commit: src/sys/arch/x86/x86
Date: Mon, 28 Aug 2017 07:03:47 +0000
Module Name: src
Committed By: msaitoh
Date: Mon Aug 28 07:03:47 UTC 2017
Modified Files:
src/sys/arch/x86/x86: procfs_machdep.c
Log Message:
Check buffer length correctly to not to print a garbage character.
Fixes PR#52352 reported by Yasushi Oshima.
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x86/x86/procfs_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/52352 CVS commit: [netbsd-8] src/sys/arch/x86/x86
Date: Thu, 31 Aug 2017 11:34:54 +0000
Module Name: src
Committed By: martin
Date: Thu Aug 31 11:34:54 UTC 2017
Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: procfs_machdep.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #247):
sys/arch/x86/x86/procfs_machdep.c: revision 1.16
Check buffer length correctly to not to print a garbage character.
Fixes PR#52352 reported by Yasushi Oshima.
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/arch/x86/x86/procfs_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/52352 CVS commit: [netbsd-7] src/sys/arch/x86/x86
Date: Mon, 11 Sep 2017 05:50:12 +0000
Module Name: src
Committed By: snj
Date: Mon Sep 11 05:50:12 UTC 2017
Modified Files:
src/sys/arch/x86/x86 [netbsd-7]: procfs_machdep.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1505):
sys/arch/x86/x86/procfs_machdep.c: 1.15-1.16
- Print 0x00000007:0 ecx leaf bits.
- Don't print fdiv_bug on amd64.
- Print APIC ID, Initial APIC ID and clflush size.
--
Check buffer length correctly to not to print a garbage character.
Fixes PR#52352 reported by Yasushi Oshima.
To generate a diff of this commit:
cvs rdiff -u -r1.6.4.2 -r1.6.4.3 src/sys/arch/x86/x86/procfs_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: msaitoh@NetBSD.org
State-Changed-When: Tue, 12 Sep 2017 04:50:52 +0000
State-Changed-Why:
Fixed and pulled-up.
Thanks.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.