[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <12102548553947-git-send-email-xiyou.wangcong@gmail.com>
Date: Thu, 8 May 2008 21:52:32 +0800
From: WANG Cong <xiyou.wangcong@...il.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Andrew Morton <akpm@...l.org>,
WANG Cong <xiyou.wangcong@...il.com>,
WANG Cong <wangcong@...ux.org>,
Alexander Viro <viro@...iv.linux.org.uk>
Subject: [Patch 7/9] fs/exec.c: fix wrong return value of prepare_binprm()
All prepare_binprm()'s callers assume that prepare_binprm() fails
when it returns negative. However, prepare_binprm() most probably returns
the return value of kernel_read(), which may return positive on failure!
Thus this should be fixed.
Signed-off-by: WANG Cong <wangcong@...ux.org>
Cc: Alexander Viro <viro@...iv.linux.org.uk>
---
diff --git a/fs/exec.c b/fs/exec.c
index aeaa979..0237541 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1063,7 +1063,11 @@ int prepare_binprm(struct linux_binprm *bprm)
return retval;
memset(bprm->buf,0,BINPRM_BUF_SIZE);
- return kernel_read(bprm->file,0,bprm->buf,BINPRM_BUF_SIZE);
+ retval = kernel_read(bprm->file, 0, bprm->buf, BINPRM_BUF_SIZE);
+ if (retval < 0)
+ return retval;
+ if (retval != BINPRM_BUF_SIZE && retval != inode->i_size)
+ return -EIO;
+ return 0;
}
EXPORT_SYMBOL(prepare_binprm);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists