From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754552Ab3FKBvw (ORCPT ); Mon, 10 Jun 2013 21:51:52 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:49069 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753507Ab3FKBvv (ORCPT ); Mon, 10 Jun 2013 21:51:51 -0400 Date: Tue, 11 Jun 2013 02:51:49 +0100 From: Al Viro To: Jeff Chua Cc: Linux Kernel , Linus Torvalds , Greg Kroah-Hartman , Andy Shevchenko Subject: Re: binfmt_misc broken Message-ID: <20130611015149.GB4165@ZenIV.linux.org.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 10, 2013 at 09:52:44PM +0800, Jeff Chua wrote: > > > According to Documentation/binfmt_misc.txt, the 'magic' and 'mask' > can be set by echoing it to /proc/sys/fs/binfmt_misc/register. > > Here's the problem I can across while working on ARM. > > # echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:' > >/proc/sys/fs/binfmt_misc/register > > # cat /proc/sys/fs/binfmt_misc/arm > wrong ... > magic 7f454c46010101 > mask ffffffffffffff > > right ... > magic 7f454c4601010100000000000000000002002800 > mask ffffffffffffff00fffffffffffffffffeffffff > > > binfmt_misc is truncating e->size, so once ARM's magic is loaded, > 32-bit x86 can no longer run. > > Here's a patch for it. It's looking for the delimiter ":" instead of > \0. Now 32-bit x86 can run concurrent while qemu-arm is handling > ARM's magic. Patch is complete BS and I really wonder what kernel have you observed that bug on - with mainline on amd64 your example yields root@kvm-amd64:~# cat /proc/sys/fs/binfmt_misc/arm enabled interpreter /usr/bin/qemu-arm-static flags: offset 0 magic 7f454c4601010100000000000000000002002800 mask ffffffffffffff00fffffffffffffffffeffffff A reproducer, please... As for the memcmp() Linus has suggested - it's !Magic case, i.e. what we are comparing there is not the file contents, it's the extension. IOW, strcmp() is the right thing to use there - pathnames do not contain NULs in the middle...