Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4448692imb; Wed, 6 Mar 2019 13:45:09 -0800 (PST) X-Google-Smtp-Source: APXvYqwaI/we2b032VnHZf9Jrh32BoX/A6vnMq+4L4AvBytAQKbk4zbFll1rxHK+VTH9obEzthty X-Received: by 2002:a63:a5b:: with SMTP id z27mr8094397pgk.78.1551908709504; Wed, 06 Mar 2019 13:45:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551908709; cv=none; d=google.com; s=arc-20160816; b=ixVTxTmSGPBMjNW7bPnHt0yxnIvAtwZacSw3r0qIQbU6fAaHuRmWJ2akm3Q6utcDWC 8ojb/ucpc6zpGTfNfPWzFi/Yj+npsrvNw3lr4gjwjRnANZH97vkbzJUWmeDUk+PUDJLi lVooE2CE4VkTf3lJ+6sJPvwxcJ5/niZO7gM2K+cg5D6JLZ6Knf4idkj6PeKRF59VH0G7 kqpS9aG/owwq3C/D9OTj8lzC03drcfzRL8H31A+LVdmmJTSbT9DeOMLISC/bnvO52NS5 dJcnJI+48DNSJorqYxsxnw9QNa1C/oKkcCsQJpID4RU/U5fwLpcb77bCzo3bluNV24oD xj5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=zrjsZN/tQaUBfGIamX0028jOepi1+b2fBzSv1f+ywzc=; b=NTejXf/KxNaBfVXpRJ9wRu47DxBmaeJrx2EM1K56uLa0rPAwHzT3oz91QOGlKAyn5p xgvYKa90JQoUgBtIarvCK0IaTvkXIrdlxeZsuorS3CNC2lWDjY1h+kdntvZmHvsIyFLX 4hCh+/Dv2dNFd1XR7Gs2Uv47H84hxX5Zr+w3oV4N6DUmTMrpbppfLl4uLkAefcbJcXKD qj6qHfZczitVMe9svCYzXj4+UL2I3CqSm+rIrFDBHfHz1wOjo+F916thXoB/b76Su5Wc n6xc5ptepxg0QunnQQVBTfpPB10CCP0Qov776MtWNVu8tIZBG1Qb8dqJ28I1Q8KhiyBe hZZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=A87pgnHd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si2423484pfh.271.2019.03.06.13.44.53; Wed, 06 Mar 2019 13:45:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=A87pgnHd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbfCFVnR (ORCPT + 99 others); Wed, 6 Mar 2019 16:43:17 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:47167 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbfCFVnQ (ORCPT ); Wed, 6 Mar 2019 16:43:16 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 3A30222AB6; Wed, 6 Mar 2019 16:43:15 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 06 Mar 2019 16:43:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=zrjsZN/tQaUBfGIam X0028jOepi1+b2fBzSv1f+ywzc=; b=A87pgnHdfZXUgxMO6i4tyYFxMjqzIHhUa WPdF8e7NjX5bC4Po8+k7LLTWWByzaHhpxS0zRlntNH0KhwWSwIVT7Z09OE0rCMuL DR4ac/Dd5N0EGe543FJPdnGSP05bAKW52tjVU5ZkY9sCMp3VcY5YHJLqyK5Ja/So uxqBF+QYP2K3yfp3RjnHpneK+qiKUvKvy41BzKSJQ8gNZIffqGIow5RsmGulH1Ov JuyMEGR5qQ2TuZdrtEKk6EAyj+PfdCJxu3B6gFyqPvq1u99s02++6v5uFWBr0/4R DpAANHoyY0ACQXEgpAQ3vT4/sYMGW2oKpV7VANIrgX+ltlSXrnH4w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrfeeigdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhnucev rdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkphepud dvgedrudeiledrhedrudehkeenucfrrghrrghmpehmrghilhhfrhhomhepthhosghinhes khgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from eros.localdomain (124-169-5-158.dyn.iinet.net.au [124.169.5.158]) by mail.messagingengine.com (Postfix) with ESMTPA id 24849E4619; Wed, 6 Mar 2019 16:43:06 -0500 (EST) From: "Tobin C. Harding" To: Kees Cook , Shuah Khan Cc: "Tobin C. Harding" , Jann Horn , Andy Shevchenko , Randy Dunlap , Rasmus Villemoes , Stephen Rothwell , Andy Lutomirski , Daniel Micay , Arnd Bergmann , Miguel Ojeda , "Gustavo A. R. Silva" , Greg Kroah-Hartman , Alexander Shishkin , kernel-hardening@lists.openwall.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/7] lib/string: Add strscpy_pad() function Date: Thu, 7 Mar 2019 08:42:19 +1100 Message-Id: <20190306214226.14598-1-tobin@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, strscpy_pad() patch set now with added test shenanigans. This version adds 5 initial patches to the set and splits the single patch from v2 into two separate patches (6 and 7). While doing the testing for strscpy_pad() it was noticed that there is duplication in how test modules are being fed to kselftest and also in the test modules themselves. This set makes an attempt at adding a framework to kselftest for writing kernel test modules. It also adds a script for use in creating script test runners for kselftest. My macro-foo is not great, all criticism and suggestions very much appreciated. The design is based on test modules lib/test_printf.c, lib/test_bitmap.c, lib/test_xarray.c. Shua, I'm by no means a kselftest expert, if this approach does not fit in with your general direction please say so. Kees, I put the strscpy_pad() addition patch separate so if this goes in through Shua's tree (and if it goes in at all) its a single patch to grab if we want to start playing around with strscpy_pad(). Patch 1 fixes module unload for lib/test_printf in preparation for the rest of the series. Patch 2 Adds a shell script that can be used to create shell script test runners. Patch 3 Converts current shell script runners in tools/testing/selftests/lib/ to use the script introduced in patch 2. Patch 4 Adds the test framework by way of a header file (inc. documentation) Patch 5 Converts a couple of current test modules to make some use of the newly added test framework. Patch 6 Adds strscpy_pad() Patch 7 Adds test module for strscpy_pad() using the new framework and script. If you are a testing geek and you would like to play with this; if you are already running a kernel built recently from your tree you may want to just apply the first 5 patches then you don't need to build/boot a new kernel, just config and build the lib/ test modules (test_printf etc.) and then: sudo make TARGETS=lib kselftest Late in the development of this I found that a bunch of boiler plate had to be added to the script to handle running tests with: make O=/path/to/kout kselftest The reason is that during the build we are in the output directory but the script is in the source directory. I get the feeling that a better understanding of how the kernel build process works would provide a better solution to this. The current solution is disappointing since removing duplication and boiler plate was the point of the whole exercise. I'd love a better way to solve this? One final interesting note: there are 36 test modules in lib/ only 3 of them are run by kselftest from tools/testing/selfests/lib? Thanks for looking at this, Tobin. Tobin C. Harding (7): lib/test_printf: Add empty module_exit function kselftest: Add test runner creation script kselftest/lib: Use new shell runner to define tests kselftest: Add test module framework header lib: Use new kselftest header lib/string: Add strscpy_pad() function lib: Add test module for strscpy_pad Documentation/dev-tools/kselftest.rst | 108 ++++++++++++- include/linux/string.h | 4 + lib/Kconfig.debug | 3 + lib/Makefile | 1 + lib/string.c | 47 +++++- lib/test_bitmap.c | 20 +-- lib/test_printf.c | 17 +-- lib/test_strscpy.c | 150 +++++++++++++++++++ tools/testing/selftests/kselftest_module.h | 48 ++++++ tools/testing/selftests/kselftest_module.sh | 75 ++++++++++ tools/testing/selftests/lib/Makefile | 2 +- tools/testing/selftests/lib/bitmap.sh | 25 ++-- tools/testing/selftests/lib/config | 1 + tools/testing/selftests/lib/prime_numbers.sh | 23 ++- tools/testing/selftests/lib/printf.sh | 25 ++-- tools/testing/selftests/lib/strscpy.sh | 17 +++ 16 files changed, 490 insertions(+), 76 deletions(-) create mode 100644 lib/test_strscpy.c create mode 100644 tools/testing/selftests/kselftest_module.h create mode 100755 tools/testing/selftests/kselftest_module.sh create mode 100755 tools/testing/selftests/lib/strscpy.sh -- 2.20.1