Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3793903img; Mon, 25 Mar 2019 18:40:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMvJIZqGKLxaL3uVO0L86Y6LIp1dPKvNhk4L97ajl9jA1Vvru/t0q+OKfxntC+xq3c3bby X-Received: by 2002:a63:7444:: with SMTP id e4mr7638255pgn.261.1553564404905; Mon, 25 Mar 2019 18:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553564404; cv=none; d=google.com; s=arc-20160816; b=WDIeYc8KBiigIsiOiW31+/8Bne3gimnXIbTaEQfiBprV5aKmnoZ9iNzrFng9thtzn0 afVbAmuw8rt43qm/jpWdwAMT9iAAKB7LixcHJO75AIOWshENv+h8ru/ergFu2nbvlzwN G1PCuRNpc/nO1CmleYver5Nc6FZ3DJvSh4FOQuSQPymBLquh+KZyhkrgU/s+UF4fduJO PVzVukXd8bw6QGNRszvSQQ4jVixPoyRLmwjISdLUn34Bg5MPgA0W6LMBU63Pbtwe3Uv0 cIMNkBF9NtU5op6FIginHdEcZnqUNSH4OqEyuMHYsRewIdmSU6uxaI5Zm1KPeXe2/2EW xybg== 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=0hWPv89aKrmHjNuWNaQhzQjW4JXy0dL622tANAQXZeo=; b=CrYPV9S9NLCfTAoj2XWpkzYohTtKoQDRVU5+SNq7RJLjydzDUiXnzrYKz5q2Lheg4a vMyKtn63uyi0llZFg7Y7Q3NGMbxk+nwzZVZV4Nx/8yNRgt8CuQXbx3w8RP4fFn8/+bR+ WD69cGe0nN2SSIrhJGHpXf56HEkpmG7KhSWQQBgGDEbG8aR3nTo69dXWxenqW17mVzDu EqrCvd/IhYQ0sXUgVX9tbi6iGr+B968glscE0adKTaKlOgDwLbevoY9HXkpEmZNKiHHL j9ZS44vLY7V26oAAbvgjJHm7eqeQ1ictyZ1BN2PNMTKwpLi5laYNQR38Qvx5z7ZfRAlR 5ILA== 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 s12si14263576pgp.241.2019.03.25.18.39.49; Mon, 25 Mar 2019 18:40:04 -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 S1730624AbfCZBjE (ORCPT + 99 others); Mon, 25 Mar 2019 21:39:04 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:58606 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727412AbfCZBjE (ORCPT ); Mon, 25 Mar 2019 21:39:04 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1h8b3K-0004Vp-Ep; Tue, 26 Mar 2019 01:38:58 +0000 Date: Tue, 26 Mar 2019 01:38:58 +0000 From: Al Viro To: Linus Torvalds Cc: syzbot , Alexei Starovoitov , Daniel Borkmann , linux-fsdevel , Linux List Kernel Mailing , syzkaller-bugs Subject: ceph: fix use-after-free on symlink traversal Message-ID: <20190326013858.GU2217@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190325233731.GS2217@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/ceph/inode.c b/fs/ceph/inode.c index e3346628efe2..2d61ddda9bf5 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -524,6 +524,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); } @@ -566,7 +567,6 @@ void ceph_destroy_inode(struct inode *inode) } } - 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);