Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2571809yba; Mon, 6 May 2019 08:10:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwb+vHDCArZrkcRKYRqWzzBUQpzwZXMAG5F140xOOnI1zTvgU5B937c1LCSEP49C4B6jbgL X-Received: by 2002:a62:e50a:: with SMTP id n10mr34330752pff.55.1557155420753; Mon, 06 May 2019 08:10:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557155420; cv=none; d=google.com; s=arc-20160816; b=O/c1hV6z9ORP9N0P9GvuOZnbRii+1Lc+/P8FD3Sl39GzSEi91Y/5cMjQz/EUkGoK8V k20W5aOfMB2EhmMhZWkF3liEmZ3/JQMNKV7pr+47+kQJ/aBi0wGgb+Up33X9Vsd2ofnt P/xGEumb6lPeEzrSQoDWcbsOMI/SCTOnYfKMjS4RENwIrkX37/fFZf/xRTj9QpDWsqLo oYc3/5EqfX7gH/cCzYVJ0/An15txcsLT03tAdWOEB1ZlL+lbx303sUu1IkYBGVbS4K5E ivhdJoI+iImKJQYuCiaAWdByR9Vic39rsaGTYXP0OYA2pm7JzyibRkcAbCwN9d59YSA0 UOUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CQYaORWFj1Ia+boU9hGt4VtaV6ZBgID0HgPm+q/FfGA=; b=BSf/FUbixUn6nw4l2eDiNvYIxtbMGnkpKuVfrLWLjfsKKO8IHrhWPo8HQ69AXt+l8B dr19yc6EDvuz9diV3Nv/rtutxo4gI2yqpSwALizS/LGRWQtSN0BdPn8fKGCwcxThsS21 GE9HW6ll/EFVppv5rvjZZ4j+Fzrd+wC1O8ja0QQJ1yiTnZvydKBWUF3GlkSCkJMkAco2 cBKAQbzAwRaSvV8WL5nQ7LRt6lab4HWEP9LFkxJQCXVrLD70WoM/MRRBHRO25pFZynig 1gxRW9JV63P4M3s8+RUY+72BcyDohSR3SVoOLv//VJGaS0cLz1awLAmjppuzGCfrATJq asRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0F5uMvM9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si16842495pln.52.2019.05.06.08.10.04; Mon, 06 May 2019 08:10:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0F5uMvM9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727037AbfEFOfz (ORCPT + 99 others); Mon, 6 May 2019 10:35:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:56050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727016AbfEFOfu (ORCPT ); Mon, 6 May 2019 10:35:50 -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 AC78920B7C; Mon, 6 May 2019 14:35:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153350; bh=JpkTfvP7iuybK9XXJKIRzG4hbXM/kJ8qskJAtD0sy8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0F5uMvM9W2WBcBzx+bGOeO3/2Kx5eSRULb0KWzLvKrAboR27LFV6VSLQdke2tgdFU 9bXb7zb07Owu6Li0T87iooZpMfbqnQcUBUPpV6MeImtGIXTTXQaeEgewm50KvzYdmu IXC9SUbtrUZ+Hs7+mgTbHeGnSyVyNrWCecOkmcd0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , "Sasha Levin (Microsoft)" Subject: [PATCH 5.0 056/122] jffs2: fix use-after-free on symlink traversal Date: Mon, 6 May 2019 16:31:54 +0200 Message-Id: <20190506143100.011884860@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143054.670334917@linuxfoundation.org> References: <20190506143054.670334917@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 4fdcfab5b5537c21891e22e65996d4d0dd8ab4ca ] 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 Signed-off-by: Sasha Levin (Microsoft) --- fs/jffs2/readinode.c | 5 ----- fs/jffs2/super.c | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index 389ea53ea487..bccfc40b3a74 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c @@ -1414,11 +1414,6 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f) jffs2_kill_fragtree(&f->fragtree, deleted?c:NULL); - if (f->target) { - kfree(f->target); - f->target = NULL; - } - fds = f->dents; while(fds) { fd = fds; diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index bb6ae387469f..05d892c79339 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c @@ -47,7 +47,10 @@ static struct inode *jffs2_alloc_inode(struct super_block *sb) static void jffs2_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); + + kfree(f->target); + kmem_cache_free(jffs2_inode_cachep, f); } static void jffs2_destroy_inode(struct inode *inode) -- 2.20.1