Skip to contentSkip to conversation

Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

PATCH In review Palmer Dabbelt 11 participants 258 messages Sep 2, 2015 – Feb 10, 2023 5 messages not in the archive Page 1 of 2

Subsystems (19)
Networking Network drivers x86 VFS +15 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

From: Palmer Dabbelt <[email protected]>

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

I went ahead and grep'd for any more of these (with headers_install_all), and this was the only one I found.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063effe0cc1..14a5c8237d84 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.6
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · On Tuesday 01 September 2015 17:10:10 Palmer Dabbelt wrote:

From: Palmer Dabbelt <[email protected]>

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

Quoted 6 lines

I went ahead and grep'd for any more of these (with headers_install_all), and this was the only one I found.

Looks good to me. Are you planning to submit the RISC-V port upstream any time soon? If so, just keep the patch in your tree and add my

However, I did see a lot of similar bugs now that you point me to it:

$  grep -r \\\<CONFIG obj-tmp/usr/include/
obj-tmp/usr/include/asm-generic/fcntl.h:#ifndef CONFIG_64BIT
obj-tmp/usr/include/asm-generic/mman-common.h:#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
obj-tmp/usr/include/asm-generic/unistd.h:#ifdef CONFIG_MMU
obj-tmp/usr/include/asm-generic/unistd.h:#endif /* CONFIG_MMU */
obj-tmp/usr/include/linux/atmdev.h:#ifdef CONFIG_COMPAT
obj-tmp/usr/include/linux/elfcore.h:#ifdef CONFIG_BINFMT_ELF_FDPIC
obj-tmp/usr/include/linux/eventpoll.h:#ifdef CONFIG_PM_SLEEP
obj-tmp/usr/include/linux/fb.h:#ifdef CONFIG_FB_BACKLIGHT
obj-tmp/usr/include/linux/flat.h:#ifdef CONFIG_BINFMT_SHARED_FLAT
obj-tmp/usr/include/linux/hw_breakpoint.h:#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
obj-tmp/usr/include/linux/pktcdvd.h:#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
obj-tmp/usr/include/linux/raw.h:#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
obj-tmp/usr/include/asm/ptrace.h:#ifdef CONFIG_CPU_ENDIAN_BE8

These all have the same problem, and we should fix them, as well as (probably) adding an automated check to scripts/headers_install.sh.

Arnd

#2 lore raw
Quoted 17 lines · On Mon, 07 Sep 2015 06:16:37 PDT (-0700), [email protected] wrote:
Quoted 16 lines · On Tuesday 01 September 2015 17:10:10 Palmer Dabbelt wrote:

From: Palmer Dabbelt <[email protected]>

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

I went ahead and grep'd for any more of these (with headers_install_all), and this was the only one I found.

Quoted 8 lines
Quoted 3 lines

Looks good to me. Are you planning to submit the RISC-V port upstream any time soon? If so, just keep the patch in your tree and add my

The RISC-V stuff is still a few months off, that's why I submitted this upstream stand-alone. The supervisor specification isn't 100% set in stone yet, and we're waiting on that before upstreaming anything significant.

Quoted 17 lines

However, I did see a lot of similar bugs now that you point me to it:

$  grep -r \\\<CONFIG obj-tmp/usr/include/
obj-tmp/usr/include/asm-generic/fcntl.h:#ifndef CONFIG_64BIT
obj-tmp/usr/include/asm-generic/mman-common.h:#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
obj-tmp/usr/include/asm-generic/unistd.h:#ifdef CONFIG_MMU
obj-tmp/usr/include/asm-generic/unistd.h:#endif /* CONFIG_MMU */
obj-tmp/usr/include/linux/atmdev.h:#ifdef CONFIG_COMPAT
obj-tmp/usr/include/linux/elfcore.h:#ifdef CONFIG_BINFMT_ELF_FDPIC
obj-tmp/usr/include/linux/eventpoll.h:#ifdef CONFIG_PM_SLEEP
obj-tmp/usr/include/linux/fb.h:#ifdef CONFIG_FB_BACKLIGHT
obj-tmp/usr/include/linux/flat.h:#ifdef CONFIG_BINFMT_SHARED_FLAT
obj-tmp/usr/include/linux/hw_breakpoint.h:#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
obj-tmp/usr/include/linux/pktcdvd.h:#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
obj-tmp/usr/include/linux/raw.h:#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
obj-tmp/usr/include/asm/ptrace.h:#ifdef CONFIG_CPU_ENDIAN_BE8
Quoted 2 lines

These all have the same problem, and we should fix them, as well as (probably) adding an automated check to scripts/headers_install.sh.

Well, I was going to go fix them all and ran a very similar grep, but I think I got a lot of false-positives. If I understand correctly, it's allowed to have CONFIG_* when guarded by __KERNEL__ in user-visible headers?

Now that I've written that, I realize it'd be pretty easy to just use cpp to drop everything inside __KERNEL__ and then look for CONFIG_*. If you want, I can try to do that, fix what triggers the check, and re-submit everything together?

maintainer
#3 lore raw
Quoted 25 lines · On Monday 07 September 2015 06:35:37 Palmer Dabbelt wrote:
Quoted 24 lines · On Mon, 07 Sep 2015 06:16:37 PDT (-0700), [email protected] wrote:
Quoted 13 lines · On Tuesday 01 September 2015 17:10:10 Palmer Dabbelt wrote:

From: Palmer Dabbelt <[email protected]>

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

Quoted 6 lines

I went ahead and grep'd for any more of these (with headers_install_all), and this was the only one I found.

Looks good to me. Are you planning to submit the RISC-V port upstream any time soon? If so, just keep the patch in your tree and add my

Quoted 6 lines
Quoted 1 line

The RISC-V stuff is still a few months off, that's why I submitted this upstream stand-alone. The supervisor specification isn't 100% set in stone yet, and we're waiting on that before upstreaming anything significant.

Ok, I see.

[adding [email protected]]

While this is a separate topic, I'd suggest you already start posting the patches for review anyway, for two reasons:

- Almost all of your code won't change any more, so by having it reviewed early, the review can be done by the time that the spec is ready and we can just merge it all. It's very rare that a new architecture gets merged within a single review cycle, so this buys you some more time.

- The people that do the review will also be the ones that are experienced on other architectures, so if there are some open questions for the architecture spec, we may be able to provide helpful suggestions. It's even possible that there is something that RISC-V currently does suboptimally and you only find out about it in the review.

In any case, when posting patches, just let us know when a patch is in a preliminary state, or when you already have plans to change a patch further.

Quoted 17 lines
Quoted 17 lines

However, I did see a lot of similar bugs now that you point me to it:

$  grep -r \\\<CONFIG obj-tmp/usr/include/
obj-tmp/usr/include/asm-generic/fcntl.h:#ifndef CONFIG_64BIT
obj-tmp/usr/include/asm-generic/mman-common.h:#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
obj-tmp/usr/include/asm-generic/unistd.h:#ifdef CONFIG_MMU
obj-tmp/usr/include/asm-generic/unistd.h:#endif /* CONFIG_MMU */
obj-tmp/usr/include/linux/atmdev.h:#ifdef CONFIG_COMPAT
obj-tmp/usr/include/linux/elfcore.h:#ifdef CONFIG_BINFMT_ELF_FDPIC
obj-tmp/usr/include/linux/eventpoll.h:#ifdef CONFIG_PM_SLEEP
obj-tmp/usr/include/linux/fb.h:#ifdef CONFIG_FB_BACKLIGHT
obj-tmp/usr/include/linux/flat.h:#ifdef CONFIG_BINFMT_SHARED_FLAT
obj-tmp/usr/include/linux/hw_breakpoint.h:#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
obj-tmp/usr/include/linux/pktcdvd.h:#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
obj-tmp/usr/include/linux/raw.h:#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
obj-tmp/usr/include/asm/ptrace.h:#ifdef CONFIG_CPU_ENDIAN_BE8
Quoted 7 lines
Quoted 2 lines

These all have the same problem, and we should fix them, as well as (probably) adding an automated check to scripts/headers_install.sh.

Well, I was going to go fix them all and ran a very similar grep, but I think I got a lot of false-positives. If I understand correctly, it's allowed to have CONFIG_* when guarded by __KERNEL__ in user-visible headers?

That is right.

Quoted 2 lines

Now that I've written that, I realize it'd be pretty easy to just use cpp to drop everything inside __KERNEL__ and then look for CONFIG_*.

The lines quoted above are from the output of 'make headers_install', which already drops everything inside of __KERNEL__. A lot of them probably just need to add that #ifdef, or move the portion of the header file to the normal (non-uabi) file.

Quoted 2 lines

If you want, I can try to do that, fix what triggers the check, and re-submit everything together?

That would be great, yes.

Arnd

#4 lore raw

I cut the RISC-V stuff, but I intend to reply to it later. As you said, it's just a different topic.

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines

However, I did see a lot of similar bugs now that you point me to it:

$  grep -r \\\<CONFIG obj-tmp/usr/include/
obj-tmp/usr/include/asm-generic/fcntl.h:#ifndef CONFIG_64BIT
obj-tmp/usr/include/asm-generic/mman-common.h:#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
obj-tmp/usr/include/asm-generic/unistd.h:#ifdef CONFIG_MMU
obj-tmp/usr/include/asm-generic/unistd.h:#endif /* CONFIG_MMU */
obj-tmp/usr/include/linux/atmdev.h:#ifdef CONFIG_COMPAT
obj-tmp/usr/include/linux/elfcore.h:#ifdef CONFIG_BINFMT_ELF_FDPIC
obj-tmp/usr/include/linux/eventpoll.h:#ifdef CONFIG_PM_SLEEP
obj-tmp/usr/include/linux/fb.h:#ifdef CONFIG_FB_BACKLIGHT
obj-tmp/usr/include/linux/flat.h:#ifdef CONFIG_BINFMT_SHARED_FLAT
obj-tmp/usr/include/linux/hw_breakpoint.h:#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
obj-tmp/usr/include/linux/pktcdvd.h:#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
obj-tmp/usr/include/linux/raw.h:#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
obj-tmp/usr/include/asm/ptrace.h:#ifdef CONFIG_CPU_ENDIAN_BE8

These all have the same problem, and we should fix them, as well as (probably) adding an automated check to scripts/headers_install.sh.

Quoted 6 lines
Quoted 4 lines

Well, I was going to go fix them all and ran a very similar grep, but I think I got a lot of false-positives. If I understand correctly, it's allowed to have CONFIG_* when guarded by __KERNEL__ in user-visible headers?

That is right.

It turns out there was actually a header checking script (scripts/headers_check.pl), and it already had a check for this. The check was just disabled because there was "too much noise". Rather than putting it in headers_install I've just fixed that script. I'm definately lacking in perl powers, so I have no idea if what I've done is sane. Specifically: there's a global variable and a line over 80 characters, but since there's a bunch of other violations I figure it's fine.

Quoted 8 lines
Quoted 2 lines

Now that I've written that, I realize it'd be pretty easy to just use cpp to drop everything inside __KERNEL__ and then look for CONFIG_*.

The lines quoted above are from the output of 'make headers_install', which already drops everything inside of __KERNEL__. A lot of them probably just need to add that #ifdef, or move the portion of the header file to the normal (non-uabi) file.

Quoted 4 lines
Quoted 2 lines

If you want, I can try to do that, fix what triggers the check, and re-submit everything together?

That would be great, yes.

OK. I think this has turned into more of a RFC than a PATCH, though... I've just #ifdef'd things for now to reduce the diff size, though I think it might be cleaner to move some of them to the non-user headers (ep_take_care_of_epollwakeup(), USE_WCACHING, MAX_RAW_MINORS).

I'm pretty far out of my depth here, so these should all be carefully considered, but there's a few that scare me more ("struct elf_prstatus", "enum by_type_idx", AT_VECTOR_SIZE_ARCH). I think there's only one actual bug here (MAP_UNINITIALIZED), the rest just quiet the checking script. Each patch has my rationale for what I did.

Since this touches a whole lot of stuff, I've added a whole bunch of CCs.

#5 lore raw

PATCH 1/13 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063effe0cc1..14a5c8237d84 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.6
#6 lore raw

PATCH 2/13 Always expose __SYSCALL(... fork ...)

In reply to Palmer Dabbelt

I think this change actually doesn't do anything: __NR_fork was still being defined either way, and on my machine fork() in <unistd.h> comes from libc.

That said, I don't think there's any way to determine this automatically, so this at least quiets the checker.

---
 include/uapi/asm-generic/unistd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/asm-generic/unistd.h +2 -2
index e016bd9b1a04..e027ef7aa01f 100644
@@ -865,11 +865,11 @@ __SYSCALL(__NR_uselib, sys_uselib)
 __SYSCALL(__NR__sysctl, sys_sysctl)
 
 #define __NR_fork 1079
-#ifdef CONFIG_MMU
+#if !defined(__KERNEL__) || defined(CONFIG_MMU)
 __SYSCALL(__NR_fork, sys_fork)
 #else
 __SYSCALL(__NR_fork, sys_ni_syscall)
-#endif /* CONFIG_MMU */
+#endif /* !__KERNEL__ || CONFIG_MMU */
 
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_fork+1)
Signature · 1 line
2.4.6
#7 lore raw

PATCH 3/13 Hide COMPAT_ATM_ADDPARTY behind #ifdef __KERNEL__

In reply to Palmer Dabbelt

This used to just be behind an #ifdef COMPAT_COMPAT, so most of userspace wouldn't have seen the definition before. This change just makes the __KERNEL__ part explicit to quiet the header checker.

---
 include/uapi/linux/atmdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/atmdev.h +1 -1
index 93e0ec008ca8..f8b6223165da 100644
@@ -100,7 +100,7 @@ struct atm_dev_stats {
 					/* use backend to make new if */
 #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
  					/* add party to p2mp call */
-#ifdef CONFIG_COMPAT
+#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
 /* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
 #define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf)
 #endif
Signature · 1 line
2.4.6
#8 lore raw

PATCH 4/13 Always expose MAP_UNINITIALIZED to userspace

In reply to Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

---
 include/uapi/asm-generic/mman-common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/asm-generic/mman-common.h +1 -1
index ddc3b36f1046..e58d1911ecc6 100644
@@ -19,7 +19,7 @@
 #define MAP_TYPE	0x0f		/* Mask for type of mapping */
 #define MAP_FIXED	0x10		/* Interpret addr exactly */
 #define MAP_ANONYMOUS	0x20		/* don't use a file */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+#if !defined(__KERNEL__) || defined(CONFIG_MMAP_ALLOW_UNINITIALIZED)
 # define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be uninitialized */
 #else
 # define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
Signature · 1 line
2.4.6
#9 lore raw

PATCH 5/13 Hide some of "struct elf_prstatus" behind #ifdef __KERNEL__

In reply to Palmer Dabbelt

This one scares me: while I can't find any system calls that directly take this as an argument, a comment in <linux/ptrace.h>

"
Generic ptrace interface that exports the architecture specific regsets using the corresponding NT_* types (which are also used in the core dump). Please note that the NT_PRSTATUS note type in a core dump contains a full 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the other user_regset flavors, the user_regset layout and the ELF core dump note payload are exactly the same layout.
"

seems to indicate that it's possible to see this sometimes. Since this would only be visible to userspace in a somewhat convoluted manner, I'm going to try and keep it as it was.

---
 include/uapi/linux/elfcore.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/elfcore.h +1 -1
index 569737cfb557..f9320b588937 100644
@@ -60,7 +60,7 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+#if defined(__KERNEL__) && defined(CONFIG_BINFMT_ELF_FDPIC)
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
Signature · 1 line
2.4.6
#10 lore raw

PATCH 6/13 Hide ep_take_care_of_epollwakeup() behind #ifdef __KERNEL__

In reply to Palmer Dabbelt

This doesn't make any sense to expose to userspace.

---
 include/uapi/linux/eventpoll.h | 3 +++
 1 file changed, 3 insertions(+)
include/uapi/linux/eventpoll.h +3 -0
index bc81fb2e1f0e..290426bfb0aa 100644
@@ -61,6 +61,7 @@ struct epoll_event {
 	__u64 data;
 } EPOLL_PACKED;
 
+#ifdef __KERNEL__
 #ifdef CONFIG_PM_SLEEP
 static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
 {
@@ -73,4 +74,6 @@ static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
 	epev->events &= ~EPOLLWAKEUP;
 }
 #endif
+#endif /*__KERNEL__*/
+
 #endif /* _UAPI_LINUX_EVENTPOLL_H */
Signature · 1 line
2.4.6
#11 lore raw

PATCH 7/13 Make FB_BACKLIGHT_{LEVELS,MAX} always visible

In reply to Palmer Dabbelt

Nothing else in the kernel defines this, and this header is visible to userspace. Rather than hiding it in an #ifdef, I think it's sane to just make this visible to userspace.

---
 include/uapi/linux/fb.h | 3 ---
 1 file changed, 3 deletions(-)
include/uapi/linux/fb.h +0 -3
index fb795c3b3c17..8926f13bc19f 100644
@@ -392,11 +392,8 @@ struct fb_cursor {
 	struct fb_image	image;	/* Cursor image */
 };
 
-#ifdef CONFIG_FB_BACKLIGHT
 /* Settings for the generic backlight code */
 #define FB_BACKLIGHT_LEVELS	128
 #define FB_BACKLIGHT_MAX	0xFF
-#endif
-
 
 #endif /* _UAPI_LINUX_FB_H */
Signature · 1 line
2.4.6
#12 lore raw

PATCH 8/13 Hide MAX_SHARED_LIBS behind #ifdef __KERNEL__

In reply to Palmer Dabbelt

I'm not sure what this is, but it doesn't feel like something that should be exposed to userspace here. I'm assuming this file was exposed for the structure in it, which doesn't depend on MAX_SHARED_LIBS.

---
 include/uapi/linux/flat.h | 2 ++
 1 file changed, 2 insertions(+)
include/uapi/linux/flat.h +2 -0
index 88cd6baba8f3..4ed679f3591e 100644
@@ -13,11 +13,13 @@
 
 #define	FLAT_VERSION			0x00000004L
 
+#ifdef __KERNEL__
 #ifdef CONFIG_BINFMT_SHARED_FLAT
 #define	MAX_SHARED_LIBS			(4)
 #else
 #define	MAX_SHARED_LIBS			(1)
 #endif
+#endif /*__KERNEL__*/
 
 /*
  * To make everything easier to port and manage cross platform
Signature · 1 line
2.4.6
#13 lore raw

PATCH 9/13 Hide bp_type_idx behind #ifdef __KERNEL__

In reply to Palmer Dabbelt

I'm actually not sure what to do here: if this enum is meant to be used by userspace, then it has to be the same regardless of kernel configuration. One option would be to have the kernel expose all the values to userspace and then map them internally if CONFIG_HAVE_MIXED_BREAKPOINT_REGS isn't set, but that feels like it'd be more invasive.

Here I took the simple and fail-fast route to hide all the definitions.

---
 include/uapi/linux/hw_breakpoint.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
include/uapi/linux/hw_breakpoint.h +3 -1
index b04000a2296a..2498bfbf56c4 100644
@@ -17,14 +17,16 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };
 
+#ifdef __KERNEL__
 enum bp_type_idx {
 	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
 	TYPE_DATA	= 0,
 #else
 	TYPE_DATA	= 1,
 #endif
 	TYPE_MAX
 };
+#endif /* __KERNEL__ */
 
 #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
Signature · 1 line
2.4.6
#14 lore raw

Re: [PATCH 09/13] Hide bp_type_idx behind #ifdef __KERNEL__

include/uapi/linux/hw_breakpoint.h enum { · line 30

Quoted 12 lines · Palmer Dabbelt
include/uapi/linux/hw_breakpoint.h +3 -1
+#ifdef __KERNEL__
 enum bp_type_idx {
 	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
 	TYPE_DATA	= 0,
 #else
 	TYPE_DATA	= 1,
 #endif
 	TYPE_MAX
 };
+#endif /* __KERNEL__ */

This should be in include/linux/hw_breakpoint.h without __KERNEL__ markings.

David

#15 lore raw

PATCH 10/13 Hide USE_WCACHING behind #ifdef __KERNEL__

In reply to Palmer Dabbelt

I don't think this was ever intended to be exposed to userspace.

---
 include/uapi/linux/pktcdvd.h | 2 ++
 1 file changed, 2 insertions(+)
include/uapi/linux/pktcdvd.h +2 -0
index 2640b9d4e243..e2a49bfee74e 100644
@@ -33,11 +33,13 @@
  * able to successfully recover with this option (drive will return good
  * status as soon as the cdb is validated).
  */
+#ifdef __KERNEL__
 #if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
 #define USE_WCACHING		1
 #else
 #define USE_WCACHING		0
 #endif
+#endif /* __KERNEL__ */
 
 /*
  * No user-servicable parts beyond this point ->
Signature · 1 line
2.4.6
#16 lore raw

Re: [PATCH 10/13] Hide USE_WCACHING behind #ifdef __KERNEL__

Quoted 1 line · Palmer Dabbelt

I don't think this was ever intended to be exposed to userspace.

Then it should be in include/linux/pktcdvd.h

David

#17 lore raw

PATCH 11/13 Hide MAX_RAW_MINORS behind #ifdef __KERNEL__

In reply to Palmer Dabbelt

I don't think this was ever meant to be exposed to userspace.

---
 include/uapi/linux/raw.h | 2 ++
 1 file changed, 2 insertions(+)
include/uapi/linux/raw.h +2 -0
index 62d543e70603..6d8d87524ff2 100644
@@ -13,6 +13,8 @@ struct raw_config_request
 	__u64	block_minor;
 };
 
+#ifdef __KERNEL__
 #define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
+#endif
 
 #endif /* __LINUX_RAW_H */
Signature · 1 line
2.4.6
#18 lore raw

Re: [PATCH 11/13] Hide MAX_RAW_MINORS behind #ifdef __KERNEL__

Quoted 1 line · Palmer Dabbelt

I don't think this was ever meant to be exposed to userspace.

Then it should be in include/linux/raw.h

David

#19 lore raw

PATCH 12/13 Hide AT_VECTOR_SIZE_ARCH behind #ifdef __KERNEL__

In reply to Palmer Dabbelt

I think this actually isn't a good idea, but I can't find anything outside of the kernel that's using this so I'm going to hide it.

---
 arch/x86/include/uapi/asm/auxvec.h | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/include/uapi/asm/auxvec.h +2 -0
index 77203ac352de..88e5fa6d97e7 100644
@@ -9,11 +9,13 @@
 #endif
 #define AT_SYSINFO_EHDR		33
 
+#ifdef __KERNEL__
 /* entries in ARCH_DLINFO: */
 #if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
 # define AT_VECTOR_SIZE_ARCH 2
 #else /* else it's non-compat x86-64 */
 # define AT_VECTOR_SIZE_ARCH 1
 #endif
+#endif /* __KERNEL__ */
 
 #endif /* _ASM_X86_AUXVEC_H */
Signature · 1 line
2.4.6
#20 lore raw

Re: [PATCH 12/13] Hide AT_VECTOR_SIZE_ARCH behind #ifdef __KERNEL__

Quoted 2 lines · Palmer Dabbelt

I think this actually isn't a good idea, but I can't find anything outside of the kernel that's using this so I'm going to hide it.

It should be in arch/x86/include/asm/auxvec.h then.

#21 lore raw

PATCH 13/13 Re-enable and clean up "check_config()" in headers_check.pl

In reply to Palmer Dabbelt

I recently got bit by a CONFIG_ in userspace bug. This has apparently happened before, but the check got disabled for triggering too much. In order to reduce false positives, I added some hueristics to avoid detecting comments.

Since these tests all pass, I've now re-enabled them.

---
 scripts/headers_check.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
scripts/headers_check.pl +17 -2
index 62320f93e903..dd413ad9c850 100755
@@ -40,7 +40,7 @@ foreach my $file (@files) {
 		&check_asm_types();
 		&check_sizetypes();
 		&check_declarations();
-		# Dropped for now. Too much noise &check_config();
+		&check_config();
 	}
 	close $fh;
 }
@@ -76,9 +76,24 @@ sub check_declarations
 	}
 }
 
+my $check_config_in_multiline_comment = 0;
 sub check_config
 {
-	if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+	my $nocomments = $line;
+	$nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+	$nocomments =~ s/\/\/.*//;     # Remove C99-style comments (// to EOL)
+
+	# Check to see if we're within a multiline comment, and if so
+	# just remove the whole line.  I tried matching on '^ * ', but
+	# there's one header that doesn't prepend multi-line comments
+	# with * so that won't work.
+	if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+	if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+	if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+	# Check to see if there is something that looks like CONFIG_
+	# inside a userspace-accessible header file and if so, print that out.
+	if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
 		printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
 	}
 }
Signature · 1 line
2.4.6
#22 lore raw
In reply to Palmer Dabbelt

Rather than iterating through all the rest of your patches and saying the same thing, if there's something in a UAPI header that needs wrapping in __KERNEL__ to exclude it from userspace's use, then it should be transferred to the non-UAPI variant of that header (which should #include the UAPI variant).

David

#23 lore raw
Quoted 4 lines · David Howells

Rather than iterating through all the rest of your patches and saying the same thing, if there's something in a UAPI header that needs wrapping in __KERNEL__ to exclude it from userspace's use, then it should be transferred to the non-UAPI variant of that header (which should #include the UAPI variant).

I should mention that there is the odd case where this is difficult to achieve. See include/uapi/linux/acct.h for an example...

David

#24 lore raw
Quoted 9 lines · On Thu, 10 Sep 2015 04:18:05 PDT (-0700), [email protected] wrote:
Quoted 4 lines · David Howells

Rather than iterating through all the rest of your patches and saying the same thing, if there's something in a UAPI header that needs wrapping in __KERNEL__ to exclude it from userspace's use, then it should be transferred to the non-UAPI variant of that header (which should #include the UAPI variant).

I should mention that there is the odd case where this is difficult to achieve. See include/uapi/linux/acct.h for an example...

OK, sorry about that. I'm submitting a v3 that should fix these problems.

#25 lore raw

PATCH v3 1/1 Remove #ifdef CONFIG_* from all userspace headers

In reply to Palmer Dabbelt

This patch set used to be called "[PATCH] Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h".

This is version 3 of the patch set. I think things are kind of cleaning up, but there's still some questions I have:

* #4 might be dangerous, but I think this is the best way to do it because otherwise arch maintainers will have to #define this to something. Since Xtensa already had exactly the same bug as the asm-generic header did, I think it'd be best to avoid those if possible.

I'm OK changing this to define the value to 0 by default (though thinking now, I think it'd be better to not define it by default), since most kernels aren't going to have MAP_UNINITIALIZED do anything anyway.

* #5 is big and I don't really understand what's going on, so it's probably broken somewhere.

Also, there's some checkpatch warnings that I purposely haven't fixed:

* In #5, there's a checkpatch.pl complaint about same-line struct braces. I've left that in to match the rest of the file, but I can also fix all of them if that would be better.

* In #10, there's a checkpatch.pl complaint about a split printk format string, but that was there before and I don't see a way to make it a lot cleaner, so I'm leaving it alone.

* In #13, there's two checkpatch.pl complains. One is about block comments that is bogus, and one is about long lines but there's more of those so I think it's OK.

Thanks to everyone who looked at v2!

Changes since v2 (<[email protected]>)

* Patch set renamed.

* #2 is rewritten to use sys_ni.c instead of an #ifdef

* #3, #6, #8, #9, #10, and #11 no longer use "#ifdef __KERNEL__" but have instead moved the offending lines to the correct, kernel-only files.

* #4 has been rewritten to always define MAP_UNINITIALIZED to non-zero, rather than defining it to zero when in userspace.

* #5 got a whole lot longer -- rather than just always hiding these fields from userspace, there is now a second "struct elf_fdpic_prstatus" structure. This should allow userspace to parse core dumps correctly.

* Rebased onto 9c488de24f7264f08d341024bffdd637b4d04c96.

Changes since v1 (<[email protected]>)

* All patches but #1 were added.

#26 lore raw

PATCH 1/13 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063effe0cc1..14a5c8237d84 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.6

A message that is not in the archive (sent off-list or not yet received): 1442271047-4908-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org

#28 lore raw

PATCH 1/13 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063effe0cc1..14a5c8237d84 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.6
#29 lore raw

PATCH 1/13 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

In reply to a message not in the archive

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063effe0cc1..14a5c8237d84 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.6
#30 lore raw

PATCH 2/13 Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU

In reply to a message not in the archive

I think this change actually doesn't do anything: __NR_fork was still being defined either way, and on my machine fork() in <unistd.h> comes from libc.

This just moves to the standard mechanism for defining syscalls that aren't implemented instead, which has the side-effect of no longer having an #ifdef CONFIG_* in a user-visible header.

---
 include/uapi/asm-generic/unistd.h | 4 ----
 kernel/sys_ni.c                   | 1 +
 2 files changed, 1 insertion(+), 4 deletions(-)
include/uapi/asm-generic/unistd.h +0 -4
index 8da542a2874d..21689284360b 100644
@@ -867,11 +867,7 @@ __SYSCALL(__NR_uselib, sys_uselib)
 __SYSCALL(__NR__sysctl, sys_sysctl)
 
 #define __NR_fork 1079
-#ifdef CONFIG_MMU
 __SYSCALL(__NR_fork, sys_fork)
-#else
-__SYSCALL(__NR_fork, sys_ni_syscall)
-#endif /* CONFIG_MMU */
 
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_fork+1)
kernel/sys_ni.c +1 -0
index a02decf15583..c830f7f9e36d 100644
@@ -174,6 +174,7 @@ cond_syscall(sys_setfsuid);
 cond_syscall(sys_setfsgid);
 cond_syscall(sys_capget);
 cond_syscall(sys_capset);
+cond_syscall(sys_fork);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
Signature · 1 line
2.4.6
#31 lore raw

PATCH 2/13 Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU

In reply to a message not in the archive

I think this change actually doesn't do anything: __NR_fork was still being defined either way, and on my machine fork() in <unistd.h> comes from libc.

This just moves to the standard mechanism for defining syscalls that aren't implemented instead, which has the side-effect of no longer having an #ifdef CONFIG_* in a user-visible header.

---
 include/uapi/asm-generic/unistd.h | 4 ----
 kernel/sys_ni.c                   | 1 +
 2 files changed, 1 insertion(+), 4 deletions(-)
include/uapi/asm-generic/unistd.h +0 -4
index 8da542a2874d..21689284360b 100644
@@ -867,11 +867,7 @@ __SYSCALL(__NR_uselib, sys_uselib)
 __SYSCALL(__NR__sysctl, sys_sysctl)
 
 #define __NR_fork 1079
-#ifdef CONFIG_MMU
 __SYSCALL(__NR_fork, sys_fork)
-#else
-__SYSCALL(__NR_fork, sys_ni_syscall)
-#endif /* CONFIG_MMU */
 
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_fork+1)
kernel/sys_ni.c +1 -0
index a02decf15583..c830f7f9e36d 100644
@@ -174,6 +174,7 @@ cond_syscall(sys_setfsuid);
 cond_syscall(sys_setfsgid);
 cond_syscall(sys_capget);
 cond_syscall(sys_capset);
+cond_syscall(sys_fork);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
Signature · 1 line
2.4.6
#32 lore raw

PATCH 3/13 Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

In reply to a message not in the archive

This used to be behind an #ifdef COMPAT_COMPAT, so most of userspace wouldn't have seen the definition before. Unfortunately this header file became visible to userspace, so the definition has instead been moved to net/atm/svc.c (the only user).

---
 include/uapi/linux/atmdev.h | 4 ----
 net/atm/svc.c               | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
include/uapi/linux/atmdev.h +0 -4
index 93e0ec008ca8..3dcec701501c 100644
@@ -100,10 +100,6 @@ struct atm_dev_stats {
 					/* use backend to make new if */
 #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
  					/* add party to p2mp call */
-#ifdef CONFIG_COMPAT
-/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
-#define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf)
-#endif
 #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)
 					/* drop party from p2mp call */
 
net/atm/svc.c +5 -0
index 3fa0a9ee98d1..9e2e6ef285e8 100644
@@ -27,6 +27,11 @@
 #include "signaling.h"
 #include "addr.h"
 
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif
+
 static int svc_create(struct net *net, struct socket *sock, int protocol,
 		      int kern);
 
Signature · 1 line
2.4.6
#33 lore raw

PATCH 4/13 Always expose MAP_UNINITIALIZED to userspace

In reply to a message not in the archive

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

This change also applies to the xtensa version of this definition, whic is the same as the generic one.

---
 arch/xtensa/include/uapi/asm/mman.h    | 4 +---
 include/uapi/asm-generic/mman-common.h | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
arch/xtensa/include/uapi/asm/mman.h +1 -3
index 201aec0e0446..2cbc1e717082 100644
@@ -55,11 +55,9 @@
 #define MAP_NONBLOCK	0x20000		/* do not block on IO */
 #define MAP_STACK	0x40000		/* give out an address that is best suited for process/thread stacks */
 #define MAP_HUGETLB	0x80000		/* create a huge page mapping */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be
 					 * uninitialized */
-#else
-# define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
 /*
include/uapi/asm-generic/mman-common.h +1 -3
index ddc3b36f1046..7aeeb12db193 100644
@@ -19,10 +19,8 @@
 #define MAP_TYPE	0x0f		/* Mask for type of mapping */
 #define MAP_FIXED	0x10		/* Interpret addr exactly */
 #define MAP_ANONYMOUS	0x20		/* don't use a file */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be uninitialized */
-#else
-# define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
 #define MS_ASYNC	1		/* sync memory asynchronously */
Signature · 1 line
2.4.6
#34 lore raw

PATCH 4/13 Always expose MAP_UNINITIALIZED to userspace

In reply to a message not in the archive

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

This change also applies to the xtensa version of this definition, whic is the same as the generic one.

---
 arch/xtensa/include/uapi/asm/mman.h    | 4 +---
 include/uapi/asm-generic/mman-common.h | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
arch/xtensa/include/uapi/asm/mman.h +1 -3
index 201aec0e0446..2cbc1e717082 100644
@@ -55,11 +55,9 @@
 #define MAP_NONBLOCK	0x20000		/* do not block on IO */
 #define MAP_STACK	0x40000		/* give out an address that is best suited for process/thread stacks */
 #define MAP_HUGETLB	0x80000		/* create a huge page mapping */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be
 					 * uninitialized */
-#else
-# define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
 /*
include/uapi/asm-generic/mman-common.h +1 -3
index ddc3b36f1046..7aeeb12db193 100644
@@ -19,10 +19,8 @@
 #define MAP_TYPE	0x0f		/* Mask for type of mapping */
 #define MAP_FIXED	0x10		/* Interpret addr exactly */
 #define MAP_ANONYMOUS	0x20		/* don't use a file */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be uninitialized */
-#else
-# define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
 #define MS_ASYNC	1		/* sync memory asynchronously */
Signature · 1 line
2.4.6
#35 lore raw

PATCH 5/13 Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

In reply to a message not in the archive

This is a pretty big change that I haven't tested any, which worries me a lot. The general idea here is that "struct elf_prstatus" can be visible to userspace (from <linux/ptrace.h>)

"
Generic ptrace interface that exports the architecture specific regsets using the corresponding NT_* types (which are also used in the core dump). Please note that the NT_PRSTATUS note type in a core dump contains a full 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the other user_regset flavors, the user_regset layout and the ELF core dump note payload are exactly the same layout.
"

so it shouldn't have an "#ifdef CONFIG_" in there.

This splits the structure into two different structures, one still named "struct elf_prstatus", and one for ELF FDPIC that is named "struct elf_fdpic_prstatus" -- the idea here is that most users are standard ELF, so that's the name that didn't change.

I tried to fix all the users of "struct elf_prstatus" that should now be using "struct elf_fdpic_prstatus". The only testing I did here was to build a Blackfin defconfig with "struct elf_prstatus" not defined, and to build an x86 defconfig with "struct elf_fdpic_prstatus" not defined.

Note that this fails checkpatch.pl with a complaint about wanting open braces on the same line as struct definitions. The existing struct definitions in this file have the brace a line afterwards, so I'm going to leave this alone.

---
 fs/binfmt_elf_fdpic.c        |  6 +++---
 fs/proc/kcore.c              | 16 ++++++++++++++++
 include/linux/kexec.h        |  4 ++++
 include/uapi/linux/elfcore.h | 37 +++++++++++++++++++++++++++++++++++--
 kernel/kexec_core.c          |  4 ++++
 5 files changed, 62 insertions(+), 5 deletions(-)
fs/binfmt_elf_fdpic.c +3 -3
index d3634bfb7fe1..587bf0466d71 100644
@@ -1323,7 +1323,7 @@ static inline void fill_note(struct memelfnote *note, const char *name, int type
  * fill up all the fields in prstatus from the given task struct, except
  * registers which need to be filled up separately.
  */
-static void fill_prstatus(struct elf_prstatus *prstatus,
+static void fill_prstatus(struct elf_fdpic_prstatus *prstatus,
 			  struct task_struct *p, long signr)
 {
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1406,7 +1406,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
 struct elf_thread_status
 {
 	struct list_head list;
-	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1539,7 +1539,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
 	loff_t offset = 0, dataoff;
 	int numnote;
 	struct memelfnote *notes = NULL;
-	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
 	struct elf_prpsinfo *psinfo = NULL;	/* NT_PRPSINFO */
  	LIST_HEAD(thread_list);
  	struct list_head *t;
fs/proc/kcore.c +16 -0
index 92e6726f6e37..b1edd77ec854 100644
@@ -90,7 +90,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 			(*nphdr + 2)*sizeof(struct elf_phdr) + 
 			3 * ((sizeof(struct elf_note)) +
 			     roundup(sizeof(CORE_STR), 4)) +
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+			roundup(sizeof(struct elf_fdpic_prstatus), 4) +
+#else
 			roundup(sizeof(struct elf_prstatus), 4) +
+#endif
 			roundup(sizeof(struct elf_prpsinfo), 4) +
 			roundup(arch_task_struct_size, 4);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
@@ -318,7 +322,11 @@ static char *storenote(struct memelfnote *men, char *bufp)
  */
 static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
+#else
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+#endif
 	struct elf_prpsinfo prpsinfo;	/* NT_PRPSINFO */
 	struct elf_phdr *nhdr, *phdr;
 	struct elfhdr *elf;
@@ -387,10 +395,18 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	/* set up the process status */
 	notes[0].name = CORE_STR;
 	notes[0].type = NT_PRSTATUS;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	notes[0].datasz = sizeof(struct elf_fdpic_prstatus);
+#else
 	notes[0].datasz = sizeof(struct elf_prstatus);
+#endif
 	notes[0].data = &prstatus;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	memset(&prstatus, 0, sizeof(struct elf_fdpic_prstatus));
+#else
 	memset(&prstatus, 0, sizeof(struct elf_prstatus));
+#endif
 
 	nhdr->p_filesz	= notesize(&notes[0]);
 	bufp = storenote(&notes[0], bufp);
include/linux/kexec.h +4 -0
index d140b1e9faa7..d9196ccd3781 100644
@@ -63,7 +63,11 @@
 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 #define KEXEC_CORE_NOTE_NAME "CORE"
 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_fdpic_prstatus), 4)
+#else
 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#endif
 /*
  * The per-cpu notes area is a list of notes terminated by a "NULL"
  * note header.  For kdump, the code in vmcore.c runs in the context
include/uapi/linux/elfcore.h +35 -2
index 569737cfb557..697c52db0227 100644
@@ -60,7 +60,40 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+	int pr_fpvalid;		/* True if math co-processor being used.  */
+};
+
+/* Architectures that set CONFIG_BINFMT_ELF_FDPIC use this instead of
+ * "struct elf_prstatus".
+ */
+struct elf_fdpic_prstatus
+{
+#if 0
+	long	pr_flags;	/* XXX Process flags */
+	short	pr_why;		/* XXX Reason for process halt */
+	short	pr_what;	/* XXX More detailed reason */
+#endif
+	struct elf_siginfo pr_info;	/* Info associated with signal */
+	short	pr_cursig;		/* Current signal */
+	unsigned long pr_sigpend;	/* Set of pending signals */
+	unsigned long pr_sighold;	/* Set of held signals */
+#if 0
+	struct sigaltstack pr_altstack;	/* Alternate stack info */
+	struct sigaction pr_action;	/* Signal action for current sig */
+#endif
+	pid_t	pr_pid;
+	pid_t	pr_ppid;
+	pid_t	pr_pgrp;
+	pid_t	pr_sid;
+	struct timeval pr_utime;	/* User time */
+	struct timeval pr_stime;	/* System time */
+	struct timeval pr_cutime;	/* Cumulative user time */
+	struct timeval pr_cstime;	/* Cumulative system time */
+#if 0
+	long	pr_instr;		/* Current instruction */
+#endif
+	elf_gregset_t pr_reg;	/* GP registers */
+
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
@@ -69,7 +102,7 @@ struct elf_prstatus
 	 */
 	unsigned long pr_exec_fdpic_loadmap;
 	unsigned long pr_interp_fdpic_loadmap;
-#endif
+
 	int pr_fpvalid;		/* True if math co-processor being used.  */
 };
 
kernel/kexec_core.c +4 -0
index 201b45327804..8d2fc707fecf 100644
@@ -977,7 +977,11 @@ static void final_note(u32 *buf)
 
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;
+#else
 	struct elf_prstatus prstatus;
+#endif
 	u32 *buf;
 
 	if ((cpu < 0) || (cpu >= nr_cpu_ids))
Signature · 1 line
2.4.6
#36 lore raw

PATCH 5/13 Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

In reply to a message not in the archive

This is a pretty big change that I haven't tested any, which worries me a lot. The general idea here is that "struct elf_prstatus" can be visible to userspace (from <linux/ptrace.h>)

"
Generic ptrace interface that exports the architecture specific regsets using the corresponding NT_* types (which are also used in the core dump). Please note that the NT_PRSTATUS note type in a core dump contains a full 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the other user_regset flavors, the user_regset layout and the ELF core dump note payload are exactly the same layout.
"

so it shouldn't have an "#ifdef CONFIG_" in there.

This splits the structure into two different structures, one still named "struct elf_prstatus", and one for ELF FDPIC that is named "struct elf_fdpic_prstatus" -- the idea here is that most users are standard ELF, so that's the name that didn't change.

I tried to fix all the users of "struct elf_prstatus" that should now be using "struct elf_fdpic_prstatus". The only testing I did here was to build a Blackfin defconfig with "struct elf_prstatus" not defined, and to build an x86 defconfig with "struct elf_fdpic_prstatus" not defined.

Note that this fails checkpatch.pl with a complaint about wanting open braces on the same line as struct definitions. The existing struct definitions in this file have the brace a line afterwards, so I'm going to leave this alone.

---
 fs/binfmt_elf_fdpic.c        |  6 +++---
 fs/proc/kcore.c              | 16 ++++++++++++++++
 include/linux/kexec.h        |  4 ++++
 include/uapi/linux/elfcore.h | 37 +++++++++++++++++++++++++++++++++++--
 kernel/kexec_core.c          |  4 ++++
 5 files changed, 62 insertions(+), 5 deletions(-)
fs/binfmt_elf_fdpic.c +3 -3
index d3634bfb7fe1..587bf0466d71 100644
@@ -1323,7 +1323,7 @@ static inline void fill_note(struct memelfnote *note, const char *name, int type
  * fill up all the fields in prstatus from the given task struct, except
  * registers which need to be filled up separately.
  */
-static void fill_prstatus(struct elf_prstatus *prstatus,
+static void fill_prstatus(struct elf_fdpic_prstatus *prstatus,
 			  struct task_struct *p, long signr)
 {
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1406,7 +1406,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
 struct elf_thread_status
 {
 	struct list_head list;
-	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1539,7 +1539,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
 	loff_t offset = 0, dataoff;
 	int numnote;
 	struct memelfnote *notes = NULL;
-	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
 	struct elf_prpsinfo *psinfo = NULL;	/* NT_PRPSINFO */
  	LIST_HEAD(thread_list);
  	struct list_head *t;
fs/proc/kcore.c +16 -0
index 92e6726f6e37..b1edd77ec854 100644
@@ -90,7 +90,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 			(*nphdr + 2)*sizeof(struct elf_phdr) + 
 			3 * ((sizeof(struct elf_note)) +
 			     roundup(sizeof(CORE_STR), 4)) +
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+			roundup(sizeof(struct elf_fdpic_prstatus), 4) +
+#else
 			roundup(sizeof(struct elf_prstatus), 4) +
+#endif
 			roundup(sizeof(struct elf_prpsinfo), 4) +
 			roundup(arch_task_struct_size, 4);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
@@ -318,7 +322,11 @@ static char *storenote(struct memelfnote *men, char *bufp)
  */
 static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
+#else
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+#endif
 	struct elf_prpsinfo prpsinfo;	/* NT_PRPSINFO */
 	struct elf_phdr *nhdr, *phdr;
 	struct elfhdr *elf;
@@ -387,10 +395,18 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	/* set up the process status */
 	notes[0].name = CORE_STR;
 	notes[0].type = NT_PRSTATUS;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	notes[0].datasz = sizeof(struct elf_fdpic_prstatus);
+#else
 	notes[0].datasz = sizeof(struct elf_prstatus);
+#endif
 	notes[0].data = &prstatus;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	memset(&prstatus, 0, sizeof(struct elf_fdpic_prstatus));
+#else
 	memset(&prstatus, 0, sizeof(struct elf_prstatus));
+#endif
 
 	nhdr->p_filesz	= notesize(&notes[0]);
 	bufp = storenote(&notes[0], bufp);
include/linux/kexec.h +4 -0
index d140b1e9faa7..d9196ccd3781 100644
@@ -63,7 +63,11 @@
 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 #define KEXEC_CORE_NOTE_NAME "CORE"
 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_fdpic_prstatus), 4)
+#else
 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#endif
 /*
  * The per-cpu notes area is a list of notes terminated by a "NULL"
  * note header.  For kdump, the code in vmcore.c runs in the context
include/uapi/linux/elfcore.h +35 -2
index 569737cfb557..697c52db0227 100644
@@ -60,7 +60,40 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+	int pr_fpvalid;		/* True if math co-processor being used.  */
+};
+
+/* Architectures that set CONFIG_BINFMT_ELF_FDPIC use this instead of
+ * "struct elf_prstatus".
+ */
+struct elf_fdpic_prstatus
+{
+#if 0
+	long	pr_flags;	/* XXX Process flags */
+	short	pr_why;		/* XXX Reason for process halt */
+	short	pr_what;	/* XXX More detailed reason */
+#endif
+	struct elf_siginfo pr_info;	/* Info associated with signal */
+	short	pr_cursig;		/* Current signal */
+	unsigned long pr_sigpend;	/* Set of pending signals */
+	unsigned long pr_sighold;	/* Set of held signals */
+#if 0
+	struct sigaltstack pr_altstack;	/* Alternate stack info */
+	struct sigaction pr_action;	/* Signal action for current sig */
+#endif
+	pid_t	pr_pid;
+	pid_t	pr_ppid;
+	pid_t	pr_pgrp;
+	pid_t	pr_sid;
+	struct timeval pr_utime;	/* User time */
+	struct timeval pr_stime;	/* System time */
+	struct timeval pr_cutime;	/* Cumulative user time */
+	struct timeval pr_cstime;	/* Cumulative system time */
+#if 0
+	long	pr_instr;		/* Current instruction */
+#endif
+	elf_gregset_t pr_reg;	/* GP registers */
+
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
@@ -69,7 +102,7 @@ struct elf_prstatus
 	 */
 	unsigned long pr_exec_fdpic_loadmap;
 	unsigned long pr_interp_fdpic_loadmap;
-#endif
+
 	int pr_fpvalid;		/* True if math co-processor being used.  */
 };
 
kernel/kexec_core.c +4 -0
index 201b45327804..8d2fc707fecf 100644
@@ -977,7 +977,11 @@ static void final_note(u32 *buf)
 
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;
+#else
 	struct elf_prstatus prstatus;
+#endif
 	u32 *buf;
 
 	if ((cpu < 0) || (cpu >= nr_cpu_ids))
Signature · 1 line
2.4.6
#37 lore raw

PATCH 6/13 Move ep_take_care_of_epollwakeup() to fs/eventpoll.c

In reply to a message not in the archive

This doesn't make any sense to expose to userspace, so it's been moved to the one user. This was introduced by commit 95f19f658ce1 ("epoll:
drop EPOLLWAKEUP if PM_SLEEP is disabled").

---
 fs/eventpoll.c                 | 13 +++++++++++++
 include/uapi/linux/eventpoll.h | 12 ------------
 2 files changed, 13 insertions(+), 12 deletions(-)
fs/eventpoll.c +13 -0
index 1e009cad8d5c..aadee3d1931a 100644
@@ -1812,6 +1812,19 @@ SYSCALL_DEFINE1(epoll_create, int, size)
 	return sys_epoll_create1(0);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
+		epev->events &= ~EPOLLWAKEUP;
+}
+#else
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	epev->events &= ~EPOLLWAKEUP;
+}
+#endif
+
 /*
  * The following function implements the controller interface for
  * the eventpoll file that enables the insertion/removal/change of
include/uapi/linux/eventpoll.h +0 -12
index bc81fb2e1f0e..7850373079ee 100644
@@ -61,16 +61,4 @@ struct epoll_event {
 	__u64 data;
 } EPOLL_PACKED;
 
-#ifdef CONFIG_PM_SLEEP
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
-		epev->events &= ~EPOLLWAKEUP;
-}
-#else
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	epev->events &= ~EPOLLWAKEUP;
-}
-#endif
 #endif /* _UAPI_LINUX_EVENTPOLL_H */
Signature · 1 line
2.4.6
#38 lore raw

PATCH 7/13 Make FB_BACKLIGHT_{LEVELS,MAX} always visible

In reply to a message not in the archive

Nothing else in the kernel defines this, and this header is visible to userspace. Rather than hiding it in an #ifdef, I think it's sane to just make this visible to userspace.

---
 include/uapi/linux/fb.h | 3 ---
 1 file changed, 3 deletions(-)
include/uapi/linux/fb.h +0 -3
index fb795c3b3c17..8926f13bc19f 100644
@@ -392,11 +392,8 @@ struct fb_cursor {
 	struct fb_image	image;	/* Cursor image */
 };
 
-#ifdef CONFIG_FB_BACKLIGHT
 /* Settings for the generic backlight code */
 #define FB_BACKLIGHT_LEVELS	128
 #define FB_BACKLIGHT_MAX	0xFF
-#endif
-
 
 #endif /* _UAPI_LINUX_FB_H */
Signature · 1 line
2.4.6
#39 lore raw

PATCH 7/13 Make FB_BACKLIGHT_{LEVELS,MAX} always visible

In reply to a message not in the archive

Nothing else in the kernel defines this, and this header is visible to userspace. Rather than hiding it in an #ifdef, I think it's sane to just make this visible to userspace.

---
 include/uapi/linux/fb.h | 3 ---
 1 file changed, 3 deletions(-)
include/uapi/linux/fb.h +0 -3
index fb795c3b3c17..8926f13bc19f 100644
@@ -392,11 +392,8 @@ struct fb_cursor {
 	struct fb_image	image;	/* Cursor image */
 };
 
-#ifdef CONFIG_FB_BACKLIGHT
 /* Settings for the generic backlight code */
 #define FB_BACKLIGHT_LEVELS	128
 #define FB_BACKLIGHT_MAX	0xFF
-#endif
-
 
 #endif /* _UAPI_LINUX_FB_H */
Signature · 1 line
2.4.6
#40 lore raw

PATCH 8/13 Move MAX_SHARED_LIBS to fs/binfmt_flat.c

In reply to a message not in the archive

I'm not sure what this is, but it doesn't feel like something that should be exposed to userspace here. I'm assuming this file was exposed for the structure in it, which doesn't depend on MAX_SHARED_LIBS.

---
 fs/binfmt_flat.c          | 6 ++++++
 include/uapi/linux/flat.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/binfmt_flat.c +6 -0
index f723cd3a455c..e89fb43c2a10 100644
@@ -72,6 +72,12 @@
 #define RELOC_FAILED 0xff00ff01		/* Relocation incorrect somewhere */
 #define UNLOADED_LIB 0x7ff000ff		/* Placeholder for unused library */
 
+#ifdef CONFIG_BINFMT_SHARED_FLAT
+#define	MAX_SHARED_LIBS			(4)
+#else
+#define	MAX_SHARED_LIBS			(1)
+#endif
+
 struct lib_info {
 	struct {
 		unsigned long start_code;		/* Start of text segment */
include/uapi/linux/flat.h +0 -6
index 88cd6baba8f3..1b177c7637c4 100644
@@ -13,12 +13,6 @@
 
 #define	FLAT_VERSION			0x00000004L
 
-#ifdef CONFIG_BINFMT_SHARED_FLAT
-#define	MAX_SHARED_LIBS			(4)
-#else
-#define	MAX_SHARED_LIBS			(1)
-#endif
-
 /*
  * To make everything easier to port and manage cross platform
  * development,  all fields are in network byte order.
Signature · 1 line
2.4.6
#41 lore raw

PATCH 9/13 Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to a message not in the archive

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -10
index b04000a2296a..7a6a5a7f9511 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};
-
 #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
kernel/events/hw_breakpoint.c +10 -0
index 92ce5f4ccc26..5ad117e0f55b 100644
@@ -58,6 +58,16 @@ struct bp_cpuinfo {
 	unsigned int	flexible; /* XXX: placeholder, see fetch_this_slot() */
 };
 
+enum bp_type_idx {
+	TYPE_INST	= 0,
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
+	TYPE_DATA	= 0,
+#else
+	TYPE_DATA	= 1,
+#endif
+	TYPE_MAX
+};
+
 static DEFINE_PER_CPU(struct bp_cpuinfo, bp_cpuinfo[TYPE_MAX]);
 static int nr_slots[TYPE_MAX];
 
Signature · 1 line
2.4.6
#42 lore raw

PATCH 9/13 Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to a message not in the archive

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -10
index b04000a2296a..7a6a5a7f9511 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};
-
 #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
kernel/events/hw_breakpoint.c +10 -0
index 92ce5f4ccc26..5ad117e0f55b 100644
@@ -58,6 +58,16 @@ struct bp_cpuinfo {
 	unsigned int	flexible; /* XXX: placeholder, see fetch_this_slot() */
 };
 
+enum bp_type_idx {
+	TYPE_INST	= 0,
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
+	TYPE_DATA	= 0,
+#else
+	TYPE_DATA	= 1,
+#endif
+	TYPE_MAX
+};
+
 static DEFINE_PER_CPU(struct bp_cpuinfo, bp_cpuinfo[TYPE_MAX]);
 static int nr_slots[TYPE_MAX];
 
Signature · 1 line
2.4.6
#43 lore raw

PATCH 10/13 Move USE_WCACHING to drivers/block/pktcdvd.c

In reply to a message not in the archive

I don't think this was ever intended to be exposed to userspace, but it did require an "#ifdef CONFIG_*". Since the name is kind of generic and was only used in one place, I've moved the definition to the one user.

---
 drivers/block/pktcdvd.c      | 11 +++++++++++
 include/uapi/linux/pktcdvd.h | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/block/pktcdvd.c +11 -0
index 7be2375db7f2..18d2d05f5ac9 100644
@@ -90,6 +90,17 @@ do {									\
 
 #define MAX_SPEED 0xffff
 
+/*
+ * use drive write caching -- we need deferred error handling to be
+ * able to successfully recover with this option (drive will return good
+ * status as soon as the cdb is validated).
+ */
+#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
+#define USE_WCACHING		1
+#else
+#define USE_WCACHING		0
+#endif
+
 static DEFINE_MUTEX(pktcdvd_mutex);
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
include/uapi/linux/pktcdvd.h +0 -11
index 2640b9d4e243..05c2bee70d6c 100644
@@ -29,17 +29,6 @@
 #define PACKET_WAIT_TIME	(HZ * 5 / 1000)
 
 /*
- * use drive write caching -- we need deferred error handling to be
- * able to successfully recover with this option (drive will return good
- * status as soon as the cdb is validated).
- */
-#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
-#define USE_WCACHING		1
-#else
-#define USE_WCACHING		0
-#endif
-
-/*
  * No user-servicable parts beyond this point ->
  */
 
Signature · 1 line
2.4.6
#44 lore raw

PATCH 11/13 Always define MAX_RAW_MINORS as 65535 in userspace

In reply to a message not in the archive

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

---
 drivers/char/raw.c       | 7 ++++---
 include/uapi/linux/raw.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/raw.c +4 -3
index 60316fbaf295..362d7a6511b9 100644
@@ -36,7 +36,7 @@ static struct raw_device_data *raw_devices;
 static DEFINE_MUTEX(raw_mutex);
 static const struct file_operations raw_ctl_fops; /* forward declaration */
 
-static int max_raw_minors = MAX_RAW_MINORS;
+static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
 
 module_param(max_raw_minors, int, 0);
 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,8 +317,9 @@ static int __init raw_init(void)
 
 	if (max_raw_minors < 1 || max_raw_minors > 65536) {
 		printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
-			" between 1 and 65536), using %d\n", MAX_RAW_MINORS);
-		max_raw_minors = MAX_RAW_MINORS;
+			" between 1 and 65536), using %d\n",
+		       CONFIG_MAX_RAW_MINORS);
+		max_raw_minors = CONFIG_MAX_RAW_MINORS;
 	}
 
 	raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
include/uapi/linux/raw.h +1 -1
index 62d543e70603..f0390b3e8530 100644
@@ -13,6 +13,6 @@ struct raw_config_request
 	__u64	block_minor;
 };
 
-#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
+#define MAX_RAW_MINORS 65535
 
 #endif /* __LINUX_RAW_H */
Signature · 1 line
2.4.6
#45 lore raw

PATCH 11/13 Always define MAX_RAW_MINORS as 65535 in userspace

In reply to a message not in the archive

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

---
 drivers/char/raw.c       | 7 ++++---
 include/uapi/linux/raw.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/raw.c +4 -3
index 60316fbaf295..362d7a6511b9 100644
@@ -36,7 +36,7 @@ static struct raw_device_data *raw_devices;
 static DEFINE_MUTEX(raw_mutex);
 static const struct file_operations raw_ctl_fops; /* forward declaration */
 
-static int max_raw_minors = MAX_RAW_MINORS;
+static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
 
 module_param(max_raw_minors, int, 0);
 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,8 +317,9 @@ static int __init raw_init(void)
 
 	if (max_raw_minors < 1 || max_raw_minors > 65536) {
 		printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
-			" between 1 and 65536), using %d\n", MAX_RAW_MINORS);
-		max_raw_minors = MAX_RAW_MINORS;
+			" between 1 and 65536), using %d\n",
+		       CONFIG_MAX_RAW_MINORS);
+		max_raw_minors = CONFIG_MAX_RAW_MINORS;
 	}
 
 	raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
include/uapi/linux/raw.h +1 -1
index 62d543e70603..f0390b3e8530 100644
@@ -13,6 +13,6 @@ struct raw_config_request
 	__u64	block_minor;
 };
 
-#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
+#define MAX_RAW_MINORS 65535
 
 #endif /* __LINUX_RAW_H */
Signature · 1 line
2.4.6
#46 lore raw

PATCH 12/13 Remove AT_VECTOR_SIZE_ARCH on x86

In reply to a message not in the archive

It looks like there aren't actually users of this macro anywhere:

* The kernel doesn't use it on x86 because we don't suppor ELF FDPIC.

* The only Google results point to LMKL patches, both the one that wrote this (from 2010) and my patch to hide it behind __KERNEL__.

* I grep'd through all the source tarballs on my machine, and the only packages that matched were the kernel and crui (which copied a PPC kernel header).

Since I'm not sure how to actually provide the right answer (if I understand correctly, CONFIG_IA32_EMULATION is not __i386__), the only thing I can think of to do is to just remove the definition.

---
 arch/x86/include/uapi/asm/auxvec.h | 7 -------
 1 file changed, 7 deletions(-)
arch/x86/include/uapi/asm/auxvec.h +0 -7
index 77203ac352de..1316b4c35425 100644
@@ -9,11 +9,4 @@
 #endif
 #define AT_SYSINFO_EHDR		33
 
-/* entries in ARCH_DLINFO: */
-#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
-# define AT_VECTOR_SIZE_ARCH 2
-#else /* else it's non-compat x86-64 */
-# define AT_VECTOR_SIZE_ARCH 1
-#endif
-
 #endif /* _ASM_X86_AUXVEC_H */
Signature · 1 line
2.4.6
#47 lore raw

PATCH 12/13 Remove AT_VECTOR_SIZE_ARCH on x86

In reply to a message not in the archive

It looks like there aren't actually users of this macro anywhere:

* The kernel doesn't use it on x86 because we don't suppor ELF FDPIC.

* The only Google results point to LMKL patches, both the one that wrote this (from 2010) and my patch to hide it behind __KERNEL__.

* I grep'd through all the source tarballs on my machine, and the only packages that matched were the kernel and crui (which copied a PPC kernel header).

Since I'm not sure how to actually provide the right answer (if I understand correctly, CONFIG_IA32_EMULATION is not __i386__), the only thing I can think of to do is to just remove the definition.

---
 arch/x86/include/uapi/asm/auxvec.h | 7 -------
 1 file changed, 7 deletions(-)
arch/x86/include/uapi/asm/auxvec.h +0 -7
index 77203ac352de..1316b4c35425 100644
@@ -9,11 +9,4 @@
 #endif
 #define AT_SYSINFO_EHDR		33
 
-/* entries in ARCH_DLINFO: */
-#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
-# define AT_VECTOR_SIZE_ARCH 2
-#else /* else it's non-compat x86-64 */
-# define AT_VECTOR_SIZE_ARCH 1
-#endif
-
 #endif /* _ASM_X86_AUXVEC_H */
Signature · 1 line
2.4.6
#48 lore raw

PATCH 13/13 Re-enable and clean up "check_config()" in headers_check.pl

In reply to a message not in the archive

I recently got bit by a CONFIG_ in userspace bug. This has apparently happened before, but the check got disabled for triggering too much. In order to reduce false positives, I added some hueristics to avoid detecting comments.

Since these tests all pass, I've now re-enabled them.

---
 scripts/headers_check.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
scripts/headers_check.pl +17 -2
index 62320f93e903..dd413ad9c850 100755
@@ -40,7 +40,7 @@ foreach my $file (@files) {
 		&check_asm_types();
 		&check_sizetypes();
 		&check_declarations();
-		# Dropped for now. Too much noise &check_config();
+		&check_config();
 	}
 	close $fh;
 }
@@ -76,9 +76,24 @@ sub check_declarations
 	}
 }
 
+my $check_config_in_multiline_comment = 0;
 sub check_config
 {
-	if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+	my $nocomments = $line;
+	$nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+	$nocomments =~ s/\/\/.*//;     # Remove C99-style comments (// to EOL)
+
+	# Check to see if we're within a multiline comment, and if so
+	# just remove the whole line.  I tried matching on '^ * ', but
+	# there's one header that doesn't prepend multi-line comments
+	# with * so that won't work.
+	if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+	if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+	if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+	# Check to see if there is something that looks like CONFIG_
+	# inside a userspace-accessible header file and if so, print that out.
+	if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
 		printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
 	}
 }
Signature · 1 line
2.4.6
#49 lore raw

PATCH 13/13 Re-enable and clean up "check_config()" in headers_check.pl

In reply to a message not in the archive

I recently got bit by a CONFIG_ in userspace bug. This has apparently happened before, but the check got disabled for triggering too much. In order to reduce false positives, I added some hueristics to avoid detecting comments.

Since these tests all pass, I've now re-enabled them.

---
 scripts/headers_check.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
scripts/headers_check.pl +17 -2
index 62320f93e903..dd413ad9c850 100755
@@ -40,7 +40,7 @@ foreach my $file (@files) {
 		&check_asm_types();
 		&check_sizetypes();
 		&check_declarations();
-		# Dropped for now. Too much noise &check_config();
+		&check_config();
 	}
 	close $fh;
 }
@@ -76,9 +76,24 @@ sub check_declarations
 	}
 }
 
+my $check_config_in_multiline_comment = 0;
 sub check_config
 {
-	if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+	my $nocomments = $line;
+	$nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+	$nocomments =~ s/\/\/.*//;     # Remove C99-style comments (// to EOL)
+
+	# Check to see if we're within a multiline comment, and if so
+	# just remove the whole line.  I tried matching on '^ * ', but
+	# there's one header that doesn't prepend multi-line comments
+	# with * so that won't work.
+	if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+	if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+	if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+	# Check to see if there is something that looks like CONFIG_
+	# inside a userspace-accessible header file and if so, print that out.
+	if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
 		printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
 	}
 }
Signature · 1 line
2.4.6
#50 lore raw

PATCH v4 1/1 Remove #ifdef CONFIG_* from all userspace headers

In reply to a message not in the archive

I think this is good to go. There are two acks, but I wasn't sure if I was supposed to collect them in the patches or not. Arnd Bergman acked #1 and #7.

Changes since v3 (<1442271047-4908-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>)

* #4 is very different: rather than defining a canonical value for MAP_UNINITIALIZED, it just punts on the problem and lets arch maintainers deal with it. There's still an #ifndef MAP_UNINITIALIZED in there, but that shouldn't get triggered by anything because the arch headers should set it to whatever they actually want.

* #11 defines MAX_RAW_MINORS to 2^20 instead of 2^16.

* #13 moves the variable around a bit so it gets initialized. I forgot I was in perl and not C :).

Changes since v2 (<1441832902-28993-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>)

* Patch set renamed.

* #2 is rewritten to use sys_ni.c instead of an #ifdef

* #3, #6, #8, #9, #10, and #11 no longer use "#ifdef __KERNEL__" but have instead moved the offending lines to the correct, kernel-only files.

* #4 has been rewritten to always define MAP_UNINITIALIZED to non-zero, rather than defining it to zero when in userspace.

* #5 got a whole lot longer -- rather than just always hiding these fields from userspace, there is now a second "struct elf_fdpic_prstatus" structure. This should allow userspace to parse core dumps correctly.

* Rebased onto 9c488de24f7264f08d341024bffdd637b4d04c96.

Changes since v1 (<1441152610-22566-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>)

* All patches but #1 were added.

#51 lore raw

PATCH v4 1/1 Remove #ifdef CONFIG_* from all userspace headers

In reply to a message not in the archive

I think this is good to go. There are two acks, but I wasn't sure if I was supposed to collect them in the patches or not. Arnd Bergman acked #1 and #7.

Changes since v3 (<1442271047-4908-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>)

* #4 is very different: rather than defining a canonical value for MAP_UNINITIALIZED, it just punts on the problem and lets arch maintainers deal with it. There's still an #ifndef MAP_UNINITIALIZED in there, but that shouldn't get triggered by anything because the arch headers should set it to whatever they actually want.

* #11 defines MAX_RAW_MINORS to 2^20 instead of 2^16.

* #13 moves the variable around a bit so it gets initialized. I forgot I was in perl and not C :).

Changes since v2 (<1441832902-28993-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>)

* Patch set renamed.

* #2 is rewritten to use sys_ni.c instead of an #ifdef

* #3, #6, #8, #9, #10, and #11 no longer use "#ifdef __KERNEL__" but have instead moved the offending lines to the correct, kernel-only files.

* #4 has been rewritten to always define MAP_UNINITIALIZED to non-zero, rather than defining it to zero when in userspace.

* #5 got a whole lot longer -- rather than just always hiding these fields from userspace, there is now a second "struct elf_fdpic_prstatus" structure. This should allow userspace to parse core dumps correctly.

* Rebased onto 9c488de24f7264f08d341024bffdd637b4d04c96.

Changes since v1 (<1441152610-22566-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>)

* All patches but #1 were added.

#52 lore raw

PATCH 1/13 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

In reply to Palmer Dabbelt

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063effe0cc1..14a5c8237d84 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.6
#53 lore raw

PATCH 1/13 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

In reply to Palmer Dabbelt

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063effe0cc1..14a5c8237d84 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.6
#54 lore raw

PATCH 2/13 Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU

In reply to Palmer Dabbelt

I think this change actually doesn't do anything: __NR_fork was still being defined either way, and on my machine fork() in <unistd.h> comes from libc.

This just moves to the standard mechanism for defining syscalls that aren't implemented instead, which has the side-effect of no longer having an #ifdef CONFIG_* in a user-visible header.

---
 include/uapi/asm-generic/unistd.h | 4 ----
 kernel/sys_ni.c                   | 1 +
 2 files changed, 1 insertion(+), 4 deletions(-)
include/uapi/asm-generic/unistd.h +0 -4
index 8da542a2874d..21689284360b 100644
@@ -867,11 +867,7 @@ __SYSCALL(__NR_uselib, sys_uselib)
 __SYSCALL(__NR__sysctl, sys_sysctl)
 
 #define __NR_fork 1079
-#ifdef CONFIG_MMU
 __SYSCALL(__NR_fork, sys_fork)
-#else
-__SYSCALL(__NR_fork, sys_ni_syscall)
-#endif /* CONFIG_MMU */
 
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_fork+1)
kernel/sys_ni.c +1 -0
index a02decf15583..c830f7f9e36d 100644
@@ -174,6 +174,7 @@ cond_syscall(sys_setfsuid);
 cond_syscall(sys_setfsgid);
 cond_syscall(sys_capget);
 cond_syscall(sys_capset);
+cond_syscall(sys_fork);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
Signature · 1 line
2.4.6
#55 lore raw

PATCH 2/13 Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU

In reply to Palmer Dabbelt

I think this change actually doesn't do anything: __NR_fork was still being defined either way, and on my machine fork() in <unistd.h> comes from libc.

This just moves to the standard mechanism for defining syscalls that aren't implemented instead, which has the side-effect of no longer having an #ifdef CONFIG_* in a user-visible header.

---
 include/uapi/asm-generic/unistd.h | 4 ----
 kernel/sys_ni.c                   | 1 +
 2 files changed, 1 insertion(+), 4 deletions(-)
include/uapi/asm-generic/unistd.h +0 -4
index 8da542a2874d..21689284360b 100644
@@ -867,11 +867,7 @@ __SYSCALL(__NR_uselib, sys_uselib)
 __SYSCALL(__NR__sysctl, sys_sysctl)
 
 #define __NR_fork 1079
-#ifdef CONFIG_MMU
 __SYSCALL(__NR_fork, sys_fork)
-#else
-__SYSCALL(__NR_fork, sys_ni_syscall)
-#endif /* CONFIG_MMU */
 
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_fork+1)
kernel/sys_ni.c +1 -0
index a02decf15583..c830f7f9e36d 100644
@@ -174,6 +174,7 @@ cond_syscall(sys_setfsuid);
 cond_syscall(sys_setfsgid);
 cond_syscall(sys_capget);
 cond_syscall(sys_capset);
+cond_syscall(sys_fork);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
Signature · 1 line
2.4.6
#56 lore raw

PATCH 2/13 Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU

In reply to Palmer Dabbelt

I think this change actually doesn't do anything: __NR_fork was still being defined either way, and on my machine fork() in <unistd.h> comes from libc.

This just moves to the standard mechanism for defining syscalls that aren't implemented instead, which has the side-effect of no longer having an #ifdef CONFIG_* in a user-visible header.

---
 include/uapi/asm-generic/unistd.h | 4 ----
 kernel/sys_ni.c                   | 1 +
 2 files changed, 1 insertion(+), 4 deletions(-)
include/uapi/asm-generic/unistd.h +0 -4
index 8da542a2874d..21689284360b 100644
@@ -867,11 +867,7 @@ __SYSCALL(__NR_uselib, sys_uselib)
 __SYSCALL(__NR__sysctl, sys_sysctl)
 
 #define __NR_fork 1079
-#ifdef CONFIG_MMU
 __SYSCALL(__NR_fork, sys_fork)
-#else
-__SYSCALL(__NR_fork, sys_ni_syscall)
-#endif /* CONFIG_MMU */
 
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_fork+1)
kernel/sys_ni.c +1 -0
index a02decf15583..c830f7f9e36d 100644
@@ -174,6 +174,7 @@ cond_syscall(sys_setfsuid);
 cond_syscall(sys_setfsgid);
 cond_syscall(sys_capget);
 cond_syscall(sys_capset);
+cond_syscall(sys_fork);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
Signature · 1 line
2.4.6
#57 lore raw

PATCH 3/13 Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

In reply to Palmer Dabbelt

This used to be behind an #ifdef COMPAT_COMPAT, so most of userspace wouldn't have seen the definition before. Unfortunately this header file became visible to userspace, so the definition has instead been moved to net/atm/svc.c (the only user).

---
 include/uapi/linux/atmdev.h | 4 ----
 net/atm/svc.c               | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
include/uapi/linux/atmdev.h +0 -4
index 93e0ec008ca8..3dcec701501c 100644
@@ -100,10 +100,6 @@ struct atm_dev_stats {
 					/* use backend to make new if */
 #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
  					/* add party to p2mp call */
-#ifdef CONFIG_COMPAT
-/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
-#define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf)
-#endif
 #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)
 					/* drop party from p2mp call */
 
net/atm/svc.c +5 -0
index 3fa0a9ee98d1..9e2e6ef285e8 100644
@@ -27,6 +27,11 @@
 #include "signaling.h"
 #include "addr.h"
 
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif
+
 static int svc_create(struct net *net, struct socket *sock, int protocol,
 		      int kern);
 
Signature · 1 line
2.4.6
#58 lore raw

Re: [PATCH 03/13] Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

net/atm/svc.c line 33

Quoted 4 lines · Palmer Dabbelt
net/atm/svc.c +4 -0
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif

I wonder if it would hurt to ditch the conditionals entirely. It only eats cpp namespace, not C namespace so it won't affect the output if it is not used because the code that uses it is compiled out.

David

#59 lore raw

Re: [PATCH 03/13] Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

Quoted 10 lines · On Thu, 17 Sep 2015 02:57:12 PDT (-0700), [email protected] wrote:

net/atm/svc.c line 33

Quoted 4 lines · Palmer Dabbelt
net/atm/svc.c +4 -0
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif

I wonder if it would hurt to ditch the conditionals entirely. It only eats cpp namespace, not C namespace so it won't affect the output if it is not used because the code that uses it is compiled out.

Makes sense to me.

#60 lore raw

PATCH 3/13 Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

In reply to Palmer Dabbelt

This used to be behind an #ifdef COMPAT_COMPAT, so most of userspace wouldn't have seen the definition before. Unfortunately this header file became visible to userspace, so the definition has instead been moved to net/atm/svc.c (the only user).

---
 include/uapi/linux/atmdev.h | 4 ----
 net/atm/svc.c               | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
include/uapi/linux/atmdev.h +0 -4
index 93e0ec008ca8..3dcec701501c 100644
@@ -100,10 +100,6 @@ struct atm_dev_stats {
 					/* use backend to make new if */
 #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
  					/* add party to p2mp call */
-#ifdef CONFIG_COMPAT
-/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
-#define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf)
-#endif
 #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)
 					/* drop party from p2mp call */
 
net/atm/svc.c +5 -0
index 3fa0a9ee98d1..9e2e6ef285e8 100644
@@ -27,6 +27,11 @@
 #include "signaling.h"
 #include "addr.h"
 
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif
+
 static int svc_create(struct net *net, struct socket *sock, int protocol,
 		      int kern);
 
Signature · 1 line
2.4.6
#61 lore raw

PATCH 3/13 Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

In reply to Palmer Dabbelt

This used to be behind an #ifdef COMPAT_COMPAT, so most of userspace wouldn't have seen the definition before. Unfortunately this header file became visible to userspace, so the definition has instead been moved to net/atm/svc.c (the only user).

---
 include/uapi/linux/atmdev.h | 4 ----
 net/atm/svc.c               | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
include/uapi/linux/atmdev.h +0 -4
index 93e0ec008ca8..3dcec701501c 100644
@@ -100,10 +100,6 @@ struct atm_dev_stats {
 					/* use backend to make new if */
 #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
  					/* add party to p2mp call */
-#ifdef CONFIG_COMPAT
-/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
-#define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf)
-#endif
 #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)
 					/* drop party from p2mp call */
 
net/atm/svc.c +5 -0
index 3fa0a9ee98d1..9e2e6ef285e8 100644
@@ -27,6 +27,11 @@
 #include "signaling.h"
 #include "addr.h"
 
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif
+
 static int svc_create(struct net *net, struct socket *sock, int protocol,
 		      int kern);
 
Signature · 1 line
2.4.6
#62 lore raw

PATCH 3/13 Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

In reply to Palmer Dabbelt

This used to be behind an #ifdef COMPAT_COMPAT, so most of userspace wouldn't have seen the definition before. Unfortunately this header file became visible to userspace, so the definition has instead been moved to net/atm/svc.c (the only user).

---
 include/uapi/linux/atmdev.h | 4 ----
 net/atm/svc.c               | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
include/uapi/linux/atmdev.h +0 -4
index 93e0ec008ca8..3dcec701501c 100644
@@ -100,10 +100,6 @@ struct atm_dev_stats {
 					/* use backend to make new if */
 #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
  					/* add party to p2mp call */
-#ifdef CONFIG_COMPAT
-/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
-#define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf)
-#endif
 #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)
 					/* drop party from p2mp call */
 
net/atm/svc.c +5 -0
index 3fa0a9ee98d1..9e2e6ef285e8 100644
@@ -27,6 +27,11 @@
 #include "signaling.h"
 #include "addr.h"
 
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif
+
 static int svc_create(struct net *net, struct socket *sock, int protocol,
 		      int kern);
 
Signature · 1 line
2.4.6
#63 lore raw

PATCH 4/13 Always expose MAP_UNINITIALIZED to userspace

In reply to Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

This change also applies to the xtensa version of this definition, whic is the same as the generic one.

---
 arch/xtensa/include/uapi/asm/mman.h    | 4 +---
 include/uapi/asm-generic/mman-common.h | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
arch/xtensa/include/uapi/asm/mman.h +1 -3
index 201aec0e0446..2cbc1e717082 100644
@@ -55,11 +55,9 @@
 #define MAP_NONBLOCK	0x20000		/* do not block on IO */
 #define MAP_STACK	0x40000		/* give out an address that is best suited for process/thread stacks */
 #define MAP_HUGETLB	0x80000		/* create a huge page mapping */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be
 					 * uninitialized */
-#else
-# define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
 /*
include/uapi/asm-generic/mman-common.h +1 -3
index ddc3b36f1046..7aeeb12db193 100644
@@ -19,10 +19,8 @@
 #define MAP_TYPE	0x0f		/* Mask for type of mapping */
 #define MAP_FIXED	0x10		/* Interpret addr exactly */
 #define MAP_ANONYMOUS	0x20		/* don't use a file */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be uninitialized */
-#else
-# define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
 #define MS_ASYNC	1		/* sync memory asynchronously */
Signature · 1 line
2.4.6
#64 lore raw

Re: [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace

Quoted 14 lines · Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

Quoted 4 lines

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

Are you sure about "wouldn't do anything"?
Suspiciously, 0x4000000 is also (1 << MAP_HUGE_SHIFT). I'm not sure if any architecture has order-1 huge pages, but still looks like we have conflict here.

I think it's harmful to expose non-zero MAP_UNINITIALIZED to system which potentially can handle multiple users. Or non-trivial user space in general.

Should we leave it at least under '#ifndef CONFIG_MMU'? I don't think it's possible to have single ABI for MMU and MMU-less systems anyway. And we can avoid conflict with MAP_HUGE_SHIFT this way.

P.S. MAP_UNINITIALIZED itself looks very broken to me. I probably need dig mailing list on why it was allowed.
But that's other topic.

Signature · 1 line
 Kirill A. Shutemov
#65 lore raw

Re: [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace

Quoted 15 lines · On Mon, 14 Sep 2015 17:23:58 PDT (-0700), [email protected] wrote:
Quoted 14 lines · Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

Quoted 6 lines
Quoted 4 lines

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

Are you sure about "wouldn't do anything"?

That was bad writing for me. I'd originally written something like "I believe this should have been visible to userspace all along", but then added the ()'s. I meant to say:

* I think MAP_UNINITIALIZED should have been non-zero in userspace.
* MAP_UNINITAILIZED was zero in userspace.
* A zero MAP_UNINITIALIZED does nothing when OR'd in.

Quoted 7 lines

Suspiciously, 0x4000000 is also (1 << MAP_HUGE_SHIFT). I'm not sure if any architecture has order-1 huge pages, but still looks like we have conflict here.

I think it's harmful to expose non-zero MAP_UNINITIALIZED to system which potentially can handle multiple users. Or non-trivial user space in general.

This doesn't have MAP_UNINITIALIZED do anything by default, it just defines the flag the same way on all systems. I was under the impression that this just happened if I set MAP_UNINITIALIZED. Looking at MAP_HUGE_SHIFT it mmap.c, that's definitely why my mmap() test case ignored the set MAP_UNINITIALIZED on my PC.

I'm going to make this

#ifndef MAP_UNINITAILIZED
#define MAP_UNINITAILIZED 0
#endif

and then leave Xtensa's port alone. This is what Arnd suggested originally, sorry for the extra work!

Quoted 3 lines

Should we leave it at least under '#ifndef CONFIG_MMU'? I don't think it's possible to have single ABI for MMU and MMU-less systems anyway. And we can avoid conflict with MAP_HUGE_SHIFT this way.

The whole goal here was to eliminate "#ifndef CONFIG_*" from the user-visible headers. This all started because I got bit by a very similar-looking bug (see patch #1), so I'd prefer not to go down that route.

Quoted 3 lines

P.S. MAP_UNINITIALIZED itself looks very broken to me. I probably need dig mailing list on why it was allowed.
But that's other topic.

A message that is not in the archive (sent off-list or not yet received): 20150915002358.GA12618-nhfs4B5ZimeFUdmeq17FyvUpdFzICT1y@public.gmane.org

#67 lore raw

Re: [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace

Quoted 15 lines · On Mon, 14 Sep 2015 17:23:58 PDT (-0700)…
Quoted 14 lines · Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

Quoted 6 lines
Quoted 4 lines

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

Are you sure about "wouldn't do anything"?

That was bad writing for me. I'd originally written something like "I believe this should have been visible to userspace all along", but then added the ()'s. I meant to say:

* I think MAP_UNINITIALIZED should have been non-zero in userspace.
* MAP_UNINITAILIZED was zero in userspace.
* A zero MAP_UNINITIALIZED does nothing when OR'd in.

Quoted 7 lines

Suspiciously, 0x4000000 is also (1 << MAP_HUGE_SHIFT). I'm not sure if any architecture has order-1 huge pages, but still looks like we have conflict here.

I think it's harmful to expose non-zero MAP_UNINITIALIZED to system which potentially can handle multiple users. Or non-trivial user space in general.

This doesn't have MAP_UNINITIALIZED do anything by default, it just defines the flag the same way on all systems. I was under the impression that this just happened if I set MAP_UNINITIALIZED. Looking at MAP_HUGE_SHIFT it mmap.c, that's definitely why my mmap() test case ignored the set MAP_UNINITIALIZED on my PC.

I'm going to make this

#ifndef MAP_UNINITAILIZED
#define MAP_UNINITAILIZED 0
#endif

and then leave Xtensa's port alone. This is what Arnd suggested originally, sorry for the extra work!

Quoted 3 lines

Should we leave it at least under '#ifndef CONFIG_MMU'? I don't think it's possible to have single ABI for MMU and MMU-less systems anyway. And we can avoid conflict with MAP_HUGE_SHIFT this way.

The whole goal here was to eliminate "#ifndef CONFIG_*" from the user-visible headers. This all started because I got bit by a very similar-looking bug (see patch #1), so I'd prefer not to go down that route.

Quoted 3 lines

P.S. MAP_UNINITIALIZED itself looks very broken to me. I probably need dig mailing list on why it was allowed.
But that's other topic.

#68 lore raw

Re: [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace

In reply to a message not in the archive
Quoted 15 lines · On Mon, 14 Sep 2015 17:23:58 PDT (-0700)…
Quoted 14 lines · Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

Quoted 6 lines
Quoted 4 lines

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

Are you sure about "wouldn't do anything"?

That was bad writing for me. I'd originally written something like "I believe this should have been visible to userspace all along", but then added the ()'s. I meant to say:

* I think MAP_UNINITIALIZED should have been non-zero in userspace.
* MAP_UNINITAILIZED was zero in userspace.
* A zero MAP_UNINITIALIZED does nothing when OR'd in.

Quoted 7 lines

Suspiciously, 0x4000000 is also (1 << MAP_HUGE_SHIFT). I'm not sure if any architecture has order-1 huge pages, but still looks like we have conflict here.

I think it's harmful to expose non-zero MAP_UNINITIALIZED to system which potentially can handle multiple users. Or non-trivial user space in general.

This doesn't have MAP_UNINITIALIZED do anything by default, it just defines the flag the same way on all systems. I was under the impression that this just happened if I set MAP_UNINITIALIZED. Looking at MAP_HUGE_SHIFT it mmap.c, that's definitely why my mmap() test case ignored the set MAP_UNINITIALIZED on my PC.

I'm going to make this

#ifndef MAP_UNINITAILIZED
#define MAP_UNINITAILIZED 0
#endif

and then leave Xtensa's port alone. This is what Arnd suggested originally, sorry for the extra work!

Quoted 3 lines

Should we leave it at least under '#ifndef CONFIG_MMU'? I don't think it's possible to have single ABI for MMU and MMU-less systems anyway. And we can avoid conflict with MAP_HUGE_SHIFT this way.

The whole goal here was to eliminate "#ifndef CONFIG_*" from the user-visible headers. This all started because I got bit by a very similar-looking bug (see patch #1), so I'd prefer not to go down that route.

Quoted 3 lines

P.S. MAP_UNINITIALIZED itself looks very broken to me. I probably need dig mailing list on why it was allowed.
But that's other topic.

#69 lore raw

Re: [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace

In reply to Kirill A. Shutemov
Quoted 15 lines · On Mon, 14 Sep 2015 17:23:58 PDT (-0700), [email protected] wrote:
Quoted 14 lines · Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

Quoted 6 lines
Quoted 4 lines

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

Are you sure about "wouldn't do anything"?

That was bad writing for me. I'd originally written something like "I believe this should have been visible to userspace all along", but then added the ()'s. I meant to say:

* I think MAP_UNINITIALIZED should have been non-zero in userspace.
* MAP_UNINITAILIZED was zero in userspace.
* A zero MAP_UNINITIALIZED does nothing when OR'd in.

Quoted 7 lines

Suspiciously, 0x4000000 is also (1 << MAP_HUGE_SHIFT). I'm not sure if any architecture has order-1 huge pages, but still looks like we have conflict here.

I think it's harmful to expose non-zero MAP_UNINITIALIZED to system which potentially can handle multiple users. Or non-trivial user space in general.

This doesn't have MAP_UNINITIALIZED do anything by default, it just defines the flag the same way on all systems. I was under the impression that this just happened if I set MAP_UNINITIALIZED. Looking at MAP_HUGE_SHIFT it mmap.c, that's definitely why my mmap() test case ignored the set MAP_UNINITIALIZED on my PC.

I'm going to make this

#ifndef MAP_UNINITAILIZED
#define MAP_UNINITAILIZED 0
#endif

and then leave Xtensa's port alone. This is what Arnd suggested originally, sorry for the extra work!

Quoted 3 lines

Should we leave it at least under '#ifndef CONFIG_MMU'? I don't think it's possible to have single ABI for MMU and MMU-less systems anyway. And we can avoid conflict with MAP_HUGE_SHIFT this way.

The whole goal here was to eliminate "#ifndef CONFIG_*" from the user-visible headers. This all started because I got bit by a very similar-looking bug (see patch #1), so I'd prefer not to go down that route.

Quoted 3 lines

P.S. MAP_UNINITIALIZED itself looks very broken to me. I probably need dig mailing list on why it was allowed.
But that's other topic.

#70 lore raw

Re: [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace

In reply to Kirill A. Shutemov
Quoted 15 lines · On Mon, 14 Sep 2015 17:23:58 PDT (-0700), [email protected] wrote:
Quoted 14 lines · Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

Quoted 6 lines
Quoted 4 lines

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

Are you sure about "wouldn't do anything"?

That was bad writing for me. I'd originally written something like "I believe this should have been visible to userspace all along", but then added the ()'s. I meant to say:

* I think MAP_UNINITIALIZED should have been non-zero in userspace.
* MAP_UNINITAILIZED was zero in userspace.
* A zero MAP_UNINITIALIZED does nothing when OR'd in.

Quoted 7 lines

Suspiciously, 0x4000000 is also (1 << MAP_HUGE_SHIFT). I'm not sure if any architecture has order-1 huge pages, but still looks like we have conflict here.

I think it's harmful to expose non-zero MAP_UNINITIALIZED to system which potentially can handle multiple users. Or non-trivial user space in general.

This doesn't have MAP_UNINITIALIZED do anything by default, it just defines the flag the same way on all systems. I was under the impression that this just happened if I set MAP_UNINITIALIZED. Looking at MAP_HUGE_SHIFT it mmap.c, that's definitely why my mmap() test case ignored the set MAP_UNINITIALIZED on my PC.

I'm going to make this

#ifndef MAP_UNINITAILIZED
#define MAP_UNINITAILIZED 0
#endif

and then leave Xtensa's port alone. This is what Arnd suggested originally, sorry for the extra work!

Quoted 3 lines

Should we leave it at least under '#ifndef CONFIG_MMU'? I don't think it's possible to have single ABI for MMU and MMU-less systems anyway. And we can avoid conflict with MAP_HUGE_SHIFT this way.

The whole goal here was to eliminate "#ifndef CONFIG_*" from the user-visible headers. This all started because I got bit by a very similar-looking bug (see patch #1), so I'd prefer not to go down that route.

Quoted 3 lines

P.S. MAP_UNINITIALIZED itself looks very broken to me. I probably need dig mailing list on why it was allowed.
But that's other topic.

#71 lore raw

Re: [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace

In reply to Kirill A. Shutemov
Quoted 20 lines · Kirill A. Shutemov
Quoted 14 lines · Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

Quoted 4 lines

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

Quoted 8 lines

Are you sure about "wouldn't do anything"?
Suspiciously, 0x4000000 is also (1 << MAP_HUGE_SHIFT). I'm not sure if any architecture has order-1 huge pages, but still looks like we have conflict here.

I think it's harmful to expose non-zero MAP_UNINITIALIZED to system which potentially can handle multiple users. Or non-trivial user space in general.

The flag should always exist. If it was defined to conflict with something else, that's a serious ABI problem. But the flag should always exist, even if the kernel ends up ignoring it.

Quoted 3 lines

Should we leave it at least under '#ifndef CONFIG_MMU'? I don't think it's possible to have single ABI for MMU and MMU-less systems anyway. And we can avoid conflict with MAP_HUGE_SHIFT this way.

No; even if you have an MMU (which is useful for things like fork()), a system without user separation (for instance, without CONFIG_MULTIUSER) can reasonably use MAP_UNINITIALIZED.

Quoted 2 lines

P.S. MAP_UNINITIALIZED itself looks very broken to me. I probably need dig mailing list on why it was allowed.

That's what the config option *and* explicit flag are for; there are more than enough warnings about the implications.

- Josh Triplett

#72 lore raw

Re: [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace

Quoted 26 lines · Josh Triplett
Quoted 25 lines · Kirill A. Shutemov
Quoted 14 lines · Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

Quoted 4 lines

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

Are you sure about "wouldn't do anything"?
Suspiciously, 0x4000000 is also (1 << MAP_HUGE_SHIFT). I'm not sure if any architecture has order-1 huge pages, but still looks like we have conflict here.

Quoted 5 lines
Quoted 3 lines

I think it's harmful to expose non-zero MAP_UNINITIALIZED to system which potentially can handle multiple users. Or non-trivial user space in general.

The flag should always exist.

Sure. And 0 is perfectly fine value for the flag. Like with MAP_FILE.

Quoted 11 lines

If it was defined to conflict with
something else, that's a serious ABI problem. But the flag should always exist, even if the kernel ends up ignoring it.

Quoted 3 lines

Should we leave it at least under '#ifndef CONFIG_MMU'? I don't think it's possible to have single ABI for MMU and MMU-less systems anyway. And we can avoid conflict with MAP_HUGE_SHIFT this way.

No; even if you have an MMU (which is useful for things like fork()), a system without user separation (for instance, without CONFIG_MULTIUSER) can reasonably use MAP_UNINITIALIZED.

Can? Yes. Reasonably? I don't think so.

Quoted 5 lines
Quoted 2 lines

P.S. MAP_UNINITIALIZED itself looks very broken to me. I probably need dig mailing list on why it was allowed.

That's what the config option *and* explicit flag are for; there are more than enough warnings about the implications.

I think it's misdesigned. It doesn't require explicid opt-in from a process who owned the page allocated in MAP_UNINITIALIZED mapping before.

#define MAP_LEAK_ME_SOME_DATA MAP_UNINITIALIZED

Signature · 1 line
 Kirill A. Shutemov
#73 lore raw

Re: [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace

Quoted 27 lines · Kirill A. Shutemov
Quoted 26 lines · Josh Triplett
Quoted 25 lines · Kirill A. Shutemov
Quoted 14 lines · Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

Quoted 4 lines

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

Are you sure about "wouldn't do anything"?
Suspiciously, 0x4000000 is also (1 << MAP_HUGE_SHIFT). I'm not sure if any architecture has order-1 huge pages, but still looks like we have conflict here.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I think it's harmful to expose non-zero MAP_UNINITIALIZED to system which potentially can handle multiple users. Or non-trivial user space in general.

The flag should always exist.

Sure. And 0 is perfectly fine value for the flag. Like with MAP_FILE.

Rephrasing: the flag should always exist with the correct value. Whether the kernel handles it or not, the kernel *headers* shouldn't change to match the kernel, not least of which because they don't necessarily match the running kernel. Just like we define the prototypes for syscalls that the running kernel may return ENOSYS for.

Quoted 8 lines
Quoted 8 lines

If it was defined to conflict with
something else, that's a serious ABI problem. But the flag should always exist, even if the kernel ends up ignoring it.

Quoted 3 lines

Should we leave it at least under '#ifndef CONFIG_MMU'? I don't think it's possible to have single ABI for MMU and MMU-less systems anyway. And we can avoid conflict with MAP_HUGE_SHIFT this way.

Quoted 5 lines
Quoted 3 lines

No; even if you have an MMU (which is useful for things like fork()), a system without user separation (for instance, without CONFIG_MULTIUSER) can reasonably use MAP_UNINITIALIZED.

Can? Yes. Reasonably? I don't think so.

Not all systems care. Otherwise you should be complaining more bitterly about options like CONFIG_MMU=n, which (*gasp*) allow access to *arbitrary memory*.

Quoted 10 lines
Quoted 5 lines
Quoted 2 lines

P.S. MAP_UNINITIALIZED itself looks very broken to me. I probably need dig mailing list on why it was allowed.

That's what the config option *and* explicit flag are for; there are more than enough warnings about the implications.

I think it's misdesigned. It doesn't require explicid opt-in from a process who owned the page allocated in MAP_UNINITIALIZED mapping before.

#define MAP_LEAK_ME_SOME_DATA MAP_UNINITIALIZED

Hence why it has a config option.

The userspace option exists primarily because otherwise userspace might get surprised by receiving a non-zeroed page. On a system with the config option turned on, processes have access to arbitrary freed memory, as long as they say they can handle not having their memory pre-zeroed.

- Josh Triplett

#74 lore raw

Re: [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace

Quoted 7 lines · Josh Triplett
Quoted 1 line

Sure. And 0 is perfectly fine value for the flag. Like with MAP_FILE.

Rephrasing: the flag should always exist with the correct value. Whether the kernel handles it or not, the kernel *headers* shouldn't change to match the kernel, not least of which because they don't necessarily match the running kernel. Just like we define the prototypes for syscalls that the running kernel may return ENOSYS for.

Josh is correct.

CONFIG_xxx *should* *not* be seen in UAPI headers, except inside #ifdef __KERNEL__ guards under special circumstances - and #ifdef __KERNEL__ guards *should* *not* be seen in UAPI headers except under special circumstances.

In terms of such special circumstances, take a peek in include/uapi/linux/acct.h at struct acct with this:

	/* m68k had no padding here. */
	#if !defined(CONFIG_M68K) || !defined(__KERNEL__)
		__u16		ac_ahz;			/* AHZ */
	#endif

in the middle of it...

Or include/{,uapi/}linux/agpgart.h where it defines two different but same-named variants of several structs.

Now, some of these - particularly things like the latter - can be fixed by someone who has the time.

David

#75 lore raw

PATCH 4/13 Always expose MAP_UNINITIALIZED to userspace

In reply to Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

This change also applies to the xtensa version of this definition, whic is the same as the generic one.

---
 arch/xtensa/include/uapi/asm/mman.h    | 4 +---
 include/uapi/asm-generic/mman-common.h | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
arch/xtensa/include/uapi/asm/mman.h +1 -3
index 201aec0e0446..2cbc1e717082 100644
@@ -55,11 +55,9 @@
 #define MAP_NONBLOCK	0x20000		/* do not block on IO */
 #define MAP_STACK	0x40000		/* give out an address that is best suited for process/thread stacks */
 #define MAP_HUGETLB	0x80000		/* create a huge page mapping */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be
 					 * uninitialized */
-#else
-# define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
 /*
include/uapi/asm-generic/mman-common.h +1 -3
index ddc3b36f1046..7aeeb12db193 100644
@@ -19,10 +19,8 @@
 #define MAP_TYPE	0x0f		/* Mask for type of mapping */
 #define MAP_FIXED	0x10		/* Interpret addr exactly */
 #define MAP_ANONYMOUS	0x20		/* don't use a file */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be uninitialized */
-#else
-# define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
 #define MS_ASYNC	1		/* sync memory asynchronously */
Signature · 1 line
2.4.6
#76 lore raw

PATCH 4/13 Always expose MAP_UNINITIALIZED to userspace

In reply to Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I could have kept hiding it, the man pages seem to indicate that MAP_UNINITIALIZED should be visible:

mmap(2)
MAP_UNINITIALIZED (since Linux 2.6.33)
Don't clear anonymous pages. This flag is intended to improve performance on embedded devices. This flag is honored only if the kernel was configured with the CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the security implications, that option is normally enabled only on embedded devices (i.e., devices where one has complete control of the contents of user memory).

and since the only time it shows up in my /usr/include is in this header I believe this should have been visible to userspace (as non-zero, which wouldn't do anything when or'd into the flags) all along.

This change also applies to the xtensa version of this definition, whic is the same as the generic one.

---
 arch/xtensa/include/uapi/asm/mman.h    | 4 +---
 include/uapi/asm-generic/mman-common.h | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
arch/xtensa/include/uapi/asm/mman.h +1 -3
index 201aec0e0446..2cbc1e717082 100644
@@ -55,11 +55,9 @@
 #define MAP_NONBLOCK	0x20000		/* do not block on IO */
 #define MAP_STACK	0x40000		/* give out an address that is best suited for process/thread stacks */
 #define MAP_HUGETLB	0x80000		/* create a huge page mapping */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be
 					 * uninitialized */
-#else
-# define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
 /*
include/uapi/asm-generic/mman-common.h +1 -3
index ddc3b36f1046..7aeeb12db193 100644
@@ -19,10 +19,8 @@
 #define MAP_TYPE	0x0f		/* Mask for type of mapping */
 #define MAP_FIXED	0x10		/* Interpret addr exactly */
 #define MAP_ANONYMOUS	0x20		/* don't use a file */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be uninitialized */
-#else
-# define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
 #define MS_ASYNC	1		/* sync memory asynchronously */
Signature · 1 line
2.4.6
#77 lore raw

PATCH 5/13 Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

In reply to Palmer Dabbelt

This is a pretty big change that I haven't tested any, which worries me a lot. The general idea here is that "struct elf_prstatus" can be visible to userspace (from <linux/ptrace.h>)

"
Generic ptrace interface that exports the architecture specific regsets using the corresponding NT_* types (which are also used in the core dump). Please note that the NT_PRSTATUS note type in a core dump contains a full 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the other user_regset flavors, the user_regset layout and the ELF core dump note payload are exactly the same layout.
"

so it shouldn't have an "#ifdef CONFIG_" in there.

This splits the structure into two different structures, one still named "struct elf_prstatus", and one for ELF FDPIC that is named "struct elf_fdpic_prstatus" -- the idea here is that most users are standard ELF, so that's the name that didn't change.

I tried to fix all the users of "struct elf_prstatus" that should now be using "struct elf_fdpic_prstatus". The only testing I did here was to build a Blackfin defconfig with "struct elf_prstatus" not defined, and to build an x86 defconfig with "struct elf_fdpic_prstatus" not defined.

Note that this fails checkpatch.pl with a complaint about wanting open braces on the same line as struct definitions. The existing struct definitions in this file have the brace a line afterwards, so I'm going to leave this alone.

---
 fs/binfmt_elf_fdpic.c        |  6 +++---
 fs/proc/kcore.c              | 16 ++++++++++++++++
 include/linux/kexec.h        |  4 ++++
 include/uapi/linux/elfcore.h | 37 +++++++++++++++++++++++++++++++++++--
 kernel/kexec_core.c          |  4 ++++
 5 files changed, 62 insertions(+), 5 deletions(-)
fs/binfmt_elf_fdpic.c +3 -3
index d3634bfb7fe1..587bf0466d71 100644
@@ -1323,7 +1323,7 @@ static inline void fill_note(struct memelfnote *note, const char *name, int type
  * fill up all the fields in prstatus from the given task struct, except
  * registers which need to be filled up separately.
  */
-static void fill_prstatus(struct elf_prstatus *prstatus,
+static void fill_prstatus(struct elf_fdpic_prstatus *prstatus,
 			  struct task_struct *p, long signr)
 {
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1406,7 +1406,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
 struct elf_thread_status
 {
 	struct list_head list;
-	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1539,7 +1539,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
 	loff_t offset = 0, dataoff;
 	int numnote;
 	struct memelfnote *notes = NULL;
-	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
 	struct elf_prpsinfo *psinfo = NULL;	/* NT_PRPSINFO */
  	LIST_HEAD(thread_list);
  	struct list_head *t;
fs/proc/kcore.c +16 -0
index 92e6726f6e37..b1edd77ec854 100644
@@ -90,7 +90,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 			(*nphdr + 2)*sizeof(struct elf_phdr) + 
 			3 * ((sizeof(struct elf_note)) +
 			     roundup(sizeof(CORE_STR), 4)) +
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+			roundup(sizeof(struct elf_fdpic_prstatus), 4) +
+#else
 			roundup(sizeof(struct elf_prstatus), 4) +
+#endif
 			roundup(sizeof(struct elf_prpsinfo), 4) +
 			roundup(arch_task_struct_size, 4);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
@@ -318,7 +322,11 @@ static char *storenote(struct memelfnote *men, char *bufp)
  */
 static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
+#else
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+#endif
 	struct elf_prpsinfo prpsinfo;	/* NT_PRPSINFO */
 	struct elf_phdr *nhdr, *phdr;
 	struct elfhdr *elf;
@@ -387,10 +395,18 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	/* set up the process status */
 	notes[0].name = CORE_STR;
 	notes[0].type = NT_PRSTATUS;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	notes[0].datasz = sizeof(struct elf_fdpic_prstatus);
+#else
 	notes[0].datasz = sizeof(struct elf_prstatus);
+#endif
 	notes[0].data = &prstatus;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	memset(&prstatus, 0, sizeof(struct elf_fdpic_prstatus));
+#else
 	memset(&prstatus, 0, sizeof(struct elf_prstatus));
+#endif
 
 	nhdr->p_filesz	= notesize(&notes[0]);
 	bufp = storenote(&notes[0], bufp);
include/linux/kexec.h +4 -0
index d140b1e9faa7..d9196ccd3781 100644
@@ -63,7 +63,11 @@
 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 #define KEXEC_CORE_NOTE_NAME "CORE"
 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_fdpic_prstatus), 4)
+#else
 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#endif
 /*
  * The per-cpu notes area is a list of notes terminated by a "NULL"
  * note header.  For kdump, the code in vmcore.c runs in the context
include/uapi/linux/elfcore.h +35 -2
index 569737cfb557..697c52db0227 100644
@@ -60,7 +60,40 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+	int pr_fpvalid;		/* True if math co-processor being used.  */
+};
+
+/* Architectures that set CONFIG_BINFMT_ELF_FDPIC use this instead of
+ * "struct elf_prstatus".
+ */
+struct elf_fdpic_prstatus
+{
+#if 0
+	long	pr_flags;	/* XXX Process flags */
+	short	pr_why;		/* XXX Reason for process halt */
+	short	pr_what;	/* XXX More detailed reason */
+#endif
+	struct elf_siginfo pr_info;	/* Info associated with signal */
+	short	pr_cursig;		/* Current signal */
+	unsigned long pr_sigpend;	/* Set of pending signals */
+	unsigned long pr_sighold;	/* Set of held signals */
+#if 0
+	struct sigaltstack pr_altstack;	/* Alternate stack info */
+	struct sigaction pr_action;	/* Signal action for current sig */
+#endif
+	pid_t	pr_pid;
+	pid_t	pr_ppid;
+	pid_t	pr_pgrp;
+	pid_t	pr_sid;
+	struct timeval pr_utime;	/* User time */
+	struct timeval pr_stime;	/* System time */
+	struct timeval pr_cutime;	/* Cumulative user time */
+	struct timeval pr_cstime;	/* Cumulative system time */
+#if 0
+	long	pr_instr;		/* Current instruction */
+#endif
+	elf_gregset_t pr_reg;	/* GP registers */
+
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
@@ -69,7 +102,7 @@ struct elf_prstatus
 	 */
 	unsigned long pr_exec_fdpic_loadmap;
 	unsigned long pr_interp_fdpic_loadmap;
-#endif
+
 	int pr_fpvalid;		/* True if math co-processor being used.  */
 };
 
kernel/kexec_core.c +4 -0
index 201b45327804..8d2fc707fecf 100644
@@ -977,7 +977,11 @@ static void final_note(u32 *buf)
 
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;
+#else
 	struct elf_prstatus prstatus;
+#endif
 	u32 *buf;
 
 	if ((cpu < 0) || (cpu >= nr_cpu_ids))
Signature · 1 line
2.4.6
#78 lore raw

Re: [PATCH 05/13] Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

Quoted 5 lines · Palmer Dabbelt

I tried to fix all the users of "struct elf_prstatus" that should now be using "struct elf_fdpic_prstatus". The only testing I did here was to build a Blackfin defconfig with "struct elf_prstatus" not defined, and to build an x86 defconfig with "struct elf_fdpic_prstatus" not defined.

You probably also need to try loading a core into a debugger.

David

#79 lore raw

PATCH 5/13 Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

In reply to Palmer Dabbelt

This is a pretty big change that I haven't tested any, which worries me a lot. The general idea here is that "struct elf_prstatus" can be visible to userspace (from <linux/ptrace.h>)

"
Generic ptrace interface that exports the architecture specific regsets using the corresponding NT_* types (which are also used in the core dump). Please note that the NT_PRSTATUS note type in a core dump contains a full 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the other user_regset flavors, the user_regset layout and the ELF core dump note payload are exactly the same layout.
"

so it shouldn't have an "#ifdef CONFIG_" in there.

This splits the structure into two different structures, one still named "struct elf_prstatus", and one for ELF FDPIC that is named "struct elf_fdpic_prstatus" -- the idea here is that most users are standard ELF, so that's the name that didn't change.

I tried to fix all the users of "struct elf_prstatus" that should now be using "struct elf_fdpic_prstatus". The only testing I did here was to build a Blackfin defconfig with "struct elf_prstatus" not defined, and to build an x86 defconfig with "struct elf_fdpic_prstatus" not defined.

Note that this fails checkpatch.pl with a complaint about wanting open braces on the same line as struct definitions. The existing struct definitions in this file have the brace a line afterwards, so I'm going to leave this alone.

---
 fs/binfmt_elf_fdpic.c        |  6 +++---
 fs/proc/kcore.c              | 16 ++++++++++++++++
 include/linux/kexec.h        |  4 ++++
 include/uapi/linux/elfcore.h | 37 +++++++++++++++++++++++++++++++++++--
 kernel/kexec_core.c          |  4 ++++
 5 files changed, 62 insertions(+), 5 deletions(-)
fs/binfmt_elf_fdpic.c +3 -3
index d3634bfb7fe1..587bf0466d71 100644
@@ -1323,7 +1323,7 @@ static inline void fill_note(struct memelfnote *note, const char *name, int type
  * fill up all the fields in prstatus from the given task struct, except
  * registers which need to be filled up separately.
  */
-static void fill_prstatus(struct elf_prstatus *prstatus,
+static void fill_prstatus(struct elf_fdpic_prstatus *prstatus,
 			  struct task_struct *p, long signr)
 {
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1406,7 +1406,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
 struct elf_thread_status
 {
 	struct list_head list;
-	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1539,7 +1539,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
 	loff_t offset = 0, dataoff;
 	int numnote;
 	struct memelfnote *notes = NULL;
-	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
 	struct elf_prpsinfo *psinfo = NULL;	/* NT_PRPSINFO */
  	LIST_HEAD(thread_list);
  	struct list_head *t;
fs/proc/kcore.c +16 -0
index 92e6726f6e37..b1edd77ec854 100644
@@ -90,7 +90,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 			(*nphdr + 2)*sizeof(struct elf_phdr) + 
 			3 * ((sizeof(struct elf_note)) +
 			     roundup(sizeof(CORE_STR), 4)) +
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+			roundup(sizeof(struct elf_fdpic_prstatus), 4) +
+#else
 			roundup(sizeof(struct elf_prstatus), 4) +
+#endif
 			roundup(sizeof(struct elf_prpsinfo), 4) +
 			roundup(arch_task_struct_size, 4);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
@@ -318,7 +322,11 @@ static char *storenote(struct memelfnote *men, char *bufp)
  */
 static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
+#else
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+#endif
 	struct elf_prpsinfo prpsinfo;	/* NT_PRPSINFO */
 	struct elf_phdr *nhdr, *phdr;
 	struct elfhdr *elf;
@@ -387,10 +395,18 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	/* set up the process status */
 	notes[0].name = CORE_STR;
 	notes[0].type = NT_PRSTATUS;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	notes[0].datasz = sizeof(struct elf_fdpic_prstatus);
+#else
 	notes[0].datasz = sizeof(struct elf_prstatus);
+#endif
 	notes[0].data = &prstatus;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	memset(&prstatus, 0, sizeof(struct elf_fdpic_prstatus));
+#else
 	memset(&prstatus, 0, sizeof(struct elf_prstatus));
+#endif
 
 	nhdr->p_filesz	= notesize(&notes[0]);
 	bufp = storenote(&notes[0], bufp);
include/linux/kexec.h +4 -0
index d140b1e9faa7..d9196ccd3781 100644
@@ -63,7 +63,11 @@
 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 #define KEXEC_CORE_NOTE_NAME "CORE"
 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_fdpic_prstatus), 4)
+#else
 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#endif
 /*
  * The per-cpu notes area is a list of notes terminated by a "NULL"
  * note header.  For kdump, the code in vmcore.c runs in the context
include/uapi/linux/elfcore.h +35 -2
index 569737cfb557..697c52db0227 100644
@@ -60,7 +60,40 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+	int pr_fpvalid;		/* True if math co-processor being used.  */
+};
+
+/* Architectures that set CONFIG_BINFMT_ELF_FDPIC use this instead of
+ * "struct elf_prstatus".
+ */
+struct elf_fdpic_prstatus
+{
+#if 0
+	long	pr_flags;	/* XXX Process flags */
+	short	pr_why;		/* XXX Reason for process halt */
+	short	pr_what;	/* XXX More detailed reason */
+#endif
+	struct elf_siginfo pr_info;	/* Info associated with signal */
+	short	pr_cursig;		/* Current signal */
+	unsigned long pr_sigpend;	/* Set of pending signals */
+	unsigned long pr_sighold;	/* Set of held signals */
+#if 0
+	struct sigaltstack pr_altstack;	/* Alternate stack info */
+	struct sigaction pr_action;	/* Signal action for current sig */
+#endif
+	pid_t	pr_pid;
+	pid_t	pr_ppid;
+	pid_t	pr_pgrp;
+	pid_t	pr_sid;
+	struct timeval pr_utime;	/* User time */
+	struct timeval pr_stime;	/* System time */
+	struct timeval pr_cutime;	/* Cumulative user time */
+	struct timeval pr_cstime;	/* Cumulative system time */
+#if 0
+	long	pr_instr;		/* Current instruction */
+#endif
+	elf_gregset_t pr_reg;	/* GP registers */
+
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
@@ -69,7 +102,7 @@ struct elf_prstatus
 	 */
 	unsigned long pr_exec_fdpic_loadmap;
 	unsigned long pr_interp_fdpic_loadmap;
-#endif
+
 	int pr_fpvalid;		/* True if math co-processor being used.  */
 };
 
kernel/kexec_core.c +4 -0
index 201b45327804..8d2fc707fecf 100644
@@ -977,7 +977,11 @@ static void final_note(u32 *buf)
 
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;
+#else
 	struct elf_prstatus prstatus;
+#endif
 	u32 *buf;
 
 	if ((cpu < 0) || (cpu >= nr_cpu_ids))
Signature · 1 line
2.4.6
#80 lore raw

PATCH 5/13 Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

In reply to Palmer Dabbelt

This is a pretty big change that I haven't tested any, which worries me a lot. The general idea here is that "struct elf_prstatus" can be visible to userspace (from <linux/ptrace.h>)

"
Generic ptrace interface that exports the architecture specific regsets using the corresponding NT_* types (which are also used in the core dump). Please note that the NT_PRSTATUS note type in a core dump contains a full 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the other user_regset flavors, the user_regset layout and the ELF core dump note payload are exactly the same layout.
"

so it shouldn't have an "#ifdef CONFIG_" in there.

This splits the structure into two different structures, one still named "struct elf_prstatus", and one for ELF FDPIC that is named "struct elf_fdpic_prstatus" -- the idea here is that most users are standard ELF, so that's the name that didn't change.

I tried to fix all the users of "struct elf_prstatus" that should now be using "struct elf_fdpic_prstatus". The only testing I did here was to build a Blackfin defconfig with "struct elf_prstatus" not defined, and to build an x86 defconfig with "struct elf_fdpic_prstatus" not defined.

Note that this fails checkpatch.pl with a complaint about wanting open braces on the same line as struct definitions. The existing struct definitions in this file have the brace a line afterwards, so I'm going to leave this alone.

---
 fs/binfmt_elf_fdpic.c        |  6 +++---
 fs/proc/kcore.c              | 16 ++++++++++++++++
 include/linux/kexec.h        |  4 ++++
 include/uapi/linux/elfcore.h | 37 +++++++++++++++++++++++++++++++++++--
 kernel/kexec_core.c          |  4 ++++
 5 files changed, 62 insertions(+), 5 deletions(-)
fs/binfmt_elf_fdpic.c +3 -3
index d3634bfb7fe1..587bf0466d71 100644
@@ -1323,7 +1323,7 @@ static inline void fill_note(struct memelfnote *note, const char *name, int type
  * fill up all the fields in prstatus from the given task struct, except
  * registers which need to be filled up separately.
  */
-static void fill_prstatus(struct elf_prstatus *prstatus,
+static void fill_prstatus(struct elf_fdpic_prstatus *prstatus,
 			  struct task_struct *p, long signr)
 {
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1406,7 +1406,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
 struct elf_thread_status
 {
 	struct list_head list;
-	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1539,7 +1539,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
 	loff_t offset = 0, dataoff;
 	int numnote;
 	struct memelfnote *notes = NULL;
-	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
 	struct elf_prpsinfo *psinfo = NULL;	/* NT_PRPSINFO */
  	LIST_HEAD(thread_list);
  	struct list_head *t;
fs/proc/kcore.c +16 -0
index 92e6726f6e37..b1edd77ec854 100644
@@ -90,7 +90,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 			(*nphdr + 2)*sizeof(struct elf_phdr) + 
 			3 * ((sizeof(struct elf_note)) +
 			     roundup(sizeof(CORE_STR), 4)) +
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+			roundup(sizeof(struct elf_fdpic_prstatus), 4) +
+#else
 			roundup(sizeof(struct elf_prstatus), 4) +
+#endif
 			roundup(sizeof(struct elf_prpsinfo), 4) +
 			roundup(arch_task_struct_size, 4);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
@@ -318,7 +322,11 @@ static char *storenote(struct memelfnote *men, char *bufp)
  */
 static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
+#else
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+#endif
 	struct elf_prpsinfo prpsinfo;	/* NT_PRPSINFO */
 	struct elf_phdr *nhdr, *phdr;
 	struct elfhdr *elf;
@@ -387,10 +395,18 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	/* set up the process status */
 	notes[0].name = CORE_STR;
 	notes[0].type = NT_PRSTATUS;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	notes[0].datasz = sizeof(struct elf_fdpic_prstatus);
+#else
 	notes[0].datasz = sizeof(struct elf_prstatus);
+#endif
 	notes[0].data = &prstatus;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	memset(&prstatus, 0, sizeof(struct elf_fdpic_prstatus));
+#else
 	memset(&prstatus, 0, sizeof(struct elf_prstatus));
+#endif
 
 	nhdr->p_filesz	= notesize(&notes[0]);
 	bufp = storenote(&notes[0], bufp);
include/linux/kexec.h +4 -0
index d140b1e9faa7..d9196ccd3781 100644
@@ -63,7 +63,11 @@
 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 #define KEXEC_CORE_NOTE_NAME "CORE"
 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_fdpic_prstatus), 4)
+#else
 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#endif
 /*
  * The per-cpu notes area is a list of notes terminated by a "NULL"
  * note header.  For kdump, the code in vmcore.c runs in the context
include/uapi/linux/elfcore.h +35 -2
index 569737cfb557..697c52db0227 100644
@@ -60,7 +60,40 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+	int pr_fpvalid;		/* True if math co-processor being used.  */
+};
+
+/* Architectures that set CONFIG_BINFMT_ELF_FDPIC use this instead of
+ * "struct elf_prstatus".
+ */
+struct elf_fdpic_prstatus
+{
+#if 0
+	long	pr_flags;	/* XXX Process flags */
+	short	pr_why;		/* XXX Reason for process halt */
+	short	pr_what;	/* XXX More detailed reason */
+#endif
+	struct elf_siginfo pr_info;	/* Info associated with signal */
+	short	pr_cursig;		/* Current signal */
+	unsigned long pr_sigpend;	/* Set of pending signals */
+	unsigned long pr_sighold;	/* Set of held signals */
+#if 0
+	struct sigaltstack pr_altstack;	/* Alternate stack info */
+	struct sigaction pr_action;	/* Signal action for current sig */
+#endif
+	pid_t	pr_pid;
+	pid_t	pr_ppid;
+	pid_t	pr_pgrp;
+	pid_t	pr_sid;
+	struct timeval pr_utime;	/* User time */
+	struct timeval pr_stime;	/* System time */
+	struct timeval pr_cutime;	/* Cumulative user time */
+	struct timeval pr_cstime;	/* Cumulative system time */
+#if 0
+	long	pr_instr;		/* Current instruction */
+#endif
+	elf_gregset_t pr_reg;	/* GP registers */
+
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
@@ -69,7 +102,7 @@ struct elf_prstatus
 	 */
 	unsigned long pr_exec_fdpic_loadmap;
 	unsigned long pr_interp_fdpic_loadmap;
-#endif
+
 	int pr_fpvalid;		/* True if math co-processor being used.  */
 };
 
kernel/kexec_core.c +4 -0
index 201b45327804..8d2fc707fecf 100644
@@ -977,7 +977,11 @@ static void final_note(u32 *buf)
 
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;
+#else
 	struct elf_prstatus prstatus;
+#endif
 	u32 *buf;
 
 	if ((cpu < 0) || (cpu >= nr_cpu_ids))
Signature · 1 line
2.4.6
#81 lore raw

PATCH 6/13 Move ep_take_care_of_epollwakeup() to fs/eventpoll.c

In reply to Palmer Dabbelt

This doesn't make any sense to expose to userspace, so it's been moved to the one user. This was introduced by commit 95f19f658ce1 ("epoll:
drop EPOLLWAKEUP if PM_SLEEP is disabled").

---
 fs/eventpoll.c                 | 13 +++++++++++++
 include/uapi/linux/eventpoll.h | 12 ------------
 2 files changed, 13 insertions(+), 12 deletions(-)
fs/eventpoll.c +13 -0
index 1e009cad8d5c..aadee3d1931a 100644
@@ -1812,6 +1812,19 @@ SYSCALL_DEFINE1(epoll_create, int, size)
 	return sys_epoll_create1(0);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
+		epev->events &= ~EPOLLWAKEUP;
+}
+#else
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	epev->events &= ~EPOLLWAKEUP;
+}
+#endif
+
 /*
  * The following function implements the controller interface for
  * the eventpoll file that enables the insertion/removal/change of
include/uapi/linux/eventpoll.h +0 -12
index bc81fb2e1f0e..7850373079ee 100644
@@ -61,16 +61,4 @@ struct epoll_event {
 	__u64 data;
 } EPOLL_PACKED;
 
-#ifdef CONFIG_PM_SLEEP
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
-		epev->events &= ~EPOLLWAKEUP;
-}
-#else
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	epev->events &= ~EPOLLWAKEUP;
-}
-#endif
 #endif /* _UAPI_LINUX_EVENTPOLL_H */
Signature · 1 line
2.4.6
#82 lore raw

PATCH 6/13 Move ep_take_care_of_epollwakeup() to fs/eventpoll.c

In reply to Palmer Dabbelt

This doesn't make any sense to expose to userspace, so it's been moved to the one user. This was introduced by commit 95f19f658ce1 ("epoll:
drop EPOLLWAKEUP if PM_SLEEP is disabled").

---
 fs/eventpoll.c                 | 13 +++++++++++++
 include/uapi/linux/eventpoll.h | 12 ------------
 2 files changed, 13 insertions(+), 12 deletions(-)
fs/eventpoll.c +13 -0
index 1e009cad8d5c..aadee3d1931a 100644
@@ -1812,6 +1812,19 @@ SYSCALL_DEFINE1(epoll_create, int, size)
 	return sys_epoll_create1(0);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
+		epev->events &= ~EPOLLWAKEUP;
+}
+#else
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	epev->events &= ~EPOLLWAKEUP;
+}
+#endif
+
 /*
  * The following function implements the controller interface for
  * the eventpoll file that enables the insertion/removal/change of
include/uapi/linux/eventpoll.h +0 -12
index bc81fb2e1f0e..7850373079ee 100644
@@ -61,16 +61,4 @@ struct epoll_event {
 	__u64 data;
 } EPOLL_PACKED;
 
-#ifdef CONFIG_PM_SLEEP
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
-		epev->events &= ~EPOLLWAKEUP;
-}
-#else
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	epev->events &= ~EPOLLWAKEUP;
-}
-#endif
 #endif /* _UAPI_LINUX_EVENTPOLL_H */
Signature · 1 line
2.4.6
#83 lore raw

PATCH 6/13 Move ep_take_care_of_epollwakeup() to fs/eventpoll.c

In reply to Palmer Dabbelt

This doesn't make any sense to expose to userspace, so it's been moved to the one user. This was introduced by commit 95f19f658ce1 ("epoll:
drop EPOLLWAKEUP if PM_SLEEP is disabled").

---
 fs/eventpoll.c                 | 13 +++++++++++++
 include/uapi/linux/eventpoll.h | 12 ------------
 2 files changed, 13 insertions(+), 12 deletions(-)
fs/eventpoll.c +13 -0
index 1e009cad8d5c..aadee3d1931a 100644
@@ -1812,6 +1812,19 @@ SYSCALL_DEFINE1(epoll_create, int, size)
 	return sys_epoll_create1(0);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
+		epev->events &= ~EPOLLWAKEUP;
+}
+#else
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	epev->events &= ~EPOLLWAKEUP;
+}
+#endif
+
 /*
  * The following function implements the controller interface for
  * the eventpoll file that enables the insertion/removal/change of
include/uapi/linux/eventpoll.h +0 -12
index bc81fb2e1f0e..7850373079ee 100644
@@ -61,16 +61,4 @@ struct epoll_event {
 	__u64 data;
 } EPOLL_PACKED;
 
-#ifdef CONFIG_PM_SLEEP
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
-		epev->events &= ~EPOLLWAKEUP;
-}
-#else
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	epev->events &= ~EPOLLWAKEUP;
-}
-#endif
 #endif /* _UAPI_LINUX_EVENTPOLL_H */
Signature · 1 line
2.4.6
#84 lore raw

PATCH 6/13 Move ep_take_care_of_epollwakeup() to fs/eventpoll.c

In reply to Palmer Dabbelt

This doesn't make any sense to expose to userspace, so it's been moved to the one user. This was introduced by commit 95f19f658ce1 ("epoll:
drop EPOLLWAKEUP if PM_SLEEP is disabled").

---
 fs/eventpoll.c                 | 13 +++++++++++++
 include/uapi/linux/eventpoll.h | 12 ------------
 2 files changed, 13 insertions(+), 12 deletions(-)
fs/eventpoll.c +13 -0
index 1e009cad8d5c..aadee3d1931a 100644
@@ -1812,6 +1812,19 @@ SYSCALL_DEFINE1(epoll_create, int, size)
 	return sys_epoll_create1(0);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
+		epev->events &= ~EPOLLWAKEUP;
+}
+#else
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	epev->events &= ~EPOLLWAKEUP;
+}
+#endif
+
 /*
  * The following function implements the controller interface for
  * the eventpoll file that enables the insertion/removal/change of
include/uapi/linux/eventpoll.h +0 -12
index bc81fb2e1f0e..7850373079ee 100644
@@ -61,16 +61,4 @@ struct epoll_event {
 	__u64 data;
 } EPOLL_PACKED;
 
-#ifdef CONFIG_PM_SLEEP
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
-		epev->events &= ~EPOLLWAKEUP;
-}
-#else
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	epev->events &= ~EPOLLWAKEUP;
-}
-#endif
 #endif /* _UAPI_LINUX_EVENTPOLL_H */
Signature · 1 line
2.4.6
#85 lore raw

PATCH 7/13 Make FB_BACKLIGHT_{LEVELS,MAX} always visible

In reply to Palmer Dabbelt

Nothing else in the kernel defines this, and this header is visible to userspace. Rather than hiding it in an #ifdef, I think it's sane to just make this visible to userspace.

---
 include/uapi/linux/fb.h | 3 ---
 1 file changed, 3 deletions(-)
include/uapi/linux/fb.h +0 -3
index fb795c3b3c17..8926f13bc19f 100644
@@ -392,11 +392,8 @@ struct fb_cursor {
 	struct fb_image	image;	/* Cursor image */
 };
 
-#ifdef CONFIG_FB_BACKLIGHT
 /* Settings for the generic backlight code */
 #define FB_BACKLIGHT_LEVELS	128
 #define FB_BACKLIGHT_MAX	0xFF
-#endif
-
 
 #endif /* _UAPI_LINUX_FB_H */
Signature · 1 line
2.4.6
#86 lore raw

PATCH 7/13 Make FB_BACKLIGHT_{LEVELS,MAX} always visible

In reply to Palmer Dabbelt

Nothing else in the kernel defines this, and this header is visible to userspace. Rather than hiding it in an #ifdef, I think it's sane to just make this visible to userspace.

---
 include/uapi/linux/fb.h | 3 ---
 1 file changed, 3 deletions(-)
include/uapi/linux/fb.h +0 -3
index fb795c3b3c17..8926f13bc19f 100644
@@ -392,11 +392,8 @@ struct fb_cursor {
 	struct fb_image	image;	/* Cursor image */
 };
 
-#ifdef CONFIG_FB_BACKLIGHT
 /* Settings for the generic backlight code */
 #define FB_BACKLIGHT_LEVELS	128
 #define FB_BACKLIGHT_MAX	0xFF
-#endif
-
 
 #endif /* _UAPI_LINUX_FB_H */
Signature · 1 line
2.4.6
#87 lore raw

PATCH 7/13 Make FB_BACKLIGHT_{LEVELS,MAX} always visible

In reply to Palmer Dabbelt

Nothing else in the kernel defines this, and this header is visible to userspace. Rather than hiding it in an #ifdef, I think it's sane to just make this visible to userspace.

---
 include/uapi/linux/fb.h | 3 ---
 1 file changed, 3 deletions(-)
include/uapi/linux/fb.h +0 -3
index fb795c3b3c17..8926f13bc19f 100644
@@ -392,11 +392,8 @@ struct fb_cursor {
 	struct fb_image	image;	/* Cursor image */
 };
 
-#ifdef CONFIG_FB_BACKLIGHT
 /* Settings for the generic backlight code */
 #define FB_BACKLIGHT_LEVELS	128
 #define FB_BACKLIGHT_MAX	0xFF
-#endif
-
 
 #endif /* _UAPI_LINUX_FB_H */
Signature · 1 line
2.4.6
#88 lore raw

PATCH 8/13 Move MAX_SHARED_LIBS to fs/binfmt_flat.c

In reply to Palmer Dabbelt

I'm not sure what this is, but it doesn't feel like something that should be exposed to userspace here. I'm assuming this file was exposed for the structure in it, which doesn't depend on MAX_SHARED_LIBS.

---
 fs/binfmt_flat.c          | 6 ++++++
 include/uapi/linux/flat.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/binfmt_flat.c +6 -0
index f723cd3a455c..e89fb43c2a10 100644
@@ -72,6 +72,12 @@
 #define RELOC_FAILED 0xff00ff01		/* Relocation incorrect somewhere */
 #define UNLOADED_LIB 0x7ff000ff		/* Placeholder for unused library */
 
+#ifdef CONFIG_BINFMT_SHARED_FLAT
+#define	MAX_SHARED_LIBS			(4)
+#else
+#define	MAX_SHARED_LIBS			(1)
+#endif
+
 struct lib_info {
 	struct {
 		unsigned long start_code;		/* Start of text segment */
include/uapi/linux/flat.h +0 -6
index 88cd6baba8f3..1b177c7637c4 100644
@@ -13,12 +13,6 @@
 
 #define	FLAT_VERSION			0x00000004L
 
-#ifdef CONFIG_BINFMT_SHARED_FLAT
-#define	MAX_SHARED_LIBS			(4)
-#else
-#define	MAX_SHARED_LIBS			(1)
-#endif
-
 /*
  * To make everything easier to port and manage cross platform
  * development,  all fields are in network byte order.
Signature · 1 line
2.4.6
#89 lore raw

PATCH 8/13 Move MAX_SHARED_LIBS to fs/binfmt_flat.c

In reply to Palmer Dabbelt

I'm not sure what this is, but it doesn't feel like something that should be exposed to userspace here. I'm assuming this file was exposed for the structure in it, which doesn't depend on MAX_SHARED_LIBS.

---
 fs/binfmt_flat.c          | 6 ++++++
 include/uapi/linux/flat.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/binfmt_flat.c +6 -0
index f723cd3a455c..e89fb43c2a10 100644
@@ -72,6 +72,12 @@
 #define RELOC_FAILED 0xff00ff01		/* Relocation incorrect somewhere */
 #define UNLOADED_LIB 0x7ff000ff		/* Placeholder for unused library */
 
+#ifdef CONFIG_BINFMT_SHARED_FLAT
+#define	MAX_SHARED_LIBS			(4)
+#else
+#define	MAX_SHARED_LIBS			(1)
+#endif
+
 struct lib_info {
 	struct {
 		unsigned long start_code;		/* Start of text segment */
include/uapi/linux/flat.h +0 -6
index 88cd6baba8f3..1b177c7637c4 100644
@@ -13,12 +13,6 @@
 
 #define	FLAT_VERSION			0x00000004L
 
-#ifdef CONFIG_BINFMT_SHARED_FLAT
-#define	MAX_SHARED_LIBS			(4)
-#else
-#define	MAX_SHARED_LIBS			(1)
-#endif
-
 /*
  * To make everything easier to port and manage cross platform
  * development,  all fields are in network byte order.
Signature · 1 line
2.4.6
#90 lore raw

PATCH 8/13 Move MAX_SHARED_LIBS to fs/binfmt_flat.c

In reply to Palmer Dabbelt

I'm not sure what this is, but it doesn't feel like something that should be exposed to userspace here. I'm assuming this file was exposed for the structure in it, which doesn't depend on MAX_SHARED_LIBS.

---
 fs/binfmt_flat.c          | 6 ++++++
 include/uapi/linux/flat.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/binfmt_flat.c +6 -0
index f723cd3a455c..e89fb43c2a10 100644
@@ -72,6 +72,12 @@
 #define RELOC_FAILED 0xff00ff01		/* Relocation incorrect somewhere */
 #define UNLOADED_LIB 0x7ff000ff		/* Placeholder for unused library */
 
+#ifdef CONFIG_BINFMT_SHARED_FLAT
+#define	MAX_SHARED_LIBS			(4)
+#else
+#define	MAX_SHARED_LIBS			(1)
+#endif
+
 struct lib_info {
 	struct {
 		unsigned long start_code;		/* Start of text segment */
include/uapi/linux/flat.h +0 -6
index 88cd6baba8f3..1b177c7637c4 100644
@@ -13,12 +13,6 @@
 
 #define	FLAT_VERSION			0x00000004L
 
-#ifdef CONFIG_BINFMT_SHARED_FLAT
-#define	MAX_SHARED_LIBS			(4)
-#else
-#define	MAX_SHARED_LIBS			(1)
-#endif
-
 /*
  * To make everything easier to port and manage cross platform
  * development,  all fields are in network byte order.
Signature · 1 line
2.4.6
#91 lore raw

PATCH 8/13 Move MAX_SHARED_LIBS to fs/binfmt_flat.c

In reply to Palmer Dabbelt

I'm not sure what this is, but it doesn't feel like something that should be exposed to userspace here. I'm assuming this file was exposed for the structure in it, which doesn't depend on MAX_SHARED_LIBS.

---
 fs/binfmt_flat.c          | 6 ++++++
 include/uapi/linux/flat.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/binfmt_flat.c +6 -0
index f723cd3a455c..e89fb43c2a10 100644
@@ -72,6 +72,12 @@
 #define RELOC_FAILED 0xff00ff01		/* Relocation incorrect somewhere */
 #define UNLOADED_LIB 0x7ff000ff		/* Placeholder for unused library */
 
+#ifdef CONFIG_BINFMT_SHARED_FLAT
+#define	MAX_SHARED_LIBS			(4)
+#else
+#define	MAX_SHARED_LIBS			(1)
+#endif
+
 struct lib_info {
 	struct {
 		unsigned long start_code;		/* Start of text segment */
include/uapi/linux/flat.h +0 -6
index 88cd6baba8f3..1b177c7637c4 100644
@@ -13,12 +13,6 @@
 
 #define	FLAT_VERSION			0x00000004L
 
-#ifdef CONFIG_BINFMT_SHARED_FLAT
-#define	MAX_SHARED_LIBS			(4)
-#else
-#define	MAX_SHARED_LIBS			(1)
-#endif
-
 /*
  * To make everything easier to port and manage cross platform
  * development,  all fields are in network byte order.
Signature · 1 line
2.4.6
#92 lore raw

PATCH 9/13 Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -10
index b04000a2296a..7a6a5a7f9511 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};
-
 #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
kernel/events/hw_breakpoint.c +10 -0
index 92ce5f4ccc26..5ad117e0f55b 100644
@@ -58,6 +58,16 @@ struct bp_cpuinfo {
 	unsigned int	flexible; /* XXX: placeholder, see fetch_this_slot() */
 };
 
+enum bp_type_idx {
+	TYPE_INST	= 0,
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
+	TYPE_DATA	= 0,
+#else
+	TYPE_DATA	= 1,
+#endif
+	TYPE_MAX
+};
+
 static DEFINE_PER_CPU(struct bp_cpuinfo, bp_cpuinfo[TYPE_MAX]);
 static int nr_slots[TYPE_MAX];
 
Signature · 1 line
2.4.6
maintainer
#93 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

Quoted 21 lines · Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -0
index b04000a2296a..7a6a5a7f9511 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };

include/uapi/linux/hw_breakpoint.h enum { · line 28

Quoted 10 lines
include/uapi/linux/hw_breakpoint.h +0 -9
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};

This is rather unfortunate; you are correct that the naming is too generic (and I tend to agree), but I think these values are required by userspace to fill out:

perf_event_attr::bp_type

So removing them will break things.

Frederic?

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

#94 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

Quoted 37 lines · On Tue, 15 Sep 2015 01:06:07 PDT (-0700), [email protected] wrote:
Quoted 21 lines · Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -0
index b04000a2296a..7a6a5a7f9511 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };

include/uapi/linux/hw_breakpoint.h enum { · line 28

Quoted 10 lines
include/uapi/linux/hw_breakpoint.h +0 -9
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};

This is rather unfortunate; you are correct that the naming is too generic (and I tend to agree), but I think these values are required by userspace to fill out:

Quoted 5 lines

perf_event_attr::bp_type

So removing them will break things.

Frederic?

perf_event_open(2) says

bp_type (since Linux 2.6.33)
This chooses the breakpoint type. It is one of:

HW_BREAKPOINT_EMPTY
No breakpoint.

HW_BREAKPOINT_R
Count when we read the memory location.

HW_BREAKPOINT_W
Count when we write the memory location.

HW_BREAKPOINT_RW
Count when we read or write the memory location.

HW_BREAKPOINT_X
Count when we execute code at the memory location.

The values can be combined via a bitwise or, but the combination of HW_BREAKPOINT_R or HW_BREAKPOINT_W with HW_BREAKPOINT_X is not allowed.

so I think removing this enum from userspace is OK. Did I miss something?

maintainer
#95 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

Quoted 64 lines · Palmer Dabbelt
Quoted 37 lines · On Tue, 15 Sep 2015 01:06:07 PDT (-0700), [email protected] wrote:
Quoted 21 lines · Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -0
index b04000a2296a..7a6a5a7f9511 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };

include/uapi/linux/hw_breakpoint.h enum { · line 28

Quoted 10 lines
include/uapi/linux/hw_breakpoint.h +0 -9
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};

This is rather unfortunate; you are correct that the naming is too generic (and I tend to agree), but I think these values are required by userspace to fill out:

Quoted 5 lines

perf_event_attr::bp_type

So removing them will break things.

Frederic?

perf_event_open(2) says

bp_type (since Linux 2.6.33)
This chooses the breakpoint type. It is one of:

HW_BREAKPOINT_EMPTY
No breakpoint.

HW_BREAKPOINT_R
Count when we read the memory location.

HW_BREAKPOINT_W
Count when we write the memory location.

HW_BREAKPOINT_RW
Count when we read or write the memory location.

HW_BREAKPOINT_X
Count when we execute code at the memory location.

Quoted 6 lines

The values can be combined via a bitwise or, but the combination of HW_BREAKPOINT_R or HW_BREAKPOINT_W with HW_BREAKPOINT_X is not allowed.

so I think removing this enum from userspace is OK. Did I miss something?

Nah, could've just been me not being awake. Unless Frederic says otherwise I'll chalk it up to not having drank enough morning juice.

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

#96 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

Quoted 69 lines · On Tue, 15 Sep 2015 12:39:10 PDT (-0700)…
Quoted 68 lines · Palmer Dabbelt
Quoted 37 lines · On Tue, 15 Sep 2015 01:06:07 PDT (-0700)…
Quoted 21 lines · Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -0
index b04000a2296a..7a6a5a7f9511 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };

include/uapi/linux/hw_breakpoint.h enum { · line 28

Quoted 10 lines
include/uapi/linux/hw_breakpoint.h +0 -9
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};

This is rather unfortunate; you are correct that the naming is too generic (and I tend to agree), but I think these values are required by userspace to fill out:

Quoted 5 lines

perf_event_attr::bp_type

So removing them will break things.

Frederic?

perf_event_open(2) says

bp_type (since Linux 2.6.33)
This chooses the breakpoint type. It is one of:

HW_BREAKPOINT_EMPTY
No breakpoint.

HW_BREAKPOINT_R
Count when we read the memory location.

HW_BREAKPOINT_W
Count when we write the memory location.

HW_BREAKPOINT_RW
Count when we read or write the memory location.

HW_BREAKPOINT_X
Count when we execute code at the memory location.

The values can be combined via a bitwise or, but the combination of HW_BREAKPOINT_R or HW_BREAKPOINT_W with HW_BREAKPOINT_X is not allowed.

Quoted 5 lines
Quoted 2 lines

so I think removing this enum from userspace is OK. Did I miss something?

Nah, could've just been me not being awake. Unless Frederic says otherwise I'll chalk it up to not having drank enough morning juice.

Well, I'm going to leave this alone, then -- as Arnd pointed out in a later email that got mis-threaded, this would be super tricky to fix if userspace actually relied on it (which is why I was scared I was wrong).

v4 (which is hopefully the final version of the patch set) will leave this as it is.

maintainer
#97 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to Peter Zijlstra
Quoted 22 lines · On Tuesday 15 September 2015 10:06:07 Peter Zijlstra wrote:
Quoted 7 lines
include/uapi/linux/hw_breakpoint.h +0 -0
index b04000a2296a..7a6a5a7f9511 100644
@@ -17,14 +17,4 @@ enum {
      HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };

include/uapi/linux/hw_breakpoint.h enum { · line 28

Quoted 10 lines
include/uapi/linux/hw_breakpoint.h +0 -9
 
-enum bp_type_idx {
-     TYPE_INST       = 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-     TYPE_DATA       = 0,
-#else
-     TYPE_DATA       = 1,
-#endif
-     TYPE_MAX
-};

This is rather unfortunate; you are correct that the naming is too generic (and I tend to agree), but I think these values are required by userspace to fill out:

Quoted 5 lines

perf_event_attr::bp_type

So removing them will break things.

Frederic?

If user space actually relies on the definition from this header file, then it will use the wrong one on x86 and get 'TYPE_DATA = 1', while the kernel uses 'TYPE_DATA = 0'.

That seems unlikely to work, so I suspect it gets a different definition. If it uses this definition and it does work, we can probably use

#if defined(__KERNEL__) && defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)

but that requires a comment explaining exactly why that works.

Arnd

#98 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

Quoted 6 lines · Arnd Bergmann

That seems unlikely to work, so I suspect it gets a different definition. If it uses this definition and it does work, we can probably use

#if defined(__KERNEL__) && defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)

but that requires a comment explaining exactly why that works.

Are you suggesting wrapping the entire construct in this within the UAPI header?

David

#99 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to Arnd Bergmann
Quoted 33 lines · Arnd Bergmann
Quoted 22 lines · On Tuesday 15 September 2015 10:06:07 Peter Zijlstra wrote:
Quoted 7 lines
include/uapi/linux/hw_breakpoint.h +0 -0
index b04000a2296a..7a6a5a7f9511 100644
@@ -17,14 +17,4 @@ enum {
      HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };

include/uapi/linux/hw_breakpoint.h enum { · line 28

Quoted 10 lines
include/uapi/linux/hw_breakpoint.h +0 -9
 
-enum bp_type_idx {
-     TYPE_INST       = 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-     TYPE_DATA       = 0,
-#else
-     TYPE_DATA       = 1,
-#endif
-     TYPE_MAX
-};

This is rather unfortunate; you are correct that the naming is too generic (and I tend to agree), but I think these values are required by userspace to fill out:

Quoted 5 lines

perf_event_attr::bp_type

So removing them will break things.

Frederic?

If user space actually relies on the definition from this header file, then it will use the wrong one on x86 and get 'TYPE_DATA = 1', while the kernel uses 'TYPE_DATA = 0'.

Quoted 6 lines

That seems unlikely to work, so I suspect it gets a different definition. If it uses this definition and it does work, we can probably use

#if defined(__KERNEL__) && defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)

but that requires a comment explaining exactly why that works.

I think this TYPE_DATA/TYPE_INST can be safely removed from uapi. This is only about internal kernel code. Userspace only relies on HW_BREAKPOINT_[R/W/X] to tell about the nature of the breakpoint.

If userspace ever relies on it, which I have no idea why, it even needs to define CONFIG_HAVE_MIXED_BREAKPOINTS_REGS. No really there shouldn't be any user of that outside the kernel.

Thanks.

Quoted 2 lines

Arnd

#100 lore raw

PATCH 9/13 Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -10
index b04000a2296a..7a6a5a7f9511 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};
-
 #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
kernel/events/hw_breakpoint.c +10 -0
index 92ce5f4ccc26..5ad117e0f55b 100644
@@ -58,6 +58,16 @@ struct bp_cpuinfo {
 	unsigned int	flexible; /* XXX: placeholder, see fetch_this_slot() */
 };
 
+enum bp_type_idx {
+	TYPE_INST	= 0,
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
+	TYPE_DATA	= 0,
+#else
+	TYPE_DATA	= 1,
+#endif
+	TYPE_MAX
+};
+
 static DEFINE_PER_CPU(struct bp_cpuinfo, bp_cpuinfo[TYPE_MAX]);
 static int nr_slots[TYPE_MAX];
 
Signature · 1 line
2.4.6
#101 lore raw

PATCH 9/13 Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -10
index b04000a2296a..7a6a5a7f9511 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};
-
 #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
kernel/events/hw_breakpoint.c +10 -0
index 92ce5f4ccc26..5ad117e0f55b 100644
@@ -58,6 +58,16 @@ struct bp_cpuinfo {
 	unsigned int	flexible; /* XXX: placeholder, see fetch_this_slot() */
 };
 
+enum bp_type_idx {
+	TYPE_INST	= 0,
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
+	TYPE_DATA	= 0,
+#else
+	TYPE_DATA	= 1,
+#endif
+	TYPE_MAX
+};
+
 static DEFINE_PER_CPU(struct bp_cpuinfo, bp_cpuinfo[TYPE_MAX]);
 static int nr_slots[TYPE_MAX];
 
Signature · 1 line
2.4.6
#102 lore raw

PATCH 10/13 Move USE_WCACHING to drivers/block/pktcdvd.c

In reply to Palmer Dabbelt

I don't think this was ever intended to be exposed to userspace, but it did require an "#ifdef CONFIG_*". Since the name is kind of generic and was only used in one place, I've moved the definition to the one user.

---
 drivers/block/pktcdvd.c      | 11 +++++++++++
 include/uapi/linux/pktcdvd.h | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/block/pktcdvd.c +11 -0
index 7be2375db7f2..18d2d05f5ac9 100644
@@ -90,6 +90,17 @@ do {									\
 
 #define MAX_SPEED 0xffff
 
+/*
+ * use drive write caching -- we need deferred error handling to be
+ * able to successfully recover with this option (drive will return good
+ * status as soon as the cdb is validated).
+ */
+#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
+#define USE_WCACHING		1
+#else
+#define USE_WCACHING		0
+#endif
+
 static DEFINE_MUTEX(pktcdvd_mutex);
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
include/uapi/linux/pktcdvd.h +0 -11
index 2640b9d4e243..05c2bee70d6c 100644
@@ -29,17 +29,6 @@
 #define PACKET_WAIT_TIME	(HZ * 5 / 1000)
 
 /*
- * use drive write caching -- we need deferred error handling to be
- * able to successfully recover with this option (drive will return good
- * status as soon as the cdb is validated).
- */
-#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
-#define USE_WCACHING		1
-#else
-#define USE_WCACHING		0
-#endif
-
-/*
  * No user-servicable parts beyond this point ->
  */
 
Signature · 1 line
2.4.6
#103 lore raw

PATCH 10/13 Move USE_WCACHING to drivers/block/pktcdvd.c

In reply to Palmer Dabbelt

I don't think this was ever intended to be exposed to userspace, but it did require an "#ifdef CONFIG_*". Since the name is kind of generic and was only used in one place, I've moved the definition to the one user.

---
 drivers/block/pktcdvd.c      | 11 +++++++++++
 include/uapi/linux/pktcdvd.h | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/block/pktcdvd.c +11 -0
index 7be2375db7f2..18d2d05f5ac9 100644
@@ -90,6 +90,17 @@ do {									\
 
 #define MAX_SPEED 0xffff
 
+/*
+ * use drive write caching -- we need deferred error handling to be
+ * able to successfully recover with this option (drive will return good
+ * status as soon as the cdb is validated).
+ */
+#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
+#define USE_WCACHING		1
+#else
+#define USE_WCACHING		0
+#endif
+
 static DEFINE_MUTEX(pktcdvd_mutex);
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
include/uapi/linux/pktcdvd.h +0 -11
index 2640b9d4e243..05c2bee70d6c 100644
@@ -29,17 +29,6 @@
 #define PACKET_WAIT_TIME	(HZ * 5 / 1000)
 
 /*
- * use drive write caching -- we need deferred error handling to be
- * able to successfully recover with this option (drive will return good
- * status as soon as the cdb is validated).
- */
-#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
-#define USE_WCACHING		1
-#else
-#define USE_WCACHING		0
-#endif
-
-/*
  * No user-servicable parts beyond this point ->
  */
 
Signature · 1 line
2.4.6
#104 lore raw

PATCH 10/13 Move USE_WCACHING to drivers/block/pktcdvd.c

In reply to Palmer Dabbelt

I don't think this was ever intended to be exposed to userspace, but it did require an "#ifdef CONFIG_*". Since the name is kind of generic and was only used in one place, I've moved the definition to the one user.

---
 drivers/block/pktcdvd.c      | 11 +++++++++++
 include/uapi/linux/pktcdvd.h | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/block/pktcdvd.c +11 -0
index 7be2375db7f2..18d2d05f5ac9 100644
@@ -90,6 +90,17 @@ do {									\
 
 #define MAX_SPEED 0xffff
 
+/*
+ * use drive write caching -- we need deferred error handling to be
+ * able to successfully recover with this option (drive will return good
+ * status as soon as the cdb is validated).
+ */
+#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
+#define USE_WCACHING		1
+#else
+#define USE_WCACHING		0
+#endif
+
 static DEFINE_MUTEX(pktcdvd_mutex);
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
include/uapi/linux/pktcdvd.h +0 -11
index 2640b9d4e243..05c2bee70d6c 100644
@@ -29,17 +29,6 @@
 #define PACKET_WAIT_TIME	(HZ * 5 / 1000)
 
 /*
- * use drive write caching -- we need deferred error handling to be
- * able to successfully recover with this option (drive will return good
- * status as soon as the cdb is validated).
- */
-#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
-#define USE_WCACHING		1
-#else
-#define USE_WCACHING		0
-#endif
-
-/*
  * No user-servicable parts beyond this point ->
  */
 
Signature · 1 line
2.4.6
#105 lore raw

PATCH 10/13 Move USE_WCACHING to drivers/block/pktcdvd.c

In reply to Palmer Dabbelt

I don't think this was ever intended to be exposed to userspace, but it did require an "#ifdef CONFIG_*". Since the name is kind of generic and was only used in one place, I've moved the definition to the one user.

---
 drivers/block/pktcdvd.c      | 11 +++++++++++
 include/uapi/linux/pktcdvd.h | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/block/pktcdvd.c +11 -0
index 7be2375db7f2..18d2d05f5ac9 100644
@@ -90,6 +90,17 @@ do {									\
 
 #define MAX_SPEED 0xffff
 
+/*
+ * use drive write caching -- we need deferred error handling to be
+ * able to successfully recover with this option (drive will return good
+ * status as soon as the cdb is validated).
+ */
+#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
+#define USE_WCACHING		1
+#else
+#define USE_WCACHING		0
+#endif
+
 static DEFINE_MUTEX(pktcdvd_mutex);
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
include/uapi/linux/pktcdvd.h +0 -11
index 2640b9d4e243..05c2bee70d6c 100644
@@ -29,17 +29,6 @@
 #define PACKET_WAIT_TIME	(HZ * 5 / 1000)
 
 /*
- * use drive write caching -- we need deferred error handling to be
- * able to successfully recover with this option (drive will return good
- * status as soon as the cdb is validated).
- */
-#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
-#define USE_WCACHING		1
-#else
-#define USE_WCACHING		0
-#endif
-
-/*
  * No user-servicable parts beyond this point ->
  */
 
Signature · 1 line
2.4.6
#106 lore raw

PATCH 11/13 Always define MAX_RAW_MINORS as 65535 in userspace

In reply to Palmer Dabbelt

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

---
 drivers/char/raw.c       | 7 ++++---
 include/uapi/linux/raw.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/raw.c +4 -3
index 60316fbaf295..362d7a6511b9 100644
@@ -36,7 +36,7 @@ static struct raw_device_data *raw_devices;
 static DEFINE_MUTEX(raw_mutex);
 static const struct file_operations raw_ctl_fops; /* forward declaration */
 
-static int max_raw_minors = MAX_RAW_MINORS;
+static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
 
 module_param(max_raw_minors, int, 0);
 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,8 +317,9 @@ static int __init raw_init(void)
 
 	if (max_raw_minors < 1 || max_raw_minors > 65536) {
 		printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
-			" between 1 and 65536), using %d\n", MAX_RAW_MINORS);
-		max_raw_minors = MAX_RAW_MINORS;
+			" between 1 and 65536), using %d\n",
+		       CONFIG_MAX_RAW_MINORS);
+		max_raw_minors = CONFIG_MAX_RAW_MINORS;
 	}
 
 	raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
include/uapi/linux/raw.h +1 -1
index 62d543e70603..f0390b3e8530 100644
@@ -13,6 +13,6 @@ struct raw_config_request
 	__u64	block_minor;
 };
 
-#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
+#define MAX_RAW_MINORS 65535
 
 #endif /* __LINUX_RAW_H */
Signature · 1 line
2.4.6
#107 lore raw

Re: [PATCH 11/13] Always define MAX_RAW_MINORS as 65535 in userspace

Quoted 11 lines · Palmer Dabbelt

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

From a UAPI perspective I would think the right value would be 2^20.

-hpa

#108 lore raw

Re: [PATCH 11/13] Always define MAX_RAW_MINORS as 65535 in userspace

Quoted 5 lines · On Tue, 15 Sep 2015 13:42:47 PDT (-0700), [email protected] wrote:
Quoted 4 lines · Palmer Dabbelt

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

Quoted 7 lines
Quoted 5 lines

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

From a UAPI perspective I would think the right value would be 2^20.

Wow, I'm super surprised. For some reason I thought major/minor numbers were 16 bits, but according to glibc I just have no idea what I'm doing :).

Thanks for catching this!

#109 lore raw

PATCH 11/13 Always define MAX_RAW_MINORS as 65535 in userspace

In reply to Palmer Dabbelt

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

---
 drivers/char/raw.c       | 7 ++++---
 include/uapi/linux/raw.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/raw.c +4 -3
index 60316fbaf295..362d7a6511b9 100644
@@ -36,7 +36,7 @@ static struct raw_device_data *raw_devices;
 static DEFINE_MUTEX(raw_mutex);
 static const struct file_operations raw_ctl_fops; /* forward declaration */
 
-static int max_raw_minors = MAX_RAW_MINORS;
+static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
 
 module_param(max_raw_minors, int, 0);
 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,8 +317,9 @@ static int __init raw_init(void)
 
 	if (max_raw_minors < 1 || max_raw_minors > 65536) {
 		printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
-			" between 1 and 65536), using %d\n", MAX_RAW_MINORS);
-		max_raw_minors = MAX_RAW_MINORS;
+			" between 1 and 65536), using %d\n",
+		       CONFIG_MAX_RAW_MINORS);
+		max_raw_minors = CONFIG_MAX_RAW_MINORS;
 	}
 
 	raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
include/uapi/linux/raw.h +1 -1
index 62d543e70603..f0390b3e8530 100644
@@ -13,6 +13,6 @@ struct raw_config_request
 	__u64	block_minor;
 };
 
-#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
+#define MAX_RAW_MINORS 65535
 
 #endif /* __LINUX_RAW_H */
Signature · 1 line
2.4.6
#110 lore raw

PATCH 11/13 Always define MAX_RAW_MINORS as 65535 in userspace

In reply to Palmer Dabbelt

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

---
 drivers/char/raw.c       | 7 ++++---
 include/uapi/linux/raw.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/raw.c +4 -3
index 60316fbaf295..362d7a6511b9 100644
@@ -36,7 +36,7 @@ static struct raw_device_data *raw_devices;
 static DEFINE_MUTEX(raw_mutex);
 static const struct file_operations raw_ctl_fops; /* forward declaration */
 
-static int max_raw_minors = MAX_RAW_MINORS;
+static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
 
 module_param(max_raw_minors, int, 0);
 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,8 +317,9 @@ static int __init raw_init(void)
 
 	if (max_raw_minors < 1 || max_raw_minors > 65536) {
 		printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
-			" between 1 and 65536), using %d\n", MAX_RAW_MINORS);
-		max_raw_minors = MAX_RAW_MINORS;
+			" between 1 and 65536), using %d\n",
+		       CONFIG_MAX_RAW_MINORS);
+		max_raw_minors = CONFIG_MAX_RAW_MINORS;
 	}
 
 	raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
include/uapi/linux/raw.h +1 -1
index 62d543e70603..f0390b3e8530 100644
@@ -13,6 +13,6 @@ struct raw_config_request
 	__u64	block_minor;
 };
 
-#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
+#define MAX_RAW_MINORS 65535
 
 #endif /* __LINUX_RAW_H */
Signature · 1 line
2.4.6
#111 lore raw

PATCH 12/13 Remove AT_VECTOR_SIZE_ARCH on x86

In reply to Palmer Dabbelt

It looks like there aren't actually users of this macro anywhere:

* The kernel doesn't use it on x86 because we don't suppor ELF FDPIC.

* The only Google results point to LMKL patches, both the one that wrote this (from 2010) and my patch to hide it behind __KERNEL__.

* I grep'd through all the source tarballs on my machine, and the only packages that matched were the kernel and crui (which copied a PPC kernel header).

Since I'm not sure how to actually provide the right answer (if I understand correctly, CONFIG_IA32_EMULATION is not __i386__), the only thing I can think of to do is to just remove the definition.

---
 arch/x86/include/uapi/asm/auxvec.h | 7 -------
 1 file changed, 7 deletions(-)
arch/x86/include/uapi/asm/auxvec.h +0 -7
index 77203ac352de..1316b4c35425 100644
@@ -9,11 +9,4 @@
 #endif
 #define AT_SYSINFO_EHDR		33
 
-/* entries in ARCH_DLINFO: */
-#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
-# define AT_VECTOR_SIZE_ARCH 2
-#else /* else it's non-compat x86-64 */
-# define AT_VECTOR_SIZE_ARCH 1
-#endif
-
 #endif /* _ASM_X86_AUXVEC_H */
Signature · 1 line
2.4.6
#112 lore raw

PATCH 12/13 Remove AT_VECTOR_SIZE_ARCH on x86

In reply to Palmer Dabbelt

It looks like there aren't actually users of this macro anywhere:

* The kernel doesn't use it on x86 because we don't suppor ELF FDPIC.

* The only Google results point to LMKL patches, both the one that wrote this (from 2010) and my patch to hide it behind __KERNEL__.

* I grep'd through all the source tarballs on my machine, and the only packages that matched were the kernel and crui (which copied a PPC kernel header).

Since I'm not sure how to actually provide the right answer (if I understand correctly, CONFIG_IA32_EMULATION is not __i386__), the only thing I can think of to do is to just remove the definition.

---
 arch/x86/include/uapi/asm/auxvec.h | 7 -------
 1 file changed, 7 deletions(-)
arch/x86/include/uapi/asm/auxvec.h +0 -7
index 77203ac352de..1316b4c35425 100644
@@ -9,11 +9,4 @@
 #endif
 #define AT_SYSINFO_EHDR		33
 
-/* entries in ARCH_DLINFO: */
-#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
-# define AT_VECTOR_SIZE_ARCH 2
-#else /* else it's non-compat x86-64 */
-# define AT_VECTOR_SIZE_ARCH 1
-#endif
-
 #endif /* _ASM_X86_AUXVEC_H */
Signature · 1 line
2.4.6
#113 lore raw

PATCH 12/13 Remove AT_VECTOR_SIZE_ARCH on x86

In reply to Palmer Dabbelt

It looks like there aren't actually users of this macro anywhere:

* The kernel doesn't use it on x86 because we don't suppor ELF FDPIC.

* The only Google results point to LMKL patches, both the one that wrote this (from 2010) and my patch to hide it behind __KERNEL__.

* I grep'd through all the source tarballs on my machine, and the only packages that matched were the kernel and crui (which copied a PPC kernel header).

Since I'm not sure how to actually provide the right answer (if I understand correctly, CONFIG_IA32_EMULATION is not __i386__), the only thing I can think of to do is to just remove the definition.

---
 arch/x86/include/uapi/asm/auxvec.h | 7 -------
 1 file changed, 7 deletions(-)
arch/x86/include/uapi/asm/auxvec.h +0 -7
index 77203ac352de..1316b4c35425 100644
@@ -9,11 +9,4 @@
 #endif
 #define AT_SYSINFO_EHDR		33
 
-/* entries in ARCH_DLINFO: */
-#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
-# define AT_VECTOR_SIZE_ARCH 2
-#else /* else it's non-compat x86-64 */
-# define AT_VECTOR_SIZE_ARCH 1
-#endif
-
 #endif /* _ASM_X86_AUXVEC_H */
Signature · 1 line
2.4.6
#114 lore raw

PATCH 13/13 Re-enable and clean up "check_config()" in headers_check.pl

In reply to Palmer Dabbelt

I recently got bit by a CONFIG_ in userspace bug. This has apparently happened before, but the check got disabled for triggering too much. In order to reduce false positives, I added some hueristics to avoid detecting comments.

Since these tests all pass, I've now re-enabled them.

---
 scripts/headers_check.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
scripts/headers_check.pl +17 -2
index 62320f93e903..dd413ad9c850 100755
@@ -40,7 +40,7 @@ foreach my $file (@files) {
 		&check_asm_types();
 		&check_sizetypes();
 		&check_declarations();
-		# Dropped for now. Too much noise &check_config();
+		&check_config();
 	}
 	close $fh;
 }
@@ -76,9 +76,24 @@ sub check_declarations
 	}
 }
 
+my $check_config_in_multiline_comment = 0;
 sub check_config
 {
-	if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+	my $nocomments = $line;
+	$nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+	$nocomments =~ s/\/\/.*//;     # Remove C99-style comments (// to EOL)
+
+	# Check to see if we're within a multiline comment, and if so
+	# just remove the whole line.  I tried matching on '^ * ', but
+	# there's one header that doesn't prepend multi-line comments
+	# with * so that won't work.
+	if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+	if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+	if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+	# Check to see if there is something that looks like CONFIG_
+	# inside a userspace-accessible header file and if so, print that out.
+	if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
 		printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
 	}
 }
Signature · 1 line
2.4.6
#115 lore raw

PATCH 13/13 Re-enable and clean up "check_config()" in headers_check.pl

In reply to Palmer Dabbelt

I recently got bit by a CONFIG_ in userspace bug. This has apparently happened before, but the check got disabled for triggering too much. In order to reduce false positives, I added some hueristics to avoid detecting comments.

Since these tests all pass, I've now re-enabled them.

---
 scripts/headers_check.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
scripts/headers_check.pl +17 -2
index 62320f93e903..dd413ad9c850 100755
@@ -40,7 +40,7 @@ foreach my $file (@files) {
 		&check_asm_types();
 		&check_sizetypes();
 		&check_declarations();
-		# Dropped for now. Too much noise &check_config();
+		&check_config();
 	}
 	close $fh;
 }
@@ -76,9 +76,24 @@ sub check_declarations
 	}
 }
 
+my $check_config_in_multiline_comment = 0;
 sub check_config
 {
-	if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+	my $nocomments = $line;
+	$nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+	$nocomments =~ s/\/\/.*//;     # Remove C99-style comments (// to EOL)
+
+	# Check to see if we're within a multiline comment, and if so
+	# just remove the whole line.  I tried matching on '^ * ', but
+	# there's one header that doesn't prepend multi-line comments
+	# with * so that won't work.
+	if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+	if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+	if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+	# Check to see if there is something that looks like CONFIG_
+	# inside a userspace-accessible header file and if so, print that out.
+	if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
 		printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
 	}
 }
Signature · 1 line
2.4.6
#116 lore raw

PATCH 13/13 Re-enable and clean up "check_config()" in headers_check.pl

In reply to Palmer Dabbelt

I recently got bit by a CONFIG_ in userspace bug. This has apparently happened before, but the check got disabled for triggering too much. In order to reduce false positives, I added some hueristics to avoid detecting comments.

Since these tests all pass, I've now re-enabled them.

---
 scripts/headers_check.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
scripts/headers_check.pl +17 -2
index 62320f93e903..dd413ad9c850 100755
@@ -40,7 +40,7 @@ foreach my $file (@files) {
 		&check_asm_types();
 		&check_sizetypes();
 		&check_declarations();
-		# Dropped for now. Too much noise &check_config();
+		&check_config();
 	}
 	close $fh;
 }
@@ -76,9 +76,24 @@ sub check_declarations
 	}
 }
 
+my $check_config_in_multiline_comment = 0;
 sub check_config
 {
-	if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+	my $nocomments = $line;
+	$nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+	$nocomments =~ s/\/\/.*//;     # Remove C99-style comments (// to EOL)
+
+	# Check to see if we're within a multiline comment, and if so
+	# just remove the whole line.  I tried matching on '^ * ', but
+	# there's one header that doesn't prepend multi-line comments
+	# with * so that won't work.
+	if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+	if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+	if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+	# Check to see if there is something that looks like CONFIG_
+	# inside a userspace-accessible header file and if so, print that out.
+	if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
 		printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
 	}
 }
Signature · 1 line
2.4.6
#117 lore raw

PATCH v4 1/1 Remove #ifdef CONFIG_* from all userspace headers

In reply to Palmer Dabbelt

I think this is good to go. There are two acks, but I wasn't sure if I was supposed to collect them in the patches or not. Arnd Bergman acked #1 and #7.

Changes since v3 (<[email protected]>)

* #4 is very different: rather than defining a canonical value for MAP_UNINITIALIZED, it just punts on the problem and lets arch maintainers deal with it. There's still an #ifndef MAP_UNINITIALIZED in there, but that shouldn't get triggered by anything because the arch headers should set it to whatever they actually want.

* #11 defines MAX_RAW_MINORS to 2^20 instead of 2^16.

* #13 moves the variable around a bit so it gets initialized. I forgot I was in perl and not C :).

Changes since v2 (<[email protected]>)

* Patch set renamed.

* #2 is rewritten to use sys_ni.c instead of an #ifdef

* #3, #6, #8, #9, #10, and #11 no longer use "#ifdef __KERNEL__" but have instead moved the offending lines to the correct, kernel-only files.

* #4 has been rewritten to always define MAP_UNINITIALIZED to non-zero, rather than defining it to zero when in userspace.

* #5 got a whole lot longer -- rather than just always hiding these fields from userspace, there is now a second "struct elf_fdpic_prstatus" structure. This should allow userspace to parse core dumps correctly.

* Rebased onto 9c488de24f7264f08d341024bffdd637b4d04c96.

Changes since v1 (<[email protected]>)

* All patches but #1 were added.

#118 lore raw

PATCH 1/13 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063eff..14a5c82 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.10

A message that is not in the archive (sent off-list or not yet received): 1446579994-9937-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org

#120 lore raw

PATCH 1/13 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063eff..14a5c82 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.10
#121 lore raw

PATCH 1/13 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

In reply to a message not in the archive

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063eff..14a5c82 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.10
#122 lore raw

PATCH 2/13 Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU

In reply to a message not in the archive

I think this change actually doesn't do anything: __NR_fork was still being defined either way, and on my machine fork() in <unistd.h> comes from libc.

This just moves to the standard mechanism for defining syscalls that aren't implemented instead, which has the side-effect of no longer having an #ifdef CONFIG_* in a user-visible header.

---
 include/uapi/asm-generic/unistd.h | 4 ----
 kernel/sys_ni.c                   | 1 +
 2 files changed, 1 insertion(+), 4 deletions(-)
include/uapi/asm-generic/unistd.h +0 -4
index ee12400..ffd2957 100644
@@ -869,11 +869,7 @@ __SYSCALL(__NR_uselib, sys_uselib)
 __SYSCALL(__NR__sysctl, sys_sysctl)
 
 #define __NR_fork 1079
-#ifdef CONFIG_MMU
 __SYSCALL(__NR_fork, sys_fork)
-#else
-__SYSCALL(__NR_fork, sys_ni_syscall)
-#endif /* CONFIG_MMU */
 
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_fork+1)
kernel/sys_ni.c +1 -0
index a02decf..c830f7f 100644
@@ -174,6 +174,7 @@ cond_syscall(sys_setfsuid);
 cond_syscall(sys_setfsgid);
 cond_syscall(sys_capget);
 cond_syscall(sys_capset);
+cond_syscall(sys_fork);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
Signature · 1 line
2.4.10
#123 lore raw

PATCH 3/13 Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

In reply to a message not in the archive

This used to be behind an #ifdef COMPAT_COMPAT, so most of userspace wouldn't have seen the definition before. Unfortunately this header file became visible to userspace, so the definition has instead been moved to net/atm/svc.c (the only user).

---
 include/uapi/linux/atmdev.h | 4 ----
 net/atm/svc.c               | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
include/uapi/linux/atmdev.h +0 -4
index 93e0ec0..3dcec70 100644
@@ -100,10 +100,6 @@ struct atm_dev_stats {
 					/* use backend to make new if */
 #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
  					/* add party to p2mp call */
-#ifdef CONFIG_COMPAT
-/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
-#define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf)
-#endif
 #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)
 					/* drop party from p2mp call */
 
net/atm/svc.c +5 -0
index 3fa0a9e..9e2e6ef 100644
@@ -27,6 +27,11 @@
 #include "signaling.h"
 #include "addr.h"
 
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif
+
 static int svc_create(struct net *net, struct socket *sock, int protocol,
 		      int kern);
 
Signature · 1 line
2.4.10
#124 lore raw

PATCH 3/13 Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

In reply to a message not in the archive

This used to be behind an #ifdef COMPAT_COMPAT, so most of userspace wouldn't have seen the definition before. Unfortunately this header file became visible to userspace, so the definition has instead been moved to net/atm/svc.c (the only user).

---
 include/uapi/linux/atmdev.h | 4 ----
 net/atm/svc.c               | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
include/uapi/linux/atmdev.h +0 -4
index 93e0ec0..3dcec70 100644
@@ -100,10 +100,6 @@ struct atm_dev_stats {
 					/* use backend to make new if */
 #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
  					/* add party to p2mp call */
-#ifdef CONFIG_COMPAT
-/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
-#define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf)
-#endif
 #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)
 					/* drop party from p2mp call */
 
net/atm/svc.c +5 -0
index 3fa0a9e..9e2e6ef 100644
@@ -27,6 +27,11 @@
 #include "signaling.h"
 #include "addr.h"
 
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif
+
 static int svc_create(struct net *net, struct socket *sock, int protocol,
 		      int kern);
 
Signature · 1 line
2.4.10
#125 lore raw

PATCH 4/13 Always expose MAP_UNINITIALIZED to userspace

In reply to a message not in the archive

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I had originally hoped to avoid hiding it, it looks like this conflicts with MAP_HUGE_SHIFT so I think it's safer to just keep this 0.

Architectures that want to define this can still override it. In fact, the Xtensa port already overrides it in a very similar manner to the previously broken one (but due to lots of conflicting opinions on how to solve this correctly, I'm just taking the easy way out and letting their arch maintainers deal with it -- sorry).

---
 include/uapi/asm-generic/mman-common.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/uapi/asm-generic/mman-common.h +1 -3
index ddc3b36..0ce2a13 100644
@@ -19,9 +19,7 @@
 #define MAP_TYPE	0x0f		/* Mask for type of mapping */
 #define MAP_FIXED	0x10		/* Interpret addr exactly */
 #define MAP_ANONYMOUS	0x20		/* don't use a file */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
-# define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be uninitialized */
-#else
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
Signature · 1 line
2.4.10
#126 lore raw

PATCH 4/13 Always expose MAP_UNINITIALIZED to userspace

In reply to a message not in the archive

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I had originally hoped to avoid hiding it, it looks like this conflicts with MAP_HUGE_SHIFT so I think it's safer to just keep this 0.

Architectures that want to define this can still override it. In fact, the Xtensa port already overrides it in a very similar manner to the previously broken one (but due to lots of conflicting opinions on how to solve this correctly, I'm just taking the easy way out and letting their arch maintainers deal with it -- sorry).

---
 include/uapi/asm-generic/mman-common.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/uapi/asm-generic/mman-common.h +1 -3
index ddc3b36..0ce2a13 100644
@@ -19,9 +19,7 @@
 #define MAP_TYPE	0x0f		/* Mask for type of mapping */
 #define MAP_FIXED	0x10		/* Interpret addr exactly */
 #define MAP_ANONYMOUS	0x20		/* don't use a file */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
-# define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be uninitialized */
-#else
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
Signature · 1 line
2.4.10
#127 lore raw

PATCH 5/13 Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

In reply to a message not in the archive

This is a pretty big change that I haven't tested any, which worries me a lot. The general idea here is that "struct elf_prstatus" can be visible to userspace (from <linux/ptrace.h>)

"
Generic ptrace interface that exports the architecture specific regsets using the corresponding NT_* types (which are also used in the core dump). Please note that the NT_PRSTATUS note type in a core dump contains a full 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the other user_regset flavors, the user_regset layout and the ELF core dump note payload are exactly the same layout.
"

so it shouldn't have an "#ifdef CONFIG_" in there.

This splits the structure into two different structures, one still named "struct elf_prstatus", and one for ELF FDPIC that is named "struct elf_fdpic_prstatus" -- the idea here is that most users are standard ELF, so that's the name that didn't change.

I tried to fix all the users of "struct elf_prstatus" that should now be using "struct elf_fdpic_prstatus". The only testing I did here was to build a Blackfin defconfig with "struct elf_prstatus" not defined, and to build an x86 defconfig with "struct elf_fdpic_prstatus" not defined.

Note that this fails checkpatch.pl with a complaint about wanting open braces on the same line as struct definitions. The existing struct definitions in this file have the brace a line afterwards, so I'm going to leave this alone.

---
 fs/binfmt_elf_fdpic.c        |  6 +++---
 fs/proc/kcore.c              | 16 ++++++++++++++++
 include/linux/kexec.h        |  4 ++++
 include/uapi/linux/elfcore.h | 37 +++++++++++++++++++++++++++++++++++--
 kernel/kexec_core.c          |  4 ++++
 5 files changed, 62 insertions(+), 5 deletions(-)
fs/binfmt_elf_fdpic.c +3 -3
index d3634bf..587bf04 100644
@@ -1323,7 +1323,7 @@ static inline void fill_note(struct memelfnote *note, const char *name, int type
  * fill up all the fields in prstatus from the given task struct, except
  * registers which need to be filled up separately.
  */
-static void fill_prstatus(struct elf_prstatus *prstatus,
+static void fill_prstatus(struct elf_fdpic_prstatus *prstatus,
 			  struct task_struct *p, long signr)
 {
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1406,7 +1406,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
 struct elf_thread_status
 {
 	struct list_head list;
-	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1539,7 +1539,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
 	loff_t offset = 0, dataoff;
 	int numnote;
 	struct memelfnote *notes = NULL;
-	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
 	struct elf_prpsinfo *psinfo = NULL;	/* NT_PRPSINFO */
  	LIST_HEAD(thread_list);
  	struct list_head *t;
fs/proc/kcore.c +16 -0
index 92e6726..b1edd77e 100644
@@ -90,7 +90,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 			(*nphdr + 2)*sizeof(struct elf_phdr) + 
 			3 * ((sizeof(struct elf_note)) +
 			     roundup(sizeof(CORE_STR), 4)) +
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+			roundup(sizeof(struct elf_fdpic_prstatus), 4) +
+#else
 			roundup(sizeof(struct elf_prstatus), 4) +
+#endif
 			roundup(sizeof(struct elf_prpsinfo), 4) +
 			roundup(arch_task_struct_size, 4);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
@@ -318,7 +322,11 @@ static char *storenote(struct memelfnote *men, char *bufp)
  */
 static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
+#else
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+#endif
 	struct elf_prpsinfo prpsinfo;	/* NT_PRPSINFO */
 	struct elf_phdr *nhdr, *phdr;
 	struct elfhdr *elf;
@@ -387,10 +395,18 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	/* set up the process status */
 	notes[0].name = CORE_STR;
 	notes[0].type = NT_PRSTATUS;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	notes[0].datasz = sizeof(struct elf_fdpic_prstatus);
+#else
 	notes[0].datasz = sizeof(struct elf_prstatus);
+#endif
 	notes[0].data = &prstatus;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	memset(&prstatus, 0, sizeof(struct elf_fdpic_prstatus));
+#else
 	memset(&prstatus, 0, sizeof(struct elf_prstatus));
+#endif
 
 	nhdr->p_filesz	= notesize(&notes[0]);
 	bufp = storenote(&notes[0], bufp);
include/linux/kexec.h +4 -0
index d140b1e..d9196cc 100644
@@ -63,7 +63,11 @@
 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 #define KEXEC_CORE_NOTE_NAME "CORE"
 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_fdpic_prstatus), 4)
+#else
 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#endif
 /*
  * The per-cpu notes area is a list of notes terminated by a "NULL"
  * note header.  For kdump, the code in vmcore.c runs in the context
include/uapi/linux/elfcore.h +35 -2
index 569737c..697c52d 100644
@@ -60,7 +60,40 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+	int pr_fpvalid;		/* True if math co-processor being used.  */
+};
+
+/* Architectures that set CONFIG_BINFMT_ELF_FDPIC use this instead of
+ * "struct elf_prstatus".
+ */
+struct elf_fdpic_prstatus
+{
+#if 0
+	long	pr_flags;	/* XXX Process flags */
+	short	pr_why;		/* XXX Reason for process halt */
+	short	pr_what;	/* XXX More detailed reason */
+#endif
+	struct elf_siginfo pr_info;	/* Info associated with signal */
+	short	pr_cursig;		/* Current signal */
+	unsigned long pr_sigpend;	/* Set of pending signals */
+	unsigned long pr_sighold;	/* Set of held signals */
+#if 0
+	struct sigaltstack pr_altstack;	/* Alternate stack info */
+	struct sigaction pr_action;	/* Signal action for current sig */
+#endif
+	pid_t	pr_pid;
+	pid_t	pr_ppid;
+	pid_t	pr_pgrp;
+	pid_t	pr_sid;
+	struct timeval pr_utime;	/* User time */
+	struct timeval pr_stime;	/* System time */
+	struct timeval pr_cutime;	/* Cumulative user time */
+	struct timeval pr_cstime;	/* Cumulative system time */
+#if 0
+	long	pr_instr;		/* Current instruction */
+#endif
+	elf_gregset_t pr_reg;	/* GP registers */
+
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
@@ -69,7 +102,7 @@ struct elf_prstatus
 	 */
 	unsigned long pr_exec_fdpic_loadmap;
 	unsigned long pr_interp_fdpic_loadmap;
-#endif
+
 	int pr_fpvalid;		/* True if math co-processor being used.  */
 };
 
kernel/kexec_core.c +4 -0
index 201b453..8d2fc70 100644
@@ -977,7 +977,11 @@ static void final_note(u32 *buf)
 
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;
+#else
 	struct elf_prstatus prstatus;
+#endif
 	u32 *buf;
 
 	if ((cpu < 0) || (cpu >= nr_cpu_ids))
Signature · 1 line
2.4.10
#128 lore raw

PATCH 5/13 Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

In reply to a message not in the archive

This is a pretty big change that I haven't tested any, which worries me a lot. The general idea here is that "struct elf_prstatus" can be visible to userspace (from <linux/ptrace.h>)

"
Generic ptrace interface that exports the architecture specific regsets using the corresponding NT_* types (which are also used in the core dump). Please note that the NT_PRSTATUS note type in a core dump contains a full 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the other user_regset flavors, the user_regset layout and the ELF core dump note payload are exactly the same layout.
"

so it shouldn't have an "#ifdef CONFIG_" in there.

This splits the structure into two different structures, one still named "struct elf_prstatus", and one for ELF FDPIC that is named "struct elf_fdpic_prstatus" -- the idea here is that most users are standard ELF, so that's the name that didn't change.

I tried to fix all the users of "struct elf_prstatus" that should now be using "struct elf_fdpic_prstatus". The only testing I did here was to build a Blackfin defconfig with "struct elf_prstatus" not defined, and to build an x86 defconfig with "struct elf_fdpic_prstatus" not defined.

Note that this fails checkpatch.pl with a complaint about wanting open braces on the same line as struct definitions. The existing struct definitions in this file have the brace a line afterwards, so I'm going to leave this alone.

---
 fs/binfmt_elf_fdpic.c        |  6 +++---
 fs/proc/kcore.c              | 16 ++++++++++++++++
 include/linux/kexec.h        |  4 ++++
 include/uapi/linux/elfcore.h | 37 +++++++++++++++++++++++++++++++++++--
 kernel/kexec_core.c          |  4 ++++
 5 files changed, 62 insertions(+), 5 deletions(-)
fs/binfmt_elf_fdpic.c +3 -3
index d3634bf..587bf04 100644
@@ -1323,7 +1323,7 @@ static inline void fill_note(struct memelfnote *note, const char *name, int type
  * fill up all the fields in prstatus from the given task struct, except
  * registers which need to be filled up separately.
  */
-static void fill_prstatus(struct elf_prstatus *prstatus,
+static void fill_prstatus(struct elf_fdpic_prstatus *prstatus,
 			  struct task_struct *p, long signr)
 {
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1406,7 +1406,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
 struct elf_thread_status
 {
 	struct list_head list;
-	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1539,7 +1539,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
 	loff_t offset = 0, dataoff;
 	int numnote;
 	struct memelfnote *notes = NULL;
-	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
 	struct elf_prpsinfo *psinfo = NULL;	/* NT_PRPSINFO */
  	LIST_HEAD(thread_list);
  	struct list_head *t;
fs/proc/kcore.c +16 -0
index 92e6726..b1edd77e 100644
@@ -90,7 +90,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 			(*nphdr + 2)*sizeof(struct elf_phdr) + 
 			3 * ((sizeof(struct elf_note)) +
 			     roundup(sizeof(CORE_STR), 4)) +
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+			roundup(sizeof(struct elf_fdpic_prstatus), 4) +
+#else
 			roundup(sizeof(struct elf_prstatus), 4) +
+#endif
 			roundup(sizeof(struct elf_prpsinfo), 4) +
 			roundup(arch_task_struct_size, 4);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
@@ -318,7 +322,11 @@ static char *storenote(struct memelfnote *men, char *bufp)
  */
 static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
+#else
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+#endif
 	struct elf_prpsinfo prpsinfo;	/* NT_PRPSINFO */
 	struct elf_phdr *nhdr, *phdr;
 	struct elfhdr *elf;
@@ -387,10 +395,18 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	/* set up the process status */
 	notes[0].name = CORE_STR;
 	notes[0].type = NT_PRSTATUS;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	notes[0].datasz = sizeof(struct elf_fdpic_prstatus);
+#else
 	notes[0].datasz = sizeof(struct elf_prstatus);
+#endif
 	notes[0].data = &prstatus;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	memset(&prstatus, 0, sizeof(struct elf_fdpic_prstatus));
+#else
 	memset(&prstatus, 0, sizeof(struct elf_prstatus));
+#endif
 
 	nhdr->p_filesz	= notesize(&notes[0]);
 	bufp = storenote(&notes[0], bufp);
include/linux/kexec.h +4 -0
index d140b1e..d9196cc 100644
@@ -63,7 +63,11 @@
 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 #define KEXEC_CORE_NOTE_NAME "CORE"
 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_fdpic_prstatus), 4)
+#else
 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#endif
 /*
  * The per-cpu notes area is a list of notes terminated by a "NULL"
  * note header.  For kdump, the code in vmcore.c runs in the context
include/uapi/linux/elfcore.h +35 -2
index 569737c..697c52d 100644
@@ -60,7 +60,40 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+	int pr_fpvalid;		/* True if math co-processor being used.  */
+};
+
+/* Architectures that set CONFIG_BINFMT_ELF_FDPIC use this instead of
+ * "struct elf_prstatus".
+ */
+struct elf_fdpic_prstatus
+{
+#if 0
+	long	pr_flags;	/* XXX Process flags */
+	short	pr_why;		/* XXX Reason for process halt */
+	short	pr_what;	/* XXX More detailed reason */
+#endif
+	struct elf_siginfo pr_info;	/* Info associated with signal */
+	short	pr_cursig;		/* Current signal */
+	unsigned long pr_sigpend;	/* Set of pending signals */
+	unsigned long pr_sighold;	/* Set of held signals */
+#if 0
+	struct sigaltstack pr_altstack;	/* Alternate stack info */
+	struct sigaction pr_action;	/* Signal action for current sig */
+#endif
+	pid_t	pr_pid;
+	pid_t	pr_ppid;
+	pid_t	pr_pgrp;
+	pid_t	pr_sid;
+	struct timeval pr_utime;	/* User time */
+	struct timeval pr_stime;	/* System time */
+	struct timeval pr_cutime;	/* Cumulative user time */
+	struct timeval pr_cstime;	/* Cumulative system time */
+#if 0
+	long	pr_instr;		/* Current instruction */
+#endif
+	elf_gregset_t pr_reg;	/* GP registers */
+
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
@@ -69,7 +102,7 @@ struct elf_prstatus
 	 */
 	unsigned long pr_exec_fdpic_loadmap;
 	unsigned long pr_interp_fdpic_loadmap;
-#endif
+
 	int pr_fpvalid;		/* True if math co-processor being used.  */
 };
 
kernel/kexec_core.c +4 -0
index 201b453..8d2fc70 100644
@@ -977,7 +977,11 @@ static void final_note(u32 *buf)
 
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;
+#else
 	struct elf_prstatus prstatus;
+#endif
 	u32 *buf;
 
 	if ((cpu < 0) || (cpu >= nr_cpu_ids))
Signature · 1 line
2.4.10
#129 lore raw

PATCH 6/13 Move ep_take_care_of_epollwakeup() to fs/eventpoll.c

In reply to a message not in the archive

This doesn't make any sense to expose to userspace, so it's been moved to the one user. This was introduced by commit 95f19f658ce1 ("epoll:
drop EPOLLWAKEUP if PM_SLEEP is disabled").

---
 fs/eventpoll.c                 | 13 +++++++++++++
 include/uapi/linux/eventpoll.h | 12 ------------
 2 files changed, 13 insertions(+), 12 deletions(-)
fs/eventpoll.c +13 -0
index 1e009ca..aadee3d 100644
@@ -1812,6 +1812,19 @@ SYSCALL_DEFINE1(epoll_create, int, size)
 	return sys_epoll_create1(0);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
+		epev->events &= ~EPOLLWAKEUP;
+}
+#else
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	epev->events &= ~EPOLLWAKEUP;
+}
+#endif
+
 /*
  * The following function implements the controller interface for
  * the eventpoll file that enables the insertion/removal/change of
include/uapi/linux/eventpoll.h +0 -12
index bc81fb2..7850373 100644
@@ -61,16 +61,4 @@ struct epoll_event {
 	__u64 data;
 } EPOLL_PACKED;
 
-#ifdef CONFIG_PM_SLEEP
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
-		epev->events &= ~EPOLLWAKEUP;
-}
-#else
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	epev->events &= ~EPOLLWAKEUP;
-}
-#endif
 #endif /* _UAPI_LINUX_EVENTPOLL_H */
Signature · 1 line
2.4.10
#130 lore raw

PATCH 6/13 Move ep_take_care_of_epollwakeup() to fs/eventpoll.c

In reply to a message not in the archive

This doesn't make any sense to expose to userspace, so it's been moved to the one user. This was introduced by commit 95f19f658ce1 ("epoll:
drop EPOLLWAKEUP if PM_SLEEP is disabled").

---
 fs/eventpoll.c                 | 13 +++++++++++++
 include/uapi/linux/eventpoll.h | 12 ------------
 2 files changed, 13 insertions(+), 12 deletions(-)
fs/eventpoll.c +13 -0
index 1e009ca..aadee3d 100644
@@ -1812,6 +1812,19 @@ SYSCALL_DEFINE1(epoll_create, int, size)
 	return sys_epoll_create1(0);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
+		epev->events &= ~EPOLLWAKEUP;
+}
+#else
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	epev->events &= ~EPOLLWAKEUP;
+}
+#endif
+
 /*
  * The following function implements the controller interface for
  * the eventpoll file that enables the insertion/removal/change of
include/uapi/linux/eventpoll.h +0 -12
index bc81fb2..7850373 100644
@@ -61,16 +61,4 @@ struct epoll_event {
 	__u64 data;
 } EPOLL_PACKED;
 
-#ifdef CONFIG_PM_SLEEP
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
-		epev->events &= ~EPOLLWAKEUP;
-}
-#else
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	epev->events &= ~EPOLLWAKEUP;
-}
-#endif
 #endif /* _UAPI_LINUX_EVENTPOLL_H */
Signature · 1 line
2.4.10
#131 lore raw

PATCH 7/13 Make FB_BACKLIGHT_{LEVELS,MAX} always visible

In reply to a message not in the archive

Nothing else in the kernel defines this, and this header is visible to userspace. Rather than hiding it in an #ifdef, I think it's sane to just make this visible to userspace.

---
 include/uapi/linux/fb.h | 3 ---
 1 file changed, 3 deletions(-)
include/uapi/linux/fb.h +0 -3
index fb795c3..8926f13 100644
@@ -392,11 +392,8 @@ struct fb_cursor {
 	struct fb_image	image;	/* Cursor image */
 };
 
-#ifdef CONFIG_FB_BACKLIGHT
 /* Settings for the generic backlight code */
 #define FB_BACKLIGHT_LEVELS	128
 #define FB_BACKLIGHT_MAX	0xFF
-#endif
-
 
 #endif /* _UAPI_LINUX_FB_H */
Signature · 1 line
2.4.10
#132 lore raw

PATCH 7/13 Make FB_BACKLIGHT_{LEVELS,MAX} always visible

In reply to a message not in the archive

Nothing else in the kernel defines this, and this header is visible to userspace. Rather than hiding it in an #ifdef, I think it's sane to just make this visible to userspace.

---
 include/uapi/linux/fb.h | 3 ---
 1 file changed, 3 deletions(-)
include/uapi/linux/fb.h +0 -3
index fb795c3..8926f13 100644
@@ -392,11 +392,8 @@ struct fb_cursor {
 	struct fb_image	image;	/* Cursor image */
 };
 
-#ifdef CONFIG_FB_BACKLIGHT
 /* Settings for the generic backlight code */
 #define FB_BACKLIGHT_LEVELS	128
 #define FB_BACKLIGHT_MAX	0xFF
-#endif
-
 
 #endif /* _UAPI_LINUX_FB_H */
Signature · 1 line
2.4.10
#133 lore raw

PATCH 8/13 Move MAX_SHARED_LIBS to fs/binfmt_flat.c

In reply to a message not in the archive

I'm not sure what this is, but it doesn't feel like something that should be exposed to userspace here. I'm assuming this file was exposed for the structure in it, which doesn't depend on MAX_SHARED_LIBS.

---
 fs/binfmt_flat.c          | 6 ++++++
 include/uapi/linux/flat.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/binfmt_flat.c +6 -0
index f723cd3..e89fb43 100644
@@ -72,6 +72,12 @@
 #define RELOC_FAILED 0xff00ff01		/* Relocation incorrect somewhere */
 #define UNLOADED_LIB 0x7ff000ff		/* Placeholder for unused library */
 
+#ifdef CONFIG_BINFMT_SHARED_FLAT
+#define	MAX_SHARED_LIBS			(4)
+#else
+#define	MAX_SHARED_LIBS			(1)
+#endif
+
 struct lib_info {
 	struct {
 		unsigned long start_code;		/* Start of text segment */
include/uapi/linux/flat.h +0 -6
index 88cd6ba..1b177c7 100644
@@ -13,12 +13,6 @@
 
 #define	FLAT_VERSION			0x00000004L
 
-#ifdef CONFIG_BINFMT_SHARED_FLAT
-#define	MAX_SHARED_LIBS			(4)
-#else
-#define	MAX_SHARED_LIBS			(1)
-#endif
-
 /*
  * To make everything easier to port and manage cross platform
  * development,  all fields are in network byte order.
Signature · 1 line
2.4.10
#134 lore raw

PATCH 8/13 Move MAX_SHARED_LIBS to fs/binfmt_flat.c

In reply to a message not in the archive

I'm not sure what this is, but it doesn't feel like something that should be exposed to userspace here. I'm assuming this file was exposed for the structure in it, which doesn't depend on MAX_SHARED_LIBS.

---
 fs/binfmt_flat.c          | 6 ++++++
 include/uapi/linux/flat.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/binfmt_flat.c +6 -0
index f723cd3..e89fb43 100644
@@ -72,6 +72,12 @@
 #define RELOC_FAILED 0xff00ff01		/* Relocation incorrect somewhere */
 #define UNLOADED_LIB 0x7ff000ff		/* Placeholder for unused library */
 
+#ifdef CONFIG_BINFMT_SHARED_FLAT
+#define	MAX_SHARED_LIBS			(4)
+#else
+#define	MAX_SHARED_LIBS			(1)
+#endif
+
 struct lib_info {
 	struct {
 		unsigned long start_code;		/* Start of text segment */
include/uapi/linux/flat.h +0 -6
index 88cd6ba..1b177c7 100644
@@ -13,12 +13,6 @@
 
 #define	FLAT_VERSION			0x00000004L
 
-#ifdef CONFIG_BINFMT_SHARED_FLAT
-#define	MAX_SHARED_LIBS			(4)
-#else
-#define	MAX_SHARED_LIBS			(1)
-#endif
-
 /*
  * To make everything easier to port and manage cross platform
  * development,  all fields are in network byte order.
Signature · 1 line
2.4.10
#135 lore raw

PATCH 9/13 Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to a message not in the archive

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -10
index b04000a..7a6a5a7 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};
-
 #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
kernel/events/hw_breakpoint.c +10 -0
index 92ce5f4..5ad117e 100644
@@ -58,6 +58,16 @@ struct bp_cpuinfo {
 	unsigned int	flexible; /* XXX: placeholder, see fetch_this_slot() */
 };
 
+enum bp_type_idx {
+	TYPE_INST	= 0,
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
+	TYPE_DATA	= 0,
+#else
+	TYPE_DATA	= 1,
+#endif
+	TYPE_MAX
+};
+
 static DEFINE_PER_CPU(struct bp_cpuinfo, bp_cpuinfo[TYPE_MAX]);
 static int nr_slots[TYPE_MAX];
 
Signature · 1 line
2.4.10
#136 lore raw

PATCH 9/13 Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to a message not in the archive

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -10
index b04000a..7a6a5a7 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};
-
 #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
kernel/events/hw_breakpoint.c +10 -0
index 92ce5f4..5ad117e 100644
@@ -58,6 +58,16 @@ struct bp_cpuinfo {
 	unsigned int	flexible; /* XXX: placeholder, see fetch_this_slot() */
 };
 
+enum bp_type_idx {
+	TYPE_INST	= 0,
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
+	TYPE_DATA	= 0,
+#else
+	TYPE_DATA	= 1,
+#endif
+	TYPE_MAX
+};
+
 static DEFINE_PER_CPU(struct bp_cpuinfo, bp_cpuinfo[TYPE_MAX]);
 static int nr_slots[TYPE_MAX];
 
Signature · 1 line
2.4.10
#137 lore raw

PATCH 10/13 Move USE_WCACHING to drivers/block/pktcdvd.c

In reply to a message not in the archive

I don't think this was ever intended to be exposed to userspace, but it did require an "#ifdef CONFIG_*". Since the name is kind of generic and was only used in one place, I've moved the definition to the one user.

---
 drivers/block/pktcdvd.c      | 11 +++++++++++
 include/uapi/linux/pktcdvd.h | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/block/pktcdvd.c +11 -0
index 7be2375..18d2d05 100644
@@ -90,6 +90,17 @@ do {									\
 
 #define MAX_SPEED 0xffff
 
+/*
+ * use drive write caching -- we need deferred error handling to be
+ * able to successfully recover with this option (drive will return good
+ * status as soon as the cdb is validated).
+ */
+#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
+#define USE_WCACHING		1
+#else
+#define USE_WCACHING		0
+#endif
+
 static DEFINE_MUTEX(pktcdvd_mutex);
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
include/uapi/linux/pktcdvd.h +0 -11
index 2640b9d..05c2bee 100644
@@ -29,17 +29,6 @@
 #define PACKET_WAIT_TIME	(HZ * 5 / 1000)
 
 /*
- * use drive write caching -- we need deferred error handling to be
- * able to successfully recover with this option (drive will return good
- * status as soon as the cdb is validated).
- */
-#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
-#define USE_WCACHING		1
-#else
-#define USE_WCACHING		0
-#endif
-
-/*
  * No user-servicable parts beyond this point ->
  */
 
Signature · 1 line
2.4.10
#138 lore raw

PATCH 10/13 Move USE_WCACHING to drivers/block/pktcdvd.c

In reply to a message not in the archive

I don't think this was ever intended to be exposed to userspace, but it did require an "#ifdef CONFIG_*". Since the name is kind of generic and was only used in one place, I've moved the definition to the one user.

---
 drivers/block/pktcdvd.c      | 11 +++++++++++
 include/uapi/linux/pktcdvd.h | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/block/pktcdvd.c +11 -0
index 7be2375..18d2d05 100644
@@ -90,6 +90,17 @@ do {									\
 
 #define MAX_SPEED 0xffff
 
+/*
+ * use drive write caching -- we need deferred error handling to be
+ * able to successfully recover with this option (drive will return good
+ * status as soon as the cdb is validated).
+ */
+#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
+#define USE_WCACHING		1
+#else
+#define USE_WCACHING		0
+#endif
+
 static DEFINE_MUTEX(pktcdvd_mutex);
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
include/uapi/linux/pktcdvd.h +0 -11
index 2640b9d..05c2bee 100644
@@ -29,17 +29,6 @@
 #define PACKET_WAIT_TIME	(HZ * 5 / 1000)
 
 /*
- * use drive write caching -- we need deferred error handling to be
- * able to successfully recover with this option (drive will return good
- * status as soon as the cdb is validated).
- */
-#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
-#define USE_WCACHING		1
-#else
-#define USE_WCACHING		0
-#endif
-
-/*
  * No user-servicable parts beyond this point ->
  */
 
Signature · 1 line
2.4.10
#139 lore raw

PATCH 11/13 Always define MAX_RAW_MINORS as 2**20 in userspace

In reply to a message not in the archive

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

---
 drivers/char/raw.c       | 7 ++++---
 include/uapi/linux/raw.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/raw.c +4 -3
index 60316fb..362d7a6 100644
@@ -36,7 +36,7 @@ static struct raw_device_data *raw_devices;
 static DEFINE_MUTEX(raw_mutex);
 static const struct file_operations raw_ctl_fops; /* forward declaration */
 
-static int max_raw_minors = MAX_RAW_MINORS;
+static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
 
 module_param(max_raw_minors, int, 0);
 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,8 +317,9 @@ static int __init raw_init(void)
 
 	if (max_raw_minors < 1 || max_raw_minors > 65536) {
 		printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
-			" between 1 and 65536), using %d\n", MAX_RAW_MINORS);
-		max_raw_minors = MAX_RAW_MINORS;
+			" between 1 and 65536), using %d\n",
+		       CONFIG_MAX_RAW_MINORS);
+		max_raw_minors = CONFIG_MAX_RAW_MINORS;
 	}
 
 	raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
include/uapi/linux/raw.h +1 -1
index 62d543e..f3d009b 100644
@@ -13,6 +13,6 @@ struct raw_config_request
 	__u64	block_minor;
 };
 
-#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
+#define MAX_RAW_MINORS (1 << 20)
 
 #endif /* __LINUX_RAW_H */
Signature · 1 line
2.4.10
#140 lore raw

PATCH 11/13 Always define MAX_RAW_MINORS as 2**20 in userspace

In reply to a message not in the archive

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

---
 drivers/char/raw.c       | 7 ++++---
 include/uapi/linux/raw.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/raw.c +4 -3
index 60316fb..362d7a6 100644
@@ -36,7 +36,7 @@ static struct raw_device_data *raw_devices;
 static DEFINE_MUTEX(raw_mutex);
 static const struct file_operations raw_ctl_fops; /* forward declaration */
 
-static int max_raw_minors = MAX_RAW_MINORS;
+static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
 
 module_param(max_raw_minors, int, 0);
 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,8 +317,9 @@ static int __init raw_init(void)
 
 	if (max_raw_minors < 1 || max_raw_minors > 65536) {
 		printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
-			" between 1 and 65536), using %d\n", MAX_RAW_MINORS);
-		max_raw_minors = MAX_RAW_MINORS;
+			" between 1 and 65536), using %d\n",
+		       CONFIG_MAX_RAW_MINORS);
+		max_raw_minors = CONFIG_MAX_RAW_MINORS;
 	}
 
 	raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
include/uapi/linux/raw.h +1 -1
index 62d543e..f3d009b 100644
@@ -13,6 +13,6 @@ struct raw_config_request
 	__u64	block_minor;
 };
 
-#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
+#define MAX_RAW_MINORS (1 << 20)
 
 #endif /* __LINUX_RAW_H */
Signature · 1 line
2.4.10
#141 lore raw

PATCH 12/13 Remove AT_VECTOR_SIZE_ARCH on x86

In reply to a message not in the archive

It looks like there aren't actually users of this macro anywhere:

* The kernel doesn't use it on x86 because we don't suppor ELF FDPIC.

* The only Google results point to LMKL patches, both the one that wrote this (from 2010) and my patch to hide it behind __KERNEL__.

* I grep'd through all the source tarballs on my machine, and the only packages that matched were the kernel and crui (which copied a PPC kernel header).

Since I'm not sure how to actually provide the right answer (if I understand correctly, CONFIG_IA32_EMULATION is not __i386__), the only thing I can think of to do is to just remove the definition.

---
 arch/x86/include/uapi/asm/auxvec.h | 7 -------
 1 file changed, 7 deletions(-)
arch/x86/include/uapi/asm/auxvec.h +0 -7
index 77203ac..1316b4c 100644
@@ -9,11 +9,4 @@
 #endif
 #define AT_SYSINFO_EHDR		33
 
-/* entries in ARCH_DLINFO: */
-#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
-# define AT_VECTOR_SIZE_ARCH 2
-#else /* else it's non-compat x86-64 */
-# define AT_VECTOR_SIZE_ARCH 1
-#endif
-
 #endif /* _ASM_X86_AUXVEC_H */
Signature · 1 line
2.4.10
#142 lore raw

PATCH 12/13 Remove AT_VECTOR_SIZE_ARCH on x86

In reply to a message not in the archive

It looks like there aren't actually users of this macro anywhere:

* The kernel doesn't use it on x86 because we don't suppor ELF FDPIC.

* The only Google results point to LMKL patches, both the one that wrote this (from 2010) and my patch to hide it behind __KERNEL__.

* I grep'd through all the source tarballs on my machine, and the only packages that matched were the kernel and crui (which copied a PPC kernel header).

Since I'm not sure how to actually provide the right answer (if I understand correctly, CONFIG_IA32_EMULATION is not __i386__), the only thing I can think of to do is to just remove the definition.

---
 arch/x86/include/uapi/asm/auxvec.h | 7 -------
 1 file changed, 7 deletions(-)
arch/x86/include/uapi/asm/auxvec.h +0 -7
index 77203ac..1316b4c 100644
@@ -9,11 +9,4 @@
 #endif
 #define AT_SYSINFO_EHDR		33
 
-/* entries in ARCH_DLINFO: */
-#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
-# define AT_VECTOR_SIZE_ARCH 2
-#else /* else it's non-compat x86-64 */
-# define AT_VECTOR_SIZE_ARCH 1
-#endif
-
 #endif /* _ASM_X86_AUXVEC_H */
Signature · 1 line
2.4.10
#143 lore raw

PATCH 13/13 Re-enable and clean up "check_config()" in headers_check.pl

In reply to a message not in the archive

I recently got bit by a CONFIG_ in userspace bug. This has apparently happened before, but the check got disabled for triggering too much. In order to reduce false positives, I added some hueristics to avoid detecting comments.

Since these tests all pass, I've now re-enabled them.

---
 scripts/headers_check.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
scripts/headers_check.pl +17 -2
index 62320f9..1634b51 100755
@@ -27,6 +27,7 @@ my $ret = 0;
 my $line;
 my $lineno = 0;
 my $filename;
+my $check_config_in_multiline_comment = 0;
 
 foreach my $file (@files) {
 	$filename = $file;
@@ -40,7 +41,7 @@ foreach my $file (@files) {
 		&check_asm_types();
 		&check_sizetypes();
 		&check_declarations();
-		# Dropped for now. Too much noise &check_config();
+		&check_config();
 	}
 	close $fh;
 }
@@ -78,7 +79,21 @@ sub check_declarations
 
 sub check_config
 {
-	if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+	my $nocomments = $line;
+	$nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+	$nocomments =~ s/\/\/.*//;     # Remove C99-style comments (// to EOL)
+
+	# Check to see if we're within a multiline comment, and if so
+	# just remove the whole line.  I tried matching on '^ * ', but
+	# there's one header that doesn't prepend multi-line comments
+	# with * so that won't work.
+	if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+	if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+	if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+	# Check to see if there is something that looks like CONFIG_
+	# inside a userspace-accessible header file and if so, print that out.
+	if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
 		printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
 	}
 }
Signature · 1 line
2.4.10
#144 lore raw

PATCH 13/13 Re-enable and clean up "check_config()" in headers_check.pl

In reply to a message not in the archive

I recently got bit by a CONFIG_ in userspace bug. This has apparently happened before, but the check got disabled for triggering too much. In order to reduce false positives, I added some hueristics to avoid detecting comments.

Since these tests all pass, I've now re-enabled them.

---
 scripts/headers_check.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
scripts/headers_check.pl +17 -2
index 62320f9..1634b51 100755
@@ -27,6 +27,7 @@ my $ret = 0;
 my $line;
 my $lineno = 0;
 my $filename;
+my $check_config_in_multiline_comment = 0;
 
 foreach my $file (@files) {
 	$filename = $file;
@@ -40,7 +41,7 @@ foreach my $file (@files) {
 		&check_asm_types();
 		&check_sizetypes();
 		&check_declarations();
-		# Dropped for now. Too much noise &check_config();
+		&check_config();
 	}
 	close $fh;
 }
@@ -78,7 +79,21 @@ sub check_declarations
 
 sub check_config
 {
-	if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+	my $nocomments = $line;
+	$nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+	$nocomments =~ s/\/\/.*//;     # Remove C99-style comments (// to EOL)
+
+	# Check to see if we're within a multiline comment, and if so
+	# just remove the whole line.  I tried matching on '^ * ', but
+	# there's one header that doesn't prepend multi-line comments
+	# with * so that won't work.
+	if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+	if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+	if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+	# Check to see if there is something that looks like CONFIG_
+	# inside a userspace-accessible header file and if so, print that out.
+	if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
 		printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
 	}
 }
Signature · 1 line
2.4.10
#145 lore raw

PATCH v5 1/1 Remove #ifdef CONFIG_* from all userspace headers

In reply to a message not in the archive

I think this should _actually_ be ready to go this time, the buildbot found some errors in arches that I didn't test for.

Changes since v4 (<1446579994-9937-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>)

* #9 was changed to work on arm by moving the enum to an in-kernel header file.

* #13 was added, this fixes a problem on blackfin.

Changes since v3 (<1442271047-4908-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>)

* #4 is very different: rather than defining a canonical value for MAP_UNINITIALIZED, it just punts on the problem and lets arch maintainers deal with it. There's still an #ifndef MAP_UNINITIALIZED in there, but that shouldn't get triggered by anything because the arch headers should set it to whatever they actually want.

* #11 defines MAX_RAW_MINORS to 2^20 instead of 2^16.

* #13 moves the variable around a bit so it gets initialized. I forgot I was in perl and not C :).

Changes since v2 (<1441832902-28993-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>)

* Patch set renamed.

* #2 is rewritten to use sys_ni.c instead of an #ifdef

* #3, #6, #8, #9, #10, and #11 no longer use "#ifdef __KERNEL__" but have instead moved the offending lines to the correct, kernel-only files.

* #4 has been rewritten to always define MAP_UNINITIALIZED to non-zero, rather than defining it to zero when in userspace.

* #5 got a whole lot longer -- rather than just always hiding these fields from userspace, there is now a second "struct elf_fdpic_prstatus" structure. This should allow userspace to parse core dumps correctly.

* Rebased onto 9c488de24f7264f08d341024bffdd637b4d04c96.

Changes since v1 (<1441152610-22566-1-git-send-email-palmer-96lFi9zoCfxBDgjK7y7TUQ@public.gmane.org>)

* All patches but #1 were added.

#146 lore raw

PATCH 1/13 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

In reply to Palmer Dabbelt

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063eff..14a5c82 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.10
#147 lore raw

PATCH 1/13 Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h

In reply to Palmer Dabbelt

When working on the RISC-V port I noticed that F_SETLK64 was being defined on our 64-bit platform, despite our port being so new that we've only ever had the 64-bit file ops. Since there's not compat layer for these, this causes fcntl to bail out.

It turns out that one of the ways in with F_SETLK64 was being defined (there's some more in glibc, but that's a whole different story... :)) is the result of CONFIG_64BIT showing up in this user-visible header. <asm-generic/bitsperlong.h> confirms this isn't sane, so I replaced it with a __BITS_PER_LONG check.

---
 include/uapi/asm-generic/fcntl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/asm-generic/fcntl.h +2 -1
index e063eff..14a5c82 100644
@@ -1,6 +1,7 @@
 #ifndef _ASM_GENERIC_FCNTL_H
 #define _ASM_GENERIC_FCNTL_H
 
+#include <asm/bitsperlong.h>
 #include <linux/types.h>
 
 /*
@@ -115,7 +116,7 @@
 #define F_GETSIG	11	/* for sockets. */
 #endif
 
-#ifndef CONFIG_64BIT
+#if (__BITS_PER_LONG == 32)
 #ifndef F_GETLK64
 #define F_GETLK64	12	/*  using 'struct flock64' */
 #define F_SETLK64	13
Signature · 1 line
2.4.10
#148 lore raw

PATCH 2/13 Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU

In reply to Palmer Dabbelt

I think this change actually doesn't do anything: __NR_fork was still being defined either way, and on my machine fork() in <unistd.h> comes from libc.

This just moves to the standard mechanism for defining syscalls that aren't implemented instead, which has the side-effect of no longer having an #ifdef CONFIG_* in a user-visible header.

---
 include/uapi/asm-generic/unistd.h | 4 ----
 kernel/sys_ni.c                   | 1 +
 2 files changed, 1 insertion(+), 4 deletions(-)
include/uapi/asm-generic/unistd.h +0 -4
index ee12400..ffd2957 100644
@@ -869,11 +869,7 @@ __SYSCALL(__NR_uselib, sys_uselib)
 __SYSCALL(__NR__sysctl, sys_sysctl)
 
 #define __NR_fork 1079
-#ifdef CONFIG_MMU
 __SYSCALL(__NR_fork, sys_fork)
-#else
-__SYSCALL(__NR_fork, sys_ni_syscall)
-#endif /* CONFIG_MMU */
 
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_fork+1)
kernel/sys_ni.c +1 -0
index a02decf..c830f7f 100644
@@ -174,6 +174,7 @@ cond_syscall(sys_setfsuid);
 cond_syscall(sys_setfsgid);
 cond_syscall(sys_capget);
 cond_syscall(sys_capset);
+cond_syscall(sys_fork);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
Signature · 1 line
2.4.10
#149 lore raw

PATCH 2/13 Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU

In reply to Palmer Dabbelt

I think this change actually doesn't do anything: __NR_fork was still being defined either way, and on my machine fork() in <unistd.h> comes from libc.

This just moves to the standard mechanism for defining syscalls that aren't implemented instead, which has the side-effect of no longer having an #ifdef CONFIG_* in a user-visible header.

---
 include/uapi/asm-generic/unistd.h | 4 ----
 kernel/sys_ni.c                   | 1 +
 2 files changed, 1 insertion(+), 4 deletions(-)
include/uapi/asm-generic/unistd.h +0 -4
index ee12400..ffd2957 100644
@@ -869,11 +869,7 @@ __SYSCALL(__NR_uselib, sys_uselib)
 __SYSCALL(__NR__sysctl, sys_sysctl)
 
 #define __NR_fork 1079
-#ifdef CONFIG_MMU
 __SYSCALL(__NR_fork, sys_fork)
-#else
-__SYSCALL(__NR_fork, sys_ni_syscall)
-#endif /* CONFIG_MMU */
 
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_fork+1)
kernel/sys_ni.c +1 -0
index a02decf..c830f7f 100644
@@ -174,6 +174,7 @@ cond_syscall(sys_setfsuid);
 cond_syscall(sys_setfsgid);
 cond_syscall(sys_capget);
 cond_syscall(sys_capset);
+cond_syscall(sys_fork);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
Signature · 1 line
2.4.10
#150 lore raw

PATCH 2/13 Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU

In reply to Palmer Dabbelt

I think this change actually doesn't do anything: __NR_fork was still being defined either way, and on my machine fork() in <unistd.h> comes from libc.

This just moves to the standard mechanism for defining syscalls that aren't implemented instead, which has the side-effect of no longer having an #ifdef CONFIG_* in a user-visible header.

---
 include/uapi/asm-generic/unistd.h | 4 ----
 kernel/sys_ni.c                   | 1 +
 2 files changed, 1 insertion(+), 4 deletions(-)
include/uapi/asm-generic/unistd.h +0 -4
index ee12400..ffd2957 100644
@@ -869,11 +869,7 @@ __SYSCALL(__NR_uselib, sys_uselib)
 __SYSCALL(__NR__sysctl, sys_sysctl)
 
 #define __NR_fork 1079
-#ifdef CONFIG_MMU
 __SYSCALL(__NR_fork, sys_fork)
-#else
-__SYSCALL(__NR_fork, sys_ni_syscall)
-#endif /* CONFIG_MMU */
 
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_fork+1)
kernel/sys_ni.c +1 -0
index a02decf..c830f7f 100644
@@ -174,6 +174,7 @@ cond_syscall(sys_setfsuid);
 cond_syscall(sys_setfsgid);
 cond_syscall(sys_capget);
 cond_syscall(sys_capset);
+cond_syscall(sys_fork);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
Signature · 1 line
2.4.10
#151 lore raw

PATCH 2/13 Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU

In reply to Palmer Dabbelt

I think this change actually doesn't do anything: __NR_fork was still being defined either way, and on my machine fork() in <unistd.h> comes from libc.

This just moves to the standard mechanism for defining syscalls that aren't implemented instead, which has the side-effect of no longer having an #ifdef CONFIG_* in a user-visible header.

---
 include/uapi/asm-generic/unistd.h | 4 ----
 kernel/sys_ni.c                   | 1 +
 2 files changed, 1 insertion(+), 4 deletions(-)
include/uapi/asm-generic/unistd.h +0 -4
index ee12400..ffd2957 100644
@@ -869,11 +869,7 @@ __SYSCALL(__NR_uselib, sys_uselib)
 __SYSCALL(__NR__sysctl, sys_sysctl)
 
 #define __NR_fork 1079
-#ifdef CONFIG_MMU
 __SYSCALL(__NR_fork, sys_fork)
-#else
-__SYSCALL(__NR_fork, sys_ni_syscall)
-#endif /* CONFIG_MMU */
 
 #undef __NR_syscalls
 #define __NR_syscalls (__NR_fork+1)
kernel/sys_ni.c +1 -0
index a02decf..c830f7f 100644
@@ -174,6 +174,7 @@ cond_syscall(sys_setfsuid);
 cond_syscall(sys_setfsgid);
 cond_syscall(sys_capget);
 cond_syscall(sys_capset);
+cond_syscall(sys_fork);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
Signature · 1 line
2.4.10
#152 lore raw

PATCH 3/13 Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

In reply to Palmer Dabbelt

This used to be behind an #ifdef COMPAT_COMPAT, so most of userspace wouldn't have seen the definition before. Unfortunately this header file became visible to userspace, so the definition has instead been moved to net/atm/svc.c (the only user).

---
 include/uapi/linux/atmdev.h | 4 ----
 net/atm/svc.c               | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
include/uapi/linux/atmdev.h +0 -4
index 93e0ec0..3dcec70 100644
@@ -100,10 +100,6 @@ struct atm_dev_stats {
 					/* use backend to make new if */
 #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
  					/* add party to p2mp call */
-#ifdef CONFIG_COMPAT
-/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
-#define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf)
-#endif
 #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)
 					/* drop party from p2mp call */
 
net/atm/svc.c +5 -0
index 3fa0a9e..9e2e6ef 100644
@@ -27,6 +27,11 @@
 #include "signaling.h"
 #include "addr.h"
 
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif
+
 static int svc_create(struct net *net, struct socket *sock, int protocol,
 		      int kern);
 
Signature · 1 line
2.4.10
#153 lore raw

PATCH 3/13 Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

In reply to Palmer Dabbelt

This used to be behind an #ifdef COMPAT_COMPAT, so most of userspace wouldn't have seen the definition before. Unfortunately this header file became visible to userspace, so the definition has instead been moved to net/atm/svc.c (the only user).

---
 include/uapi/linux/atmdev.h | 4 ----
 net/atm/svc.c               | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
include/uapi/linux/atmdev.h +0 -4
index 93e0ec0..3dcec70 100644
@@ -100,10 +100,6 @@ struct atm_dev_stats {
 					/* use backend to make new if */
 #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
  					/* add party to p2mp call */
-#ifdef CONFIG_COMPAT
-/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
-#define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf)
-#endif
 #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)
 					/* drop party from p2mp call */
 
net/atm/svc.c +5 -0
index 3fa0a9e..9e2e6ef 100644
@@ -27,6 +27,11 @@
 #include "signaling.h"
 #include "addr.h"
 
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif
+
 static int svc_create(struct net *net, struct socket *sock, int protocol,
 		      int kern);
 
Signature · 1 line
2.4.10
#154 lore raw

PATCH 3/13 Move COMPAT_ATM_ADDPARTY to net/atm/svc.c

In reply to Palmer Dabbelt

This used to be behind an #ifdef COMPAT_COMPAT, so most of userspace wouldn't have seen the definition before. Unfortunately this header file became visible to userspace, so the definition has instead been moved to net/atm/svc.c (the only user).

---
 include/uapi/linux/atmdev.h | 4 ----
 net/atm/svc.c               | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)
include/uapi/linux/atmdev.h +0 -4
index 93e0ec0..3dcec70 100644
@@ -100,10 +100,6 @@ struct atm_dev_stats {
 					/* use backend to make new if */
 #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)
  					/* add party to p2mp call */
-#ifdef CONFIG_COMPAT
-/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
-#define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf)
-#endif
 #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)
 					/* drop party from p2mp call */
 
net/atm/svc.c +5 -0
index 3fa0a9e..9e2e6ef 100644
@@ -27,6 +27,11 @@
 #include "signaling.h"
 #include "addr.h"
 
+#ifdef CONFIG_COMPAT
+/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */
+#define COMPAT_ATM_ADDPARTY _IOW('a', ATMIOC_SPECIAL+4, struct compat_atm_iobuf)
+#endif
+
 static int svc_create(struct net *net, struct socket *sock, int protocol,
 		      int kern);
 
Signature · 1 line
2.4.10
#155 lore raw

PATCH 4/13 Always expose MAP_UNINITIALIZED to userspace

In reply to Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I had originally hoped to avoid hiding it, it looks like this conflicts with MAP_HUGE_SHIFT so I think it's safer to just keep this 0.

Architectures that want to define this can still override it. In fact, the Xtensa port already overrides it in a very similar manner to the previously broken one (but due to lots of conflicting opinions on how to solve this correctly, I'm just taking the easy way out and letting their arch maintainers deal with it -- sorry).

---
 include/uapi/asm-generic/mman-common.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/uapi/asm-generic/mman-common.h +1 -3
index ddc3b36..0ce2a13 100644
@@ -19,9 +19,7 @@
 #define MAP_TYPE	0x0f		/* Mask for type of mapping */
 #define MAP_FIXED	0x10		/* Interpret addr exactly */
 #define MAP_ANONYMOUS	0x20		/* don't use a file */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
-# define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be uninitialized */
-#else
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
Signature · 1 line
2.4.10
#156 lore raw

PATCH 4/13 Always expose MAP_UNINITIALIZED to userspace

In reply to Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I had originally hoped to avoid hiding it, it looks like this conflicts with MAP_HUGE_SHIFT so I think it's safer to just keep this 0.

Architectures that want to define this can still override it. In fact, the Xtensa port already overrides it in a very similar manner to the previously broken one (but due to lots of conflicting opinions on how to solve this correctly, I'm just taking the easy way out and letting their arch maintainers deal with it -- sorry).

---
 include/uapi/asm-generic/mman-common.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/uapi/asm-generic/mman-common.h +1 -3
index ddc3b36..0ce2a13 100644
@@ -19,9 +19,7 @@
 #define MAP_TYPE	0x0f		/* Mask for type of mapping */
 #define MAP_FIXED	0x10		/* Interpret addr exactly */
 #define MAP_ANONYMOUS	0x20		/* don't use a file */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
-# define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be uninitialized */
-#else
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
Signature · 1 line
2.4.10
#157 lore raw

PATCH 4/13 Always expose MAP_UNINITIALIZED to userspace

In reply to Palmer Dabbelt

This used to be hidden behind CONFIG_MMAP_ALLOW_UNINITIALIZED, so userspace wouldn't actually ever see it be non-zero. While I had originally hoped to avoid hiding it, it looks like this conflicts with MAP_HUGE_SHIFT so I think it's safer to just keep this 0.

Architectures that want to define this can still override it. In fact, the Xtensa port already overrides it in a very similar manner to the previously broken one (but due to lots of conflicting opinions on how to solve this correctly, I'm just taking the easy way out and letting their arch maintainers deal with it -- sorry).

---
 include/uapi/asm-generic/mman-common.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/uapi/asm-generic/mman-common.h +1 -3
index ddc3b36..0ce2a13 100644
@@ -19,9 +19,7 @@
 #define MAP_TYPE	0x0f		/* Mask for type of mapping */
 #define MAP_FIXED	0x10		/* Interpret addr exactly */
 #define MAP_ANONYMOUS	0x20		/* don't use a file */
-#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
-# define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be uninitialized */
-#else
+#ifndef MAP_UNINITIALIZED
 # define MAP_UNINITIALIZED 0x0		/* Don't support this flag */
 #endif
 
Signature · 1 line
2.4.10
#158 lore raw

PATCH 5/13 Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

In reply to Palmer Dabbelt

This is a pretty big change that I haven't tested any, which worries me a lot. The general idea here is that "struct elf_prstatus" can be visible to userspace (from <linux/ptrace.h>)

"
Generic ptrace interface that exports the architecture specific regsets using the corresponding NT_* types (which are also used in the core dump). Please note that the NT_PRSTATUS note type in a core dump contains a full 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the other user_regset flavors, the user_regset layout and the ELF core dump note payload are exactly the same layout.
"

so it shouldn't have an "#ifdef CONFIG_" in there.

This splits the structure into two different structures, one still named "struct elf_prstatus", and one for ELF FDPIC that is named "struct elf_fdpic_prstatus" -- the idea here is that most users are standard ELF, so that's the name that didn't change.

I tried to fix all the users of "struct elf_prstatus" that should now be using "struct elf_fdpic_prstatus". The only testing I did here was to build a Blackfin defconfig with "struct elf_prstatus" not defined, and to build an x86 defconfig with "struct elf_fdpic_prstatus" not defined.

Note that this fails checkpatch.pl with a complaint about wanting open braces on the same line as struct definitions. The existing struct definitions in this file have the brace a line afterwards, so I'm going to leave this alone.

---
 fs/binfmt_elf_fdpic.c        |  6 +++---
 fs/proc/kcore.c              | 16 ++++++++++++++++
 include/linux/kexec.h        |  4 ++++
 include/uapi/linux/elfcore.h | 37 +++++++++++++++++++++++++++++++++++--
 kernel/kexec_core.c          |  4 ++++
 5 files changed, 62 insertions(+), 5 deletions(-)
fs/binfmt_elf_fdpic.c +3 -3
index d3634bf..587bf04 100644
@@ -1323,7 +1323,7 @@ static inline void fill_note(struct memelfnote *note, const char *name, int type
  * fill up all the fields in prstatus from the given task struct, except
  * registers which need to be filled up separately.
  */
-static void fill_prstatus(struct elf_prstatus *prstatus,
+static void fill_prstatus(struct elf_fdpic_prstatus *prstatus,
 			  struct task_struct *p, long signr)
 {
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1406,7 +1406,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
 struct elf_thread_status
 {
 	struct list_head list;
-	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1539,7 +1539,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
 	loff_t offset = 0, dataoff;
 	int numnote;
 	struct memelfnote *notes = NULL;
-	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
 	struct elf_prpsinfo *psinfo = NULL;	/* NT_PRPSINFO */
  	LIST_HEAD(thread_list);
  	struct list_head *t;
fs/proc/kcore.c +16 -0
index 92e6726..b1edd77e 100644
@@ -90,7 +90,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 			(*nphdr + 2)*sizeof(struct elf_phdr) + 
 			3 * ((sizeof(struct elf_note)) +
 			     roundup(sizeof(CORE_STR), 4)) +
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+			roundup(sizeof(struct elf_fdpic_prstatus), 4) +
+#else
 			roundup(sizeof(struct elf_prstatus), 4) +
+#endif
 			roundup(sizeof(struct elf_prpsinfo), 4) +
 			roundup(arch_task_struct_size, 4);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
@@ -318,7 +322,11 @@ static char *storenote(struct memelfnote *men, char *bufp)
  */
 static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
+#else
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+#endif
 	struct elf_prpsinfo prpsinfo;	/* NT_PRPSINFO */
 	struct elf_phdr *nhdr, *phdr;
 	struct elfhdr *elf;
@@ -387,10 +395,18 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	/* set up the process status */
 	notes[0].name = CORE_STR;
 	notes[0].type = NT_PRSTATUS;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	notes[0].datasz = sizeof(struct elf_fdpic_prstatus);
+#else
 	notes[0].datasz = sizeof(struct elf_prstatus);
+#endif
 	notes[0].data = &prstatus;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	memset(&prstatus, 0, sizeof(struct elf_fdpic_prstatus));
+#else
 	memset(&prstatus, 0, sizeof(struct elf_prstatus));
+#endif
 
 	nhdr->p_filesz	= notesize(&notes[0]);
 	bufp = storenote(&notes[0], bufp);
include/linux/kexec.h +4 -0
index d140b1e..d9196cc 100644
@@ -63,7 +63,11 @@
 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 #define KEXEC_CORE_NOTE_NAME "CORE"
 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_fdpic_prstatus), 4)
+#else
 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#endif
 /*
  * The per-cpu notes area is a list of notes terminated by a "NULL"
  * note header.  For kdump, the code in vmcore.c runs in the context
include/uapi/linux/elfcore.h +35 -2
index 569737c..697c52d 100644
@@ -60,7 +60,40 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+	int pr_fpvalid;		/* True if math co-processor being used.  */
+};
+
+/* Architectures that set CONFIG_BINFMT_ELF_FDPIC use this instead of
+ * "struct elf_prstatus".
+ */
+struct elf_fdpic_prstatus
+{
+#if 0
+	long	pr_flags;	/* XXX Process flags */
+	short	pr_why;		/* XXX Reason for process halt */
+	short	pr_what;	/* XXX More detailed reason */
+#endif
+	struct elf_siginfo pr_info;	/* Info associated with signal */
+	short	pr_cursig;		/* Current signal */
+	unsigned long pr_sigpend;	/* Set of pending signals */
+	unsigned long pr_sighold;	/* Set of held signals */
+#if 0
+	struct sigaltstack pr_altstack;	/* Alternate stack info */
+	struct sigaction pr_action;	/* Signal action for current sig */
+#endif
+	pid_t	pr_pid;
+	pid_t	pr_ppid;
+	pid_t	pr_pgrp;
+	pid_t	pr_sid;
+	struct timeval pr_utime;	/* User time */
+	struct timeval pr_stime;	/* System time */
+	struct timeval pr_cutime;	/* Cumulative user time */
+	struct timeval pr_cstime;	/* Cumulative system time */
+#if 0
+	long	pr_instr;		/* Current instruction */
+#endif
+	elf_gregset_t pr_reg;	/* GP registers */
+
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
@@ -69,7 +102,7 @@ struct elf_prstatus
 	 */
 	unsigned long pr_exec_fdpic_loadmap;
 	unsigned long pr_interp_fdpic_loadmap;
-#endif
+
 	int pr_fpvalid;		/* True if math co-processor being used.  */
 };
 
kernel/kexec_core.c +4 -0
index 201b453..8d2fc70 100644
@@ -977,7 +977,11 @@ static void final_note(u32 *buf)
 
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;
+#else
 	struct elf_prstatus prstatus;
+#endif
 	u32 *buf;
 
 	if ((cpu < 0) || (cpu >= nr_cpu_ids))
Signature · 1 line
2.4.10
#159 lore raw

PATCH 5/13 Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

In reply to Palmer Dabbelt

This is a pretty big change that I haven't tested any, which worries me a lot. The general idea here is that "struct elf_prstatus" can be visible to userspace (from <linux/ptrace.h>)

"
Generic ptrace interface that exports the architecture specific regsets using the corresponding NT_* types (which are also used in the core dump). Please note that the NT_PRSTATUS note type in a core dump contains a full 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the other user_regset flavors, the user_regset layout and the ELF core dump note payload are exactly the same layout.
"

so it shouldn't have an "#ifdef CONFIG_" in there.

This splits the structure into two different structures, one still named "struct elf_prstatus", and one for ELF FDPIC that is named "struct elf_fdpic_prstatus" -- the idea here is that most users are standard ELF, so that's the name that didn't change.

I tried to fix all the users of "struct elf_prstatus" that should now be using "struct elf_fdpic_prstatus". The only testing I did here was to build a Blackfin defconfig with "struct elf_prstatus" not defined, and to build an x86 defconfig with "struct elf_fdpic_prstatus" not defined.

Note that this fails checkpatch.pl with a complaint about wanting open braces on the same line as struct definitions. The existing struct definitions in this file have the brace a line afterwards, so I'm going to leave this alone.

---
 fs/binfmt_elf_fdpic.c        |  6 +++---
 fs/proc/kcore.c              | 16 ++++++++++++++++
 include/linux/kexec.h        |  4 ++++
 include/uapi/linux/elfcore.h | 37 +++++++++++++++++++++++++++++++++++--
 kernel/kexec_core.c          |  4 ++++
 5 files changed, 62 insertions(+), 5 deletions(-)
fs/binfmt_elf_fdpic.c +3 -3
index d3634bf..587bf04 100644
@@ -1323,7 +1323,7 @@ static inline void fill_note(struct memelfnote *note, const char *name, int type
  * fill up all the fields in prstatus from the given task struct, except
  * registers which need to be filled up separately.
  */
-static void fill_prstatus(struct elf_prstatus *prstatus,
+static void fill_prstatus(struct elf_fdpic_prstatus *prstatus,
 			  struct task_struct *p, long signr)
 {
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1406,7 +1406,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
 struct elf_thread_status
 {
 	struct list_head list;
-	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1539,7 +1539,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
 	loff_t offset = 0, dataoff;
 	int numnote;
 	struct memelfnote *notes = NULL;
-	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
 	struct elf_prpsinfo *psinfo = NULL;	/* NT_PRPSINFO */
  	LIST_HEAD(thread_list);
  	struct list_head *t;
fs/proc/kcore.c +16 -0
index 92e6726..b1edd77e 100644
@@ -90,7 +90,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 			(*nphdr + 2)*sizeof(struct elf_phdr) + 
 			3 * ((sizeof(struct elf_note)) +
 			     roundup(sizeof(CORE_STR), 4)) +
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+			roundup(sizeof(struct elf_fdpic_prstatus), 4) +
+#else
 			roundup(sizeof(struct elf_prstatus), 4) +
+#endif
 			roundup(sizeof(struct elf_prpsinfo), 4) +
 			roundup(arch_task_struct_size, 4);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
@@ -318,7 +322,11 @@ static char *storenote(struct memelfnote *men, char *bufp)
  */
 static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
+#else
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+#endif
 	struct elf_prpsinfo prpsinfo;	/* NT_PRPSINFO */
 	struct elf_phdr *nhdr, *phdr;
 	struct elfhdr *elf;
@@ -387,10 +395,18 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	/* set up the process status */
 	notes[0].name = CORE_STR;
 	notes[0].type = NT_PRSTATUS;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	notes[0].datasz = sizeof(struct elf_fdpic_prstatus);
+#else
 	notes[0].datasz = sizeof(struct elf_prstatus);
+#endif
 	notes[0].data = &prstatus;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	memset(&prstatus, 0, sizeof(struct elf_fdpic_prstatus));
+#else
 	memset(&prstatus, 0, sizeof(struct elf_prstatus));
+#endif
 
 	nhdr->p_filesz	= notesize(&notes[0]);
 	bufp = storenote(&notes[0], bufp);
include/linux/kexec.h +4 -0
index d140b1e..d9196cc 100644
@@ -63,7 +63,11 @@
 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 #define KEXEC_CORE_NOTE_NAME "CORE"
 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_fdpic_prstatus), 4)
+#else
 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#endif
 /*
  * The per-cpu notes area is a list of notes terminated by a "NULL"
  * note header.  For kdump, the code in vmcore.c runs in the context
include/uapi/linux/elfcore.h +35 -2
index 569737c..697c52d 100644
@@ -60,7 +60,40 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+	int pr_fpvalid;		/* True if math co-processor being used.  */
+};
+
+/* Architectures that set CONFIG_BINFMT_ELF_FDPIC use this instead of
+ * "struct elf_prstatus".
+ */
+struct elf_fdpic_prstatus
+{
+#if 0
+	long	pr_flags;	/* XXX Process flags */
+	short	pr_why;		/* XXX Reason for process halt */
+	short	pr_what;	/* XXX More detailed reason */
+#endif
+	struct elf_siginfo pr_info;	/* Info associated with signal */
+	short	pr_cursig;		/* Current signal */
+	unsigned long pr_sigpend;	/* Set of pending signals */
+	unsigned long pr_sighold;	/* Set of held signals */
+#if 0
+	struct sigaltstack pr_altstack;	/* Alternate stack info */
+	struct sigaction pr_action;	/* Signal action for current sig */
+#endif
+	pid_t	pr_pid;
+	pid_t	pr_ppid;
+	pid_t	pr_pgrp;
+	pid_t	pr_sid;
+	struct timeval pr_utime;	/* User time */
+	struct timeval pr_stime;	/* System time */
+	struct timeval pr_cutime;	/* Cumulative user time */
+	struct timeval pr_cstime;	/* Cumulative system time */
+#if 0
+	long	pr_instr;		/* Current instruction */
+#endif
+	elf_gregset_t pr_reg;	/* GP registers */
+
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
@@ -69,7 +102,7 @@ struct elf_prstatus
 	 */
 	unsigned long pr_exec_fdpic_loadmap;
 	unsigned long pr_interp_fdpic_loadmap;
-#endif
+
 	int pr_fpvalid;		/* True if math co-processor being used.  */
 };
 
kernel/kexec_core.c +4 -0
index 201b453..8d2fc70 100644
@@ -977,7 +977,11 @@ static void final_note(u32 *buf)
 
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;
+#else
 	struct elf_prstatus prstatus;
+#endif
 	u32 *buf;
 
 	if ((cpu < 0) || (cpu >= nr_cpu_ids))
Signature · 1 line
2.4.10
#160 lore raw

PATCH 5/13 Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

In reply to Palmer Dabbelt

This is a pretty big change that I haven't tested any, which worries me a lot. The general idea here is that "struct elf_prstatus" can be visible to userspace (from <linux/ptrace.h>)

"
Generic ptrace interface that exports the architecture specific regsets using the corresponding NT_* types (which are also used in the core dump). Please note that the NT_PRSTATUS note type in a core dump contains a full 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the other user_regset flavors, the user_regset layout and the ELF core dump note payload are exactly the same layout.
"

so it shouldn't have an "#ifdef CONFIG_" in there.

This splits the structure into two different structures, one still named "struct elf_prstatus", and one for ELF FDPIC that is named "struct elf_fdpic_prstatus" -- the idea here is that most users are standard ELF, so that's the name that didn't change.

I tried to fix all the users of "struct elf_prstatus" that should now be using "struct elf_fdpic_prstatus". The only testing I did here was to build a Blackfin defconfig with "struct elf_prstatus" not defined, and to build an x86 defconfig with "struct elf_fdpic_prstatus" not defined.

Note that this fails checkpatch.pl with a complaint about wanting open braces on the same line as struct definitions. The existing struct definitions in this file have the brace a line afterwards, so I'm going to leave this alone.

---
 fs/binfmt_elf_fdpic.c        |  6 +++---
 fs/proc/kcore.c              | 16 ++++++++++++++++
 include/linux/kexec.h        |  4 ++++
 include/uapi/linux/elfcore.h | 37 +++++++++++++++++++++++++++++++++++--
 kernel/kexec_core.c          |  4 ++++
 5 files changed, 62 insertions(+), 5 deletions(-)
fs/binfmt_elf_fdpic.c +3 -3
index d3634bf..587bf04 100644
@@ -1323,7 +1323,7 @@ static inline void fill_note(struct memelfnote *note, const char *name, int type
  * fill up all the fields in prstatus from the given task struct, except
  * registers which need to be filled up separately.
  */
-static void fill_prstatus(struct elf_prstatus *prstatus,
+static void fill_prstatus(struct elf_fdpic_prstatus *prstatus,
 			  struct task_struct *p, long signr)
 {
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1406,7 +1406,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
 struct elf_thread_status
 {
 	struct list_head list;
-	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1539,7 +1539,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
 	loff_t offset = 0, dataoff;
 	int numnote;
 	struct memelfnote *notes = NULL;
-	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
 	struct elf_prpsinfo *psinfo = NULL;	/* NT_PRPSINFO */
  	LIST_HEAD(thread_list);
  	struct list_head *t;
fs/proc/kcore.c +16 -0
index 92e6726..b1edd77e 100644
@@ -90,7 +90,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 			(*nphdr + 2)*sizeof(struct elf_phdr) + 
 			3 * ((sizeof(struct elf_note)) +
 			     roundup(sizeof(CORE_STR), 4)) +
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+			roundup(sizeof(struct elf_fdpic_prstatus), 4) +
+#else
 			roundup(sizeof(struct elf_prstatus), 4) +
+#endif
 			roundup(sizeof(struct elf_prpsinfo), 4) +
 			roundup(arch_task_struct_size, 4);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
@@ -318,7 +322,11 @@ static char *storenote(struct memelfnote *men, char *bufp)
  */
 static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
+#else
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+#endif
 	struct elf_prpsinfo prpsinfo;	/* NT_PRPSINFO */
 	struct elf_phdr *nhdr, *phdr;
 	struct elfhdr *elf;
@@ -387,10 +395,18 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	/* set up the process status */
 	notes[0].name = CORE_STR;
 	notes[0].type = NT_PRSTATUS;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	notes[0].datasz = sizeof(struct elf_fdpic_prstatus);
+#else
 	notes[0].datasz = sizeof(struct elf_prstatus);
+#endif
 	notes[0].data = &prstatus;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	memset(&prstatus, 0, sizeof(struct elf_fdpic_prstatus));
+#else
 	memset(&prstatus, 0, sizeof(struct elf_prstatus));
+#endif
 
 	nhdr->p_filesz	= notesize(&notes[0]);
 	bufp = storenote(&notes[0], bufp);
include/linux/kexec.h +4 -0
index d140b1e..d9196cc 100644
@@ -63,7 +63,11 @@
 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 #define KEXEC_CORE_NOTE_NAME "CORE"
 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_fdpic_prstatus), 4)
+#else
 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#endif
 /*
  * The per-cpu notes area is a list of notes terminated by a "NULL"
  * note header.  For kdump, the code in vmcore.c runs in the context
include/uapi/linux/elfcore.h +35 -2
index 569737c..697c52d 100644
@@ -60,7 +60,40 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+	int pr_fpvalid;		/* True if math co-processor being used.  */
+};
+
+/* Architectures that set CONFIG_BINFMT_ELF_FDPIC use this instead of
+ * "struct elf_prstatus".
+ */
+struct elf_fdpic_prstatus
+{
+#if 0
+	long	pr_flags;	/* XXX Process flags */
+	short	pr_why;		/* XXX Reason for process halt */
+	short	pr_what;	/* XXX More detailed reason */
+#endif
+	struct elf_siginfo pr_info;	/* Info associated with signal */
+	short	pr_cursig;		/* Current signal */
+	unsigned long pr_sigpend;	/* Set of pending signals */
+	unsigned long pr_sighold;	/* Set of held signals */
+#if 0
+	struct sigaltstack pr_altstack;	/* Alternate stack info */
+	struct sigaction pr_action;	/* Signal action for current sig */
+#endif
+	pid_t	pr_pid;
+	pid_t	pr_ppid;
+	pid_t	pr_pgrp;
+	pid_t	pr_sid;
+	struct timeval pr_utime;	/* User time */
+	struct timeval pr_stime;	/* System time */
+	struct timeval pr_cutime;	/* Cumulative user time */
+	struct timeval pr_cstime;	/* Cumulative system time */
+#if 0
+	long	pr_instr;		/* Current instruction */
+#endif
+	elf_gregset_t pr_reg;	/* GP registers */
+
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
@@ -69,7 +102,7 @@ struct elf_prstatus
 	 */
 	unsigned long pr_exec_fdpic_loadmap;
 	unsigned long pr_interp_fdpic_loadmap;
-#endif
+
 	int pr_fpvalid;		/* True if math co-processor being used.  */
 };
 
kernel/kexec_core.c +4 -0
index 201b453..8d2fc70 100644
@@ -977,7 +977,11 @@ static void final_note(u32 *buf)
 
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;
+#else
 	struct elf_prstatus prstatus;
+#endif
 	u32 *buf;
 
 	if ((cpu < 0) || (cpu >= nr_cpu_ids))
Signature · 1 line
2.4.10
#161 lore raw

PATCH 6/13 Move ep_take_care_of_epollwakeup() to fs/eventpoll.c

In reply to Palmer Dabbelt

This doesn't make any sense to expose to userspace, so it's been moved to the one user. This was introduced by commit 95f19f658ce1 ("epoll:
drop EPOLLWAKEUP if PM_SLEEP is disabled").

---
 fs/eventpoll.c                 | 13 +++++++++++++
 include/uapi/linux/eventpoll.h | 12 ------------
 2 files changed, 13 insertions(+), 12 deletions(-)
fs/eventpoll.c +13 -0
index 1e009ca..aadee3d 100644
@@ -1812,6 +1812,19 @@ SYSCALL_DEFINE1(epoll_create, int, size)
 	return sys_epoll_create1(0);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
+		epev->events &= ~EPOLLWAKEUP;
+}
+#else
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	epev->events &= ~EPOLLWAKEUP;
+}
+#endif
+
 /*
  * The following function implements the controller interface for
  * the eventpoll file that enables the insertion/removal/change of
include/uapi/linux/eventpoll.h +0 -12
index bc81fb2..7850373 100644
@@ -61,16 +61,4 @@ struct epoll_event {
 	__u64 data;
 } EPOLL_PACKED;
 
-#ifdef CONFIG_PM_SLEEP
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
-		epev->events &= ~EPOLLWAKEUP;
-}
-#else
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	epev->events &= ~EPOLLWAKEUP;
-}
-#endif
 #endif /* _UAPI_LINUX_EVENTPOLL_H */
Signature · 1 line
2.4.10
#162 lore raw

PATCH 6/13 Move ep_take_care_of_epollwakeup() to fs/eventpoll.c

In reply to Palmer Dabbelt

This doesn't make any sense to expose to userspace, so it's been moved to the one user. This was introduced by commit 95f19f658ce1 ("epoll:
drop EPOLLWAKEUP if PM_SLEEP is disabled").

---
 fs/eventpoll.c                 | 13 +++++++++++++
 include/uapi/linux/eventpoll.h | 12 ------------
 2 files changed, 13 insertions(+), 12 deletions(-)
fs/eventpoll.c +13 -0
index 1e009ca..aadee3d 100644
@@ -1812,6 +1812,19 @@ SYSCALL_DEFINE1(epoll_create, int, size)
 	return sys_epoll_create1(0);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
+		epev->events &= ~EPOLLWAKEUP;
+}
+#else
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	epev->events &= ~EPOLLWAKEUP;
+}
+#endif
+
 /*
  * The following function implements the controller interface for
  * the eventpoll file that enables the insertion/removal/change of
include/uapi/linux/eventpoll.h +0 -12
index bc81fb2..7850373 100644
@@ -61,16 +61,4 @@ struct epoll_event {
 	__u64 data;
 } EPOLL_PACKED;
 
-#ifdef CONFIG_PM_SLEEP
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
-		epev->events &= ~EPOLLWAKEUP;
-}
-#else
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	epev->events &= ~EPOLLWAKEUP;
-}
-#endif
 #endif /* _UAPI_LINUX_EVENTPOLL_H */
Signature · 1 line
2.4.10
#163 lore raw

PATCH 6/13 Move ep_take_care_of_epollwakeup() to fs/eventpoll.c

In reply to Palmer Dabbelt

This doesn't make any sense to expose to userspace, so it's been moved to the one user. This was introduced by commit 95f19f658ce1 ("epoll:
drop EPOLLWAKEUP if PM_SLEEP is disabled").

---
 fs/eventpoll.c                 | 13 +++++++++++++
 include/uapi/linux/eventpoll.h | 12 ------------
 2 files changed, 13 insertions(+), 12 deletions(-)
fs/eventpoll.c +13 -0
index 1e009ca..aadee3d 100644
@@ -1812,6 +1812,19 @@ SYSCALL_DEFINE1(epoll_create, int, size)
 	return sys_epoll_create1(0);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
+		epev->events &= ~EPOLLWAKEUP;
+}
+#else
+static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
+{
+	epev->events &= ~EPOLLWAKEUP;
+}
+#endif
+
 /*
  * The following function implements the controller interface for
  * the eventpoll file that enables the insertion/removal/change of
include/uapi/linux/eventpoll.h +0 -12
index bc81fb2..7850373 100644
@@ -61,16 +61,4 @@ struct epoll_event {
 	__u64 data;
 } EPOLL_PACKED;
 
-#ifdef CONFIG_PM_SLEEP
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
-		epev->events &= ~EPOLLWAKEUP;
-}
-#else
-static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
-{
-	epev->events &= ~EPOLLWAKEUP;
-}
-#endif
 #endif /* _UAPI_LINUX_EVENTPOLL_H */
Signature · 1 line
2.4.10
#164 lore raw

PATCH 7/13 Make FB_BACKLIGHT_{LEVELS,MAX} always visible

In reply to Palmer Dabbelt

Nothing else in the kernel defines this, and this header is visible to userspace. Rather than hiding it in an #ifdef, I think it's sane to just make this visible to userspace.

---
 include/uapi/linux/fb.h | 3 ---
 1 file changed, 3 deletions(-)
include/uapi/linux/fb.h +0 -3
index fb795c3..8926f13 100644
@@ -392,11 +392,8 @@ struct fb_cursor {
 	struct fb_image	image;	/* Cursor image */
 };
 
-#ifdef CONFIG_FB_BACKLIGHT
 /* Settings for the generic backlight code */
 #define FB_BACKLIGHT_LEVELS	128
 #define FB_BACKLIGHT_MAX	0xFF
-#endif
-
 
 #endif /* _UAPI_LINUX_FB_H */
Signature · 1 line
2.4.10
#165 lore raw

PATCH 7/13 Make FB_BACKLIGHT_{LEVELS,MAX} always visible

In reply to Palmer Dabbelt

Nothing else in the kernel defines this, and this header is visible to userspace. Rather than hiding it in an #ifdef, I think it's sane to just make this visible to userspace.

---
 include/uapi/linux/fb.h | 3 ---
 1 file changed, 3 deletions(-)
include/uapi/linux/fb.h +0 -3
index fb795c3..8926f13 100644
@@ -392,11 +392,8 @@ struct fb_cursor {
 	struct fb_image	image;	/* Cursor image */
 };
 
-#ifdef CONFIG_FB_BACKLIGHT
 /* Settings for the generic backlight code */
 #define FB_BACKLIGHT_LEVELS	128
 #define FB_BACKLIGHT_MAX	0xFF
-#endif
-
 
 #endif /* _UAPI_LINUX_FB_H */
Signature · 1 line
2.4.10
#166 lore raw

PATCH 7/13 Make FB_BACKLIGHT_{LEVELS,MAX} always visible

In reply to Palmer Dabbelt

Nothing else in the kernel defines this, and this header is visible to userspace. Rather than hiding it in an #ifdef, I think it's sane to just make this visible to userspace.

---
 include/uapi/linux/fb.h | 3 ---
 1 file changed, 3 deletions(-)
include/uapi/linux/fb.h +0 -3
index fb795c3..8926f13 100644
@@ -392,11 +392,8 @@ struct fb_cursor {
 	struct fb_image	image;	/* Cursor image */
 };
 
-#ifdef CONFIG_FB_BACKLIGHT
 /* Settings for the generic backlight code */
 #define FB_BACKLIGHT_LEVELS	128
 #define FB_BACKLIGHT_MAX	0xFF
-#endif
-
 
 #endif /* _UAPI_LINUX_FB_H */
Signature · 1 line
2.4.10
#167 lore raw

PATCH 8/13 Move MAX_SHARED_LIBS to fs/binfmt_flat.c

In reply to Palmer Dabbelt

I'm not sure what this is, but it doesn't feel like something that should be exposed to userspace here. I'm assuming this file was exposed for the structure in it, which doesn't depend on MAX_SHARED_LIBS.

---
 fs/binfmt_flat.c          | 6 ++++++
 include/uapi/linux/flat.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/binfmt_flat.c +6 -0
index f723cd3..e89fb43 100644
@@ -72,6 +72,12 @@
 #define RELOC_FAILED 0xff00ff01		/* Relocation incorrect somewhere */
 #define UNLOADED_LIB 0x7ff000ff		/* Placeholder for unused library */
 
+#ifdef CONFIG_BINFMT_SHARED_FLAT
+#define	MAX_SHARED_LIBS			(4)
+#else
+#define	MAX_SHARED_LIBS			(1)
+#endif
+
 struct lib_info {
 	struct {
 		unsigned long start_code;		/* Start of text segment */
include/uapi/linux/flat.h +0 -6
index 88cd6ba..1b177c7 100644
@@ -13,12 +13,6 @@
 
 #define	FLAT_VERSION			0x00000004L
 
-#ifdef CONFIG_BINFMT_SHARED_FLAT
-#define	MAX_SHARED_LIBS			(4)
-#else
-#define	MAX_SHARED_LIBS			(1)
-#endif
-
 /*
  * To make everything easier to port and manage cross platform
  * development,  all fields are in network byte order.
Signature · 1 line
2.4.10
#168 lore raw

PATCH 8/13 Move MAX_SHARED_LIBS to fs/binfmt_flat.c

In reply to Palmer Dabbelt

I'm not sure what this is, but it doesn't feel like something that should be exposed to userspace here. I'm assuming this file was exposed for the structure in it, which doesn't depend on MAX_SHARED_LIBS.

---
 fs/binfmt_flat.c          | 6 ++++++
 include/uapi/linux/flat.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/binfmt_flat.c +6 -0
index f723cd3..e89fb43 100644
@@ -72,6 +72,12 @@
 #define RELOC_FAILED 0xff00ff01		/* Relocation incorrect somewhere */
 #define UNLOADED_LIB 0x7ff000ff		/* Placeholder for unused library */
 
+#ifdef CONFIG_BINFMT_SHARED_FLAT
+#define	MAX_SHARED_LIBS			(4)
+#else
+#define	MAX_SHARED_LIBS			(1)
+#endif
+
 struct lib_info {
 	struct {
 		unsigned long start_code;		/* Start of text segment */
include/uapi/linux/flat.h +0 -6
index 88cd6ba..1b177c7 100644
@@ -13,12 +13,6 @@
 
 #define	FLAT_VERSION			0x00000004L
 
-#ifdef CONFIG_BINFMT_SHARED_FLAT
-#define	MAX_SHARED_LIBS			(4)
-#else
-#define	MAX_SHARED_LIBS			(1)
-#endif
-
 /*
  * To make everything easier to port and manage cross platform
  * development,  all fields are in network byte order.
Signature · 1 line
2.4.10
#169 lore raw

PATCH 8/13 Move MAX_SHARED_LIBS to fs/binfmt_flat.c

In reply to Palmer Dabbelt

I'm not sure what this is, but it doesn't feel like something that should be exposed to userspace here. I'm assuming this file was exposed for the structure in it, which doesn't depend on MAX_SHARED_LIBS.

---
 fs/binfmt_flat.c          | 6 ++++++
 include/uapi/linux/flat.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
fs/binfmt_flat.c +6 -0
index f723cd3..e89fb43 100644
@@ -72,6 +72,12 @@
 #define RELOC_FAILED 0xff00ff01		/* Relocation incorrect somewhere */
 #define UNLOADED_LIB 0x7ff000ff		/* Placeholder for unused library */
 
+#ifdef CONFIG_BINFMT_SHARED_FLAT
+#define	MAX_SHARED_LIBS			(4)
+#else
+#define	MAX_SHARED_LIBS			(1)
+#endif
+
 struct lib_info {
 	struct {
 		unsigned long start_code;		/* Start of text segment */
include/uapi/linux/flat.h +0 -6
index 88cd6ba..1b177c7 100644
@@ -13,12 +13,6 @@
 
 #define	FLAT_VERSION			0x00000004L
 
-#ifdef CONFIG_BINFMT_SHARED_FLAT
-#define	MAX_SHARED_LIBS			(4)
-#else
-#define	MAX_SHARED_LIBS			(1)
-#endif
-
 /*
  * To make everything easier to port and manage cross platform
  * development,  all fields are in network byte order.
Signature · 1 line
2.4.10
#170 lore raw

PATCH 9/13 Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -10
index b04000a..7a6a5a7 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};
-
 #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
kernel/events/hw_breakpoint.c +10 -0
index 92ce5f4..5ad117e 100644
@@ -58,6 +58,16 @@ struct bp_cpuinfo {
 	unsigned int	flexible; /* XXX: placeholder, see fetch_this_slot() */
 };
 
+enum bp_type_idx {
+	TYPE_INST	= 0,
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
+	TYPE_DATA	= 0,
+#else
+	TYPE_DATA	= 1,
+#endif
+	TYPE_MAX
+};
+
 static DEFINE_PER_CPU(struct bp_cpuinfo, bp_cpuinfo[TYPE_MAX]);
 static int nr_slots[TYPE_MAX];
 
Signature · 1 line
2.4.10
#171 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi Palmer,

[auto build test ERROR on v4.3-rc7]
[also ERROR on: next-20151103]

url:    https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/Remove-ifdef-CONFIG_64BIT-from-all-asm-generic-fcntl-h/20151104-035501
base:   https://github.com/0day-ci/linux Palmer-Dabbelt/Remove-ifdef-CONFIG_64BIT-from-all-asm-generic-fcntl-h/20151104-035501
config: powerpc-defconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc

All errors (new ones prefixed by >>):

arch/powerpc/kernel/hw_breakpoint.c: In function 'hw_breakpoint_slots':

>> arch/powerpc/kernel/hw_breakpoint.c:49:14: error: 'TYPE_DATA' undeclared (first use in this function)
     if (type == TYPE_DATA)
                 ^

arch/powerpc/kernel/hw_breakpoint.c:49:14: note: each undeclared identifier is reported only once for each function it appears in

vim +/TYPE_DATA +49 arch/powerpc/kernel/hw_breakpoint.c

5aae8a53 K.Prasad       2010-06-15  43  
5aae8a53 K.Prasad       2010-06-15  44  /*
d09ec738 Paul Mackerras 2010-06-29  45   * Returns total number of data or instruction breakpoints available.
d09ec738 Paul Mackerras 2010-06-29  46   */
d09ec738 Paul Mackerras 2010-06-29  47  int hw_breakpoint_slots(int type)
d09ec738 Paul Mackerras 2010-06-29  48  {
d09ec738 Paul Mackerras 2010-06-29 @49  	if (type == TYPE_DATA)
d09ec738 Paul Mackerras 2010-06-29  50  		return HBP_NUM;
d09ec738 Paul Mackerras 2010-06-29  51  	return 0;		/* no instruction breakpoints available */
d09ec738 Paul Mackerras 2010-06-29  52  }

:::::: The code at line 49 was first introduced by commit
:::::: d09ec7387184eba9e3030496f0451204090ff610 powerpc, hw_breakpoint: Tell generic code we have no instruction breakpoints

:::::: TO: Paul Mackerras <[email protected]> :::::: CC: Paul Mackerras <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#172 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to Palmer Dabbelt
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi Palmer,

[auto build test ERROR on v4.3-rc7]
[also ERROR on: next-20151103]

url:    https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/Remove-ifdef-CONFIG_64BIT-from-all-asm-generic-fcntl-h/20151104-035501
base:   https://github.com/0day-ci/linux Palmer-Dabbelt/Remove-ifdef-CONFIG_64BIT-from-all-asm-generic-fcntl-h/20151104-035501
config: arm-socfpga_defconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All errors (new ones prefixed by >>):

arch/arm/kernel/ptrace.c: In function 'ptrace_get_hbp_resource_info':

>> arch/arm/kernel/ptrace.c:440:33: error: 'TYPE_INST' undeclared (first use in this function)
     num_brps = hw_breakpoint_slots(TYPE_INST);
                                    ^
   arch/arm/kernel/ptrace.c:440:33: note: each undeclared identifier is reported only once for each function it appears in
>> arch/arm/kernel/ptrace.c:441:33: error: 'TYPE_DATA' undeclared (first use in this function)
     num_wrps = hw_breakpoint_slots(TYPE_DATA);
                                    ^
--
   arch/arm/kernel/hw_breakpoint.c: In function 'hw_breakpoint_slots':
>> arch/arm/kernel/hw_breakpoint.c:290:7: error: 'TYPE_INST' undeclared (first use in this function)
     case TYPE_INST:
          ^
   arch/arm/kernel/hw_breakpoint.c:290:7: note: each undeclared identifier is reported only once for each function it appears in
>> arch/arm/kernel/hw_breakpoint.c:292:7: error: 'TYPE_DATA' undeclared (first use in this function)
     case TYPE_DATA:
          ^

vim +/TYPE_INST +440 arch/arm/kernel/ptrace.c

864232fa Will Deacon 2010-09-03  434  
864232fa Will Deacon 2010-09-03  435  static u32 ptrace_get_hbp_resource_info(void)
864232fa Will Deacon 2010-09-03  436  {
864232fa Will Deacon 2010-09-03  437  	u8 num_brps, num_wrps, debug_arch, wp_len;
864232fa Will Deacon 2010-09-03  438  	u32 reg = 0;
864232fa Will Deacon 2010-09-03  439  
864232fa Will Deacon 2010-09-03 @440  	num_brps	= hw_breakpoint_slots(TYPE_INST);
864232fa Will Deacon 2010-09-03 @441  	num_wrps	= hw_breakpoint_slots(TYPE_DATA);
864232fa Will Deacon 2010-09-03  442  	debug_arch	= arch_get_debug_arch();
864232fa Will Deacon 2010-09-03  443  	wp_len		= arch_get_max_wp_len();

864232fa Will Deacon 2010-09-03 444

:::::: The code at line 440 was first introduced by commit
:::::: 864232fa1a2f8dfe003438ef0851a56722740f3e ARM: 6357/1: hw-breakpoint: add new ptrace requests for hw-breakpoint interaction

:::::: TO: Will Deacon <[email protected]> :::::: CC: Russell King <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

maintainer Acked-by on v1 9/13
#173 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to Palmer Dabbelt
Quoted 9 lines · Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

Assuming you want to keep all these patches together in a tree or so. Let me know if you want me to take this patch.

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

maintainer
#174 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

Quoted 8 lines
Quoted 3 lines

Assuming you want to keep all these patches together in a tree or so. Let me know if you want me to take this patch.

Ah, build-bot finds your change is broken and you didn't grep right. It is used in more places.

How about moving it to include/linux/hw_breakpoint.h, instead of having it in the uapi crud?

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

#175 lore raw

Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c

Quoted 8 lines · On Wed, 04 Nov 2015 04:21:51 PST (-0800)…
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Assuming you want to keep all these patches together in a tree or so. Let me know if you want me to take this patch.

Well, the plan was to try to get the whole patch set all upstream together. I'd prefer that, because it'll be easier to make sure everything gets in before the last checker patch. Since it touches so many different places I'd be OK with doing it peicemeal.

I'm kind of new to this whole process: do you think someone is likely to take this patch set all together?

Quoted 4 lines
Quoted 1 line

Ah, build-bot finds your change is broken and you didn't grep right. It is used in more places.

Sorry about that, I must have mis-grep'd. I guess that's what the build-bot is for :).

Quoted 2 lines

How about moving it to include/linux/hw_breakpoint.h, instead of having it in the uapi crud?

Yep, that makes sense.

I'm going to re-submit a v5 of this patch set, since there was also a missing patch for blackfin that the buildbot found.

#176 lore raw

PATCH 9/13 Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -10
index b04000a..7a6a5a7 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};
-
 #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
kernel/events/hw_breakpoint.c +10 -0
index 92ce5f4..5ad117e 100644
@@ -58,6 +58,16 @@ struct bp_cpuinfo {
 	unsigned int	flexible; /* XXX: placeholder, see fetch_this_slot() */
 };
 
+enum bp_type_idx {
+	TYPE_INST	= 0,
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
+	TYPE_DATA	= 0,
+#else
+	TYPE_DATA	= 1,
+#endif
+	TYPE_MAX
+};
+
 static DEFINE_PER_CPU(struct bp_cpuinfo, bp_cpuinfo[TYPE_MAX]);
 static int nr_slots[TYPE_MAX];
 
Signature · 1 line
2.4.10
#177 lore raw

PATCH 9/13 Move bp_type_idx to kernel/event/hw_breakpoint.c

In reply to Palmer Dabbelt

This has a "#ifdef CONFIG_*" that used to be exposed to userspace.

The names in here are so generic that I don't think it's a good idea to expose them to userspace (or even the rest of the kernel). Since there's only one kernel user, it's been moved to that file.

---
 include/uapi/linux/hw_breakpoint.h | 10 ----------
 kernel/events/hw_breakpoint.c      | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/hw_breakpoint.h +0 -10
index b04000a..7a6a5a7 100644
@@ -17,14 +17,4 @@ enum {
 	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
 };
 
-enum bp_type_idx {
-	TYPE_INST 	= 0,
-#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
-	TYPE_DATA	= 0,
-#else
-	TYPE_DATA	= 1,
-#endif
-	TYPE_MAX
-};
-
 #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
kernel/events/hw_breakpoint.c +10 -0
index 92ce5f4..5ad117e 100644
@@ -58,6 +58,16 @@ struct bp_cpuinfo {
 	unsigned int	flexible; /* XXX: placeholder, see fetch_this_slot() */
 };
 
+enum bp_type_idx {
+	TYPE_INST	= 0,
+#if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
+	TYPE_DATA	= 0,
+#else
+	TYPE_DATA	= 1,
+#endif
+	TYPE_MAX
+};
+
 static DEFINE_PER_CPU(struct bp_cpuinfo, bp_cpuinfo[TYPE_MAX]);
 static int nr_slots[TYPE_MAX];
 
Signature · 1 line
2.4.10
#178 lore raw

PATCH 10/13 Move USE_WCACHING to drivers/block/pktcdvd.c

In reply to Palmer Dabbelt

I don't think this was ever intended to be exposed to userspace, but it did require an "#ifdef CONFIG_*". Since the name is kind of generic and was only used in one place, I've moved the definition to the one user.

---
 drivers/block/pktcdvd.c      | 11 +++++++++++
 include/uapi/linux/pktcdvd.h | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/block/pktcdvd.c +11 -0
index 7be2375..18d2d05 100644
@@ -90,6 +90,17 @@ do {									\
 
 #define MAX_SPEED 0xffff
 
+/*
+ * use drive write caching -- we need deferred error handling to be
+ * able to successfully recover with this option (drive will return good
+ * status as soon as the cdb is validated).
+ */
+#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
+#define USE_WCACHING		1
+#else
+#define USE_WCACHING		0
+#endif
+
 static DEFINE_MUTEX(pktcdvd_mutex);
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
include/uapi/linux/pktcdvd.h +0 -11
index 2640b9d..05c2bee 100644
@@ -29,17 +29,6 @@
 #define PACKET_WAIT_TIME	(HZ * 5 / 1000)
 
 /*
- * use drive write caching -- we need deferred error handling to be
- * able to successfully recover with this option (drive will return good
- * status as soon as the cdb is validated).
- */
-#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
-#define USE_WCACHING		1
-#else
-#define USE_WCACHING		0
-#endif
-
-/*
  * No user-servicable parts beyond this point ->
  */
 
Signature · 1 line
2.4.10
#179 lore raw

PATCH 10/13 Move USE_WCACHING to drivers/block/pktcdvd.c

In reply to Palmer Dabbelt

I don't think this was ever intended to be exposed to userspace, but it did require an "#ifdef CONFIG_*". Since the name is kind of generic and was only used in one place, I've moved the definition to the one user.

---
 drivers/block/pktcdvd.c      | 11 +++++++++++
 include/uapi/linux/pktcdvd.h | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/block/pktcdvd.c +11 -0
index 7be2375..18d2d05 100644
@@ -90,6 +90,17 @@ do {									\
 
 #define MAX_SPEED 0xffff
 
+/*
+ * use drive write caching -- we need deferred error handling to be
+ * able to successfully recover with this option (drive will return good
+ * status as soon as the cdb is validated).
+ */
+#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
+#define USE_WCACHING		1
+#else
+#define USE_WCACHING		0
+#endif
+
 static DEFINE_MUTEX(pktcdvd_mutex);
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
include/uapi/linux/pktcdvd.h +0 -11
index 2640b9d..05c2bee 100644
@@ -29,17 +29,6 @@
 #define PACKET_WAIT_TIME	(HZ * 5 / 1000)
 
 /*
- * use drive write caching -- we need deferred error handling to be
- * able to successfully recover with this option (drive will return good
- * status as soon as the cdb is validated).
- */
-#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
-#define USE_WCACHING		1
-#else
-#define USE_WCACHING		0
-#endif
-
-/*
  * No user-servicable parts beyond this point ->
  */
 
Signature · 1 line
2.4.10
#180 lore raw

PATCH 10/13 Move USE_WCACHING to drivers/block/pktcdvd.c

In reply to Palmer Dabbelt

I don't think this was ever intended to be exposed to userspace, but it did require an "#ifdef CONFIG_*". Since the name is kind of generic and was only used in one place, I've moved the definition to the one user.

---
 drivers/block/pktcdvd.c      | 11 +++++++++++
 include/uapi/linux/pktcdvd.h | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/block/pktcdvd.c +11 -0
index 7be2375..18d2d05 100644
@@ -90,6 +90,17 @@ do {									\
 
 #define MAX_SPEED 0xffff
 
+/*
+ * use drive write caching -- we need deferred error handling to be
+ * able to successfully recover with this option (drive will return good
+ * status as soon as the cdb is validated).
+ */
+#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
+#define USE_WCACHING		1
+#else
+#define USE_WCACHING		0
+#endif
+
 static DEFINE_MUTEX(pktcdvd_mutex);
 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
 static struct proc_dir_entry *pkt_proc;
include/uapi/linux/pktcdvd.h +0 -11
index 2640b9d..05c2bee 100644
@@ -29,17 +29,6 @@
 #define PACKET_WAIT_TIME	(HZ * 5 / 1000)
 
 /*
- * use drive write caching -- we need deferred error handling to be
- * able to successfully recover with this option (drive will return good
- * status as soon as the cdb is validated).
- */
-#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
-#define USE_WCACHING		1
-#else
-#define USE_WCACHING		0
-#endif
-
-/*
  * No user-servicable parts beyond this point ->
  */
 
Signature · 1 line
2.4.10
#181 lore raw

PATCH 11/13 Always define MAX_RAW_MINORS as 2**20 in userspace

In reply to Palmer Dabbelt

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

---
 drivers/char/raw.c       | 7 ++++---
 include/uapi/linux/raw.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/raw.c +4 -3
index 60316fb..362d7a6 100644
@@ -36,7 +36,7 @@ static struct raw_device_data *raw_devices;
 static DEFINE_MUTEX(raw_mutex);
 static const struct file_operations raw_ctl_fops; /* forward declaration */
 
-static int max_raw_minors = MAX_RAW_MINORS;
+static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
 
 module_param(max_raw_minors, int, 0);
 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,8 +317,9 @@ static int __init raw_init(void)
 
 	if (max_raw_minors < 1 || max_raw_minors > 65536) {
 		printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
-			" between 1 and 65536), using %d\n", MAX_RAW_MINORS);
-		max_raw_minors = MAX_RAW_MINORS;
+			" between 1 and 65536), using %d\n",
+		       CONFIG_MAX_RAW_MINORS);
+		max_raw_minors = CONFIG_MAX_RAW_MINORS;
 	}
 
 	raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
include/uapi/linux/raw.h +1 -1
index 62d543e..f3d009b 100644
@@ -13,6 +13,6 @@ struct raw_config_request
 	__u64	block_minor;
 };
 
-#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
+#define MAX_RAW_MINORS (1 << 20)
 
 #endif /* __LINUX_RAW_H */
Signature · 1 line
2.4.10
#182 lore raw

Re: [PATCH 11/13] Always define MAX_RAW_MINORS as 2**20 in userspace

reproduce:

Hi Palmer,

[auto build test ERROR on v4.3-rc7]
[also ERROR on: next-20151103]

url:    https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/Remove-ifdef-CONFIG_64BIT-from-all-asm-generic-fcntl-h/20151104-035501
base:   https://github.com/0day-ci/linux Palmer-Dabbelt/Remove-ifdef-CONFIG_64BIT-from-all-asm-generic-fcntl-h/20151104-035501
config: x86_64-randconfig-x014-11022153 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> drivers/char/raw.c:39:29: error: 'CONFIG_MAX_RAW_MINORS' undeclared here (not in a function)
    static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
                                ^

vim +/CONFIG_MAX_RAW_MINORS +39 drivers/char/raw.c

    33	
    34	static struct class *raw_class;
    35	static struct raw_device_data *raw_devices;
    36	static DEFINE_MUTEX(raw_mutex);
    37	static const struct file_operations raw_ctl_fops; /* forward declaration */
    38	
  > 39	static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
    40	
    41	module_param(max_raw_minors, int, 0);
    42	MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#183 lore raw

PATCH 11/13 Always define MAX_RAW_MINORS as 2**20 in userspace

In reply to Palmer Dabbelt

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

---
 drivers/char/raw.c       | 7 ++++---
 include/uapi/linux/raw.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/raw.c +4 -3
index 60316fb..362d7a6 100644
@@ -36,7 +36,7 @@ static struct raw_device_data *raw_devices;
 static DEFINE_MUTEX(raw_mutex);
 static const struct file_operations raw_ctl_fops; /* forward declaration */
 
-static int max_raw_minors = MAX_RAW_MINORS;
+static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
 
 module_param(max_raw_minors, int, 0);
 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,8 +317,9 @@ static int __init raw_init(void)
 
 	if (max_raw_minors < 1 || max_raw_minors > 65536) {
 		printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
-			" between 1 and 65536), using %d\n", MAX_RAW_MINORS);
-		max_raw_minors = MAX_RAW_MINORS;
+			" between 1 and 65536), using %d\n",
+		       CONFIG_MAX_RAW_MINORS);
+		max_raw_minors = CONFIG_MAX_RAW_MINORS;
 	}
 
 	raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
include/uapi/linux/raw.h +1 -1
index 62d543e..f3d009b 100644
@@ -13,6 +13,6 @@ struct raw_config_request
 	__u64	block_minor;
 };
 
-#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
+#define MAX_RAW_MINORS (1 << 20)
 
 #endif /* __LINUX_RAW_H */
Signature · 1 line
2.4.10
#184 lore raw

PATCH 11/13 Always define MAX_RAW_MINORS as 2**20 in userspace

In reply to Palmer Dabbelt

While I don't think this was ever meant to be exposed to userspace, if anyone is using it then this will at least provide a correct (if unlikely) definition.

MAX_RAW_MINORS used to be used in the kernel, where it's been replaced with CONFIG_MAX_RAW_MINORS.

Note that there's a checkpatch.pl warning about a split config string here, but I've left that alone.

---
 drivers/char/raw.c       | 7 ++++---
 include/uapi/linux/raw.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/char/raw.c +4 -3
index 60316fb..362d7a6 100644
@@ -36,7 +36,7 @@ static struct raw_device_data *raw_devices;
 static DEFINE_MUTEX(raw_mutex);
 static const struct file_operations raw_ctl_fops; /* forward declaration */
 
-static int max_raw_minors = MAX_RAW_MINORS;
+static int max_raw_minors = CONFIG_MAX_RAW_MINORS;
 
 module_param(max_raw_minors, int, 0);
 MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
@@ -317,8 +317,9 @@ static int __init raw_init(void)
 
 	if (max_raw_minors < 1 || max_raw_minors > 65536) {
 		printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
-			" between 1 and 65536), using %d\n", MAX_RAW_MINORS);
-		max_raw_minors = MAX_RAW_MINORS;
+			" between 1 and 65536), using %d\n",
+		       CONFIG_MAX_RAW_MINORS);
+		max_raw_minors = CONFIG_MAX_RAW_MINORS;
 	}
 
 	raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
include/uapi/linux/raw.h +1 -1
index 62d543e..f3d009b 100644
@@ -13,6 +13,6 @@ struct raw_config_request
 	__u64	block_minor;
 };
 
-#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
+#define MAX_RAW_MINORS (1 << 20)
 
 #endif /* __LINUX_RAW_H */
Signature · 1 line
2.4.10
#185 lore raw

PATCH 12/13 Remove AT_VECTOR_SIZE_ARCH on x86

In reply to Palmer Dabbelt

It looks like there aren't actually users of this macro anywhere:

* The kernel doesn't use it on x86 because we don't suppor ELF FDPIC.

* The only Google results point to LMKL patches, both the one that wrote this (from 2010) and my patch to hide it behind __KERNEL__.

* I grep'd through all the source tarballs on my machine, and the only packages that matched were the kernel and crui (which copied a PPC kernel header).

Since I'm not sure how to actually provide the right answer (if I understand correctly, CONFIG_IA32_EMULATION is not __i386__), the only thing I can think of to do is to just remove the definition.

---
 arch/x86/include/uapi/asm/auxvec.h | 7 -------
 1 file changed, 7 deletions(-)
arch/x86/include/uapi/asm/auxvec.h +0 -7
index 77203ac..1316b4c 100644
@@ -9,11 +9,4 @@
 #endif
 #define AT_SYSINFO_EHDR		33
 
-/* entries in ARCH_DLINFO: */
-#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
-# define AT_VECTOR_SIZE_ARCH 2
-#else /* else it's non-compat x86-64 */
-# define AT_VECTOR_SIZE_ARCH 1
-#endif
-
 #endif /* _ASM_X86_AUXVEC_H */
Signature · 1 line
2.4.10
#186 lore raw

PATCH 12/13 Remove AT_VECTOR_SIZE_ARCH on x86

In reply to Palmer Dabbelt

It looks like there aren't actually users of this macro anywhere:

* The kernel doesn't use it on x86 because we don't suppor ELF FDPIC.

* The only Google results point to LMKL patches, both the one that wrote this (from 2010) and my patch to hide it behind __KERNEL__.

* I grep'd through all the source tarballs on my machine, and the only packages that matched were the kernel and crui (which copied a PPC kernel header).

Since I'm not sure how to actually provide the right answer (if I understand correctly, CONFIG_IA32_EMULATION is not __i386__), the only thing I can think of to do is to just remove the definition.

---
 arch/x86/include/uapi/asm/auxvec.h | 7 -------
 1 file changed, 7 deletions(-)
arch/x86/include/uapi/asm/auxvec.h +0 -7
index 77203ac..1316b4c 100644
@@ -9,11 +9,4 @@
 #endif
 #define AT_SYSINFO_EHDR		33
 
-/* entries in ARCH_DLINFO: */
-#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
-# define AT_VECTOR_SIZE_ARCH 2
-#else /* else it's non-compat x86-64 */
-# define AT_VECTOR_SIZE_ARCH 1
-#endif
-
 #endif /* _ASM_X86_AUXVEC_H */
Signature · 1 line
2.4.10
#187 lore raw

PATCH 12/13 Remove AT_VECTOR_SIZE_ARCH on x86

In reply to Palmer Dabbelt

It looks like there aren't actually users of this macro anywhere:

* The kernel doesn't use it on x86 because we don't suppor ELF FDPIC.

* The only Google results point to LMKL patches, both the one that wrote this (from 2010) and my patch to hide it behind __KERNEL__.

* I grep'd through all the source tarballs on my machine, and the only packages that matched were the kernel and crui (which copied a PPC kernel header).

Since I'm not sure how to actually provide the right answer (if I understand correctly, CONFIG_IA32_EMULATION is not __i386__), the only thing I can think of to do is to just remove the definition.

---
 arch/x86/include/uapi/asm/auxvec.h | 7 -------
 1 file changed, 7 deletions(-)
arch/x86/include/uapi/asm/auxvec.h +0 -7
index 77203ac..1316b4c 100644
@@ -9,11 +9,4 @@
 #endif
 #define AT_SYSINFO_EHDR		33
 
-/* entries in ARCH_DLINFO: */
-#if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64)
-# define AT_VECTOR_SIZE_ARCH 2
-#else /* else it's non-compat x86-64 */
-# define AT_VECTOR_SIZE_ARCH 1
-#endif
-
 #endif /* _ASM_X86_AUXVEC_H */
Signature · 1 line
2.4.10
#188 lore raw

PATCH 13/13 Re-enable and clean up "check_config()" in headers_check.pl

In reply to Palmer Dabbelt

I recently got bit by a CONFIG_ in userspace bug. This has apparently happened before, but the check got disabled for triggering too much. In order to reduce false positives, I added some hueristics to avoid detecting comments.

Since these tests all pass, I've now re-enabled them.

---
 scripts/headers_check.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
scripts/headers_check.pl +17 -2
index 62320f9..1634b51 100755
@@ -27,6 +27,7 @@ my $ret = 0;
 my $line;
 my $lineno = 0;
 my $filename;
+my $check_config_in_multiline_comment = 0;
 
 foreach my $file (@files) {
 	$filename = $file;
@@ -40,7 +41,7 @@ foreach my $file (@files) {
 		&check_asm_types();
 		&check_sizetypes();
 		&check_declarations();
-		# Dropped for now. Too much noise &check_config();
+		&check_config();
 	}
 	close $fh;
 }
@@ -78,7 +79,21 @@ sub check_declarations
 
 sub check_config
 {
-	if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+	my $nocomments = $line;
+	$nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+	$nocomments =~ s/\/\/.*//;     # Remove C99-style comments (// to EOL)
+
+	# Check to see if we're within a multiline comment, and if so
+	# just remove the whole line.  I tried matching on '^ * ', but
+	# there's one header that doesn't prepend multi-line comments
+	# with * so that won't work.
+	if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+	if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+	if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+	# Check to see if there is something that looks like CONFIG_
+	# inside a userspace-accessible header file and if so, print that out.
+	if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
 		printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
 	}
 }
Signature · 1 line
2.4.10
#189 lore raw

Re: [PATCH 13/13] Re-enable and clean up "check_config()" in headers_check.pl

reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi Palmer,

[auto build test WARNING on v4.3-rc7]
[also WARNING on: next-20151103]

url:    https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/Remove-ifdef-CONFIG_64BIT-from-all-asm-generic-fcntl-h/20151104-035501
base:   https://github.com/0day-ci/linux Palmer-Dabbelt/Remove-ifdef-CONFIG_64BIT-from-all-asm-generic-fcntl-h/20151104-035501
config: blackfin-TCM-BF537_defconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=blackfin

All warnings (new ones prefixed by >>):

>> ./usr/include/asm/fixed_code.h:14: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid

./usr/include/asm/fixed_code.h:15: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:18: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:20: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:22: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:24: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:25: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:26: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:27: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:28: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:29: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:30: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:32: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:34: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid ./usr/include/asm/fixed_code.h:36: leaks CONFIG_PHY_RAM_BASE_ADDRESS to userspace where it is not valid

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#190 lore raw

Re: [PATCH 13/13] Re-enable and clean up "check_config()" in headers_check.pl

In reply to Palmer Dabbelt
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi Palmer,

[auto build test WARNING on v4.3-rc7]
[also WARNING on: next-20151103]

url:    https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/Remove-ifdef-CONFIG_64BIT-from-all-asm-generic-fcntl-h/20151104-035501
base:   https://github.com/0day-ci/linux Palmer-Dabbelt/Remove-ifdef-CONFIG_64BIT-from-all-asm-generic-fcntl-h/20151104-035501
config: alpha-defconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=alpha

All warnings (new ones prefixed by >>):

>> ./usr/include/asm/setup.h:16: leaks CONFIG_ALPHA_LEGACY_START_ADDRESS to userspace where it is not valid

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#191 lore raw

PATCH 13/13 Re-enable and clean up "check_config()" in headers_check.pl

In reply to Palmer Dabbelt

I recently got bit by a CONFIG_ in userspace bug. This has apparently happened before, but the check got disabled for triggering too much. In order to reduce false positives, I added some hueristics to avoid detecting comments.

Since these tests all pass, I've now re-enabled them.

---
 scripts/headers_check.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
scripts/headers_check.pl +17 -2
index 62320f9..1634b51 100755
@@ -27,6 +27,7 @@ my $ret = 0;
 my $line;
 my $lineno = 0;
 my $filename;
+my $check_config_in_multiline_comment = 0;
 
 foreach my $file (@files) {
 	$filename = $file;
@@ -40,7 +41,7 @@ foreach my $file (@files) {
 		&check_asm_types();
 		&check_sizetypes();
 		&check_declarations();
-		# Dropped for now. Too much noise &check_config();
+		&check_config();
 	}
 	close $fh;
 }
@@ -78,7 +79,21 @@ sub check_declarations
 
 sub check_config
 {
-	if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+	my $nocomments = $line;
+	$nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+	$nocomments =~ s/\/\/.*//;     # Remove C99-style comments (// to EOL)
+
+	# Check to see if we're within a multiline comment, and if so
+	# just remove the whole line.  I tried matching on '^ * ', but
+	# there's one header that doesn't prepend multi-line comments
+	# with * so that won't work.
+	if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+	if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+	if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+	# Check to see if there is something that looks like CONFIG_
+	# inside a userspace-accessible header file and if so, print that out.
+	if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
 		printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
 	}
 }
Signature · 1 line
2.4.10
#192 lore raw

PATCH 13/13 Re-enable and clean up "check_config()" in headers_check.pl

In reply to Palmer Dabbelt

I recently got bit by a CONFIG_ in userspace bug. This has apparently happened before, but the check got disabled for triggering too much. In order to reduce false positives, I added some hueristics to avoid detecting comments.

Since these tests all pass, I've now re-enabled them.

---
 scripts/headers_check.pl | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
scripts/headers_check.pl +17 -2
index 62320f9..1634b51 100755
@@ -27,6 +27,7 @@ my $ret = 0;
 my $line;
 my $lineno = 0;
 my $filename;
+my $check_config_in_multiline_comment = 0;
 
 foreach my $file (@files) {
 	$filename = $file;
@@ -40,7 +41,7 @@ foreach my $file (@files) {
 		&check_asm_types();
 		&check_sizetypes();
 		&check_declarations();
-		# Dropped for now. Too much noise &check_config();
+		&check_config();
 	}
 	close $fh;
 }
@@ -78,7 +79,21 @@ sub check_declarations
 
 sub check_config
 {
-	if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
+	my $nocomments = $line;
+	$nocomments =~ s/\/\*.*\*\///; # Remove ANSI-style comments (/* to */)
+	$nocomments =~ s/\/\/.*//;     # Remove C99-style comments (// to EOL)
+
+	# Check to see if we're within a multiline comment, and if so
+	# just remove the whole line.  I tried matching on '^ * ', but
+	# there's one header that doesn't prepend multi-line comments
+	# with * so that won't work.
+	if ($nocomments =~ m/\/\*/) { $check_config_in_multiline_comment = 1; }
+	if ($nocomments =~ m/\*\//) { $check_config_in_multiline_comment = 0; }
+	if ($check_config_in_multiline_comment == 1) { $nocomments = "" }
+
+	# Check to see if there is something that looks like CONFIG_
+	# inside a userspace-accessible header file and if so, print that out.
+	if ($nocomments =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/) {
 		printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
 	}
 }
Signature · 1 line
2.4.10
#193 lore raw

PATCH v5 1/1 Remove #ifdef CONFIG_* from all userspace headers

In reply to Palmer Dabbelt

I think this should _actually_ be ready to go this time, the buildbot found some errors in arches that I didn't test for.

Changes since v4 (<[email protected]>)

* #9 was changed to work on arm by moving the enum to an in-kernel header file.

* #13 was added, this fixes a problem on blackfin.

Changes since v3 (<[email protected]>)

* #4 is very different: rather than defining a canonical value for MAP_UNINITIALIZED, it just punts on the problem and lets arch maintainers deal with it. There's still an #ifndef MAP_UNINITIALIZED in there, but that shouldn't get triggered by anything because the arch headers should set it to whatever they actually want.

* #11 defines MAX_RAW_MINORS to 2^20 instead of 2^16.

* #13 moves the variable around a bit so it gets initialized. I forgot I was in perl and not C :).

Changes since v2 (<[email protected]>)

* Patch set renamed.

* #2 is rewritten to use sys_ni.c instead of an #ifdef

* #3, #6, #8, #9, #10, and #11 no longer use "#ifdef __KERNEL__" but have instead moved the offending lines to the correct, kernel-only files.

* #4 has been rewritten to always define MAP_UNINITIALIZED to non-zero, rather than defining it to zero when in userspace.

* #5 got a whole lot longer -- rather than just always hiding these fields from userspace, there is now a second "struct elf_fdpic_prstatus" structure. This should allow userspace to parse core dumps correctly.

* Rebased onto 9c488de24f7264f08d341024bffdd637b4d04c96.

Changes since v1 (<[email protected]>)

* All patches but #1 were added.