Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3795765img; Mon, 25 Mar 2019 18:43:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqJ0Qd/Qkny+bNVOaDmOIH4hqaI++PvaoBwxVMExtxwSse7ve07II8EoVQCxuk0Khu8Skj X-Received: by 2002:a17:902:9043:: with SMTP id w3mr28140872plz.101.1553564601694; Mon, 25 Mar 2019 18:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553564601; cv=none; d=google.com; s=arc-20160816; b=nNs5PpiO+4SgLvhR9hDKJKFx9la4x1UQ+QwDPtA4mfrw25gMukOIxx6aBis2nVGCTg H9Nk1F3wqjMnnUpNAFdk2updjSw18cib2MH4sTg0M7fyM9uAGS0v8fV4JoQSlxH9DRHM yrx4/8m1BzptVrQAVz4LKMSh/1Wd/oUNtFJmf0cKW92uJbAJ1jmI2+xMRP+6MTYoDj71 F73gG4NKj8uphNBRy/2joEOmZrRXeOZbE1ZvO2V4ggzJGI2XxJ554w2tQsQnGgILvoxn 663ggSTMVM4Dkim/yweGHwLKrrBpa62SK04udeI4swpwlqdosxn39DLA78mJL5jDSSau bx/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=5tgfMNk3fLDQCLo0CYfxDJ/O2q+L9v/1Ewth5/EdBzg=; b=iCoRMrdhGe2OyOj3OB0agjkNxGNGF7SpRJQT22US5jt6uGuX58DncUdxtm9mLyLh7B 99EJkd1FNoQJrtTp1wUdeOrU7hyze8aXZ7CT9zHD8I8ETd4A+6Ju5btA/G2VITZYa8h3 NgRdXQtITRfnvSDCOH/QkXe6SmZDyBHC1xLc/FfpPDqUcJcdts0Xk2KfcwN3fsEznx6P jsQYGwPxrMVjqUw+3lsoPhRj7g7uUkRNNyLmbe3OT3+NhEuN2gdjLjTHSOqPbLykd7iq OgRf3CtGGqPm4N0Io3lfzKxWmMRR7/XLvWFPkd33X5YMUTNOCSWgjAZ4py4XiTBuHR8n 1fMw== ARC-Authentication-Results: i=1; mx.google.com; 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 n8si15431109plk.316.2019.03.25.18.43.06; Mon, 25 Mar 2019 18:43:21 -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; 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 S1730918AbfCZBkn (ORCPT + 99 others); Mon, 25 Mar 2019 21:40:43 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:58644 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727506AbfCZBkm (ORCPT ); Mon, 25 Mar 2019 21:40:42 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1h8b4x-0004Yr-0Z; Tue, 26 Mar 2019 01:40:39 +0000 Date: Tue, 26 Mar 2019 01:40:38 +0000 From: Al Viro To: Linus Torvalds Cc: syzbot , Alexei Starovoitov , Daniel Borkmann , linux-fsdevel , Linux List Kernel Mailing , syzkaller-bugs Subject: ubifs: fix use-after-free on symlink traversal Message-ID: <20190326014038.GW2217@ZenIV.linux.org.uk> References: <0000000000006946d2057bbd0eef@google.com> <20190325045744.GK2217@ZenIV.linux.org.uk> <20190325211405.GP2217@ZenIV.linux.org.uk> <20190325233731.GS2217@ZenIV.linux.org.uk> <20190326013858.GU2217@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190326013858.GU2217@ZenIV.linux.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 8dc2818fdd84..12628184772c 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -276,14 +276,12 @@ static void ubifs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); struct ubifs_inode *ui = ubifs_inode(inode); + kfree(ui->data); kmem_cache_free(ubifs_inode_slab, ui); } static void ubifs_destroy_inode(struct inode *inode) { - struct ubifs_inode *ui = ubifs_inode(inode); - - kfree(ui->data); call_rcu(&inode->i_rcu, ubifs_i_callback); }