From: Junio C Hamano <gitster@pobox.com>
To: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Set hard limit on delta chain depth
Date: Fri, 09 Dec 2011 16:02:19 -0800 [thread overview]
Message-ID: <7vsjktb8fo.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: CACsJy8AZg3DgZzmPyXhCH9bGBqo9UN7-zLt_feTtpyajf5U1tw@mail.gmail.com
Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
> That's interesting. First of all xmalloc() is controlled by us while
> index-pack code might lead to stack overflow exploit (never done it,
> not sure if it's really pratical to do in this case).
What do you exactly mean by "stack overflow exploit"?
If your callee has prepares a stackframe that is not sufficiently big but
carelessly tries to store more than it has space for, such a write can
overflow the stack (without hardware traps) and overwrite return address,
and instead of coming back to you, the control can be transferred to
random places.
But I do not think that is what we are talking about here.
You attempt to write parameters and return address to the area of memory
pointed by your stack pointer, advance the stack pointer to create a stack
frame and the callee attempts to write to its local variables in the newly
allocated stack frame. These memory accesses eventually attempt to touch
memory beyond the address range the kernel gave you page table entries to
be used as your stack space, and hardware traps. If you haven't run out of
the stack, a new page is lazily added to the page table and your attempted
access will succeed. If you are recursing too deeply, you won't be given a
new page and you will be killed by the kernel. That is a rather controlled
death of the process, unlike smashing the contents of the stack to jump to
a randomly chosen place, isn't it?
Of course, some platforms do not have an unwritable gap between the stack
segment that grow downwards and the heap that grow upwards, and also your
stackframe could be larger than such a gap (in this particular callchain I
do not think that is the case), so the above discussion does not apply
universally, though.
next prev parent reply other threads:[~2011-12-10 0:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-05 7:04 [PATCH] Set hard limit on delta chain depth Nguyễn Thái Ngọc Duy
2011-12-06 12:17 ` Erik Faye-Lund
2011-12-06 12:32 ` Nguyen Thai Ngoc Duy
2011-12-06 12:41 ` Erik Faye-Lund
2011-12-06 12:48 ` Nguyen Thai Ngoc Duy
2011-12-06 14:54 ` Michael Haggerty
2011-12-06 15:30 ` Nguyen Thai Ngoc Duy
2011-12-06 18:12 ` Shawn Pearce
2011-12-06 18:56 ` Jeff King
2011-12-06 15:06 ` Junio C Hamano
2011-12-06 15:45 ` Nguyen Thai Ngoc Duy
2011-12-10 0:02 ` Junio C Hamano [this message]
2011-12-07 17:50 ` [PATCH] index-pack: eliminate unlimited recursion in get_delta_base() Nguyễn Thái Ngọc Duy
2011-12-08 3:02 ` Shawn Pearce
2011-12-08 11:06 ` Nguyen Thai Ngoc Duy
2011-12-08 13:40 ` [PATCH 1/2] index_pack: indent find_unresolved_detals one level pclouds
2011-12-09 21:27 ` Junio C Hamano
[not found] ` <1323351638-4790-1-git-send-email-y>
2011-12-08 13:40 ` [PATCH 2/2] index-pack: a naive attempt to flatten find_unresolved_deltas pclouds
2011-12-08 16:42 ` Shawn Pearce
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=7vsjktb8fo.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).