From patchwork Fri Jul 21 14:12:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 792145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3xDXlc3jGLz9s7g; Sat, 22 Jul 2017 00:12:28 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1dYYfK-00007v-E1; Fri, 21 Jul 2017 14:12:26 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1dYYfG-00006O-1E for fwts-devel@lists.ubuntu.com; Fri, 21 Jul 2017 14:12:22 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1dYYfF-0005G5-N9; Fri, 21 Jul 2017 14:12:21 +0000 Subject: Re: Tip regression - bus error (bisected) To: fwts-devel@lists.ubuntu.com References: From: Colin Ian King Message-ID: <57d64408-6ef3-407e-3a77-819c060f2158@canonical.com> Date: Fri, 21 Jul 2017 15:12:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com On 21/07/17 03:18, Jeffrey Hugo wrote: > I noticed a consistent bus error when running tip on a ARM64 platform - > > ubuntu@ubuntu:~$ sudo fwts > Running 71 tests, results appended to results.log > Test: Gather kernel system information. > Gather kernel signature. 1 skipped, 1 > info only > Gather kernel system information. 1 info only > Gather kernel boot command line. 1 info only > Gather ACPI driver version. 1 info only > Test: OPAL Processor Power Management DT Validation Tests > Test skipped, missing features: devicetree > Test: OPAL Reserved memory DT Validation Test > Test skipped, missing features: devicetree > Test: OPAL Processor Recovery Diagnostics Info > Test skipped, missing features: devicetree > Test: Scan kernel log for Oopses. > Kernel log oops check. 2 passed > Test: Run OLOG scan and analysis checks. > Test skipped. > Test: Scan kernel log for errors and warnings. > Kernel log error check. 1 passed > Test: BMC Info > BMC Info 1 passed > Test: General ACPI information test. > Determine Kernel ACPI version. 1 info only > Determine machine's ACPI version. : > 11.7% | > Caught SIGNAL 7 (Bus error), aborting. > Backtrace: > 0x0000ffff7eae09e4 /usr/local/lib/fwts/libfwts.so.1(+0x109e4) > > I bisected the issue down to this commit - > > commit cc3ea59404ef2bb89e40556bce8a8d803b39d3ce > Author: Colin Ian King > Date: Fri Jul 14 09:35:10 2017 +0100 > > lib: fwts_safe_mem: remove need to copy into a buffer > > While fwts_safe_memread() works fine as it is, it is copying data > to the stack and we don't guard how big that copy can be, so we > potentially could get a segfault if we run out of stack. Instead > just read the data. Force gcc not to optimize out the reads by > using volatile. > > Signed-off-by: Colin Ian King > Acked-by: Alex Hung > Acked-by: Ivan Hu > > I haven't really looked further into the issue, but is there additional > information that would be useful to root cause and fix? > So, can you apply the following: and run with: sudo fwts - >& fwts.log and send that fwts.log to me. Thanks! diff --git a/src/lib/src/fwts_safe_mem.c b/src/lib/src/fwts_safe_mem.c index 216ad8e2..08a79350 100644 --- a/src/lib/src/fwts_safe_mem.c +++ b/src/lib/src/fwts_safe_mem.c @@ -71,8 +71,12 @@ int fwts_safe_memread(const void *src, const size_t n) const volatile uint8_t *ptr = src; const volatile uint8_t *end = ptr + n; - if (sigsetjmp(jmpbuf, 1) != 0) + printf("fwts_safe_memread: %p..%p\n", src, src + n); + + if (sigsetjmp(jmpbuf, 1) != 0) { + printf(" Region cannot be read safely\n"); return FWTS_ERROR; + } fwts_sig_handler_set(SIGSEGV, sig_handler, &old_segv_action); fwts_sig_handler_set(SIGBUS, sig_handler, &old_bus_action); @@ -83,5 +87,7 @@ int fwts_safe_memread(const void *src, const size_t n) fwts_sig_handler_restore(SIGSEGV, &old_segv_action); fwts_sig_handler_restore(SIGBUS, &old_bus_action); + printf(" :Region can be read safely\n"); + return FWTS_OK; }