Bug 235611 - Using kcov results in lockup
Summary: Using kcov results in lockup
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Michael Tuexen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-08 20:49 UTC by Michael Tuexen
Modified: 2019-02-11 15:40 UTC (History)
2 users (show)

See Also:


Attachments
Test program (2.31 KB, text/plain)
2019-02-08 20:49 UTC, Michael Tuexen
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Tuexen freebsd_committer freebsd_triage 2019-02-08 20:49:11 UTC
Created attachment 201852 [details]
Test program

When using the attached test program (which is part of syzkaller) results in a lockup of the operating system. I tested this on FreeBSD head r343837 on amd64 and arm64.
Comment 1 Michael Tuexen freebsd_committer freebsd_triage 2019-02-08 23:44:03 UTC
The problem was introduced by the change of head/sys/conf/files in base r343746.
Comment 2 Michael Tuexen freebsd_committer freebsd_triage 2019-02-09 10:50:16 UTC
The problem is that calling clang with -fsanitize-coverage=trace-pc,trace-cmp -fno-sanitize=all does not turn off the coverage sanitizer.

This can be demonstrated:

tuexen@epyc:~ % cat test.c
int main(void)
{
	return (0);
}
tuexen@epyc:~ % cc -fsanitize-coverage=trace-pc,trace-cmp -o test_1.o -c test.c
tuexen@epyc:~ % cc -fsanitize-coverage=trace-pc,trace-cmp -fno-sanitize-coverage=trace-pc,trace-cmp -o test_2.o -c test.c
tuexen@epyc:~ % cc -fsanitize-coverage=trace-pc,trace-cmp -fno-sanitize=all -o test_3.o -c test.c
tuexen@epyc:~ % ls -l test_?.o
-rw-r--r--  1 tuexen  wheel  1928 Feb  9 11:44 test_1.o
-rw-r--r--  1 tuexen  wheel  1016 Feb  9 11:44 test_2.o
-rw-r--r--  1 tuexen  wheel  1928 Feb  9 11:44 test_3.o
tuexen@epyc:~ % diff test_1.o test_3.o

So wither this is a bug in clang or you can't use -fno-sanitize=all to turn off the coverage sanitizers.
Comment 3 Michael Tuexen freebsd_committer freebsd_triage 2019-02-09 19:03:06 UTC
A potential fix is discussed in review D19135.
Comment 4 commit-hook freebsd_committer freebsd_triage 2019-02-11 15:39:09 UTC
A commit references this bug:

Author: tuexen
Date: Mon Feb 11 15:38:05 UTC 2019
New revision: 344012
URL: https://svnweb.freebsd.org/changeset/base/344012

Log:
  Fix flags used when compiling kern_kcov.c and subr_coverage.c.

  Without this fix, the usage of kernel coverage would lockup the system.
  Thanks to Andrew for suggesting the final form of the fix.

  PR:			235611
  Reviewed by:		andrew@, emaste@
  Differential Revision:	https://reviews.freebsd.org/D19135

Changes:
  head/sys/conf/files