linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] security: keys: add __randomize_layout to keyring_search_context
@ 2022-05-18  9:18 GONG, Ruiqi
  2022-05-18 20:25 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: GONG, Ruiqi @ 2022-05-18  9:18 UTC (permalink / raw)
  To: David Howells, Jarkko Sakkinen, James Morris, Serge E . Hallyn,
	Kees Cook
  Cc: keyrings, linux-security-module, linux-kernel, Wang Weiyang,
	Xiu Jianfeng, gongruiqi1

Struct keyring_search_context contains a pointer to `struct cred`, which
is a security-critical structure and whose layout is randomized already.
Apply __randomize_layout to struct keyring_search_context as well, as
suggested in [1].

[1]: https://github.com/KSPP/linux/issues/188

Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
---
 security/keys/internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/keys/internal.h b/security/keys/internal.h
index 9b9cf3b6fcbb..3e3def5fbaa4 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -136,7 +136,7 @@ struct keyring_search_context {
 	bool			possessed;
 	key_ref_t		result;
 	time64_t		now;
-};
+} __randomize_layout;
 
 extern bool key_default_cmp(const struct key *key,
 			    const struct key_match_data *match_data);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] security: keys: add __randomize_layout to keyring_search_context
  2022-05-18  9:18 [PATCH] security: keys: add __randomize_layout to keyring_search_context GONG, Ruiqi
@ 2022-05-18 20:25 ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2022-05-18 20:25 UTC (permalink / raw)
  To: GONG, Ruiqi
  Cc: David Howells, Jarkko Sakkinen, James Morris, Serge E . Hallyn,
	keyrings, linux-security-module, linux-kernel, Wang Weiyang,
	Xiu Jianfeng

On Wed, May 18, 2022 at 09:18:41AM +0000, GONG, Ruiqi wrote:
> Struct keyring_search_context contains a pointer to `struct cred`, which
> is a security-critical structure and whose layout is randomized already.
> Apply __randomize_layout to struct keyring_search_context as well, as
> suggested in [1].
> 
> [1]: https://github.com/KSPP/linux/issues/188
> 
> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>

Seems reasonable to me; it's an entirely internal structure.

Reviewed-by: Kees Cook <keescook@chromium.org>

> ---
>  security/keys/internal.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/security/keys/internal.h b/security/keys/internal.h
> index 9b9cf3b6fcbb..3e3def5fbaa4 100644
> --- a/security/keys/internal.h
> +++ b/security/keys/internal.h
> @@ -136,7 +136,7 @@ struct keyring_search_context {
>  	bool			possessed;
>  	key_ref_t		result;
>  	time64_t		now;
> -};
> +} __randomize_layout;
>  
>  extern bool key_default_cmp(const struct key *key,
>  			    const struct key_match_data *match_data);
> -- 
> 2.17.1
> 

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-18 20:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18  9:18 [PATCH] security: keys: add __randomize_layout to keyring_search_context GONG, Ruiqi
2022-05-18 20:25 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).