Reproducer for the landlock houdini bug
v2 cover Reproducer for the landlock houdini bug
More information at:
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-42318
---
Changes in v2:
- add SAFE_KEYCTL macro
- verify in setup that landlock is activated
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Andrea Cervesato (2):
Add SAFE_KEYCTL macro
Add landlock07 test
include/lapi/keyctl.h | 26 +++++- runtest/syscalls | 1 + testcases/kernel/syscalls/landlock/.gitignore | 1 + testcases/kernel/syscalls/landlock/landlock07.c | 109 ++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 1 deletion(-)
---
base-commit: edc79222abdcf32a344c806275a30a5c7cbf1ef3
change-id: 20240820-landlock_houdini-f244f52e87c3
Best regards,
Signature · 1 line
Andrea Cervesato <[email protected]>
PATCH v2 1/2 Add SAFE_KEYCTL macro
From: Andrea Cervesato <[email protected]>
--- include/lapi/keyctl.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
include/lapi/keyctl.h +25 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-or-later /* -* Copyright (c) 2017 Cyril Hrubis <[email protected]> +* Ccmdyright (c) 2017 Cyril Hrubis <[email protected]> */ #ifndef LAPI_KEYCTL_H__
@@ -179,4 +179,28 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {# define KEY_OTH_ALL 0x0000003f#endif /* !KEY_POS_VIEW */ +static inline long safe_keyctl (const char *file,const int lineno, +int cmd,unsigned long arg2,unsigned long arg3, +unsigned long arg4,unsigned long arg5) +{ +long rval; + + rval =keyctl (cmd, arg2, arg3, arg4, arg5); +if (rval ==-1 ) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"keyctl(%d, %lu, %lu, %lu, %lu)" , + cmd, arg2, arg3, arg4, arg5); + }else if (rval <0 ) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"Invalid keyctl(%d, %lu, %lu, %lu, %lu) " +"return value %ld" , + cmd, arg2, arg3, arg4, arg5, rval); + } + +return rval; +} +#define SAFE_KEYCTL (cmd, arg2, arg3, arg4, arg5) \ + safe_keyctl(__FILE__, __LINE__, \ + (cmd), (arg2), (arg3), (arg4), (arg5)) +#endif /* LAPI_KEYCTL_H__ */
Signature · 1 line
2.43.0
Re: [LTP] [PATCH v2 1/2] Add SAFE_KEYCTL macro
Hi!
Quoted 4 lines
// SPDX-License-Identifier: GPL-2.0-or-later /*
- * Copyright (c) 2017 Cyril Hrubis <[email protected]>
+ * Ccmdyright (c) 2017 Cyril Hrubis <[email protected]>
I suppose that you did replace op with cmd and corrupted this line.
include/lapi/keyctl.h static inline key_serial_t keyctl_join_session_keyring(const char *name) { · line 184
Quoted 10 lines
*/
#ifndef
LAPI_KEYCTL_H__include/lapi/keyctl.h +3
-0@@ -179,4 +179,28 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {# define KEY_OTH_ALL 0x0000003f#endif /* !KEY_POS_VIEW */ +static inline long safe_keyctl (const char *file,const int lineno, +int cmd,unsigned long arg2,unsigned long arg3, +unsigned long arg4,unsigned long arg5)
^ trailing whitespaces
Quoted 4 lines
include/lapi/keyctl.h +4
-0+{ +long rval; + + rval =keyctl (cmd, arg2, arg3, arg4, arg5);
include/lapi/keyctl.h static inline key_serial_t keyctl_join_session_keyring(const char *name) { · line 198
Quoted 10 lines
include/lapi/keyctl.h +10
-0+if (rval ==-1 ) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"keyctl(%d, %lu, %lu, %lu, %lu)" , + cmd, arg2, arg3, arg4, arg5); + }else if (rval <0 ) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"Invalid keyctl(%d, %lu, %lu, %lu, %lu) " +"return value %ld" , + cmd, arg2, arg3, arg4, arg5, rval); + }
Looking at man 2 keyctl() we should fail for non-zero return value for most of the operations but the ones listed in RETURN VALUE paragraph.
Quoted 14 lines
include/lapi/keyctl.h +6
-0+ return rval; +} +#define SAFE_KEYCTL (cmd, arg2, arg3, arg4, arg5) \ + safe_keyctl(__FILE__, __LINE__, \ + (cmd), (arg2), (arg3), (arg4), (arg5)) +#endif /* LAPI_KEYCTL_H__ */ Signature · 6 lines
-- 2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 2/2 Add landlock07 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
This test is a reproducer for the CVE-2024-42318 bug, also known as landlock Houdini.
More information at:
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-42318
--- runtest/syscalls | 1 + testcases/kernel/syscalls/landlock/.gitignore | 1 + testcases/kernel/syscalls/landlock/landlock07.c | 109 ++++++++++++++++++++++++ 3 files changed, 111 insertions(+)
runtest/syscalls +1 -0
@@ -706,6 +706,7 @@ landlock03 landlock03 landlock04 landlock04 landlock05 landlock05 landlock06 landlock06 +landlock07 landlock07 lchown01 lchown01 lchown01_16 lchown01_16
testcases/kernel/syscalls/landlock/.gitignore +1 -0
@@ -5,3 +5,4 @@ landlock03 landlock04 landlock05 landlock06 +landlock07
testcases/kernel/syscalls/landlock/landlock07.c new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.43.0