From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C809FC282D8 for ; Fri, 1 Feb 2019 06:58:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B52120869 for ; Fri, 1 Feb 2019 06:58:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726060AbfBAG6J (ORCPT ); Fri, 1 Feb 2019 01:58:09 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:47674 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbfBAG6I (ORCPT ); Fri, 1 Feb 2019 01:58:08 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.91 #2 (Red Hat Linux)) id 1gpSm6-0003NF-DY; Fri, 01 Feb 2019 06:58:06 +0000 Date: Fri, 1 Feb 2019 06:58:06 +0000 From: Al Viro To: Chandan Rajendra Cc: linux-fsdevel@vger.kernel.org, joe@perches.com, miklos@szeredi.hu Subject: Re: [PATCH] copy_mount_string: Limit string length to PATH_MAX Message-ID: <20190201065806.GO2217@ZenIV.linux.org.uk> References: <20190122065152.19173-1-chandan@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190122065152.19173-1-chandan@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Jan 22, 2019 at 12:21:52PM +0530, Chandan Rajendra wrote: > On ppc64le, When a string with PAGE_SIZE - 1 (i.e. 64k-1) length is > passed as a "filesystem type" argument to the mount(2) syscall, > copy_mount_string() ends up allocating 64k (the PAGE_SIZE on ppc64le) > worth of space for holding the string in kernel's address space. > > Later, in set_precision() (invoked by get_fs_type() -> > __request_module() -> vsnprintf()), we end up assigning > strlen(fs-type-string) i.e. 65535 as the > value to 'struct printf_spec'->precision member. This field has a width > of 16 bits and it is a 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 limiting the length of the string passed by > copy_mount_string() to strndup_user() to PATH_MAX. > > Signed-off-by: Chandan Rajendra > Reported-by: Abdul Haleem > Suggested-by: Al Viro Applied