lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Sun, 24 Oct 2010 20:02:32 +0530
From:	"Aneesh Kumar K. V" <aneesh.kumar@...ux.vnet.ibm.com>
To:	Brad Boyer <flar@...andria.com>
Cc:	v9fs-developer@...ts.sourceforge.net,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
	Sanchit Garg <sancgarg@...ux.vnet.ibm.com>
Subject: Re: [PATCH 2/2] net/9p: Return error on read with NULL buffer

On Sat, 23 Oct 2010 12:59:57 -0700, Brad Boyer <flar@...andria.com> wrote:
> On Mon, Oct 18, 2010 at 08:10:53PM +0530, Aneesh Kumar K.V wrote:
> > This patch ensures that a read(fd, NULL, 0 ) returns  EFAULT on a 9p file.
> 
> Is there some specific reason you want this behavior? I believe the
> generic Linux code returns success in this case. I tried this exact
> system call with fd being a pty or a file on ext3 and got 0 for both.

Linux code return 0 in case count == 0;
This is what i find on ext4.

open("a.c", O_RDONLY)                   = 3
read(3, 0, 10)                          = -1 EFAULT (Bad address)

open("a.c", O_RDONLY)                   = 3
read(3, NULL, 0)                        = 0

This patch ensure that we get the behaviour as in case one in case of 9p
file system. But patch broke the behaviour in step 2. So below is the
updated one

commit bd1717e5300ab0bb9aa2df139ffbc5e49f1baeb6
Author: Sanchit Garg <sancgarg@...ux.vnet.ibm.com>
Date:   Tue Oct 19 09:17:02 2010 +0530

    net/9p: Return error on read with NULL buffer
    
    This patch ensures that a read(fd, NULL, 10) returns  EFAULT on a 9p file.
    
    Signed-off-by: Sanchit Garg <sancgarg@...ux.vnet.ibm.com>
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@...ux.vnet.ibm.com>

diff --git a/net/9p/client.c b/net/9p/client.c
index e141e46..dbca5b3 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -1333,16 +1333,13 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
 
 	if (data) {
 		memmove(data, dataptr, count);
-	}
-
-	if (udata) {
+	} else {
 		err = copy_to_user(udata, dataptr, count);
 		if (err) {
 			err = -EFAULT;
 			goto free_and_error;
 		}
 	}
-
 	p9_free_req(clnt, req);
 	return count;
 


-aneesh
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ