Message ID | 20230828150858.393570-4-revest@chromium.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | MDWE without inheritance | expand |
On Mon, Aug 28, 2023 at 05:08:55PM +0200, Florent Revest wrote: > Invalid prctls return a negative code and set errno. It's good practice > to check that errno is set as expected. > > Signed-off-by: Florent Revest <revest@chromium.org> Thanks! Reviewed-by: Kees Cook <keescook@chromium.org>
On Mon, Aug 28, 2023 at 05:08:55PM +0200, Florent Revest wrote: > Invalid prctls return a negative code and set errno. It's good practice > to check that errno is set as expected. > > Signed-off-by: Florent Revest <revest@chromium.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com>
diff --git a/tools/testing/selftests/mm/mdwe_test.c b/tools/testing/selftests/mm/mdwe_test.c index 91aa9c3099e7..1b84cf8e1bbe 100644 --- a/tools/testing/selftests/mm/mdwe_test.c +++ b/tools/testing/selftests/mm/mdwe_test.c @@ -23,14 +23,22 @@ TEST(prctl_flags) { EXPECT_LT(prctl(PR_SET_MDWE, 7L, 0L, 0L, 0L), 0); + EXPECT_EQ(errno, EINVAL); EXPECT_LT(prctl(PR_SET_MDWE, 0L, 7L, 0L, 0L), 0); + EXPECT_EQ(errno, EINVAL); EXPECT_LT(prctl(PR_SET_MDWE, 0L, 0L, 7L, 0L), 0); + EXPECT_EQ(errno, EINVAL); EXPECT_LT(prctl(PR_SET_MDWE, 0L, 0L, 0L, 7L), 0); + EXPECT_EQ(errno, EINVAL); EXPECT_LT(prctl(PR_GET_MDWE, 7L, 0L, 0L, 0L), 0); + EXPECT_EQ(errno, EINVAL); EXPECT_LT(prctl(PR_GET_MDWE, 0L, 7L, 0L, 0L), 0); + EXPECT_EQ(errno, EINVAL); EXPECT_LT(prctl(PR_GET_MDWE, 0L, 0L, 7L, 0L), 0); + EXPECT_EQ(errno, EINVAL); EXPECT_LT(prctl(PR_GET_MDWE, 0L, 0L, 0L, 7L), 0); + EXPECT_EQ(errno, EINVAL); } FIXTURE(mdwe)
Invalid prctls return a negative code and set errno. It's good practice to check that errno is set as expected. Signed-off-by: Florent Revest <revest@chromium.org> --- tools/testing/selftests/mm/mdwe_test.c | 8 ++++++++ 1 file changed, 8 insertions(+)