* [LTP] [PATCH] keyctl: Fix struct keyctl_dh_params build on Bionic
@ 2026-10-02 13:05 Wake Liu via ltp
2026-10-02 13:44 ` [LTP] " linuxtestproject.agent
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Wake Liu via ltp @ 2026-10-02 13:05 UTC (permalink / raw)
To: ltp
Bionic generates its copy of the UAPI headers with the C++ keyword
'private' renamed to '__linux_private', so its struct keyctl_dh_params
only provides the 'priv' alias added in kernel 4.20. Since keyctl25-28
were switched to 'private', they fail to build on Android:
error: no member named 'private' in 'struct keyctl_dh_params'
Detect the 'private' member in configure and access the member via a
new KEYCTL_DH_PRIVATE() macro, which falls back to 'priv' when
'private' is not available, similar to FSID_VAL_MEMBER() in
lapi/fanotify.h.
Checking for 'private' rather than 'priv' leaves every build whose UAPI
headers provide 'private' unchanged, including headers older than 4.20
which lack 'priv'. It also makes 'priv' the default when configure is
not run, as in the Android build, which uses a hand-maintained
config.h. The LTP fallback definition provides both members.
Fixes: 71353a6c009b ("keyctl: Use struct keyctl_dh_params 'private' instead of 'priv'")
Signed-off-by: Wake Liu <wakel@google.com>
---
configure.ac | 1 +
include/lapi/keyctl.h | 14 ++++++++++++++
testcases/kernel/syscalls/keyctl/keyctl25.c | 5 +++--
testcases/kernel/syscalls/keyctl/keyctl26.c | 5 +++--
testcases/kernel/syscalls/keyctl/keyctl27.c | 5 +++--
testcases/kernel/syscalls/keyctl/keyctl28.c | 2 +-
6 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index e979de0e7..4087856c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -302,6 +302,7 @@ AC_CHECK_TYPES([struct uffdio_writeprotect],,,[#include <linux/userfaultfd.h>])
AC_CHECK_TYPES([struct keyctl_dh_params, struct keyctl_kdf_params,
struct keyctl_pkey_query, struct keyctl_pkey_params],,,
[#include <linux/keyctl.h>])
+AC_CHECK_MEMBERS([struct keyctl_dh_params.private],,,[#include <linux/keyctl.h>])
# Tools knobs
diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
index eb4d25c42..788c4d509 100644
--- a/include/lapi/keyctl.h
+++ b/include/lapi/keyctl.h
@@ -67,6 +67,20 @@ struct keyctl_dh_params {
};
#endif
+/**
+ * KEYCTL_DH_PRIVATE - Access the private key in struct keyctl_dh_params.
+ * @params: Pointer to struct keyctl_dh_params.
+ *
+ * Uses 'private' if the UAPI headers provide it, 'priv' otherwise. UAPI
+ * headers older than 4.20 provide only 'private'. Bionic renames 'private'
+ * (a C++ keyword) to '__linux_private', so only 'priv' is usable there.
+ */
+#ifdef HAVE_STRUCT_KEYCTL_DH_PARAMS_PRIVATE
+# define KEYCTL_DH_PRIVATE(params) ((params)->private)
+#else
+# define KEYCTL_DH_PRIVATE(params) ((params)->priv)
+#endif
+
#ifndef HAVE_STRUCT_KEYCTL_KDF_PARAMS
struct keyctl_kdf_params {
char *hashname;
diff --git a/testcases/kernel/syscalls/keyctl/keyctl25.c b/testcases/kernel/syscalls/keyctl/keyctl25.c
index 84e76c019..80a341cf3 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl25.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl25.c
@@ -22,8 +22,9 @@ static void setup(void)
{
SAFE_KEYCTL(KEYCTL_JOIN_SESSION_KEYRING, 0, 0, 0, 0);
- dh_params->private = SAFE_NEW_USER_KEY("dh_priv", dh_priv, sizeof(dh_priv),
- KEY_SPEC_PROCESS_KEYRING);
+ KEYCTL_DH_PRIVATE(dh_params) =
+ SAFE_NEW_USER_KEY("dh_priv", dh_priv, sizeof(dh_priv),
+ KEY_SPEC_PROCESS_KEYRING);
dh_params->prime = SAFE_NEW_USER_KEY("dh_prime", dh_prime, sizeof(dh_prime),
KEY_SPEC_PROCESS_KEYRING);
dh_params->base = SAFE_NEW_USER_KEY("dh_base", dh_base, sizeof(dh_base),
diff --git a/testcases/kernel/syscalls/keyctl/keyctl26.c b/testcases/kernel/syscalls/keyctl/keyctl26.c
index 9488e736f..3d693e0ec 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl26.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl26.c
@@ -21,8 +21,9 @@ static void setup(void)
{
SAFE_KEYCTL(KEYCTL_JOIN_SESSION_KEYRING, 0, 0, 0, 0);
- dh_params->private = SAFE_NEW_USER_KEY("dh_priv", dh_priv, sizeof(dh_priv),
- KEY_SPEC_PROCESS_KEYRING);
+ KEYCTL_DH_PRIVATE(dh_params) =
+ SAFE_NEW_USER_KEY("dh_priv", dh_priv, sizeof(dh_priv),
+ KEY_SPEC_PROCESS_KEYRING);
dh_params->prime = SAFE_NEW_USER_KEY("dh_prime", dh_prime, sizeof(dh_prime),
KEY_SPEC_PROCESS_KEYRING);
dh_params->base = SAFE_NEW_USER_KEY("dh_base", dh_base, sizeof(dh_base),
diff --git a/testcases/kernel/syscalls/keyctl/keyctl27.c b/testcases/kernel/syscalls/keyctl/keyctl27.c
index e69b52064..1ba338dcb 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl27.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl27.c
@@ -27,8 +27,9 @@ static void setup(void)
{
SAFE_KEYCTL(KEYCTL_JOIN_SESSION_KEYRING, 0, 0, 0, 0);
- dh_params->private = SAFE_NEW_USER_KEY("dh_priv", dh_priv, sizeof(dh_priv),
- KEY_SPEC_PROCESS_KEYRING);
+ KEYCTL_DH_PRIVATE(dh_params) =
+ SAFE_NEW_USER_KEY("dh_priv", dh_priv, sizeof(dh_priv),
+ KEY_SPEC_PROCESS_KEYRING);
dh_params->prime = SAFE_NEW_USER_KEY("dh_prime", dh_prime, sizeof(dh_prime),
KEY_SPEC_PROCESS_KEYRING);
dh_params->base = SAFE_NEW_USER_KEY("dh_base", dh_base, sizeof(dh_base),
diff --git a/testcases/kernel/syscalls/keyctl/keyctl28.c b/testcases/kernel/syscalls/keyctl/keyctl28.c
index 15ca3b8fe..4e7710d25 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl28.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl28.c
@@ -78,7 +78,7 @@ static void setup(void)
key_base = SAFE_NEW_USER_KEY("dh_base", dh_base, sizeof(dh_base),
KEY_SPEC_PROCESS_KEYRING);
- dh_params->private = key_priv;
+ KEYCTL_DH_PRIVATE(dh_params) = key_priv;
dh_params->prime = key_prime;
dh_params->base = key_base;
--
2.56.0.rc1.315.gc6ed9934b7-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] keyctl: Fix struct keyctl_dh_params build on Bionic
2026-10-02 13:05 [LTP] [PATCH] keyctl: Fix struct keyctl_dh_params build on Bionic Wake Liu via ltp
@ 2026-10-02 13:44 ` linuxtestproject.agent
2026-10-07 9:59 ` [LTP] [PATCH] " Petr Vorel
2026-10-12 11:49 ` Andrea Cervesato via ltp
2 siblings, 0 replies; 5+ messages in thread
From: linuxtestproject.agent @ 2026-10-02 13:44 UTC (permalink / raw)
To: Wake Liu; +Cc: ltp
Hi Wake,
On Fri, 2 Oct 2026, Wake Liu wrote:
> keyctl: Fix struct keyctl_dh_params build on Bionic
Verdict - Reviewed
Pre-existing issue (low severity, not introduced by this patch):
In include/lapi/keyctl.h:55-56, keyctl_join_session_keyring() uses
KEYCTL_JOIN_SESSION_KEYRING before its fallback definition. When
HAVE_LINUX_KEYCTL_H is unset, including this header fails to compile;
the same failure occurs with the parent commit. Move the fallback
definition before the helper in a separate change.
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] keyctl: Fix struct keyctl_dh_params build on Bionic
2026-10-02 13:05 [LTP] [PATCH] keyctl: Fix struct keyctl_dh_params build on Bionic Wake Liu via ltp
2026-10-02 13:44 ` [LTP] " linuxtestproject.agent
@ 2026-10-07 9:59 ` Petr Vorel
2026-10-13 16:04 ` Petr Vorel
2026-10-12 11:49 ` Andrea Cervesato via ltp
2 siblings, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2026-10-07 9:59 UTC (permalink / raw)
To: Wake Liu; +Cc: ltp
Hi Wake Liu, Cyril,
> Bionic generates its copy of the UAPI headers with the C++ keyword
Ah, we forget on the most used C++ libc when we prepared 71353a6c009b.
> 'private' renamed to '__linux_private', so its struct keyctl_dh_params
> only provides the 'priv' alias added in kernel 4.20. Since keyctl25-28
> were switched to 'private', they fail to build on Android:
> error: no member named 'private' in 'struct keyctl_dh_params'
> Detect the 'private' member in configure and access the member via a
> new KEYCTL_DH_PRIVATE() macro, which falls back to 'priv' when
> 'private' is not available, similar to FSID_VAL_MEMBER() in
> lapi/fanotify.h.
> Checking for 'private' rather than 'priv' leaves every build whose UAPI
> headers provide 'private' unchanged, including headers older than 4.20
> which lack 'priv'. It also makes 'priv' the default when configure is
> not run, as in the Android build, which uses a hand-maintained
> config.h. The LTP fallback definition provides both members.
> Fixes: 71353a6c009b ("keyctl: Use struct keyctl_dh_params 'private' instead of 'priv'")
> Signed-off-by: Wake Liu <wakel@google.com>
Looks like we cannot avoid struct keyctl_dh_params.private. Make sense.
Cc Cyril just in case he has some different idea.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> ---
> configure.ac | 1 +
> include/lapi/keyctl.h | 14 ++++++++++++++
> testcases/kernel/syscalls/keyctl/keyctl25.c | 5 +++--
> testcases/kernel/syscalls/keyctl/keyctl26.c | 5 +++--
> testcases/kernel/syscalls/keyctl/keyctl27.c | 5 +++--
> testcases/kernel/syscalls/keyctl/keyctl28.c | 2 +-
> 6 files changed, 25 insertions(+), 7 deletions(-)
> diff --git a/configure.ac b/configure.ac
> index e979de0e7..4087856c8 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -302,6 +302,7 @@ AC_CHECK_TYPES([struct uffdio_writeprotect],,,[#include <linux/userfaultfd.h>])
> AC_CHECK_TYPES([struct keyctl_dh_params, struct keyctl_kdf_params,
> struct keyctl_pkey_query, struct keyctl_pkey_params],,,
> [#include <linux/keyctl.h>])
> +AC_CHECK_MEMBERS([struct keyctl_dh_params.private],,,[#include <linux/keyctl.h>])
> # Tools knobs
> diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
> index eb4d25c42..788c4d509 100644
> --- a/include/lapi/keyctl.h
> +++ b/include/lapi/keyctl.h
> @@ -67,6 +67,20 @@ struct keyctl_dh_params {
> };
> #endif
> +/**
> + * KEYCTL_DH_PRIVATE - Access the private key in struct keyctl_dh_params.
> + * @params: Pointer to struct keyctl_dh_params.
> + *
> + * Uses 'private' if the UAPI headers provide it, 'priv' otherwise. UAPI
> + * headers older than 4.20 provide only 'private'. Bionic renames 'private'
> + * (a C++ keyword) to '__linux_private', so only 'priv' is usable there.
> + */
> +#ifdef HAVE_STRUCT_KEYCTL_DH_PARAMS_PRIVATE
> +# define KEYCTL_DH_PRIVATE(params) ((params)->private)
> +#else
> +# define KEYCTL_DH_PRIVATE(params) ((params)->priv)
> +#endif
> +
> #ifndef HAVE_STRUCT_KEYCTL_KDF_PARAMS
> struct keyctl_kdf_params {
> char *hashname;
> diff --git a/testcases/kernel/syscalls/keyctl/keyctl25.c b/testcases/kernel/syscalls/keyctl/keyctl25.c
> index 84e76c019..80a341cf3 100644
> --- a/testcases/kernel/syscalls/keyctl/keyctl25.c
> +++ b/testcases/kernel/syscalls/keyctl/keyctl25.c
> @@ -22,8 +22,9 @@ static void setup(void)
> {
> SAFE_KEYCTL(KEYCTL_JOIN_SESSION_KEYRING, 0, 0, 0, 0);
> - dh_params->private = SAFE_NEW_USER_KEY("dh_priv", dh_priv, sizeof(dh_priv),
> - KEY_SPEC_PROCESS_KEYRING);
> + KEYCTL_DH_PRIVATE(dh_params) =
> + SAFE_NEW_USER_KEY("dh_priv", dh_priv, sizeof(dh_priv),
> + KEY_SPEC_PROCESS_KEYRING);
> dh_params->prime = SAFE_NEW_USER_KEY("dh_prime", dh_prime, sizeof(dh_prime),
> KEY_SPEC_PROCESS_KEYRING);
> dh_params->base = SAFE_NEW_USER_KEY("dh_base", dh_base, sizeof(dh_base),
...
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] keyctl: Fix struct keyctl_dh_params build on Bionic
2026-10-02 13:05 [LTP] [PATCH] keyctl: Fix struct keyctl_dh_params build on Bionic Wake Liu via ltp
2026-10-02 13:44 ` [LTP] " linuxtestproject.agent
2026-10-07 9:59 ` [LTP] [PATCH] " Petr Vorel
@ 2026-10-12 11:49 ` Andrea Cervesato via ltp
2 siblings, 0 replies; 5+ messages in thread
From: Andrea Cervesato via ltp @ 2026-10-12 11:49 UTC (permalink / raw)
To: Wake Liu; +Cc: ltp
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] keyctl: Fix struct keyctl_dh_params build on Bionic
2026-10-07 9:59 ` [LTP] [PATCH] " Petr Vorel
@ 2026-10-13 16:04 ` Petr Vorel
0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2026-10-13 16:04 UTC (permalink / raw)
To: Wake Liu, ltp
Hi all,
> Hi Wake Liu, Cyril,
> > Bionic generates its copy of the UAPI headers with the C++ keyword
> Ah, we forget on the most used C++ libc when we prepared 71353a6c009b.
> > 'private' renamed to '__linux_private', so its struct keyctl_dh_params
> > only provides the 'priv' alias added in kernel 4.20. Since keyctl25-28
> > were switched to 'private', they fail to build on Android:
> > error: no member named 'private' in 'struct keyctl_dh_params'
> > Detect the 'private' member in configure and access the member via a
> > new KEYCTL_DH_PRIVATE() macro, which falls back to 'priv' when
> > 'private' is not available, similar to FSID_VAL_MEMBER() in
> > lapi/fanotify.h.
> > Checking for 'private' rather than 'priv' leaves every build whose UAPI
> > headers provide 'private' unchanged, including headers older than 4.20
> > which lack 'priv'. It also makes 'priv' the default when configure is
> > not run, as in the Android build, which uses a hand-maintained
> > config.h. The LTP fallback definition provides both members.
> > Fixes: 71353a6c009b ("keyctl: Use struct keyctl_dh_params 'private' instead of 'priv'")
> > Signed-off-by: Wake Liu <wakel@google.com>
> Looks like we cannot avoid struct keyctl_dh_params.private. Make sense.
> Cc Cyril just in case he has some different idea.
Thank you. Indeed this autotools fix is the safest way. I verified the it did
not break the original fix in 71353a6c009b (SLE12-SP5) and merged as
6262a5fc31 ("keyctl: Fix struct keyctl_dh_params build on Bionic")
I'm also going to send a follow up to simplify struct keyctl_dh_params again.
(Probably union is not needed any more.)
Kind regards,
Petr
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Kind regards,
> Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-13 16:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02 13:05 [LTP] [PATCH] keyctl: Fix struct keyctl_dh_params build on Bionic Wake Liu via ltp
2026-10-02 13:44 ` [LTP] " linuxtestproject.agent
2026-10-07 9:59 ` [LTP] [PATCH] " Petr Vorel
2026-10-13 16:04 ` Petr Vorel
2026-10-12 11:49 ` Andrea Cervesato via ltp
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.