Skip to content

Commit

Permalink
keys: Fix the use of the C++ keyword "private" in uapi/linux/keyctl.h
Browse files Browse the repository at this point in the history
The keyctl_dh_params struct in uapi/linux/keyctl.h contains the symbol
"private" which means that the header file will cause compilation failure
if #included in to a C++ program.  Further, the patch that added the same
struct to the keyutils package named the symbol "priv", not "private".

The previous attempt to fix this (commit 8a2336e) did so by simply
renaming the kernel's copy of the field to dh_private, but this then breaks
existing userspace and as such has been reverted (commit 8c0f9f5).

[And note, to those who think that wrapping the struct in extern "C" {}
 will work: it won't; that only changes how symbol names are presented to
 the assembler and linker.].

Instead, insert an anonymous union around the "private" member and add a
second member in there with the name "priv" to match the one in the
keyutils package.  The "private" member is then wrapped in !__cplusplus
cpp-conditionals to hide it from C++.

Fixes: ddbb411 ("KEYS: Add KEYCTL_DH_COMPUTE command")
Fixes: 8a2336e ("uapi/linux/keyctl.h: don't use C++ reserved keyword as a struct member name")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Randy Dunlap <rdunlap@infradead.org>
cc: Lubomir Rintel <lkundrak@v3.sk>
cc: James Morris <jmorris@namei.org>
cc: Mat Martineau <mathew.j.martineau@linux.intel.com>
cc: Stephan Mueller <smueller@chronox.de>
cc: Andrew Morton <akpm@linux-foundation.org>
cc: Linus Torvalds <torvalds@linux-foundation.org>
cc: stable@vger.kernel.org
Signed-off-by: James Morris <james.morris@microsoft.com>
  • Loading branch information
David Howells authored and James Morris committed Sep 28, 2018
1 parent 0d42d73 commit 2ecefa0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/uapi/linux/keyctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@

/* keyctl structures */
struct keyctl_dh_params {
__s32 private;
union {
#ifndef __cplusplus
__s32 private;
#endif
__s32 priv;
};
__s32 prime;
__s32 base;
};
Expand Down

0 comments on commit 2ecefa0

Please sign in to comment.