Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754296AbcJNCsA (ORCPT ); Thu, 13 Oct 2016 22:48:00 -0400 Received: from mail-vk0-f65.google.com ([209.85.213.65]:36073 "EHLO mail-vk0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752071AbcJNCrw (ORCPT ); Thu, 13 Oct 2016 22:47:52 -0400 MIME-Version: 1.0 In-Reply-To: <1476371737-2116-1-git-send-email-geert@linux-m68k.org> References: <1476371737-2116-1-git-send-email-geert@linux-m68k.org> From: "Yan, Zheng" Date: Fri, 14 Oct 2016 10:47:51 +0800 Message-ID: Subject: Re: [PATCH] ceph: Fix uninitialized dentry pointer in ceph_real_mount() To: Geert Uytterhoeven Cc: Zheng Yan , Ilya Dryomov , ceph-devel , linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id u9E2m3x3021826 Content-Length: 1423 Lines: 44 On Thu, Oct 13, 2016 at 11:15 PM, Geert Uytterhoeven wrote: > fs/ceph/super.c: In function ‘ceph_real_mount’: > fs/ceph/super.c:818: warning: ‘root’ may be used uninitialized in this function > > If s_root is already valid, dentry pointer root is never initialized, > and returned by ceph_real_mount(). This will cause a crash later when > the caller dereferences the pointer. > > Fix this by initializing root early. > > Fixes: ce2728aaa82bbeba ("ceph: avoid accessing / when mounting a subpath") > Signed-off-by: Geert Uytterhoeven > --- > Compile-tested only. > --- > fs/ceph/super.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/ceph/super.c b/fs/ceph/super.c > index a29ffce981879d5f..794c5fd0e0cf5e45 100644 > --- a/fs/ceph/super.c > +++ b/fs/ceph/super.c > @@ -821,7 +821,8 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc) > dout("mount start %p\n", fsc); > mutex_lock(&fsc->client->mount_mutex); > > - if (!fsc->sb->s_root) { > + root = fsc->sb->s_root; > + if (!root) { > const char *path; > err = __ceph_open_session(fsc->client, started); > if (err < 0) For sb->s_root is not NULL case, we also need to increase sb->s_root's reference count. I applied this patch and fixed it. Regards Yan, Zheng > -- > 1.9.1 >