* [LTP] [PATCH 1/1] lapi/keyctl.h: Fix compilation on old kernel
@ 2026-09-21 11:14 Petr Vorel
2026-09-21 11:52 ` Cyril Hrubis
2026-09-21 13:46 ` [LTP] " linuxtestproject.agent
0 siblings, 2 replies; 6+ messages in thread
From: Petr Vorel @ 2026-09-21 11:14 UTC (permalink / raw)
To: ltp; +Cc: linuxtestproject.agent
priv member was added in kernel v4.20 (which we still support) in commit
2ecefa0a15fd0 ("keys: Fix the use of the C++ keyword "private" in
uapi/linux/keyctl.h")
Use macro definition to fix missing 'priv' in the old UAPI headers. This
fixes error:
keyctl25.c:25:11: error: ‘struct keyctl_dh_params’ has no member named ‘priv’
Fixes: ee02118e9f ("lapi/keyctl.h: Add fallback definitions for extended ops")
Suggested-by: linuxtestproject.agent@gmail.com
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Yet another pre-release fix, required for compilation on SLE12-SP5.
Kind regards,
Petr
include/lapi/keyctl.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
index fdb68d1725..e1e46b7865 100644
--- a/include/lapi/keyctl.h
+++ b/include/lapi/keyctl.h
@@ -69,6 +69,12 @@ struct keyctl_dh_params {
};
#endif
+/* Fix for kernel < v4.20 */
+#if defined(HAVE_STRUCT_KEYCTL_DH_PARAMS) && \
+ !defined(HAVE_STRUCT_KEYCTL_DH_PARAMS_PRIV)
+# define priv private
+#endif
+
#ifndef HAVE_STRUCT_KEYCTL_KDF_PARAMS
struct keyctl_kdf_params {
char *hashname;
--
2.55.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH 1/1] lapi/keyctl.h: Fix compilation on old kernel
2026-09-21 11:14 [LTP] [PATCH 1/1] lapi/keyctl.h: Fix compilation on old kernel Petr Vorel
@ 2026-09-21 11:52 ` Cyril Hrubis
2026-09-21 13:36 ` Petr Vorel
2026-09-21 13:46 ` [LTP] " linuxtestproject.agent
1 sibling, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2026-09-21 11:52 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp, linuxtestproject.agent
Hi!
> diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
> index fdb68d1725..e1e46b7865 100644
> --- a/include/lapi/keyctl.h
> +++ b/include/lapi/keyctl.h
> @@ -69,6 +69,12 @@ struct keyctl_dh_params {
> };
> #endif
>
> +/* Fix for kernel < v4.20 */
> +#if defined(HAVE_STRUCT_KEYCTL_DH_PARAMS) && \
> + !defined(HAVE_STRUCT_KEYCTL_DH_PARAMS_PRIV)
> +# define priv private
> +#endif
I do not like this one, we may end up redefining wrong priv and break
everything.
Given that the private stil exists in the structure for C code:
(/usr/include/linux/keyctl.h)
/* keyctl structures */
struct keyctl_dh_params {
union {
#ifndef __cplusplus
__s32 private;
#endif
__s32 priv;
};
__s32 prime;
__s32 base;
};
We may as well use private in the tests consistently and update our
fallback with the union as well.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH 1/1] lapi/keyctl.h: Fix compilation on old kernel
2026-09-21 11:52 ` Cyril Hrubis
@ 2026-09-21 13:36 ` Petr Vorel
2026-09-21 13:41 ` Petr Vorel
0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2026-09-21 13:36 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp, linuxtestproject.agent
> Hi!
> > diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
> > index fdb68d1725..e1e46b7865 100644
> > --- a/include/lapi/keyctl.h
> > +++ b/include/lapi/keyctl.h
> > @@ -69,6 +69,12 @@ struct keyctl_dh_params {
> > };
> > #endif
> > +/* Fix for kernel < v4.20 */
> > +#if defined(HAVE_STRUCT_KEYCTL_DH_PARAMS) && \
> > + !defined(HAVE_STRUCT_KEYCTL_DH_PARAMS_PRIV)
> > +# define priv private
> > +#endif
> I do not like this one, we may end up redefining wrong priv and break
> everything.
> Given that the private stil exists in the structure for C code:
> (/usr/include/linux/keyctl.h)
> /* keyctl structures */
> struct keyctl_dh_params {
> union {
> #ifndef __cplusplus
> __s32 private;
> #endif
> __s32 priv;
> };
> __s32 prime;
> __s32 base;
> };
> We may as well use private in the tests consistently and update our
> fallback with the union as well.
When I looked in the struct in UAPI I considered define better, but indeed
mirroring UAPI the same way is really better.
I'll retest it and send v2.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH 1/1] lapi/keyctl.h: Fix compilation on old kernel
2026-09-21 13:36 ` Petr Vorel
@ 2026-09-21 13:41 ` Petr Vorel
2026-09-22 8:55 ` Petr Vorel
0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2026-09-21 13:41 UTC (permalink / raw)
To: Cyril Hrubis, ltp, Li Wang, Avinesh Kumar, Wei Gao,
Andrea Cervesato, linuxtestproject.agent
> > Hi!
> > > diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
> > > index fdb68d1725..e1e46b7865 100644
> > > --- a/include/lapi/keyctl.h
> > > +++ b/include/lapi/keyctl.h
> > > @@ -69,6 +69,12 @@ struct keyctl_dh_params {
> > > };
> > > #endif
> > > +/* Fix for kernel < v4.20 */
> > > +#if defined(HAVE_STRUCT_KEYCTL_DH_PARAMS) && \
> > > + !defined(HAVE_STRUCT_KEYCTL_DH_PARAMS_PRIV)
> > > +# define priv private
> > > +#endif
> > I do not like this one, we may end up redefining wrong priv and break
> > everything.
> > Given that the private stil exists in the structure for C code:
> > (/usr/include/linux/keyctl.h)
> > /* keyctl structures */
> > struct keyctl_dh_params {
> > union {
> > #ifndef __cplusplus
> > __s32 private;
> > #endif
> > __s32 priv;
> > };
> > __s32 prime;
> > __s32 base;
> > };
> > We may as well use private in the tests consistently and update our
> > fallback with the union as well.
> When I looked in the struct in UAPI I considered define better, but indeed
> mirroring UAPI the same way is really better.
> I'll retest it and send v2.
Just the only thing - we will need to have to use our custom struct
e.g. ltp_keyctl_dh_params (similarly to ltp_statx), because the problem is on
the code which defines struct keyctl_dh_params, but without that fallback.
Kind regards,
Petr
> Kind regards,
> Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] lapi/keyctl.h: Fix compilation on old kernel
2026-09-21 11:14 [LTP] [PATCH 1/1] lapi/keyctl.h: Fix compilation on old kernel Petr Vorel
2026-09-21 11:52 ` Cyril Hrubis
@ 2026-09-21 13:46 ` linuxtestproject.agent
1 sibling, 0 replies; 6+ messages in thread
From: linuxtestproject.agent @ 2026-09-21 13:46 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi Petr,
On Mon, 21 Sep 2026 13:14:07 +0200, Petr Vorel <pvorel@suse.cz> wrote:
> lapi/keyctl.h: Fix compilation on old kernel
Verdict - Reviewed
---
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] 6+ messages in thread
* Re: [LTP] [PATCH 1/1] lapi/keyctl.h: Fix compilation on old kernel
2026-09-21 13:41 ` Petr Vorel
@ 2026-09-22 8:55 ` Petr Vorel
0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2026-09-22 8:55 UTC (permalink / raw)
To: Cyril Hrubis, ltp, Li Wang, Avinesh Kumar, Wei Gao,
Andrea Cervesato, linuxtestproject.agent
> > > Hi!
> > > > diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
> > > > index fdb68d1725..e1e46b7865 100644
> > > > --- a/include/lapi/keyctl.h
> > > > +++ b/include/lapi/keyctl.h
> > > > @@ -69,6 +69,12 @@ struct keyctl_dh_params {
> > > > };
> > > > #endif
> > > > +/* Fix for kernel < v4.20 */
> > > > +#if defined(HAVE_STRUCT_KEYCTL_DH_PARAMS) && \
> > > > + !defined(HAVE_STRUCT_KEYCTL_DH_PARAMS_PRIV)
> > > > +# define priv private
> > > > +#endif
> > > I do not like this one, we may end up redefining wrong priv and break
> > > everything.
> > > Given that the private stil exists in the structure for C code:
> > > (/usr/include/linux/keyctl.h)
> > > /* keyctl structures */
> > > struct keyctl_dh_params {
> > > union {
> > > #ifndef __cplusplus
> > > __s32 private;
> > > #endif
> > > __s32 priv;
> > > };
> > > __s32 prime;
> > > __s32 base;
> > > };
FYI the userspace keyutils.h uses only priv [1]:
struct keyctl_dh_params {
key_serial_t priv;
key_serial_t prime;
key_serial_t base;
};
[1] https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/tree/keyutils.h
> > > We may as well use private in the tests consistently and update our
> > > fallback with the union as well.
Thinking about it twice, I think the original solution is safe enough, based on
autotools check. As I wrote before if you really don't want it, we'd need to
vendor the struct. At that point we don't need private.
Look at the diff I posted (I can post it officially as v2). The cons is
maintaining the struct (but we do it for the fallback anyway). Pros is getting
rid some of autotools checks (small speedup).
WDYT?
Kind regards,
Petr
> > When I looked in the struct in UAPI I considered define better, but indeed
> > mirroring UAPI the same way is really better.
> > I'll retest it and send v2.
> Just the only thing - we will need to have to use our custom struct
> e.g. ltp_keyctl_dh_params (similarly to ltp_statx), because the problem is on
> the code which defines struct keyctl_dh_params, but without that fallback.
> Kind regards,
> Petr
> > Kind regards,
> > Petr
diff --git include/lapi/keyctl.h include/lapi/keyctl.h
index fdb68d1725..d1cea85aba 100644
--- include/lapi/keyctl.h
+++ include/lapi/keyctl.h
@@ -61,13 +61,11 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {
#endif /* defined(HAVE_KEYUTILS_H) && defined(HAVE_LIBKEYUTILS) */
-#ifndef HAVE_STRUCT_KEYCTL_DH_PARAMS
-struct keyctl_dh_params {
+struct ltp_keyctl_dh_params {
int32_t priv;
int32_t prime;
int32_t base;
};
-#endif
#ifndef HAVE_STRUCT_KEYCTL_KDF_PARAMS
struct keyctl_kdf_params {
diff --git m4/ltp-keyutils.m4 m4/ltp-keyutils.m4
index 35bad783e5..b073183405 100644
--- m4/ltp-keyutils.m4
+++ m4/ltp-keyutils.m4
@@ -9,9 +9,6 @@ AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT], [
[AC_DEFINE(HAVE_LIBKEYUTILS, 1, [Define to 1 if you have libkeyutils installed.])
AC_SUBST(KEYUTILS_LIBS, "-lkeyutils")])
- AC_CHECK_TYPES([struct keyctl_dh_params, struct keyctl_kdf_params,
- struct keyctl_pkey_query, struct keyctl_pkey_params],,,
+ AC_CHECK_TYPES([struct keyctl_kdf_params, struct keyctl_pkey_query, struct keyctl_pkey_params],,,
[#include <linux/keyctl.h>])
-
- AC_CHECK_MEMBERS([struct keyctl_dh_params.priv],,,[#include <linux/keyctl.h>])
])
diff --git testcases/kernel/syscalls/keyctl/keyctl25.c testcases/kernel/syscalls/keyctl/keyctl25.c
index d1aa3425d4..a99503183a 100644
--- testcases/kernel/syscalls/keyctl/keyctl25.c
+++ testcases/kernel/syscalls/keyctl/keyctl25.c
@@ -15,7 +15,7 @@
#include "keyctl_common.h"
#include "keyctl_dh_data.h"
-static struct keyctl_dh_params *dh_params;
+static struct ltp_keyctl_dh_params *dh_params;
static unsigned char out_buf[256];
static void setup(void)
diff --git testcases/kernel/syscalls/keyctl/keyctl26.c testcases/kernel/syscalls/keyctl/keyctl26.c
index bdd852fb4c..df80aadb6c 100644
--- testcases/kernel/syscalls/keyctl/keyctl26.c
+++ testcases/kernel/syscalls/keyctl/keyctl26.c
@@ -15,7 +15,7 @@
#include "keyctl_common.h"
#include "keyctl_dh_data.h"
-static struct keyctl_dh_params *dh_params;
+static struct ltp_keyctl_dh_params *dh_params;
static void setup(void)
{
diff --git testcases/kernel/syscalls/keyctl/keyctl27.c testcases/kernel/syscalls/keyctl/keyctl27.c
index 13a1538ce6..0ecf7dc389 100644
--- testcases/kernel/syscalls/keyctl/keyctl27.c
+++ testcases/kernel/syscalls/keyctl/keyctl27.c
@@ -19,7 +19,7 @@
#define KDF_OTHERINFO "LTP-KDF-TEST-INFO"
-static struct keyctl_dh_params *dh_params;
+static struct ltp_keyctl_dh_params *dh_params;
static struct keyctl_kdf_params *kdf_params;
static unsigned char out_buf[32];
diff --git testcases/kernel/syscalls/keyctl/keyctl28.c testcases/kernel/syscalls/keyctl/keyctl28.c
index 4c7f6be17e..53a59322b4 100644
--- testcases/kernel/syscalls/keyctl/keyctl28.c
+++ testcases/kernel/syscalls/keyctl/keyctl28.c
@@ -21,9 +21,9 @@
#include "keyctl_common.h"
#include "keyctl_dh_data.h"
-static struct keyctl_dh_params *dh_params;
-static struct keyctl_dh_params *dh_bogus_prime;
-static struct keyctl_dh_params *dh_nonuser_prime;
+static struct ltp_keyctl_dh_params *dh_params;
+static struct ltp_keyctl_dh_params *dh_bogus_prime;
+static struct ltp_keyctl_dh_params *dh_nonuser_prime;
static struct keyctl_kdf_params *kdf_valid;
static struct keyctl_kdf_params *kdf_spare_nonzero;
@@ -33,7 +33,7 @@ static struct keyctl_kdf_params *kdf_unknown_hash;
static unsigned char out_buf[1025];
static struct tcase {
- struct keyctl_dh_params **params;
+ struct ltp_keyctl_dh_params **params;
void *buffer;
size_t buflen;
struct keyctl_kdf_params **kdf;
@@ -105,7 +105,7 @@ static void setup(void)
static void verify_negative(unsigned int n)
{
struct tcase *tc = &tcases[n];
- struct keyctl_dh_params *p = *tc->params;
+ struct ltp_keyctl_dh_params *p = *tc->params;
struct keyctl_kdf_params *kdf = tc->kdf ? *tc->kdf : NULL;
TST_EXP_FAIL2(keyctl(KEYCTL_DH_COMPUTE, (unsigned long)p,
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-22 8:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-21 11:14 [LTP] [PATCH 1/1] lapi/keyctl.h: Fix compilation on old kernel Petr Vorel
2026-09-21 11:52 ` Cyril Hrubis
2026-09-21 13:36 ` Petr Vorel
2026-09-21 13:41 ` Petr Vorel
2026-09-22 8:55 ` Petr Vorel
2026-09-21 13:46 ` [LTP] " linuxtestproject.agent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox