From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff King Subject: Re: [PATCH 2/1] apply: reject input that touches outside $cwd Date: Fri, 30 Jan 2015 13:24:56 -0500 Message-ID: <20150130182456.GA29477@peff.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: Git Mailing List , Josh Boyer , "Linux-Kernel@Vger. Kernel. Org" , twaugh@redhat.com, Linus Torvalds To: Junio C Hamano X-From: linux-kernel-owner@vger.kernel.org Fri Jan 30 19:25:08 2015 Return-path: Envelope-to: glk-linux-kernel-3@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YHGFf-0005CH-HM for glk-linux-kernel-3@plane.gmane.org; Fri, 30 Jan 2015 19:25:07 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763006AbbA3SZA (ORCPT ); Fri, 30 Jan 2015 13:25:00 -0500 Received: from cloud.peff.net ([50.56.180.127]:43380 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754116AbbA3SY7 (ORCPT ); Fri, 30 Jan 2015 13:24:59 -0500 Received: (qmail 30783 invoked by uid 102); 30 Jan 2015 18:24:59 -0000 Received: from Unknown (HELO peff.net) (10.0.1.1) by cloud.peff.net (qpsmtpd/0.84) with SMTP; Fri, 30 Jan 2015 12:24:59 -0600 Received: (qmail 25968 invoked by uid 107); 30 Jan 2015 18:25:28 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.84) with SMTP; Fri, 30 Jan 2015 13:25:28 -0500 Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Fri, 30 Jan 2015 13:24:56 -0500 Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Archived-At: On Thu, Jan 29, 2015 at 03:48:14PM -0800, Junio C Hamano wrote: > By default, a patch that affects outside the working area is > rejected as a mistake; Git itself never creates such a patch > unless the user bends backwards and specifies nonstandard > prefix to "git diff" and friends. > > When `git apply` is used without either `--index` or `--cached` > option as a "better GNU patch", the user can pass `--allow-uplevel` > option to override this safety check. This cannot be used to escape > outside the working tree when using `--index` or `--cached` to apply > the patch to the index. It looks like your new --allow-uplevel goes to verify_path(). So this isn't just about "..", but it will also protect against applying a patch inside ".git". Which seems like a good thing to me, but I wonder if the option name is a little misleading. It is really about applying the same checks we do for index paths to the non-index mode of "git apply". > * Meant to apply on top of the previous one, but these two are > about separate and orthogonal issues. I agree they are orthogonal in concept, though I doubt the symlink tests here would pass without the previous one (since verify_path does not know or care about crossing symlink boundaries). -Peff