[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210611164157.87AB4246@viggo.jf.intel.com>
Date: Fri, 11 Jun 2021 09:41:57 -0700
From: Dave Hansen <dave.hansen@...ux.intel.com>
To: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org,
Dave Hansen <dave.hansen@...ux.intel.com>, tglx@...utronix.de,
linuxram@...ibm.com, sandipan@...ux.ibm.com,
akpm@...ux-foundation.org, fweimer@...hat.com,
desnesn@...ux.vnet.ibm.com, mingo@...nel.org,
bauerman@...ux.ibm.com, aneesh.kumar@...ux.ibm.com,
mpe@...erman.id.au, mhocko@...nel.org, msuchanek@...e.de,
shuah@...nel.org, x86@...nel.org
Subject: [PATCH 2/4] selftests/vm/pkeys: Handle negative sys_pkey_alloc() return code
From: Dave Hansen <dave.hansen@...ux.intel.com>
The alloc_pkey() sefltest function wraps the sys_pkey_alloc() system
call. On success, it updates its "shadow" register value because
sys_pkey_alloc() updates the real register.
But, the success check is wrong. pkey_alloc() considers any
non-zero return code to indicate success where the pkey register
will be modified. This fails to take negative return codes into
account.
Consider only a positive return value as a successful call.
Fixes: 5f23f6d082a9 ("x86/pkeys: Add self-tests")
Reported-by: Thomas Gleixner <tglx@...utronix.de>
Signed-off-by: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Ram Pai <linuxram@...ibm.com>
Cc: Sandipan Das <sandipan@...ux.ibm.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Florian Weimer <fweimer@...hat.com>
Cc: "Desnes A. Nunes do Rosario" <desnesn@...ux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Thiago Jung Bauermann <bauerman@...ux.ibm.com>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>
Cc: Michael Ellerman <mpe@...erman.id.au>
Cc: Michal Hocko <mhocko@...nel.org>
Cc: Michal Suchanek <msuchanek@...e.de>
Cc: Shuah Khan <shuah@...nel.org>
Cc: x86@...nel.org
---
b/tools/testing/selftests/vm/protection_keys.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff -puN tools/testing/selftests/vm/protection_keys.c~selftests_vm_pkeys_ret-code tools/testing/selftests/vm/protection_keys.c
--- a/tools/testing/selftests/vm/protection_keys.c~selftests_vm_pkeys_ret-code 2021-06-11 09:41:32.448468063 -0700
+++ b/tools/testing/selftests/vm/protection_keys.c 2021-06-11 09:41:32.453468063 -0700
@@ -510,7 +510,7 @@ int alloc_pkey(void)
" shadow: 0x%016llx\n",
__func__, __LINE__, ret, __read_pkey_reg(),
shadow_pkey_reg);
- if (ret) {
+ if (ret > 0) {
/* clear both the bits: */
shadow_pkey_reg = set_pkey_bits(shadow_pkey_reg, ret,
~PKEY_MASK);
_
Powered by blists - more mailing lists