Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1126400pxb; Wed, 15 Sep 2021 23:40:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3MYLV+FcGE1L02PrX0o8b2DPcscsVc9Fq/9T3mikr41FIIJ0CuIKN5M4RLMW1fqruZEM6 X-Received: by 2002:a05:6e02:1bc2:: with SMTP id x2mr2847330ilv.98.1631774454302; Wed, 15 Sep 2021 23:40:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631774454; cv=none; d=google.com; s=arc-20160816; b=ITd9ZQcrorJI17pV49vxenBS1p/RWEIlvdPdLokHHDwQC/osPxsPeaqRAXcdid8U1P aG9masglbLNyxlkgEZPP8DehXLkOjUX9a/OuWcTyZE83Q/1xBIJkoacIvM6ZGF2NQOYZ kNmIv1XP87UtDn3GjXU+s74aFtiCaOaWfG0zOo1M9UT4PXFuAmvBQwnEZT21UasT9DZb Hoj1JcGObCfWGY1pI5L1QtsBwVmYU2JvSqPNDV6+EKJ5pKimlSueeNIIbGjgYs1ULSqB YvUKLPvkndHK20LxIPOTmTo0yld0zEVHWcyT6f9dYvMdVlH9OYTVHuP+hCcKnc/iB2FV 4pBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7BbuzwOthGVRqV8KZor3zQQ2pilc0nFfPq3ri52XdlM=; b=G9TJgoAbwglblWOcPMro8gLGFitTlHvbtO/CCCntwmoxfPvWxYHufOSLNoKwh3ccDP 4TK6gtsKNV/m5aDDcMHBKDfD4Yr/dG5JgBcH4przaQf4MoxSJA56jRCCbWopBsD5R6p5 I883Fl7mSL6OJCR/en7019UF2bvRZh4JVkbE/3CZnO6v+tcp99vxDdhBt6rjEI4rLKtN 2DCT9fiqUm7K2mopyGpkdSvVXnHw8uKQdhwYkHkC6kckkuDWXZFHCYv8ZbAqt3uOhSTw OtU/5Gd0obAZRmlDD+xnjWB7yeNmlR1PEExE77XSI9FlxRS1hG6kMuojQpzASXMT7fP6 Hmmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=jyQaVrli; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si2075736ilj.162.2021.09.15.23.40.42; Wed, 15 Sep 2021 23:40:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=jyQaVrli; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234552AbhIPGlX (ORCPT + 99 others); Thu, 16 Sep 2021 02:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234505AbhIPGlW (ORCPT ); Thu, 16 Sep 2021 02:41:22 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 261C3C061574; Wed, 15 Sep 2021 23:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=7BbuzwOthGVRqV8KZor3zQQ2pilc0nFfPq3ri52XdlM=; b=jyQaVrliIgQoL05ExjcW2HtXwO OkntrAQuOUDI/s3Hb3yICfIhHkK/OH05ncz+FjvCZE2yrk/hB7iqcg4y/SVq5AhESnfSmdRj2CeYI m6XKJYTZTwoyCTId3snqur1urlSvkGVgaBP6nd6NxsgGOscJXUSZhUhljhywneeBYujPg7LqpgSJx ePmMieZYnfH/2NtqEy0zGKNxfysRLhWys68FzmkHET68k/5S0lMZYzONHG/tx1Xjdo4+s7yQpka4s agnBMCGDH19ouIvzKDxndQegOuZDXuAtLuD1kK12filXsQdW+BXEttO1njalILinutDXS453CG1E9 YzMQAHFw==; Received: from hch by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQl38-00GNxg-QV; Thu, 16 Sep 2021 06:39:18 +0000 Date: Thu, 16 Sep 2021 07:39:10 +0100 From: Christoph Hellwig To: Vivek Goyal Cc: viro@zeniv.linux.org.uk, Linux fsdevel mailing list , linux kernel mailing list , Jan Kara , xu.xin16@zte.com.cn, Christoph Hellwig , zhang.yunkai@zte.com.cn Subject: Re: [PATCH] init/do_mounts.c: Harden split_fs_names() against buffer overflow Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 15, 2021 at 11:22:04AM -0400, Vivek Goyal wrote: > Will be nice to pass size of input buffer to split_fs_names() and > put enough checks in place so such buffer overrun possibilities > do not occur. Will be nice sounds weird. > > Hence this patch adds "size" parameter to split_fs_names() and makes > sure we do not access memory beyond size. If input string "names" > is larger than passed in buffer, input string will be truncated to > fit in buffer. There's really two aspects here: checking for a max size and explicitly passing one. I'm fine with passing the argument even if it always is PAGE_SIZE, but this should probably be documented a little better. Otherwise looks good: Reviewed-by: Christoph Hellwig