From patchwork Wed Jun 10 15:49:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11598187 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F9BE90 for ; Wed, 10 Jun 2020 15:50:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 564AC206C3 for ; Wed, 10 Jun 2020 15:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591804212; bh=fJXKd3vsVsiHq4HN5zcf+YrN0uorpWyT3caoSFBfyBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=NDaKK+b4iwISGkFhjr8CD1DaOyBhm7DVdxkFt9erElhRMNCgglvwBOUkzzOJZXQ1e JmKfzgfI14vLK5J9YmVuID8RGuMLBucYGkmID48/i/OzA8K8XRXgIQTt56hVqNDgPz zYVaR/7x4e/5HZRJ/pUfrB4PQ875gWdIKAE+szrI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728247AbgFJPt2 (ORCPT ); Wed, 10 Jun 2020 11:49:28 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46080 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbgFJPt1 (ORCPT ); Wed, 10 Jun 2020 11:49:27 -0400 Received: by mail-pl1-f195.google.com with SMTP id n2so1091036pld.13; Wed, 10 Jun 2020 08:49:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VaG7u6/oJsTeb5TEDlgcUeH6UZPnr3RsvPE6NVTbAOU=; b=LONDURJ+m34Rxt1zTQe26+zWI6iaGPKGUxgdfRPEybeVavviQUFyqeE3i56mvhOQCe dsyIkhS2WvRfkbIhtpyDJ+pshgtxrMFb+annPnC30/wNc81XpPA1fSZHycni4/DOIbmX 2eKf3ETss9jPM0WMumqHK/5efJVLrlLC2/S1HMN7mQEpmHuuAjTaw6oF9JUdYPiURw9/ t/h87jaU9/ZkyhpIcejulLPiWtGqO8gedYFjQdndyUx110UCQo50XaiLS7KJeWAsGFMI cQJ1y0F0arwIsTwRFX2INy+l3PZunoRN/5CVHAYwkGxAGnyosx7XNrHh3sn/IUn1bfrr UlrQ== X-Gm-Message-State: AOAM530qnyKN5H2P0PmV+ujZTW25xpAXAmyVtX+dYKbVTNR0Xlrqdo30 e5doaI8Z9A25Tr0DcfMqJqg= X-Google-Smtp-Source: ABdhPJzZoTl6eBSN8rqRCZozE//xcl2A2KM4BNx2Ocdpgf10NDUQ83ejBj8RMkeBJS9LOY1t52eKiw== X-Received: by 2002:a17:90a:21a2:: with SMTP id q31mr3700686pjc.230.1591804166854; Wed, 10 Jun 2020 08:49:26 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id p31sm252812pgb.46.2020.06.10.08.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 08:49:25 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 3872940B24; Wed, 10 Jun 2020 15:49:25 +0000 (UTC) From: "Luis R. Rodriguez" To: gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, axboe@kernel.dk, bfields@fieldses.org, chuck.lever@oracle.com, roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com, davem@davemloft.net, kuba@kernel.org, dhowells@redhat.com, jarkko.sakkinen@linux.intel.com, jmorris@namei.org, serge@hallyn.com, christian.brauner@ubuntu.com Cc: slyfox@gentoo.org, ast@kernel.org, keescook@chromium.org, josh@joshtriplett.org, ravenexp@gmail.com, chainsaw@gentoo.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, bridge@lists.linux-foundation.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Tiezhu Yang , Luis Chamberlain Subject: [PATCH 1/5] selftests: kmod: Use variable NAME in kmod_test_0001() Date: Wed, 10 Jun 2020 15:49:19 +0000 Message-Id: <20200610154923.27510-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200610154923.27510-1-mcgrof@kernel.org> References: <20200610154923.27510-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Tiezhu Yang Use the variable NAME instead of "\000" directly in kmod_test_0001(). Acked-by: Luis Chamberlain Signed-off-by: Tiezhu Yang Signed-off-by: Luis Chamberlain --- tools/testing/selftests/kmod/kmod.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kmod/kmod.sh b/tools/testing/selftests/kmod/kmod.sh index 3702dbcc90a7..da60c3bd4f23 100755 --- a/tools/testing/selftests/kmod/kmod.sh +++ b/tools/testing/selftests/kmod/kmod.sh @@ -341,7 +341,7 @@ kmod_test_0001_driver() kmod_defaults_driver config_num_threads 1 - printf '\000' >"$DIR"/config_test_driver + printf $NAME >"$DIR"/config_test_driver config_trigger ${FUNCNAME[0]} config_expect_result ${FUNCNAME[0]} MODULE_NOT_FOUND } @@ -352,7 +352,7 @@ kmod_test_0001_fs() kmod_defaults_fs config_num_threads 1 - printf '\000' >"$DIR"/config_test_fs + printf $NAME >"$DIR"/config_test_fs config_trigger ${FUNCNAME[0]} config_expect_result ${FUNCNAME[0]} -EINVAL } From patchwork Wed Jun 10 15:49:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11598181 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2129892A for ; Wed, 10 Jun 2020 15:50:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07FA5206F4 for ; Wed, 10 Jun 2020 15:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591804211; bh=p6i/IqPt79eKNWiJ/ilbD6VdrBxWjGYWZhum1eNHc/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Y7GXY3CjFC+Vxfmxat/59gFMIVj6JfZpyf7XwtasHChJFSgouxNVwcFqfI+MQniw4 V8Y+fcP9zb24yswMlm3ZpJTqveQlyZ0AVyZnz4v8wxst0ypNSebbRv/tW2WSvyV1h1 L18WgKkWMEnF1l0oYdUMGO7pPVzcR4JiRmYITIlo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730402AbgFJPuF (ORCPT ); Wed, 10 Jun 2020 11:50:05 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44741 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730336AbgFJPta (ORCPT ); Wed, 10 Jun 2020 11:49:30 -0400 Received: by mail-pf1-f193.google.com with SMTP id 64so1260190pfv.11; Wed, 10 Jun 2020 08:49:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CrxGEOGFjsdVHn3Jd9UDXtWDflxIQ5FEpiOYf5podJs=; b=K4vctIrodxtU656nnPd0chQXWRRECjOiTHcokQ3nwzufmTJH48yozHbRvOCQ0mTLJJ EAW/wqlgQC6svpjRJXD/iBd+JtHpxEoDFIFddPTD7nu7czb218EYL30ZZwnDdlrvPZMZ nkN/6xXB6y25bdJz3vybKfdQkWxz5Qwjeho3wGqDidMv+CGPw3POKKOg523eI5qtL7F0 oJxTImI5/M5rt+mNxX3mrfj1KBI1Fzcq0ccG9pLpKsY2+PKF1WJySJa9siG3vUxH8Vhp c/a8bjp/5ij6LRNdPBQSgdzpnb3n1r4SBQAajDTGpslv/Yh3iHCKVnurtp4OyPlt0ZG3 nzqg== X-Gm-Message-State: AOAM531W96+PUtpPQt5YADLaZqYLW3WxLAgYAxzLatPnsAM2QKs4i5qt fGuXMZgB65p5ABWhJHc8G9Q= X-Google-Smtp-Source: ABdhPJwXqgq7uS6Tcjx1SZx1Aww2/d5U2tI05GsSHHER7yozK95nSSwZLGkFi7ZnI4HAy3+k2OwCKQ== X-Received: by 2002:a63:ce14:: with SMTP id y20mr3147465pgf.186.1591804168526; Wed, 10 Jun 2020 08:49:28 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id c9sm302681pfp.100.2020.06.10.08.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 08:49:26 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 4CCCE40ED5; Wed, 10 Jun 2020 15:49:25 +0000 (UTC) From: "Luis R. Rodriguez" To: gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, axboe@kernel.dk, bfields@fieldses.org, chuck.lever@oracle.com, roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com, davem@davemloft.net, kuba@kernel.org, dhowells@redhat.com, jarkko.sakkinen@linux.intel.com, jmorris@namei.org, serge@hallyn.com, christian.brauner@ubuntu.com Cc: slyfox@gentoo.org, ast@kernel.org, keescook@chromium.org, josh@joshtriplett.org, ravenexp@gmail.com, chainsaw@gentoo.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, bridge@lists.linux-foundation.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Tiezhu Yang , Luis Chamberlain Subject: [PATCH 2/5] kmod: Remove redundant "be an" in the comment Date: Wed, 10 Jun 2020 15:49:20 +0000 Message-Id: <20200610154923.27510-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200610154923.27510-1-mcgrof@kernel.org> References: <20200610154923.27510-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Tiezhu Yang There exists redundant "be an" in the comment, remove it. Acked-by: Luis Chamberlain Signed-off-by: Tiezhu Yang Signed-off-by: Luis Chamberlain --- kernel/kmod.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/kmod.c b/kernel/kmod.c index 37c3c4b97b8e..3cd075ce2a1e 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c @@ -36,9 +36,8 @@ * * If you need less than 50 threads would mean we're dealing with systems * smaller than 3200 pages. This assumes you are capable of having ~13M memory, - * and this would only be an be an upper limit, after which the OOM killer - * would take effect. Systems like these are very unlikely if modules are - * enabled. + * and this would only be an upper limit, after which the OOM killer would take + * effect. Systems like these are very unlikely if modules are enabled. */ #define MAX_KMOD_CONCURRENT 50 static atomic_t kmod_concurrent_max = ATOMIC_INIT(MAX_KMOD_CONCURRENT); From patchwork Wed Jun 10 15:49:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11598147 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DFD91391 for ; Wed, 10 Jun 2020 15:49:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 351A22070B for ; Wed, 10 Jun 2020 15:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591804172; bh=lqkmGRLsCrqJLSBkfcGA1y6l9/8phOppP14+RBqy6FM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=npXo/2TQv6mH4h3DSdo3bxn5eHxsyWWuZwnL5atoor3Nn/8oeL3NDa77cSBOO3XSG +Hh0HoxTONgySBLnAE7hTqo5HK7tPmZikM3A9Vd28/J43guVMIN99+9ff0mU9pBpGm j+nT3n8oGuiFj9eSLrMd4eumGNp1MJwj+y+1iw4c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730340AbgFJPtb (ORCPT ); Wed, 10 Jun 2020 11:49:31 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33074 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbgFJPt3 (ORCPT ); Wed, 10 Jun 2020 11:49:29 -0400 Received: by mail-pg1-f193.google.com with SMTP id s10so1172047pgm.0; Wed, 10 Jun 2020 08:49:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qSIwN4KZGofFPlUal7btJTGNfkPGbkCJjMaiuCB3kq4=; b=idX9HP+xbdH5W0ymKxrXC5TgZruF6m/3aFicOX7DGbsOqw7iARid6WHbe7UFklwcN+ UTdizeWKK6JQ3BGDKSEoDT8efVyqudWIfDcNi6HYhppjzKka4OBhLSvyUSYj5/sgXg/Z 2X8VrNRK9AbhalAoYh/rs6LbVw2jNbWyNUldpkGjA1Zdpwpv25VQirAJ1E2yWtJWk+6o 2mlUnj8fcwp2wDwlLebwkGONyhxKkorTdy3YzbKt83cAw08TnZcvTKXhZNTKRFrld2D1 UmsIZQwEyBLtWp1nmdVrHDjIAoVEKRAi9uPi90aXUjBpsZF6fH5gOosehGgGCH/vEW4R AZYQ== X-Gm-Message-State: AOAM530jWXWIfpGEOMbrSHH+NLw0fxVgiKvMIHCdWUzrMIi24keGlo7J EvBMxk+nUl8vuxtKsq9lS1qppR0e/21v6w== X-Google-Smtp-Source: ABdhPJzQjKy64D7JAY2b9Df/J8XTTNXeIN4ec7JdMHHdnO0cu4EShFKvEj31fLfQzVASTIHoxJ1AIw== X-Received: by 2002:a62:4e91:: with SMTP id c139mr3418995pfb.18.1591804167551; Wed, 10 Jun 2020 08:49:27 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id 12sm338947pfb.3.2020.06.10.08.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 08:49:25 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 606C741C23; Wed, 10 Jun 2020 15:49:25 +0000 (UTC) From: "Luis R. Rodriguez" To: gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, axboe@kernel.dk, bfields@fieldses.org, chuck.lever@oracle.com, roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com, davem@davemloft.net, kuba@kernel.org, dhowells@redhat.com, jarkko.sakkinen@linux.intel.com, jmorris@namei.org, serge@hallyn.com, christian.brauner@ubuntu.com Cc: slyfox@gentoo.org, ast@kernel.org, keescook@chromium.org, josh@joshtriplett.org, ravenexp@gmail.com, chainsaw@gentoo.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, bridge@lists.linux-foundation.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Tiezhu Yang , Luis Chamberlain Subject: [PATCH 3/5] test_kmod: Avoid potential double free in trigger_config_run_type() Date: Wed, 10 Jun 2020 15:49:21 +0000 Message-Id: <20200610154923.27510-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200610154923.27510-1-mcgrof@kernel.org> References: <20200610154923.27510-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Tiezhu Yang Reset the member "test_fs" of the test configuration after a call of the function "kfree_const" to a null pointer so that a double memory release will not be performed. Fixes: d9c6a72d6fa2 ("kmod: add test driver to stress test the module loader") Acked-by: Luis Chamberlain Signed-off-by: Tiezhu Yang Signed-off-by: Luis Chamberlain --- lib/test_kmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_kmod.c b/lib/test_kmod.c index e651c37d56db..eab52770070d 100644 --- a/lib/test_kmod.c +++ b/lib/test_kmod.c @@ -745,7 +745,7 @@ static int trigger_config_run_type(struct kmod_test_device *test_dev, break; case TEST_KMOD_FS_TYPE: kfree_const(config->test_fs); - config->test_driver = NULL; + config->test_fs = NULL; copied = config_copy_test_fs(config, test_str, strlen(test_str)); break; From patchwork Wed Jun 10 15:49:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11598157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F56813B1 for ; Wed, 10 Jun 2020 15:49:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 624E6206C3 for ; Wed, 10 Jun 2020 15:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591804199; bh=pjY7spR70EH/xQNoAxXjwLQQ7Kuhz4SZIi8IRGuz7is=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=kv1detwggCqXY/Z9DgWP/o9xousBPYgS+BsMFiUc8iCYDLO7+f4kJsCaf0GyQbFDL yBgeDpYFnWBVrBo3LjQph81NJ4p5p2Eg3emH/TY2Tfq9u+zJus7mymVVWyxEZQz2V6 Jugz4IQbtMRB4CJ/7gGbDEHHibC1P/ZpMqxuzxrk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730386AbgFJPto (ORCPT ); Wed, 10 Jun 2020 11:49:44 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:43773 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbgFJPtf (ORCPT ); Wed, 10 Jun 2020 11:49:35 -0400 Received: by mail-pf1-f193.google.com with SMTP id 23so1262530pfw.10; Wed, 10 Jun 2020 08:49:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ttnu+GumEeK2dxlrXFIgjuU2z6ZpHty3fj6TVLOpBV8=; b=sM6bANWh4UjbXp03MJVOonzPUWXJlh2cXCu4Eq+CQLYBsKyBGbFEuO1abWEJum4E59 n3DEQEDt9il0AQvgI78hNAK6CzURvBZhH2LV2hupGFEI+Bs/WuGVY2FNBppfjrzHQqDg k6S8wjB/x6+bu8qOTLi5TzGYhZ672/omdQj5D5gf9PSU23CxChJc5kBrjF1+gI13RsIc QUaki2Cizke7yAJ6KYsbKcfrfVi9D/rL5Nee5epN09GfON9ilm8LFZOF/GRfTA8zfP8j RDKAtTou/jbGTQbXIyQ5qtKrXChSxiC+m29j9119is39vItLOw9Im2DVKc/bf/7WGiTn 51kQ== X-Gm-Message-State: AOAM531haJWhUwKdzAPQDlLvMnPw81llEjMgb57CwRHPEyM4UeWK66rN ++T4fK60DEZpomwDQKEj40Q= X-Google-Smtp-Source: ABdhPJy4BST5Ypqj52/eoac8mQmWFwF6I7vWpY7xXXn85YwjFOb1Y0c/dkStnzo1uFPTe0w13h7IUw== X-Received: by 2002:a63:58d:: with SMTP id 135mr3011251pgf.2.1591804173617; Wed, 10 Jun 2020 08:49:33 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id w65sm272528pfb.160.2020.06.10.08.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 08:49:26 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 7148441D95; Wed, 10 Jun 2020 15:49:25 +0000 (UTC) From: "Luis R. Rodriguez" To: gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, axboe@kernel.dk, bfields@fieldses.org, chuck.lever@oracle.com, roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com, davem@davemloft.net, kuba@kernel.org, dhowells@redhat.com, jarkko.sakkinen@linux.intel.com, jmorris@namei.org, serge@hallyn.com, christian.brauner@ubuntu.com Cc: slyfox@gentoo.org, ast@kernel.org, keescook@chromium.org, josh@joshtriplett.org, ravenexp@gmail.com, chainsaw@gentoo.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, bridge@lists.linux-foundation.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain , Tiezhu Yang Subject: [PATCH 4/5] umh: fix processed error when UMH_WAIT_PROC is used Date: Wed, 10 Jun 2020 15:49:22 +0000 Message-Id: <20200610154923.27510-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200610154923.27510-1-mcgrof@kernel.org> References: <20200610154923.27510-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Luis Chamberlain When UMH_WAIT_PROC is used we call kernel_wait4(). This is the *only* place in the kernel where we actually inspect the error code. Prior to this patch we returned the value from the wait call, and that technically requires us to use wrappers such as WEXITSTATUS(). We either fix all callers to start using WEXITSTATUS() and friends *or* we do address this within the umh code and let the callers get the actual error code. The way we use kernel_wait4() on the umh is with the options set to 0, and when this is done the wait call only waits for terminated children. Because of this, there is no point to complicate checks for the umh with W*() calls. That would make the checks complex, redundant, and simply not needed. By making the umh do the checks for us we keep users kernel_wait4() at bay, and promote avoiding introduction of further W*() macros and the complexities this can bring. There were only a few callers which properly checked for the error status using open-coded solutions. We remove them as they are no longer needed, and also remove open coded implicit uses of W*() uses which should never trigger given that the options passed to wait is 0. The only helpers we really need are for termination, so we just include those, and we prefix our W*() helpers with K. Since all this does is *correct* an error code, if one was found, this change only fixes reporting the *correct* error, and there are two places where this matters, and which this patch fixes: * request_module() used to fail with an error code of 256 when a module was not found. Now it properly returns 1. * fs/nfsd/nfs4recover.c: we never were disabling the upcall as the error code of -ENOENT or -EACCES was *never* properly checked for. Reported-by: Tiezhu Yang Signed-off-by: Luis Chamberlain --- drivers/block/drbd/drbd_nl.c | 20 ++++++++------------ fs/nfsd/nfs4recover.c | 2 +- include/linux/sched/task.h | 13 +++++++++++++ kernel/umh.c | 4 ++-- net/bridge/br_stp_if.c | 10 ++-------- security/keys/request_key.c | 2 +- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index da4a3ebe04ef..aee272e620b9 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -382,13 +382,11 @@ int drbd_khelper(struct drbd_device *device, char *cmd) notify_helper(NOTIFY_CALL, device, connection, cmd, 0); ret = call_usermodehelper(drbd_usermode_helper, argv, envp, UMH_WAIT_PROC); if (ret) - drbd_warn(device, "helper command: %s %s %s exit code %u (0x%x)\n", - drbd_usermode_helper, cmd, mb, - (ret >> 8) & 0xff, ret); + drbd_warn(device, "helper command: %s %s %s failed with exit code %u (0x%x)\n", + drbd_usermode_helper, cmd, mb, ret, ret); else - drbd_info(device, "helper command: %s %s %s exit code %u (0x%x)\n", - drbd_usermode_helper, cmd, mb, - (ret >> 8) & 0xff, ret); + drbd_info(device, "helper command: %s %s %s completed successfully\n", + drbd_usermode_helper, cmd, mb); sib.sib_reason = SIB_HELPER_POST; sib.helper_exit_code = ret; drbd_bcast_event(device, &sib); @@ -424,13 +422,11 @@ enum drbd_peer_state conn_khelper(struct drbd_connection *connection, char *cmd) ret = call_usermodehelper(drbd_usermode_helper, argv, envp, UMH_WAIT_PROC); if (ret) - drbd_warn(connection, "helper command: %s %s %s exit code %u (0x%x)\n", - drbd_usermode_helper, cmd, resource_name, - (ret >> 8) & 0xff, ret); + drbd_warn(connection, "helper command: %s %s %s failed with exit code %u (0x%x)\n", + drbd_usermode_helper, cmd, resource_name, ret, ret); else - drbd_info(connection, "helper command: %s %s %s exit code %u (0x%x)\n", - drbd_usermode_helper, cmd, resource_name, - (ret >> 8) & 0xff, ret); + drbd_info(connection, "helper command: %s %s %s completed successfully\n", + drbd_usermode_helper, cmd, resource_name); /* TODO: conn_bcast_event() ?? */ notify_helper(NOTIFY_RESPONSE, NULL, connection, cmd, ret); diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 9e40dfecf1b1..33e6a7fd7961 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -1820,7 +1820,7 @@ nfsd4_umh_cltrack_upcall(char *cmd, char *arg, char *env0, char *env1) ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC); /* - * Disable the upcall mechanism if we're getting an ENOENT or EACCES + * Disable the upcall mechanism if we're getting an -ENOENT or -EACCES * error. The admin can re-enable it on the fly by using sysfs * once the problem has been fixed. */ diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h index 38359071236a..bba06befbff5 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -103,6 +103,19 @@ struct mm_struct *copy_init_mm(void); extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); extern long kernel_wait4(pid_t, int __user *, int, struct rusage *); +/* Only add helpers for actual use cases in the kernel */ +#define KWEXITSTATUS(status) (__KWEXITSTATUS(status)) +#define KWIFEXITED(status) (__KWIFEXITED(status)) + +/* Nonzero if STATUS indicates normal termination. */ +#define __KWIFEXITED(status) (__KWTERMSIG(status) == 0) + +/* If KWIFEXITED(STATUS), the low-order 8 bits of the status. */ +#define __KWEXITSTATUS(status) (((status) & 0xff00) >> 8) + +/* If KWIFSIGNALED(STATUS), the terminating signal. */ +#define __KWTERMSIG(status) ((status) & 0x7f) + extern void free_task(struct task_struct *tsk); /* sched_exec is called by processes performing an exec */ diff --git a/kernel/umh.c b/kernel/umh.c index 79f139a7ca03..f81e8698e36e 100644 --- a/kernel/umh.c +++ b/kernel/umh.c @@ -154,8 +154,8 @@ static void call_usermodehelper_exec_sync(struct subprocess_info *sub_info) * the real error code is already in sub_info->retval or * sub_info->retval is 0 anyway, so don't mess with it then. */ - if (ret) - sub_info->retval = ret; + if (KWIFEXITED(ret)) + sub_info->retval = KWEXITSTATUS(ret); } /* Restore default kernel sig handler */ diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c index ba55851fe132..bdd94b45396b 100644 --- a/net/bridge/br_stp_if.c +++ b/net/bridge/br_stp_if.c @@ -133,14 +133,8 @@ static int br_stp_call_user(struct net_bridge *br, char *arg) /* call userspace STP and report program errors */ rc = call_usermodehelper(BR_STP_PROG, argv, envp, UMH_WAIT_PROC); - if (rc > 0) { - if (rc & 0xff) - br_debug(br, BR_STP_PROG " received signal %d\n", - rc & 0x7f); - else - br_debug(br, BR_STP_PROG " exited with code %d\n", - (rc >> 8) & 0xff); - } + if (rc != 0) + br_debug(br, BR_STP_PROG " failed with exit code %d\n", rc); return rc; } diff --git a/security/keys/request_key.c b/security/keys/request_key.c index e1b9f1a80676..ff462f3d46ca 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c @@ -193,7 +193,7 @@ static int call_sbin_request_key(struct key *authkey, void *aux) ret = call_usermodehelper_keys(request_key, argv, envp, keyring, UMH_WAIT_PROC); kdebug("usermode -> 0x%x", ret); - if (ret >= 0) { + if (ret != 0) { /* ret is the exit/wait code */ if (test_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags) || key_validate(key) < 0) From patchwork Wed Jun 10 15:49:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11598153 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7365492A for ; Wed, 10 Jun 2020 15:49:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B5352072F for ; Wed, 10 Jun 2020 15:49:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591804185; bh=9m16IR+6N55Eqvqofrw6QBfEO4rIFvzaCGchbnRQNq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=I2Y9B/gYlS7lvY1hqdCdnjIs8F5FdoqKEYXxJ1EW4SQ3XV3i1iK6IRKKBJAtDfstN iKxks9+mo/WdA2KY+JhH+YnxMn/ydIz/Bykil5Dav1FvHoWSd+EbtgZJ4GOXjmeSlZ Z0EbKtXo7MOkJ0zRuZXgnzNWMEKE/RMGHYv1o2KU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730381AbgFJPto (ORCPT ); Wed, 10 Jun 2020 11:49:44 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40841 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730357AbgFJPtf (ORCPT ); Wed, 10 Jun 2020 11:49:35 -0400 Received: by mail-pg1-f193.google.com with SMTP id e18so1158407pgn.7; Wed, 10 Jun 2020 08:49:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ht44Q655K+m4n+7cL9U0d/GUBshFxQzLVevKrr2oj0M=; b=UeqiLKBwMMpyNhNwyNWB86Wi4G23QdyqZIvrfKNvXCnjX0MSKPxC0GkslMg6lAC3qU fp8mdqtqt9AQjAopXVIjoMS5oV3iuz4ExE6TaMwMCNsJIj4bAcdxiRR2SwnDzcg2TjUq vUw7niJXVFqD/tZJEB7tyzvOKUmP/YBUpisgVDOQDfvZAdtkyvC1OCkaWv6w0u0M7+Gc Mnkan/ZlrweFcXRosYrGOqjGu7bb2Chs1oCFClRt5Z1obrT/ZZSz/T8aI2qlIZ2ugVjI 8XxlXgaWm+3TkEsJZz/GQMC/zs2YzKRbMInW6WMOjLMCjC2Ob10j0D0i6TzeTAb5Oggm dvww== X-Gm-Message-State: AOAM533MKh2QjOo+0rCUCt2jr997ZQB1CEd6L3c1F9OM6kQPeT+KWaVr QBQ9cbkSCL5kHVIIP65uNQM= X-Google-Smtp-Source: ABdhPJy5SAdyQfQNoaTz3plQH9NsEWiOAvKCXruBaMt6+7nC5TCy5/CdN/0cXMcdcKFyT5YHNMINbw== X-Received: by 2002:a62:7a89:: with SMTP id v131mr3246047pfc.38.1591804174942; Wed, 10 Jun 2020 08:49:34 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id m15sm247162pgv.45.2020.06.10.08.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 08:49:33 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 94C9741DD1; Wed, 10 Jun 2020 15:49:25 +0000 (UTC) From: "Luis R. Rodriguez" To: gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, axboe@kernel.dk, bfields@fieldses.org, chuck.lever@oracle.com, roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com, davem@davemloft.net, kuba@kernel.org, dhowells@redhat.com, jarkko.sakkinen@linux.intel.com, jmorris@namei.org, serge@hallyn.com, christian.brauner@ubuntu.com Cc: slyfox@gentoo.org, ast@kernel.org, keescook@chromium.org, josh@joshtriplett.org, ravenexp@gmail.com, chainsaw@gentoo.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, bridge@lists.linux-foundation.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain , Tiezhu Yang Subject: [PATCH 5/5] selftests: simplify kmod failure value Date: Wed, 10 Jun 2020 15:49:23 +0000 Message-Id: <20200610154923.27510-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200610154923.27510-1-mcgrof@kernel.org> References: <20200610154923.27510-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Luis Chamberlain The "odd" 256 value was just an issue with the umh never wrapping it around with WEXITSTATUS() for us. Now that it does that, we can use a sane value / name for the selftest, and this is no longer a oddity. We add a way to detect this for older kernels, and support the old return value for kernel code where it was given. This never affected userspace. Reported-by: Tiezhu Yang Signed-off-by: Luis Chamberlain --- tools/testing/selftests/kmod/kmod.sh | 46 +++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/kmod/kmod.sh b/tools/testing/selftests/kmod/kmod.sh index da60c3bd4f23..df7b21d8561c 100755 --- a/tools/testing/selftests/kmod/kmod.sh +++ b/tools/testing/selftests/kmod/kmod.sh @@ -64,6 +64,8 @@ ALL_TESTS="$ALL_TESTS 0009:150:1" ALL_TESTS="$ALL_TESTS 0010:1:1" ALL_TESTS="$ALL_TESTS 0011:1:1" +MODULE_NOT_FOUND="FAILURE" + # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 @@ -155,14 +157,19 @@ test_finish() echo "Test completed" } +# OLD_FAILURE is just because the old kernel umh never wrapped +# the error with WEXITSTATUS(). Now that it does it, we get the +# appropriate actual value from userspace observed in-kernel. + +# We keep the old mapping to ensure this script keeps working +# with older kernels. errno_name_to_val() { case "$1" in - # kmod calls modprobe and upon of a module not found - # modprobe returns just 1... However in the kernel we - # *sometimes* see 256... - MODULE_NOT_FOUND) + OLD_FAILURE) echo 256;; + FAILURE) + echo 1;; SUCCESS) echo 0;; -EPERM) @@ -181,7 +188,9 @@ errno_name_to_val() errno_val_to_name() case "$1" in 256) - echo MODULE_NOT_FOUND;; + echo OLD_FAILURE;; + 1) + echo FAILURE;; 0) echo SUCCESS;; -1) @@ -335,6 +344,28 @@ kmod_defaults_fs() config_set_test_case_fs } +check_umh() +{ + NAME='' + + kmod_defaults_driver + config_num_threads 1 + printf '\0' >"$DIR"/config_test_driver + config_trigger ${FUNCNAME[0]} + RC=$(config_get_test_result) + if [[ "$RC" == "256" ]]; then + MODULE_NOT_FOUND="OLD_FAILURE" + echo "check_umh: you have and old umh which didn't wrap errors" + echo " with WEXITSTATUS(). This is OK!" + elif [[ "$RC" != "1" ]]; then + echo "check_umh: Unexpected return value with no modprobe argument: $RC" + exit + else + echo "check_umh: You have a new umh which wraps erros with" + echo " WEXITSTATUS(). This is OK!" + fi +} + kmod_test_0001_driver() { NAME='\000' @@ -343,7 +374,7 @@ kmod_test_0001_driver() config_num_threads 1 printf $NAME >"$DIR"/config_test_driver config_trigger ${FUNCNAME[0]} - config_expect_result ${FUNCNAME[0]} MODULE_NOT_FOUND + config_expect_result ${FUNCNAME[0]} $MODULE_NOT_FOUND } kmod_test_0001_fs() @@ -371,7 +402,7 @@ kmod_test_0002_driver() config_set_driver $NAME config_num_threads 1 config_trigger ${FUNCNAME[0]} - config_expect_result ${FUNCNAME[0]} MODULE_NOT_FOUND + config_expect_result ${FUNCNAME[0]} $MODULE_NOT_FOUND } kmod_test_0002_fs() @@ -648,6 +679,7 @@ load_req_mod MODPROBE=$(