mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: kosaki.motohiro@jp.fujitsu.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: Is it legal to return positive value when do_execve() succeeds?
Date: Tue,  5 Oct 2010 10:28:44 +0900 (JST)	[thread overview]
Message-ID: <20101005102446.28C3.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <201010042231.EEG13079.OFSFtOMJHVFLQO@I-love.SAKURA.ne.jp>

> KOSAKI Motohiro wrote:
> > > fs/binfmt_elf.c:
> > >  77 #define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE)
> > Can do_brk() return BAD_ADDR() _and_ !IS_ERR_VALUE() value? when?
> 
> For example, arch/mips/include/asm/processor.h has below definitions
> which is smaller than INT_MAX
> 
>  47 #ifdef CONFIG_32BIT
> (...snipped...)
>  52 #define TASK_SIZE       0x7fff8000UL
> (...snipped...)
>  63 #endif
>  64 
>  65 #ifdef CONFIG_64BIT
> (...snipped...)
>  74 #define TASK_SIZE       0x10000000000UL
> (...snipped...)
>  91 #endif
> 
> Also, several architectures define TASK_SIZE as
> 
>   #define TASK_SIZE               PAGE_OFFSET
> 
> and PAGE_OFFSET could be 0 if CONFIG_KERNEL_RAM_BASE_ADDRESS is not defined.
> 
> include/asm-generic/page.h
>  68 #ifdef CONFIG_KERNEL_RAM_BASE_ADDRESS
>  69 #define PAGE_OFFSET             (CONFIG_KERNEL_RAM_BASE_ADDRESS)
>  70 #else
>  71 #define PAGE_OFFSET             (0)
>  72 #endif
> 
> If TASK_SIZE == 0, BAD_ADDR(x) is always true and !IS_ERR_VALUE(x) can be true.
> Although I don't know which combination makes such environment,
> I think "BAD_ADDR() _and_ !IS_ERR_VALUE()" can happen.

I think you should read do_brk() itself. the spec is

success case:
	return addr argument

error case: 
	return error code

When does it return invalid address?





  reply	other threads:[~2010-10-05  1:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-30 13:07 Tetsuo Handa
2010-10-01  2:29 ` Tetsuo Handa
2010-10-01  5:19   ` Tetsuo Handa
2010-10-04  4:59     ` KOSAKI Motohiro
2010-10-04 13:31       ` Tetsuo Handa
2010-10-05  1:28         ` KOSAKI Motohiro [this message]
2010-10-05  2:24           ` Tetsuo Handa
2010-10-05  5:21             ` KOSAKI Motohiro
2010-10-05  6:48               ` Tetsuo Handa
2010-10-05  2:37           ` KOSAKI Motohiro
2010-10-05  2:55             ` KOSAKI Motohiro
2010-10-05  4:40               ` Tetsuo Handa
2010-10-01 12:44 ` Tetsuo Handa

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=20101005102446.28C3.A69D9226@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    /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

Powered by JetHome