Skip to content

Commit d12fe87

Browse files
committed
signal/testing: Don't look for __SI_FAULT in userspace
Fix the debug print statements in these tests where they reference si_codes and in particular __SI_FAULT. __SI_FAULT is a kernel internal value and should never be seen by userspace. While I am in there also fix si_code_str. si_codes are an enumeration there are not a bitmap so == and not & is the apropriate operation to test for an si_code. Cc: Dave Hansen <[email protected]> Fixes: 5f23f6d ("x86/pkeys: Add self-tests") Fixes: e754aed ("x86/mpx, selftests: Add MPX self test") Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent ea1b75c commit d12fe87

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

tools/testing/selftests/x86/mpx-mini-test.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,7 @@ void handler(int signum, siginfo_t *si, void *vucontext)
391391
br_count++;
392392
dprintf1("#BR 0x%jx (total seen: %d)\n", status, br_count);
393393

394-
#define __SI_FAULT (3 << 16)
395-
#define SEGV_BNDERR (__SI_FAULT|3) /* failed address bound checks */
394+
#define SEGV_BNDERR 3 /* failed address bound checks */
396395

397396
dprintf2("Saw a #BR! status 0x%jx at %016lx br_reason: %jx\n",
398397
status, ip, br_reason);

tools/testing/selftests/x86/protection_keys.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,18 @@ void dump_mem(void *dumpme, int len_bytes)
212212
}
213213
}
214214

215-
#define __SI_FAULT (3 << 16)
216-
#define SEGV_BNDERR (__SI_FAULT|3) /* failed address bound checks */
217-
#define SEGV_PKUERR (__SI_FAULT|4)
215+
#define SEGV_BNDERR 3 /* failed address bound checks */
216+
#define SEGV_PKUERR 4
218217

219218
static char *si_code_str(int si_code)
220219
{
221-
if (si_code & SEGV_MAPERR)
220+
if (si_code == SEGV_MAPERR)
222221
return "SEGV_MAPERR";
223-
if (si_code & SEGV_ACCERR)
222+
if (si_code == SEGV_ACCERR)
224223
return "SEGV_ACCERR";
225-
if (si_code & SEGV_BNDERR)
224+
if (si_code == SEGV_BNDERR)
226225
return "SEGV_BNDERR";
227-
if (si_code & SEGV_PKUERR)
226+
if (si_code == SEGV_PKUERR)
228227
return "SEGV_PKUERR";
229228
return "UNKNOWN";
230229
}

0 commit comments

Comments
 (0)