Skip to contentSkip to conversation

kexec.h: stop exporting kexec_load() to userspace

PATCH NAK Paul Bolle 3 participants 4 messages Jan 15, 2014

Subsystems (3)
lore
Share & tools
lore

Paul Bolle

author
#0 lore raw

PATCH 1/1 kexec.h: stop exporting kexec_load() to userspace

Since v3.5 kexec.h is exported to userspace. That includes its declaration of kexec_load():
extern int kexec_load(void *, size_t, struct kexec_segment *,
unsigned long int);

This declaration isn't very useful to userspace programs on itself. They still have to define a matching function (which basically wraps the kexec_load syscall). I'm not aware of programs or libraries that actually do that.

It can be removed. The programs that actually use it, if there are any, should then provide their own declaration to keep compiling. Already compiled binaries will not be affected.

This gets rid of the headers_check warning that can be seen ever since
this header was exported:
[...]/usr/include/linux/kexec.h:49: userspace cannot reference function or variable defined in the kernel

---
This declaration of kexec_load() was added to kexec.h in commit 29a5c67e7a ("kexec: export kexec.h to user space").

 include/uapi/linux/kexec.h | 7 -------
 1 file changed, 7 deletions(-)
include/uapi/linux/kexec.h +0 -7
index 104838f..c7897b6 100644
@@ -42,13 +42,6 @@ struct kexec_segment {
 	const void *mem;
 	size_t memsz;
 };
-
-/* Load a new kernel image as described by the kexec_segment array
- * consisting of passed number of segments at the entry-point address.
- * The flags allow different useage types.
- */
-extern int kexec_load(void *, size_t, struct kexec_segment *,
-		unsigned long int);
 #endif /* __KERNEL__ */
 
 #endif /* _UAPILINUX_KEXEC_H */
Signature · 1 line
1.8.4.2
#1 lore raw
Quoted 5 lines · Paul Bolle

Since v3.5 kexec.h is exported to userspace. That includes its declaration of kexec_load():
extern int kexec_load(void *, size_t, struct kexec_segment *,
unsigned long int);

Quoted 8 lines

This declaration isn't very useful to userspace programs on itself. They still have to define a matching function (which basically wraps the kexec_load syscall). I'm not aware of programs or libraries that actually do that.

It can be removed. The programs that actually use it, if there are any, should then provide their own declaration to keep compiling. Already compiled binaries will not be affected.

nack, klibc uses the header and there was some discussion that glibc could/should use it too. I didn't follow kexec git, but there is/was a version that just uses the kexec_load() if the c library provides it. Until Santa Claus materialises in form of a direct kernel user-space API, see follow ups on http://lwn.net/Articles/534682/ and proposal by hpa

Quoted 4 lines

This gets rid of the headers_check warning that can be seen ever since
this header was exported:
[...]/usr/include/linux/kexec.h:49: userspace cannot reference function or variable defined in the kernel

this is the wrong way of fix.

Signature · 1 line
maks
author
#2 lore raw
Quoted 11 lines · Maximilian Attems
Quoted 10 lines · Paul Bolle

Since v3.5 kexec.h is exported to userspace. That includes its declaration of kexec_load():
extern int kexec_load(void *, size_t, struct kexec_segment *,
unsigned long int);

This declaration isn't very useful to userspace programs on itself. They still have to define a matching function (which basically wraps the kexec_load syscall). I'm not aware of programs or libraries that actually do that.

Quoted 6 lines
Quoted 3 lines

It can be removed. The programs that actually use it, if there are any, should then provide their own declaration to keep compiling. Already compiled binaries will not be affected.

nack, klibc uses the header and there was some discussion that glibc could/should use it too.

The versions of klibc I stumbled on (via codesearch.debian.net) didn't use a kexec_load() that match that declaration. Has that changed? In which version?

Quoted 11 lines

I didn't follow kexec git, but there is/was
a version that just uses the kexec_load() if the c library provides it. Until Santa Claus materialises in form of a direct kernel user-space API, see follow ups on http://lwn.net/Articles/534682/ and proposal by hpa

Quoted 4 lines

This gets rid of the headers_check warning that can be seen ever since
this header was exported:
[...]/usr/include/linux/kexec.h:49: userspace cannot reference function or variable defined in the kernel

this is the wrong way of fix.

Paul Bolle

#3 lore raw
In reply to Maximilian Attems

We shouldn't put prototypes of user-space functions in the kernel, at least not until we actually export all the signatures. The prototype should instead be in a userspace <sys/kexec.h> header.

Quoted 33 lines · Maximilian Attems
Quoted 6 lines · Paul Bolle

Since v3.5 kexec.h is exported to userspace. That includes its declaration of kexec_load():
extern int kexec_load(void *, size_t, struct kexec_segment *,
unsigned long int);

This declaration isn't very useful to userspace programs on itself.

They

Quoted 2 lines

still have to define a matching function (which basically wraps the kexec_load syscall). I'm not aware of programs or libraries that

actually

Quoted 5 lines

do that.

It can be removed. The programs that actually use it, if there are any, should then provide their own declaration to keep compiling. Already compiled binaries will not be affected.

nack, klibc uses the header and there was some discussion that glibc could/should use it too. I didn't follow kexec git, but there is/was a version that just uses the kexec_load() if the c library provides it. Until Santa Claus materialises in form of a direct kernel user-space API,
see follow ups on http://lwn.net/Articles/534682/ and proposal by hpa

Quoted 1 line

This gets rid of the headers_check warning that can be seen ever

since

Quoted 2 lines

this header was exported:
[...]/usr/include/linux/kexec.h:49: userspace cannot reference

function or variable defined in the kernel

Quoted 1 line

this is the wrong way of fix.

Signature · 6 lines
Sent from my mobile phone.  Please pardon brevity and lack of formatting.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec