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]
Message-ID: <20101208151628.GE13666@dezo.moloch.sk>
Date:	Wed, 8 Dec 2010 16:16:29 +0100
From:	Martin Lucina <mato@...elna.sk>
To:	Eric Dumazet <eric.dumazet@...il.com>
Cc:	Martin Sustrik <sustrik@...bpm.com>, netdev@...r.kernel.org
Subject: Re: Polling on sockets in kernel space and struct file

Hi Eric,

oddly enough our BUG at fs/inode.c seems to have gone away; may be a race
of some sort...

> you could call sock_map_fd() then :
> 
> 
> 	int fd = sock_map_fd(sock, flags);
> 	struct file *file = NULL;
> 
> 	if (fd != -1) {
> 		file = fget(fd);
> 		sys_close(fd);  /* still racy */
> 	}
> 
> 	if (file) ...
> 
> Take a look at net/9p/trans_fd.c

Interesting approach. 

We're currently doing the following -- we add this function to
net/socket.c:

int sock_map_anon(struct socket *sock, const char *name, int flags)
{
	struct file *newfile;
	
	newfile = anon_inode_getfile(name, &socket_file_ops, sock, flags);
	sock->file = newfile;
	return 0;
}

and then call it instead of sock_map_fd() from our sock_create():

	/* Create peer socket and associated file structure */
	rc = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sp->peer);
	if (rc < 0)
		goto out;
	rc = sock_map_anon(sp->peer, "[sp]", 0);
	if (rc < 0)
		goto out_release;

Is this a valid approach to achieve the same thing?

It's not clear what, if anything special we need to do to correctly release
the anonymous inode when we are releasing our socket...  is
sock_release(sp->peer) sufficient?

Also, I see in 9p/trans_fd.c that it's using get_file() to increment the
file refcount; do we need to do this for all sockets/files we create in
kernel space or is this only for the sys_close() hack?

Thanks,

-mato
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ