From mboxrd@z Thu Jan 1 00:00:00 1970 From: WANG Cong Subject: [Patch] fs/binfmt_elf.c: fix wrong return values Date: Sat, 3 May 2008 22:14:24 +0800 Message-ID: <20080503141409.GC3986@hack> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Alexander Viro , Andrew Morton , linux-fsdevel@vger.kernel.org To: LKML Return-path: Received: from wf-out-1314.google.com ([209.85.200.175]:22083 "EHLO wf-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753216AbYECOK0 (ORCPT ); Sat, 3 May 2008 10:10:26 -0400 Received: by wf-out-1314.google.com with SMTP id 27so406432wfd.4 for ; Sat, 03 May 2008 07:10:26 -0700 (PDT) Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: When strnlen_user() fails, return 0 is suspecious. What's more, the caller returns 0 on success, so that logic is obviously wrong. I am not sure if returning -EINVAL is good enough. I think it's better than -EFAULT here. NOTE: This patch is _not_ tested yet! Signed-off-by: WANG Cong Cc: Alexander Viro --- fs/binfmt_elf.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 43254e3..10f9642 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -256,7 +256,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec, return -EFAULT; len = strnlen_user((void __user *)p, MAX_ARG_STRLEN); if (!len || len > MAX_ARG_STRLEN) - return 0; + return -EINVAL; p += len; } if (__put_user(0, argv)) @@ -268,7 +268,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec, return -EFAULT; len = strnlen_user((void __user *)p, MAX_ARG_STRLEN); if (!len || len > MAX_ARG_STRLEN) - return 0; + return -EINVAL; p += len; } if (__put_user(0, envp)) -- 1.5.4.1