Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp462740imm; Sat, 7 Jul 2018 00:58:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd/gi8sXD1XmsWFTORDXzIofGtUKNInrIquzax2UHiBE3zW3jiPMHEd6qerEwlEgLoRaPxD X-Received: by 2002:a17:902:20ca:: with SMTP id v10-v6mr12850609plg.255.1530950331030; Sat, 07 Jul 2018 00:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530950330; cv=none; d=google.com; s=arc-20160816; b=Ef5DF8/kcUhWGG3EjnU58Pv01qrmBRp6Dt+vVj/SUG/Uv/xkKcjY08VKpJGm7rQy1O VANv6osWTdYwS9qDla8TNHIiTgpnp+tAKLF+egeHfiqdxdlI91ldEi8D8Sv8TrXBtk1r Z2TNEwbTE4nJ7G72ZApSFezdXrJGkTN3PH6EermCVABEA6BggiTCKx/3DkjHE9qFXtF0 tkaavDhB2gnXuVl8MRYuKr5k9pcL2Ts01ZlarEa+mjg90JrIYYhhWrYJ0nTsfbCelHc0 fzk6BZBzDGNbs+lRtG/vdpVzPMtrcTlC1vm5OWUDMBEZpRUHPUwMx74fXyZ7Bz2h95A9 qRpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=GxkHHMl5alDbUfflkUzqMLJxd7aCq4Hv8WqOX/N6UpA=; b=Ogp+sIYjKuenj4daaGBOdbj7WgdDk7kNlXaKshI94uLOvIoNgXZJetkk48EajgOziw Jl+g6ACe+0no/GSJAKClA2mp+/b1c3pYl1bltzKYD7IPrjuFIFnEFafYPDHJ4vse6VKK DjBPCUg/Nu1qcf6idaRqpBtywKKmpX+Q9Gf1pEFBSibqAF9JcfqzqV9TxkBmIeY1/3nv j/egsL3FA6yeDKZkb1/9bzHjJS9kdcEUf7K0zlnKEMhP+nib33l9P0ZscuXL3ZteNe0T Mj2tXklJZ+fvcEAhuF3tAexS4xjXnPu6l8Dr+f5lkczScsalrKQK5vSlz70/bMdxJmJP MHwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2-v6si9126739pgr.33.2018.07.07.00.58.36; Sat, 07 Jul 2018 00:58:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752171AbeGGH56 (ORCPT + 99 others); Sat, 7 Jul 2018 03:57:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36994 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750973AbeGGH56 (ORCPT ); Sat, 7 Jul 2018 03:57:58 -0400 Received: from localhost (unknown [37.170.5.79]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D921DAD2; Sat, 7 Jul 2018 07:57:56 +0000 (UTC) Date: Sat, 7 Jul 2018 09:56:31 +0200 From: Greg Kroah-Hartman To: Bernd Edlinger Cc: Tejun Heo , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] Fix range checks in kernfs_get_target_path Message-ID: <20180707075631.GA24038@kroah.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 06, 2018 at 09:08:49PM +0000, Bernd Edlinger wrote: > The strncpy causes a warning [-Wstringop-truncation] here, > which indicates that it never appends a NUL byte to the path. > The NUL byte is only there because the buffer is allocated > with kzalloc(PAGE_SIZE, GFP_KERNEL), but since the range-check > is also off-by-one, and PAGE_SIZE==PATH_MAX the returned string > will not be zero-terminated if it is exactly PATH_MAX characters. > Furthermore also the initial loop may theoretically exceed PATH_MAX > and cause a fault. > > Signed-off-by: Bernd Edlinger > --- > fs/kernfs/symlink.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/fs/kernfs/symlink.c b/fs/kernfs/symlink.c > index 08ccabd..c8b7d44a 100644 > --- a/fs/kernfs/symlink.c > +++ b/fs/kernfs/symlink.c > @@ -63,7 +63,10 @@ static int kernfs_get_target_path(struct kernfs_node > *parent, Your patch is line-wrapped and can not be applied :(