From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 947F924466C for ; Sat, 4 Apr 2026 16:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775319355; cv=none; b=PJAgaXvYDxClUQFO96WkheE6+7NxYmQb8w36kh4ccOBtQcJiWwW9ZbnC+gtn/4TjQoLv+qbUzDuRYhanGeXxAkQ0gMsblHznLXPTIjKAa5GA1BE6yuNEXI+6XmOxSxkpJMjKARb7R+pj32Q4pH107b81Bigk8fGVOJaPxhvC2v0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775319355; c=relaxed/simple; bh=BvWvbjC370o99H7WRSGi4DdGeFCV13brI+ZHs/LyukE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=grVGt4d3slr1s0WnrffrtlhFkMlHxd234yfeeec585aS7wKffeJ0AtwQytTcIDlh74HXTRlemrdJfd3GXEjaNZj+sYpspXVkt6kxmcXU75fQP1br/xtRqW3JXV5IIIuXcoA8lEmuA/k1q6KxbsfsOpMLNj5+rcx6pQ+Vz30bwBQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=swh/5Nz9; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="swh/5Nz9" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NdDIooNat2ROwutPU1pR9YzFStaAeOq1jK+HAeyn4pU=; b=swh/5Nz9uQ1EMmkd6SMwo/tdtl jA1VmEUiYWvqhDNz+DQ4yCyBnXRTDbOw7Y5G5qIlEOYO9JlqSvzUDCW2e4oHHzDK7Ng5qlGFQq0Ai BCs/Chat+rUvljaI/vjZoyFlJqQF4j8PAsPlXi7vdP4U82c/CNL9w8o35yA7cRiLA8Y/CoRT0SAH5 rUnuq2RJVKFGOnHYbdH0zLnE2r/SD92zagaVBuONap991JllRVxnAeyIf6thqsZPbmWzpB5+Nta0B I9dsf90yqFlwsiPPo3KnQp1CUpULibHd+p20zis6S36cD8w36rwTYsayYqG6Ucbk4eTU5CBsBKU3Y +2o9U6iw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1w93ib-0000000BZk0-3DUd; Sat, 04 Apr 2026 16:19:29 +0000 Date: Sat, 4 Apr 2026 17:19:29 +0100 From: Al Viro To: Zhan Xusheng Cc: Konstantin Komarov , linux-kernel@vger.kernel.org, Zhan Xusheng Subject: Re: [PATCH] fs/ntfs3: fix potential double iput on d_make_root() failure Message-ID: <20260404161929.GQ3836593@ZenIV> References: <20260326091232.92760-1-zhanxusheng@xiaomi.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260326091232.92760-1-zhanxusheng@xiaomi.com> Sender: Al Viro On Thu, Mar 26, 2026 at 05:12:32PM +0800, Zhan Xusheng wrote: > d_make_root() consumes the reference to the passed inode: it either > attaches it to the newly created dentry on success, or drops it via > iput() on failure. > > In the error path, the code currently does: > sb->s_root = d_make_root(inode); > if (!sb->s_root) > goto put_inode_out; > > which leads to a second iput(inode) in put_inode_out. This results in > a double iput and may trigger a use-after-free if the inode gets freed > after the first iput(). > > Fix this by jumping directly to the common cleanup path, avoiding the > extra iput(inode). Matter of fact, the whole put_inode_out should go; if you *ever* get an inode with NULL ->i_op, it's a bug. NULL should never be stored there; not even transiently. Yes, ntfs_read_mft() _is_ bogus, as NTFS folks had been repeatedly told before, to no visible effect.