From patchwork Tue May 5 05:22:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 6334661 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 430849F32E for ; Tue, 5 May 2015 05:32:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7552220268 for ; Tue, 5 May 2015 05:32:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8879120266 for ; Tue, 5 May 2015 05:32:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965395AbbEEFcW (ORCPT ); Tue, 5 May 2015 01:32:22 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:40069 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755635AbbEEFXI (ORCPT ); Tue, 5 May 2015 01:23:08 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.76 #1 (Red Hat Linux)) id 1YpVJy-0001P5-6T; Tue, 05 May 2015 05:23:06 +0000 From: Al Viro To: Linus Torvalds Cc: Neil Brown , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 77/79] namei: move unlazying on symlinks towards get_link() call sites Date: Tue, 5 May 2015 06:22:51 +0100 Message-Id: <1430803373-4948-77-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <20150505052205.GS889@ZenIV.linux.org.uk> References: <20150505052205.GS889@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Al Viro Signed-off-by: Al Viro --- fs/namei.c | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 98e932c..eb3f7d9 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -538,10 +538,18 @@ static void restore_nameidata(struct nameidata *old) static int __nd_alloc_stack(struct nameidata *nd) { - struct saved *p = kmalloc(MAXSYMLINKS * sizeof(struct saved), - GFP_KERNEL); - if (unlikely(!p)) - return -ENOMEM; + struct saved *p; + if (nd->flags & LOOKUP_RCU) { + p = kmalloc(MAXSYMLINKS * sizeof(struct saved), + GFP_ATOMIC); + if (unlikely(!p)) + return -ECHILD; + } else { + p = kmalloc(MAXSYMLINKS * sizeof(struct saved), + GFP_KERNEL); + if (unlikely(!p)) + return -ENOMEM; + } memcpy(p, nd->internal, sizeof(nd->internal)); nd->stack = p; return 0; @@ -1561,12 +1569,6 @@ static int pick_link(struct nameidata *nd, struct path *link) path_to_nameidata(link, nd); return -ELOOP; } - if (nd->flags & LOOKUP_RCU) { - if (unlikely(nd->path.mnt != link->mnt || - unlazy_walk(nd, link->dentry))) { - return -ECHILD; - } - } error = nd_alloc_stack(nd); if (unlikely(error)) { path_to_nameidata(link, nd); @@ -1839,7 +1841,17 @@ OK: break; if (err) { - const char *s = get_link(nd); + const char *s; + + if (nd->flags & LOOKUP_RCU) { + if (unlikely(nd->link.mnt != nd->path.mnt || + unlazy_walk(nd, nd->link.dentry))) { + err = -ECHILD; + break; + } + } + + s = get_link(nd); if (unlikely(IS_ERR(s))) { err = PTR_ERR(s); @@ -1992,7 +2004,16 @@ static void path_cleanup(struct nameidata *nd) static int trailing_symlink(struct nameidata *nd) { const char *s; - int error = may_follow_link(&nd->link, nd); + int error; + + if (nd->flags & LOOKUP_RCU) { + if (unlikely(nd->link.mnt != nd->path.mnt || + unlazy_walk(nd, nd->link.dentry))) { + terminate_walk(nd); + return -ECHILD; + } + } + error = may_follow_link(&nd->link, nd); if (unlikely(error)) return error; nd->flags |= LOOKUP_PARENT;