diff options
author | Mark Huang <mlhuang@CS.Princeton.EDU> | 2006-05-15 12:44:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-05-15 14:20:55 -0400 |
commit | 6a050da45b5d855b48b057446847ff1542977b52 (patch) | |
tree | f455f444ddd5be62740cd430c595c6d6a13fb4db | |
parent | 698d070746770aaaec78ab4ffa3ab1f1d5c6abe8 (diff) |
[PATCH] initramfs: fix CPIO hardlink check
Copy the filenames of hardlinks when inserting them into the hash, since
the "name" pointer may point to scratch space (name_buf). Not doing so
results in corruption if the scratch space is later overwritten: the wrong
file may be hardlinked, or, if the scratch space contains garbage, the link
will fail and a 0-byte file will be created instead.
Signed-off-by: Mark Huang <mlhuang@cs.princeton.edu>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | init/initramfs.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/init/initramfs.c b/init/initramfs.c index 679d870d991b..f81cfa40a719 100644 --- a/init/initramfs.c +++ b/init/initramfs.c | |||
@@ -26,10 +26,12 @@ static void __init free(void *where) | |||
26 | 26 | ||
27 | /* link hash */ | 27 | /* link hash */ |
28 | 28 | ||
29 | #define N_ALIGN(len) ((((len) + 1) & ~3) + 2) | ||
30 | |||
29 | static __initdata struct hash { | 31 | static __initdata struct hash { |
30 | int ino, minor, major; | 32 | int ino, minor, major; |
31 | struct hash *next; | 33 | struct hash *next; |
32 | char *name; | 34 | char name[N_ALIGN(PATH_MAX)]; |
33 | } *head[32]; | 35 | } *head[32]; |
34 | 36 | ||
35 | static inline int hash(int major, int minor, int ino) | 37 | static inline int hash(int major, int minor, int ino) |
@@ -57,7 +59,7 @@ static char __init *find_link(int major, int minor, int ino, char *name) | |||
57 | q->ino = ino; | 59 | q->ino = ino; |
58 | q->minor = minor; | 60 | q->minor = minor; |
59 | q->major = major; | 61 | q->major = major; |
60 | q->name = name; | 62 | strcpy(q->name, name); |
61 | q->next = NULL; | 63 | q->next = NULL; |
62 | *p = q; | 64 | *p = q; |
63 | return NULL; | 65 | return NULL; |
@@ -133,8 +135,6 @@ static inline void eat(unsigned n) | |||
133 | count -= n; | 135 | count -= n; |
134 | } | 136 | } |
135 | 137 | ||
136 | #define N_ALIGN(len) ((((len) + 1) & ~3) + 2) | ||
137 | |||
138 | static __initdata char *collected; | 138 | static __initdata char *collected; |
139 | static __initdata int remains; | 139 | static __initdata int remains; |
140 | static __initdata char *collect; | 140 | static __initdata char *collect; |