From patchwork Thu Oct 13 19:58:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineeth Remanan Pillai X-Patchwork-Id: 9375703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DF81F607FD for ; Thu, 13 Oct 2016 19:59:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D35432A1B2 for ; Thu, 13 Oct 2016 19:59:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C519C2A1B4; Thu, 13 Oct 2016 19:59:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B69A22A1B2 for ; Thu, 13 Oct 2016 19:59:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756408AbcJMT7V (ORCPT ); Thu, 13 Oct 2016 15:59:21 -0400 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:36594 "EHLO smtp-fw-2101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751981AbcJMT7U (ORCPT ); Thu, 13 Oct 2016 15:59:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1476388760; x=1507924760; h=from:to:cc:subject:date:message-id; bh=yFSQDO9vdRLL6OgKlh44e0Du47Z1IVxa17MTYviBpg8=; b=HRQCHA+c34pLBhtqRIgHxlfXR1G/b7UupCc3aT3yCW7KpAIM+NcnQ6yD nQuEwjoGCFKH45F/g3bFRmYh86FpC61Nbp/1HRgBr1su8zt0G9e8E3dBH fLxJSiHzqX1AIyDVfBSKez3owEXhROenuUv9KYEwRVCqHB5zi0xYjuq5I s=; X-IronPort-AV: E=Sophos;i="5.31,489,1473120000"; d="scan'208";a="617688875" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-6005.iad6.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 13 Oct 2016 19:59:19 +0000 Received: from dev-dsk-vineethp-a-i-1153bf85.us-west-2.amazon.com (iad1-ws-svc-lb91-vlan2.amazon.com [10.0.103.146]) by email-inbound-relay-6005.iad6.amazon.com (8.14.7/8.14.7) with ESMTP id u9DJxGdJ018882; Thu, 13 Oct 2016 19:59:17 GMT From: Vineeth Remanan Pillai To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vineeth Remanan Pillai , kamatam@amazon.com, aliguori@amazon.com Subject: [PATCH] namei: revert old behaviour for filename_lookup with LOOKUP_PARENT flag Date: Thu, 13 Oct 2016 19:58:51 +0000 Message-Id: <1476388731-24053-1-git-send-email-vineethp@amazon.com> X-Mailer: git-send-email 2.1.2.AMZN Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP filename_lookup used to return success for non-existing file when called with LOOKUP_PARENT flag. This behaviour was changed with commit 8bcb77fabd7c ("namei: split off filename_lookupat() with LOOKUP_PARENT") The above patch split parent lookup functionality to a different function filename_parentat and changed all calls to filename_lookup(LOOKUP_PARENT) to the new function filename_parentat. But functions like kern_path which passed the flags directly to filename_lookup regressed due to this. This patch aims to fix the regressed behaviour by calling filename_parentat from filename_lookup if the flags contain LOOKUP_PARENT. Signed-off-by: Vineeth Remanan Pillai --- fs/namei.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fs/namei.c b/fs/namei.c index adb0414..e16ab09 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2292,6 +2292,21 @@ static int filename_lookup(int dfd, struct filename *name, unsigned flags, { int retval; struct nameidata nd; + + if (flags & LOOKUP_PARENT) { + struct qstr last; + struct filename *filename; + int type; + + filename = filename_parentat(dfd, name, flags ^ LOOKUP_PARENT, + path, &last, &type); + if (IS_ERR(filename)) + return PTR_ERR(filename); + + putname(filename); + return 0; + } + if (IS_ERR(name)) return PTR_ERR(name); if (unlikely(root)) {