Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755522Ab2BVCYc (ORCPT ); Tue, 21 Feb 2012 21:24:32 -0500 Received: from mail-ww0-f44.google.com ([74.125.82.44]:38037 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753319Ab2BVCYb (ORCPT ); Tue, 21 Feb 2012 21:24:31 -0500 Authentication-Results: mr.google.com; spf=pass (google.com: domain of linus971@gmail.com designates 10.180.24.202 as permitted sender) smtp.mail=linus971@gmail.com; dkim=pass header.i=linus971@gmail.com MIME-Version: 1.0 From: Linus Torvalds Date: Tue, 21 Feb 2012 18:24:10 -0800 X-Google-Sender-Auth: m5xJneUBTDBfnJXgvvzzh2uAYLo Message-ID: Subject: compat: autofs v5 packet size ambiguity - update To: Linux Kernel Mailing List , "H. Peter Anvin" , autofs mailing list Cc: Thomas Meyer , Al Viro Content-Type: multipart/mixed; boundary=f46d04182598355f2904b9843ace Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7957 Lines: 130 --f46d04182598355f2904b9843ace Content-Type: text/plain; charset=ISO-8859-1 Btw, thinking more about the autofs patch, I realized that despite it all working well for Thomas in his case, it's fundamentally wrong. And it's not fundamentally wrong because of any ambiguities about the size of the structure: that structure is clearly 304 bytes on x86-64 (and most other platforms, buth 32-bit and 64-bit), but it's 300 bytes on x86-32 and m68k. No, the problem is that "is_compat_task()" is not the right check. It's not the task that *waits* for autofs that matters, it's that damn autofs daemon task. IOW, what we actually want to test is whether the other end of that autofs sbi->pipe is a compat task or not. And I have no idea how to do that. Can I assume that whoever does the original "mount()" system call is the daemon? It needs to have that pipe somehow.. Is there something that the daemon does early on that we can use to capture whether the daemon is a compat task or not? Ian, Peter, anybody who knows autofs? Is perhaps one of the ioctl's always done by the daemon, where we could then use "is_compat_task()" at that point to figure out whether it is going to expect the 300-byte packet or the 304-byte packet? We could just initialize sbi->v5_packet_size to the plain sizeof(), but when we see that ioctl and realize that the daemon is a x86-32 binary we'd reset the packet size to 300. Anyway, here's the patch again with a long explanation, but with a "THIS IS WRONG" comment in the code, and an explanation in the commit log. It works for Thomas, but it works for the wrong reasons - in his setup, all binaries are compat binaries, so "is_compat_task()" just happens to get the right value for the daemon too. But if you have a mixture of binaries, you might get the autofs *request* in a compat binary while the daemon is a 64-bit native x86-64 binary, or the other way around, and then this patch would use the wrong packet size to communicate with the daemon. Hmm? Linus --f46d04182598355f2904b9843ace Content-Type: text/x-patch; charset=US-ASCII; name="0001-autofs-work-around-unhappy-compat-problem-on-x86-64.patch" Content-Disposition: attachment; filename="0001-autofs-work-around-unhappy-compat-problem-on-x86-64.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gyxqh8fk0 RnJvbSBiY2E3OTNkNjBkMDdkNzk1MDFhODNiNGU4M2E4NTZjM2JkYmZkNTM1IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMaW51cyBUb3J2YWxkcyA8dG9ydmFsZHNAbGludXgtZm91bmRh dGlvbi5vcmc+CkRhdGU6IFR1ZSwgMjEgRmViIDIwMTIgMTc6MzY6MDYgLTA4MDAKU3ViamVjdDog W1BBVENIXSBhdXRvZnM6IHdvcmsgYXJvdW5kIHVuaGFwcHkgY29tcGF0IHByb2JsZW0gb24geDg2 LTY0CgpXaGVuIHRoZSBhdXRvZnMgcHJvdG9jb2wgdmVyc2lvbiA1IHBhY2tldCB0eXBlIHdhcyBh ZGRlZCBpbiBjb21taXQKNWMwYTMyZmMyY2QwICgiYXV0b2ZzNDogYWRkIG5ldyBwYWNrZXQgdHlw ZSBmb3IgdjUgY29tbXVuaWNhdGlvbnMiKSwgaXQKb2J2b3VzbHkgdHJpZWQgcXVpdGUgaGFyZCB0 byBiZSB3b3JkLXNpemUgYWdub3N0aWMsIGFuZCB1c2VzIGV4cGxpY2l0bHkKc2l6ZWQgZmllbGRz IHRoYXQgYXJlIGFsbCBjb3JyZ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Zm8gKnNi aSwKIAl7CiAJCXN0cnVjdCBhdXRvZnNfdjVfcGFja2V0ICpwYWNrZXQgPSAmcGt0LnY1X3BrdC52 NV9wYWNrZXQ7CiAKLQkJcGt0c3ogPSBzaXplb2YoKnBhY2tldCk7Ci0KKwkJcGt0c3ogPSBhdXRv ZnNfdjVfcGFja2V0X3NpemUoKTsKIAkJcGFja2V0LT53YWl0X3F1ZXVlX3Rva2VuID0gd3EtPndh aXRfcXVldWVfdG9rZW47CiAJCXBhY2tldC0+bGVuID0gd3EtPm5hbWUubGVuOwogCQltZW1jcHko cGFja2V0LT5uYW1lLCB3cS0+bmFtZS5uYW1lLCB3cS0+bmFtZS5sZW4pOwotLSAKMS43LjkuMTg4 LmcxMjc2Ni5kaXJ0eQoK --f46d04182598355f2904b9843ace-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/