Skip to contentSkip to conversation

include/linux/sysctl.h needs linux/compiler.h

PATCH In review Kevin P. Fleming 4 participants 12 messages May 31, 2003 – Jun 2, 2003 Proc sysctl

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include/linux/sysctl.h needs linux/compiler.h

Changes during 2.5.70 added _user tags to various bits in include/linux/sysctl.h. __user is defined in linux/compiler.h, which is included by linux/kernel.h but only if __KERNEL__ is defined. Compiliing uClibc against 2.5.70 fails because __user__ is not defined.

Adding patch below solves the problem (yes, I know, userspace is not supposed to use kernel headers...)

include/linux/sysctl.h renamed from include/linux/sysctl.h~ +1 -0
@@ -27,6 +27,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/list.h>
+#include <linux/compiler.h>
 
 struct file;
 
#1 lore raw
Quoted 2 lines · Kevin P. Fleming

Adding patch below solves the problem (yes, I know, userspace is not supposed to use kernel headers...)

So why do you try it anyway?

#2 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 1 line · Kevin P. Fleming

Adding patch below solves the problem (yes, I know, userspace is not supposed to use kernel headers...)

So why do you try it anyway?

Until someone addresses this issue with a permanent fix, is there another choice? How can any userspace library that needs to issue syscalls compile against the existing sysctl.h without this change? I'm open to suggestions, obviously this was a quick and dirty fix (copied from other existing headers in .../linux already, which is certainly no excuse).

#3 lore raw
In reply to Kevin P. Fleming
Quoted 11 lines · Kevin P. Fleming

Changes during 2.5.70 added _user tags to various bits in include/linux/sysctl.h. __user is defined in linux/compiler.h, which is included by linux/kernel.h but only if __KERNEL__ is defined. Compiliing uClibc against 2.5.70 fails because __user__ is not defined.

Adding patch below solves the problem (yes, I know, userspace is not supposed to use kernel headers...)

include/linux/sysctl.h line 32

Quoted 6 lines
include/linux/sysctl.h renamed from include/linux/sysctl.h~ +1 -0
@@ -27,6 +27,7 @@
  #include <linux/kernel.h>
  #include <linux/types.h>
  #include <linux/list.h>
+#include <linux/compiler.h>
 
  struct file;

linux/kernel.h includes <linux/compiler.h>.

Regards,
/ismail

#4 lore raw
Quoted 18 lines · ismail (cartman) donmez
Quoted 16 lines · Kevin P. Fleming

Changes during 2.5.70 added _user tags to various bits in include/linux/sysctl.h. __user is defined in linux/compiler.h, which is included by linux/kernel.h but only if __KERNEL__ is defined. Compiliing uClibc against 2.5.70 fails because __user__ is not defined.

Adding patch below solves the problem (yes, I know, userspace is not supposed to use kernel headers...)

include/linux/sysctl.h renamed from include/linux/sysctl.h~ +1 -0
@@ -27,6 +27,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/list.h>
+#include <linux/compiler.h>
 
Quoted 5 lines

include/linux/sysctl.h line 32

Quoted 1 line
include/linux/sysctl.h renamed from include/linux/sysctl.h~ +0 -0
 struct file;

linux/kernel.h includes <linux/compiler.h>.

See the beginning of my message... it only does so if _KERNEL_ is defined. Since other header files also directly include compiler.h even though they already include kernel.h, I didn't think this was an unreasonable solution (i.e. they must have done it for the same reason, since there are comments specifically about including compiler.h for "__user").

#5 lore raw
Quoted 7 lines · Kevin P. Fleming

See the beginning of my message... it only does so if _KERNEL_ is defined. Since other header files also directly include compiler.h even though they already include kernel.h, I didn't think this was an unreasonable solution (i.e. they must have done it for the same reason, since there are comments specifically about including compiler.h for "__user").

Thats a bigger problem and should be solved like ( imho ) with higher level of kernel api which provides userspace apps kernel level operations.

Regards,
/ismail

#6 lore raw
Quoted 11 lines · ismail (cartman) donmez
Quoted 7 lines · Kevin P. Fleming

See the beginning of my message... it only does so if _KERNEL_ is defined. Since other header files also directly include compiler.h even though they already include kernel.h, I didn't think this was an unreasonable solution (i.e. they must have done it for the same reason, since there are comments specifically about including compiler.h for "__user").

Quoted 2 lines

Thats a bigger problem and should be solved like ( imho ) with higher level of kernel api which provides userspace apps kernel level operations.

Right. But until such time as that happens (even if started today that's many months away), real world libraries need to be compiled to be used against the new kernel.

#7 lore raw
Quoted 4 lines · Kevin P. Fleming

Right. But until such time as that happens (even if started today that's many months away), real world libraries need to be compiled to be used against the new kernel.

Yes I reported to binutils hackers that this change broke binutils ( + glibc ) but kernel guys just say "do not include kernel headers in userspace" .

Regards,
/ismail

#8 lore raw
Quoted 10 lines · ismail (cartman) donmez
Quoted 4 lines · Kevin P. Fleming

Right. But until such time as that happens (even if started today that's many months away), real world libraries need to be compiled to be used against the new kernel.

Yes I reported to binutils hackers that this change broke binutils ( + glibc ) but kernel guys just say "do not include kernel headers in userspace" .

Oh, I saw that discussion. I fully agree. If I can help the process of creating a sanitized userspace set of kernel headers I'll be happy to.

In the meantime, a small change to a kernel header, that provides _zero_ functional difference to the kernel itself (it's only there for source code checkers, as best I can tell) shouldn't break existing userspace libraries.

If it's going to, then we should just go ahead and break everything and get it done right. It's late in the 2.6 game, but the first few steps on the path have already been taken.

#9 lore raw
Quoted 7 lines · Kevin P. Fleming

Oh, I saw that discussion. I fully agree. If I can help the process of creating a sanitized userspace set of kernel headers I'll be happy to.

In the meantime, a small change to a kernel header, that provides _zero_ functional difference to the kernel itself (it's only there for source code checkers, as best I can tell) shouldn't break existing userspace libraries.

Fully ACK.

Regards,
/ismail

#10 lore raw
Quoted 4 lines · ismail (cartman) donmez
Quoted 3 lines · Kevin P. Fleming

Oh, I saw that discussion. I fully agree. If I can help the process of creating a sanitized userspace set of kernel headers I'll be happy to.

Well, Redhat do have "sanitized kernel headers", but according to the whole thread about glibc being broken, it is not the preferred solution.

The solution is to have a set of API headers that userspace can use, and that the kernel headers in turn include.

Problem now (as usual), is that even though I and a few others did offer to help or organise help if one kernel hacker is willing to take the lead, nobody responded, so I guess we will not see this any time soon.

Quoted 6 lines
Quoted 4 lines

In the meantime, a small change to a kernel header, that provides _zero_ functional difference to the kernel itself (it's only there for source code checkers, as best I can tell) shouldn't break existing userspace libraries.

Fully ACK.

Same here, as the "solution" will not be seen any time soon :/

Regards,

Signature · 1 line
Martin Schlemmer
#11 lore raw
Quoted 3 lines · Martin Schlemmer

The solution is to have a set of API headers that userspace can use, and that the kernel headers in turn include.

Yeah that would be great.

Quoted 5 lines

Problem now (as usual), is that even though I and a few others did offer to help or organise help if one kernel hacker is willing to take the lead, nobody responded, so I guess we will not see this any time soon.

No glibc,binutils for us then.

Regards,
/ismail