From: Al Viro Subject: Re: [patch 07/21] fs: fix overflow in sys_mount() for in-kernel calls Date: Mon, 21 Sep 2009 11:34:09 +0100 Message-ID: <20090921103408.GK5858@ZenIV.linux.org.uk> References: <200909182005.n8IK5jCI019175@imap1.linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, vegard.nossum@gmail.com, mingo@elte.hu, penberg@cs.helsinki.fi To: akpm@linux-foundation.org Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:38343 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750783AbZIUKeH (ORCPT ); Mon, 21 Sep 2009 06:34:07 -0400 Content-Disposition: inline In-Reply-To: <200909182005.n8IK5jCI019175@imap1.linux-foundation.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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...