2009-01-14 20:42:44

by Cyrill Gorcunov

[permalink] [raw]
Subject: [patch 1/5] x86: headers cleanup - boot.h

Impact: cleanup

'make headers_check' warn us about leaking of kernel private
(mostly compile time vars) data to userspace in headers. Fix it.

Neither BOOT_HEAP_SIZE, BOOT_STACK_SIZE refs
was found by searching thru net (ie in user-space area)
so fence this all by __KERNEL__ guard.

Signed-off-by: Cyrill Gorcunov <[email protected]>
---

---
arch/x86/include/asm/boot.h | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

Index: linux-2.6.git/arch/x86/include/asm/boot.h
===================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/boot.h
+++ linux-2.6.git/arch/x86/include/asm/boot.h
@@ -10,14 +10,16 @@
#define EXTENDED_VGA 0xfffe /* 80x50 mode */
#define ASK_VGA 0xfffd /* ask for it at bootup */

+#ifdef __KERNEL__
+
/* Physical address where kernel should be loaded. */
#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
+ (CONFIG_PHYSICAL_ALIGN - 1)) \
& ~(CONFIG_PHYSICAL_ALIGN - 1))

-#if (defined CONFIG_KERNEL_BZIP2)
+#ifdef CONFIG_KERNEL_BZIP2
#define BOOT_HEAP_SIZE 0x400000
-#else
+#else /* !CONFIG_KERNEL_BZIP2 */

#ifdef CONFIG_X86_64
#define BOOT_HEAP_SIZE 0x7000
@@ -25,7 +27,7 @@
#define BOOT_HEAP_SIZE 0x4000
#endif

-#endif
+#endif /* !CONFIG_KERNEL_BZIP2 */

#ifdef CONFIG_X86_64
#define BOOT_STACK_SIZE 0x4000
@@ -33,4 +35,6 @@
#define BOOT_STACK_SIZE 0x1000
#endif

+#endif /* __KERNEL__ */
+
#endif /* _ASM_X86_BOOT_H */

--


2009-01-14 21:04:51

by Harvey Harrison

[permalink] [raw]
Subject: Re: [patch 1/5] x86: headers cleanup - boot.h

On Wed, 2009-01-14 at 23:37 +0300, Cyrill Gorcunov wrote:
> -#if (defined CONFIG_KERNEL_BZIP2)
> +#ifdef CONFIG_KERNEL_BZIP2
> #define BOOT_HEAP_SIZE 0x400000
> -#else
> +#else /* !CONFIG_KERNEL_BZIP2 */

Curious, I haven't seen the #else comments with the extra ! before,
is that something that's coming into common use?

Harvey

2009-01-14 21:11:55

by Cyrill Gorcunov

[permalink] [raw]
Subject: Re: [patch 1/5] x86: headers cleanup - boot.h

[Harvey Harrison - Wed, Jan 14, 2009 at 01:04:40PM -0800]
| On Wed, 2009-01-14 at 23:37 +0300, Cyrill Gorcunov wrote:
| > -#if (defined CONFIG_KERNEL_BZIP2)
| > +#ifdef CONFIG_KERNEL_BZIP2
| > #define BOOT_HEAP_SIZE 0x400000
| > -#else
| > +#else /* !CONFIG_KERNEL_BZIP2 */
|
| Curious, I haven't seen the #else comments with the extra ! before,
| is that something that's coming into common use?
|
| Harvey
|

Actually I saw the both.

./arch/mips/include/asm/dec/prom.h:54:#else /* !CONFIG_64BIT */
./arch/mips/include/asm/dec/prom.h:58:#endif /* !CONFIG_64BIT */

- Cyrill -

2009-01-14 21:20:54

by Cyrill Gorcunov

[permalink] [raw]
Subject: Re: [patch 1/5] x86: headers cleanup - boot.h

[Cyrill Gorcunov - Thu, Jan 15, 2009 at 12:11:42AM +0300]
| [Harvey Harrison - Wed, Jan 14, 2009 at 01:04:40PM -0800]
| | On Wed, 2009-01-14 at 23:37 +0300, Cyrill Gorcunov wrote:
| | > -#if (defined CONFIG_KERNEL_BZIP2)
| | > +#ifdef CONFIG_KERNEL_BZIP2
| | > #define BOOT_HEAP_SIZE 0x400000
| | > -#else
| | > +#else /* !CONFIG_KERNEL_BZIP2 */
| |
| | Curious, I haven't seen the #else comments with the extra ! before,
| | is that something that's coming into common use?
| |
| | Harvey
| |
|
| Actually I saw the both.
|
| ./arch/mips/include/asm/dec/prom.h:54:#else /* !CONFIG_64BIT */
| ./arch/mips/include/asm/dec/prom.h:58:#endif /* !CONFIG_64BIT */
|
| - Cyrill -

You know Harvey, I think such a details could be
mentioned in CodingStyle. At least I found two
types of comments:

1) Forward comments:

#if FOO
#else /* !FOO */
#endif /* !FOO */

2) Backward comments:

#if FOO
#else /* FOO */
#endif /* !FOO */

I prefer the first variant. But with any variant
I'm always rereading twice what is defined and
what is not :)

- Cyrill -