From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01357C04E53 for ; Wed, 15 May 2019 12:19:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9DEF20843 for ; Wed, 15 May 2019 12:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557922788; bh=6GBlRDutjYYSnUOI+q1Z1S5qJL1lRgpLPV4+WuZIv1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zWECkSZhzGaaQSacwAvXHbC2xa8Sg2UTUJsu8Ruh4CCTMZT+eoGIjDjFjyVznEQcy SxhV+i1Is+OnNp+dUEtoyPIvliCfbHh+rT+zH+xR9+S+3o51bZAX/EDR346cnAiB/F QLvIIa6WwzPB797NYPA+MoclFNzzQISXgOi7l5x8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727424AbfEOLA1 (ORCPT ); Wed, 15 May 2019 07:00:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:57216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbfEOLAZ (ORCPT ); Wed, 15 May 2019 07:00:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3938420881; Wed, 15 May 2019 11:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918024; bh=6GBlRDutjYYSnUOI+q1Z1S5qJL1lRgpLPV4+WuZIv1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cHZ4wULsB9ZnqEjkVFr1ZoHL/DgnDVprL7FW9oLlQ4n92U9duts8yZi5kFxZJcp08 QP6qapn4kvPoQJHB4mWiduJjSCbY+n+Gdvas4o4qX6feg2NF79p9VPgDdwLOqLtiav yDO5teq9BI4kqJYfOwhu+LPOW2Z+GDQ74zPTlPr8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , Jeff Layton , Ilya Dryomov , "Sasha Levin (Microsoft)" Subject: [PATCH 3.18 24/86] ceph: fix use-after-free on symlink traversal Date: Wed, 15 May 2019 12:55:01 +0200 Message-Id: <20190515090647.754349132@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090642.339346723@linuxfoundation.org> References: <20190515090642.339346723@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit daf5cc27eed99afdea8d96e71b89ba41f5406ef6 ] free the symlink body after the same RCU delay we have for freeing the struct inode itself, so that traversal during RCU pathwalk wouldn't step into freed memory. Signed-off-by: Al Viro Reviewed-by: Jeff Layton Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin (Microsoft) --- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 7a1df90c7771..7641fcf83ac8 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -472,6 +472,7 @@ static void ceph_i_callback(struct rcu_head *head) struct inode *inode = container_of(head, struct inode, i_rcu); struct ceph_inode_info *ci = ceph_inode(inode); + kfree(ci->i_symlink); kmem_cache_free(ceph_inode_cachep, ci); } @@ -503,7 +504,6 @@ void ceph_destroy_inode(struct inode *inode) ceph_put_snap_realm(mdsc, realm); } - kfree(ci->i_symlink); while ((n = rb_first(&ci->i_fragtree)) != NULL) { frag = rb_entry(n, struct ceph_inode_frag, node); rb_erase(n, &ci->i_fragtree); -- 2.19.1