From: Pekka Enberg Subject: Re: [patch 07/21] fs: fix overflow in sys_mount() for in-kernel calls Date: Wed, 23 Sep 2009 09:26:50 +0300 Message-ID: <1253687210.4971.0.camel@penberg-laptop> References: <200909182005.n8IK5jCI019175@imap1.linux-foundation.org> <20090921103408.GK5858@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, vegard.nossum@gmail.com, mingo@elte.hu To: Al Viro Return-path: Received: from courier.cs.helsinki.fi ([128.214.9.1]:36248 "EHLO mail.cs.helsinki.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753982AbZIWG0t (ORCPT ); Wed, 23 Sep 2009 02:26:49 -0400 In-Reply-To: <20090921103408.GK5858@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, 2009-09-21 at 11:34 +0100, Al Viro wrote: > On Fri, Sep 18, 2009 at 01:05:45PM -0700, akpm@linux-foundation.org wrote: > > From: Vegard Nossum > > > > On 2009/6/17 Ingo Molnar reported: > > > > > > btw., here's an old friend of a warning: > > > > > [snip] > > > @@ -1640,7 +1640,7 @@ static int do_new_mount(struct path *pat > > { > > struct vfsmount *mnt; > > > > - if (!type || !memchr(type, 0, PAGE_SIZE)) > > + if (!type) > > return -EINVAL; > > > > /* we need capabilities... */ > > @@ -1871,6 +1871,23 @@ int copy_mount_options(const void __user > > return 0; > > } > > > @@ -1900,8 +1917,6 @@ long do_mount(char *dev_name, char *dir_ > > > > if (!dir_name || !*dir_name || !memchr(dir_name, 0, PAGE_SIZE)) > > return -EINVAL; > > - if (dev_name && !memchr(dev_name, 0, PAGE_SIZE)) > > - return -EINVAL; > > > > if (data_page) > > ((char *)data_page)[PAGE_SIZE - 1] = 0; > > In this form it's simply b0rken - you need to take care of other do_mount() > callers. arch/alpha/kernel/osf_sys.c is safe, but fs/compat.c isn't... Vegard, ping?