From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754079AbdFWPzQ (ORCPT ); Fri, 23 Jun 2017 11:55:16 -0400 Received: from resqmta-po-08v.sys.comcast.net ([96.114.154.167]:48884 "EHLO resqmta-po-08v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753447AbdFWPzO (ORCPT ); Fri, 23 Jun 2017 11:55:14 -0400 Reply-To: shuah@kernel.org Subject: Re: [PATCH V3] tools/testing/selftests/sysctl: Add pre-check to the value of writes_strict To: Orson Zhai , Kees Cook Cc: LKML , Sumit Semwal , linux-kselftest@vger.kernel.org, Shuah Khan References: From: Shuah Khan Message-ID: <1bc754dd-26e0-e88e-7db8-29509c763d69@kernel.org> Date: Fri, 23 Jun 2017 09:55:12 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfNFVtjcwKDfzxRTfQ9ItPKcNYLqsfLrJx59OeYB+C0D5wBkzceZui5Gxy/ruNy2lSca4VW4HCQdDjFdEa0it2nYtPB9IJxSE5I5D75XnzIpsYslPTgGc YZT7e4Z171NPahW8VUxRuMYy9Rp+QIdEc2Xo2jD8Jhl3bW4zpnryIjpsN8ayuvNtUg+hV3HViBfS25vhhXs6OVrWsxmAMbjiidBVqy91FZfeqIREdZXCYN73 c52sEpN2Gs3R6vD+gXXFl3NwO/bOF+Mhv2kvozhRtxmyynNTb5xFC8/6VztAC6suoDGXdJ+m906+SIj5+fo4m6t+TLB3RQ3kVUdfYKLTc8rzulrlRpUpUGOa /Ws/FbHQ Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Orson, On 06/22/2017 10:24 PM, Orson Zhai wrote: > Sysctl test will fail in some items if the value of /proc/sys/kernel > /sysctrl_writes_strict is 0 as the default value in kernel older than v4.5. > > Make this test more robust and compatible with older kernels by checking and > update sysctrl_writes_strict value and restore it when test is done. > > Signed-off-by: Orson Zhai > Reviewed-by: Sumit Semwal > Tested-by: Sumit Semwal This patch failed to apply on linux-kselftest next. Could you please rebase and send it. thanks, -- Shuah > --- > tools/testing/selftests/sysctl/common_tests | 22 ++++++++++++++++++++++ > tools/testing/selftests/sysctl/run_numerictests | 2 +- > tools/testing/selftests/sysctl/run_stringtests | 2 +- > 3 files changed, 24 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/sysctl/common_tests > b/tools/testing/selftests/sysctl/common_tests > index 17d534b1b7b4..dfb1fcfc3142 100644 > --- a/tools/testing/selftests/sysctl/common_tests > +++ b/tools/testing/selftests/sysctl/common_tests > @@ -24,6 +24,14 @@ verify() > return 0 > } > > +exit_test() > +{ > + if [ ! -z ${old_strict} ]; then > + echo ${old_strict} > ${WRITES_STRICT} > + fi > + exit $rc > +} > + > trap 'set_orig; rm -f "${TEST_FILE}"' EXIT > > rc=0 > @@ -63,6 +71,20 @@ else > echo "ok" > fi > > +echo -n "Checking write strict setting ... " > +WRITES_STRICT="${SYSCTL}/kernel/sysctl_writes_strict" > +if [ ! -e ${WRITES_STRICT} ]; then > + echo "FAIL, but skip in case of old kernel" >&2 > +else > + old_strict=$(cat ${WRITES_STRICT}) > + if [ "$old_strict" = "1" ]; then > + echo "ok" > + else > + echo "FAIL, strict value is 0 but force to 1 to continue" >&2 > + echo "1" > ${WRITES_STRICT} > + fi > +fi > + > # Now that we've validated the sanity of "set_test" and "set_orig", > # we can use those functions to set starting states before running > # specific behavioral tests. > diff --git a/tools/testing/selftests/sysctl/run_numerictests > b/tools/testing/selftests/sysctl/run_numerictests > index 8510f93f2d14..e6e76c93d948 100755 > --- a/tools/testing/selftests/sysctl/run_numerictests > +++ b/tools/testing/selftests/sysctl/run_numerictests > @@ -7,4 +7,4 @@ TEST_STR=$(( $ORIG + 1 )) > > . ./common_tests > > -exit $rc > +exit_test > diff --git a/tools/testing/selftests/sysctl/run_stringtests > b/tools/testing/selftests/sysctl/run_stringtests > index 90a9293d520c..857ec667fb02 100755 > --- a/tools/testing/selftests/sysctl/run_stringtests > +++ b/tools/testing/selftests/sysctl/run_stringtests > @@ -74,4 +74,4 @@ else > echo "ok" > fi > > -exit $rc > +exit_test > -- > 2.12.2 > >