From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35327 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932476AbdGXPRq (ORCPT ); Mon, 24 Jul 2017 11:17:46 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6OFEOXF004506 for ; Mon, 24 Jul 2017 11:17:46 -0400 Received: from e23smtp05.au.ibm.com (e23smtp05.au.ibm.com [202.81.31.147]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bwhjqwcqx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 24 Jul 2017 11:17:45 -0400 Received: from localhost by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Jul 2017 01:17:43 +1000 Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6OFHX1530802042 for ; Tue, 25 Jul 2017 01:17:41 +1000 Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v6OFH9Ab029178 for ; Tue, 25 Jul 2017 01:17:09 +1000 From: Chandan Rajendra To: viro@zeniv.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, abdhalee@linux.vnet.ibm.com, joe@perches.com Subject: Re: [PATCH V2] get_fs_type: Validate fs type string argument Date: Mon, 24 Jul 2017 20:47:20 +0530 In-Reply-To: <20170711140421.31205-1-chandan@linux.vnet.ibm.com> References: <20170711134709.29343-1-chandan@linux.vnet.ibm.com> <20170711140421.31205-1-chandan@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Message-Id: <1842620.RrM76BaaeK@localhost.localdomain> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tuesday, July 11, 2017 7:34:21 PM IST Chandan Rajendra wrote: > On ppc64, When a non-nul terminated string is passed as an argument to > the mount(2) syscall, copy_mount_string() ends up allocating 64k (the > PAGE_SIZE on ppc64) worth of space for holding the string in kernel's > address space. > > Later, in set_precision() (invoked indirectly by get_fs_type()), we end > up assigning 65535 as the value to 'struct printf_spec'->precision > member. This field has a width of 16 bits and also it is signed data > type. Hence an invalid value ends up getting assigned. This causes the > "WARN_ONCE(spec->precision != prec, "precision %d too large", prec)" > statement inside set_precision() to be executed. > > This commit fixes the bug by validating the length of the "filesystem > type" argument passed to get_fs_type() function. > > Signed-off-by: Chandan Rajendra > Reported-by: Abdul Haleem > Suggested-by: Joe Perches > --- > Changelog: > v1->v2: Fix commit message. > > fs/filesystems.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/filesystems.c b/fs/filesystems.c > index a920ad2..8e309d3 100644 > --- a/fs/filesystems.c > +++ b/fs/filesystems.c > @@ -275,6 +275,9 @@ struct file_system_type *get_fs_type(const char *name) > const char *dot = strchr(name, '.'); > int len = dot ? dot - name : strlen(name); > > + if (len >= PATH_MAX) > + return NULL; > + > fs = __get_fs_type(name, len); > if (!fs && (request_module("fs-%.*s", len, name) == 0)) { > fs = __get_fs_type(name, len); > Hi Al Viro, Can you please let me know if you have any review comments about this patch. -- chandan