From patchwork Thu Dec 19 21:58:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1213721 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Po4v8tg2"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47f5PJ5kDyz9sPL for ; Fri, 20 Dec 2019 08:58:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=rjrpSkwOonIDS67qQMb5e3/MfSfFhi+HhJvE5ce072E=; b=Po4v8tg2d0g8Rd vqFUSsLl+h1URy4p6udNmxHNdDAGatKqhQd4Ho9uhrhVkmXLmXQ6s00vVPvd22u64ZjBb1mAE8XT1 cTt7pSyeRFYdk7am9o6xme82wb4xEjKhkUkJOcvLYHzO7aea62BrGPLq15iUJpAxrYB/mXbTEAu2S ggr6O45omVvrwz7iy6tClFyizxqOyJtkQAZopJ07vSDwGH59y/zMZcG+AlkwVZl9sgzOLSrGWSfh8 Yd/OL5vrQWgg/nyejguqmxwLlokHaq4bYPiMyynGLDXYrwxr2U4zOcGMEbVmCsp5uPlpdtRq9dSTe vHoEaRLnHAHH/6tQJdYw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii3oq-0000th-67; Thu, 19 Dec 2019 21:58:52 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii3om-0000qq-KE for openwrt-devel@lists.openwrt.org; Thu, 19 Dec 2019 21:58:50 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id D60144B41; Thu, 19 Dec 2019 22:58:41 +0100 (CET) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 6a950149; Thu, 19 Dec 2019 22:58:31 +0100 (CET) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Date: Thu, 19 Dec 2019 22:58:16 +0100 Message-Id: <20191219215836.21773-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191219_135848_819128_887C7F41 X-CRM114-Status: UNSURE ( 9.15 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [178.217.244.18 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record Subject: [OpenWrt-Devel] [PATCH libubox 00/20] tests, fuzzing, fixes and improvements X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Hi, this patch series adds unit tests passed through Valgrind, unit tests covered with Clang's {Address,Leak,UndefinedBehavior}Sanitizer, fuzzing with libFuzzer and bunch of fixes uncovered by the new tests. Petr Štetiar (17): cmake: use extra compiler warnings only on gcc6+ blobmsg/ulog: fix format string compiler warnings cmake: add more hardening compiler flags tests: add unit tests covered with Clang sanitizers tests: add libFuzzer based tests tests: add test cases for blob parsing test: fuzz: add blob_parse crashes blob: refactor attr parsing into separate function blob: introduce blob_parse_untrusted tests: use blob_parse_untrusted variant blob: fix OOB access in blob_check_type test: fuzz: add blobmsg_check_attr crashes tests: add test cases for blobmsg parsing blobmsg: make blobmsg_len and blobmsg_data_len return unsigned value blobmsg: fix heap buffer overflow in blobmsg_parse tests: fuzz: fuzz _len variants of checking methods blobmsg: reuse blobmsg_namelen in blobmsg_data Tobias Schramm (3): Ensure blob_attr length check does not perform out of bounds reads Replace use of blobmsg_check_attr by blobmsg_check_attr_len blobmsg: add _len variants for all attribute checking methods CMakeLists.txt | 20 +- blob.c | 98 +++++++--- blob.h | 11 +- blobmsg.c | 89 ++++++--- blobmsg.h | 68 ++++++- tests/CMakeLists.txt | 9 +- tests/cram/inputs/invalid.ucert | Bin 0 -> 362 bytes tests/cram/inputs/key-build.ucert | Bin 0 -> 356 bytes tests/cram/test_avl.t | 9 + tests/cram/test_base64.t | 30 ++- tests/cram/test_blob_parse.t | 78 ++++++++ tests/cram/test_blobmsg.t | 15 ++ tests/cram/test_blobmsg_parse.t | 65 +++++++ tests/cram/test_jshn.t | 144 ++++++++++++++ tests/cram/test_json_script.t | 55 ++++++ tests/cram/test_list.t | 20 ++ tests/cram/test_runqueue.t | 12 ++ tests/fuzz/CMakeLists.txt | 18 ++ .../71520a5c4b5ca73903216857abbad54a8002d44a | Bin 0 -> 2 bytes .../c1dfd96eea8cc2b62785275bca38ac261256e278 | 1 + .../c42ac1c46f1d4e211c735cc7dfad4ff8391110e9 | Bin 0 -> 3 bytes ...h-1b8fb1be45db3aff7699100f497fb74138f3df4f | Bin 0 -> 6 bytes ...h-333757b203a44751d3535f24b05f467183a96d09 | Bin 0 -> 10 bytes ...h-4c4d2c3c9ade5da9347534e290305c3b9760f627 | Bin 0 -> 17 bytes ...h-5e9937b197c88bf4e7b7ee2612456cad4cb83f5b | Bin 0 -> 86 bytes ...h-75b146c4e6fac64d3e62236b27c64b50657bab2a | Bin 0 -> 4 bytes ...h-813f3e68661da09c26d4a87dbb9d5099e92be50f | Bin 0 -> 36 bytes ...h-98595faa58ba01d85ba4fd0b109cd3d490b45795 | Bin 0 -> 6 bytes ...h-d0f3aa7d60a094b021f635d4edb7807c055a4ea1 | 1 + ...h-df9d1243057b27bbad6211e5a23d1cb699028aa2 | Bin 0 -> 16 bytes ...h-e2fd5ecb3b37926743256f1083f47a07c39e10c2 | Bin 0 -> 66 bytes tests/fuzz/corpus/valid-blobmsg.bin | Bin 0 -> 176 bytes tests/fuzz/test-fuzz.c | 100 ++++++++++ tests/test-blob-parse.c | 175 ++++++++++++++++++ tests/test-blobmsg-parse.c | 74 ++++++++ ulog.c | 3 + 36 files changed, 1035 insertions(+), 60 deletions(-) create mode 100644 tests/cram/inputs/invalid.ucert create mode 100644 tests/cram/inputs/key-build.ucert create mode 100644 tests/cram/test_blob_parse.t create mode 100644 tests/cram/test_blobmsg_parse.t create mode 100644 tests/fuzz/CMakeLists.txt create mode 100644 tests/fuzz/corpus/71520a5c4b5ca73903216857abbad54a8002d44a create mode 100644 tests/fuzz/corpus/c1dfd96eea8cc2b62785275bca38ac261256e278 create mode 100644 tests/fuzz/corpus/c42ac1c46f1d4e211c735cc7dfad4ff8391110e9 create mode 100644 tests/fuzz/corpus/crash-1b8fb1be45db3aff7699100f497fb74138f3df4f create mode 100644 tests/fuzz/corpus/crash-333757b203a44751d3535f24b05f467183a96d09 create mode 100644 tests/fuzz/corpus/crash-4c4d2c3c9ade5da9347534e290305c3b9760f627 create mode 100644 tests/fuzz/corpus/crash-5e9937b197c88bf4e7b7ee2612456cad4cb83f5b create mode 100644 tests/fuzz/corpus/crash-75b146c4e6fac64d3e62236b27c64b50657bab2a create mode 100644 tests/fuzz/corpus/crash-813f3e68661da09c26d4a87dbb9d5099e92be50f create mode 100644 tests/fuzz/corpus/crash-98595faa58ba01d85ba4fd0b109cd3d490b45795 create mode 100644 tests/fuzz/corpus/crash-d0f3aa7d60a094b021f635d4edb7807c055a4ea1 create mode 100644 tests/fuzz/corpus/crash-df9d1243057b27bbad6211e5a23d1cb699028aa2 create mode 100644 tests/fuzz/corpus/crash-e2fd5ecb3b37926743256f1083f47a07c39e10c2 create mode 100644 tests/fuzz/corpus/valid-blobmsg.bin create mode 100644 tests/fuzz/test-fuzz.c create mode 100644 tests/test-blob-parse.c create mode 100644 tests/test-blobmsg-parse.c