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] [thread-next>] [day] [month] [year] [list]
Message-ID: <4F45293C.8050209@zytor.com>
Date:	Wed, 22 Feb 2012 09:43:24 -0800
From:	"H. Peter Anvin" <hpa@...or.com>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
CC:	Ian Kent <raven@...maw.net>, David Miller <davem@...emloft.net>,
	linux-kernel@...r.kernel.org, autofs@...r.kernel.org,
	Thomas Meyer <thomas@...3r.de>,
	Al Viro <viro@...iv.linux.org.uk>
Subject: Re: compat: autofs v5 packet size ambiguity - update

On 02/22/2012 08:10 AM, Linus Torvalds wrote:
> 
> Well, the kernel gives the right semantics for pipes too - writes are
> guaranteed to be "atomic", so even in the presence of multiple writers
> you can trivially do packetized data.
> 
> You just have to (a) add the length to the packet and (b) do the
> length+packet write as a single write (which is limited to PIPE_SIZE -
> 4kB - for the atomicity guarantee).
> 
> If you don't have multiple concurrent writers without locking, the (b)
> part falls away entirely, of course.
> 
> Yes, for the reader side you need to be able to handle the fact that
> you can get more than one packet in one read() call, but sorting that
> out isn't hard either.
> 

What you describe above is pretty much how autofs 3 used to work; except
it would do one read() for the header including length and then another
read() for the body.  Of course, it could just have read ahead -- if you
read part of the next packet, it wouldn't really matter since at least
at that time the daemon was single-threaded and would have to loop back
anyway.

The PIPE_SIZE guarantee took care of the fact that this was a multiple
writer/single reader situation (since the writes happens in the context
of the process requesting a mount.)  Either way, SOCK_DGRAM and
SOCK_SEQPACKET would solve all of the problems and would Just Work, and
packet boundaries would then be explicit.

> But yeah, writing fixed-size data and then having a reader that reads
> fixed-size data is just not a very good approach. It's doubly bad when
> the "fixed size" isn't an explicit size that is documented in the
> protocol, but depends on data structures.

Indeed.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

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