All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Huang <mlhuang@CS.Princeton.EDU>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] initramfs: fix CPIO hardlink check
Date: Thu, 04 May 2006 14:43:28 -0400	[thread overview]
Message-ID: <445A4B50.8060104@cs.princeton.edu> (raw)

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.

Cc: me on responses.

Signed-off-by: Mark Huang <mlhuang@cs.princeton.edu>

--- linux-2.6.16.13/init/initramfs.c	2006-05-02 17:38:44.000000000 -0400
+++ linux-2.6.16.13.initramfs/init/initramfs.c	2006-05-04 
14:26:44.000000000 -0400
@@ -26,10 +26,12 @@ static void __init free(void *where)

  /* link hash */

+#define N_ALIGN(len) ((((len) + 1) & ~3) + 2)
+
  static __initdata struct hash {
  	int ino, minor, major;
  	struct hash *next;
-	char *name;
+	char name[N_ALIGN(PATH_MAX)];
  } *head[32];

  static inline int hash(int major, int minor, int ino)
@@ -57,7 +59,7 @@ static char __init *find_link(int major,
  	q->ino = ino;
  	q->minor = minor;
  	q->major = major;
-	q->name = name;
+	strcpy(q->name, name);
  	q->next = NULL;
  	*p = q;
  	return NULL;
@@ -133,8 +135,6 @@ static inline void eat(unsigned n)
  	count -= n;
  }

-#define N_ALIGN(len) ((((len) + 1) & ~3) + 2)
-
  static __initdata char *collected;
  static __initdata int remains;
  static __initdata char *collect;


                 reply	other threads:[~2006-05-04 18:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=445A4B50.8060104@cs.princeton.edu \
    --to=mlhuang@cs.princeton.edu \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.