From patchwork Tue Nov 26 12:33:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13885859 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B2AC18F2DA for ; Tue, 26 Nov 2024 12:33:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732624441; cv=none; b=ixarP27lA+EK07S9Nr+w1tcfnGAshlAJS4WM5g+w16ioOlVxvLKS+llPoNsE/5BVNjCQqfZNVSAllMXxIOTdgkUKb7Gul7qgreM40MuMsuQHAaJGATrp6jwp/5M5jBNj2P8voMaOVKJdfpeePvrAc5G11ogUA1Ff1eQFvz14bSM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732624441; c=relaxed/simple; bh=c843F4qLc8eeg+M4IQtcd79FGCDz6ZGoJtPZYEpL1uw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IMTQQ0L+SDsptem1Aex8pYEXgC0BgAAbPW/J2Kgkloib9sRSppnBvxeGPiVh7HgP5QnkDrwqbUJK52qGTvnCTNfJ7+E1Ljtc//iLSrEiwIQAUI/DbExlzwil9upuEGiHXSE1LhwG/vfcNjz2d4oFKFdcw/bHHK2N4Mjm8r0HWLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=n72pUCAn; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=m8bvr8Px; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=n72pUCAn; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=m8bvr8Px; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="n72pUCAn"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="m8bvr8Px"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="n72pUCAn"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="m8bvr8Px" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3D86D1F770; Tue, 26 Nov 2024 12:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732624438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zq0paHWaxrcwEjkb69+xpIhndjoU4T+YlqBfan0Ov50=; b=n72pUCAnhZ7wfxlvQgc1RpYw1kbcnqjLW7KQ4MkkyrY5JuZgsGjm5eTg7eTUC9i+4TQeqp UlSH82WsmYPyH0cLh0DONjE/DD39yJ3FzS/4dFID8k0hKJrzo9gsMJw/BikVeDlwtzvCCQ GXHY80J5dkKCKwtZe6VXti3kX2goKDg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732624438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zq0paHWaxrcwEjkb69+xpIhndjoU4T+YlqBfan0Ov50=; b=m8bvr8Pxj8w0h1UZzCtsy2qxLxX95owaHa0L04nB82EuJADbU9nzrvq+WK6XM3g91tH+L0 XU3pULmsxa/1r8Bw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=n72pUCAn; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=m8bvr8Px DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732624438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zq0paHWaxrcwEjkb69+xpIhndjoU4T+YlqBfan0Ov50=; b=n72pUCAnhZ7wfxlvQgc1RpYw1kbcnqjLW7KQ4MkkyrY5JuZgsGjm5eTg7eTUC9i+4TQeqp UlSH82WsmYPyH0cLh0DONjE/DD39yJ3FzS/4dFID8k0hKJrzo9gsMJw/BikVeDlwtzvCCQ GXHY80J5dkKCKwtZe6VXti3kX2goKDg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732624438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zq0paHWaxrcwEjkb69+xpIhndjoU4T+YlqBfan0Ov50=; b=m8bvr8Pxj8w0h1UZzCtsy2qxLxX95owaHa0L04nB82EuJADbU9nzrvq+WK6XM3g91tH+L0 XU3pULmsxa/1r8Bw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2EB6E13A6E; Tue, 26 Nov 2024 12:33:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id /TcYCzbARWfMUAAAD6G6ig (envelope-from ); Tue, 26 Nov 2024 12:33:58 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id C2238A08A6; Tue, 26 Nov 2024 13:33:57 +0100 (CET) From: Jan Kara To: Cc: Jan Kara Subject: [PATCH 1/2] udf: Skip parent dir link count update if corrupted Date: Tue, 26 Nov 2024 13:33:48 +0100 Message-Id: <20241126123349.24798-2-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241126123349.24798-1-jack@suse.cz> References: <20241126123349.24798-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=933; i=jack@suse.cz; h=from:subject; bh=c843F4qLc8eeg+M4IQtcd79FGCDz6ZGoJtPZYEpL1uw=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBnRcAs2/c3857qQsLysjC7VCaYp3xUo23Mszh4XXfP p6JH71GJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZ0XALAAKCRCcnaoHP2RA2eurB/ 9kP8XM+DfKzQfx3CscgpSap71L6odfMSZNcw0oSrwI0rCxcbs7LVfilldcoon3aIovwZzlh0q21pqz ZM2skKXxutyofIJB3cpUaFIvGPJ87BQy1yhOfEUNH6VGV/wYyaI7pg4waDGzQVMr3J6rnD50gAzUYC ojd24SfIvOu9jKQ4k5vPPOxR2mDo1LIvQBGzVGTGN2WCP9fknmQKVs4MHHswLcolnQMbBa4XYTtP9i CXRCzDnbZbt4DxA/hzduPllR3uFdNCpBRvHi6t4HeSWl6HjSywxmQrMy5/GXlBj4ZCZW8PXH32WRE9 pyJ9ejz/WDQ6YzAv3GoSn3L7bOuzyA X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Queue-Id: 3D86D1F770 X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Flag: NO If the parent directory link count is too low (likely directory inode corruption), just skip updating its link count as if it goes to 0 too early it can cause unexpected issues. Signed-off-by: Jan Kara --- fs/udf/namei.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 78a603129dd5..2be775d30ac1 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -517,7 +517,11 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry) inode->i_nlink); clear_nlink(inode); inode->i_size = 0; - inode_dec_link_count(dir); + if (dir->i_nlink >= 3) + inode_dec_link_count(dir); + else + udf_warn(inode->i_sb, "parent dir link count too low (%u)\n", + dir->i_nlink); udf_add_fid_counter(dir->i_sb, true, -1); inode_set_mtime_to_ts(dir, inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode))); From patchwork Tue Nov 26 12:33:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13885861 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B25527442 for ; Tue, 26 Nov 2024 12:33:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732624442; cv=none; b=d3dwnyIvJis60Khfof8ILitbg2onbQZqb3Qgs6KPXITpzD3dtEhchedm0PZ5jI8PN/VgEebQL26cEFx3PLo4XshXDyJl0pIDaae1ZUpFPpFBndUapIjuD6GTK/LlciLn58DaAzD6X0heZLyqETsZueOSmdsv1PBHdGnpJdopNlA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732624442; c=relaxed/simple; bh=EwKrdYK/wuwy4Lq8gR/dyraqGdVWk+4V2eTIlbC8jMQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jA0uUjvCZMX3x0H7qCiwVfSmUSzM+mniYNaQv9Hhy7btOW77fKwmF6P195mTb5NY+A7PoqAMUavTn1JdgQWuECksHi+5S0a3+Nr391BOhcgdqE+kbnxlDj8Sz6/2Eieamts9TGt1msVqRy2pcfhOUnzIR4MNzflMZPfQiFClRSs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=TKzBRPKI; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=tL9iBoWY; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=TKzBRPKI; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=tL9iBoWY; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="TKzBRPKI"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="tL9iBoWY"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="TKzBRPKI"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="tL9iBoWY" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3CF371F745; Tue, 26 Nov 2024 12:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732624438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IMuYAwb1imuEU4MhwhHruanvqPLAeJY1EvyYvhCTLdU=; b=TKzBRPKI/5wmBOuyUh/pXHI2KQxLVoV/JuPDuoKt81LB05bJFBUrLA1BtEnXeG/TQHdBRv X/C68qv1pvYReZYwBGuchbAFWF7M5vxAeC5t7I3+DZfDlv2qgaRHXSaFSScfMt2+/RVRDb 7X104gUHWxKZSCHE1RkemCSeeuctyJ4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732624438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IMuYAwb1imuEU4MhwhHruanvqPLAeJY1EvyYvhCTLdU=; b=tL9iBoWY1xf2jWfxPtfR5hI/qhBOiSwOEwhr7UNTpJ03k+lDobv0WL8/Mm1qWrbTCtiuhi 5meD4pxEErdkdaBw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=TKzBRPKI; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tL9iBoWY DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1732624438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IMuYAwb1imuEU4MhwhHruanvqPLAeJY1EvyYvhCTLdU=; b=TKzBRPKI/5wmBOuyUh/pXHI2KQxLVoV/JuPDuoKt81LB05bJFBUrLA1BtEnXeG/TQHdBRv X/C68qv1pvYReZYwBGuchbAFWF7M5vxAeC5t7I3+DZfDlv2qgaRHXSaFSScfMt2+/RVRDb 7X104gUHWxKZSCHE1RkemCSeeuctyJ4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1732624438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IMuYAwb1imuEU4MhwhHruanvqPLAeJY1EvyYvhCTLdU=; b=tL9iBoWY1xf2jWfxPtfR5hI/qhBOiSwOEwhr7UNTpJ03k+lDobv0WL8/Mm1qWrbTCtiuhi 5meD4pxEErdkdaBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2D03913A27; Tue, 26 Nov 2024 12:33:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WGn6CjbARWfLUAAAD6G6ig (envelope-from ); Tue, 26 Nov 2024 12:33:58 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id CBB72A0901; Tue, 26 Nov 2024 13:33:57 +0100 (CET) From: Jan Kara To: Cc: Jan Kara , syzbot+3ff7365dc04a6bcafa66@syzkaller.appspotmail.com Subject: [PATCH 2/2] udf: Verify inode link counts before performing rename Date: Tue, 26 Nov 2024 13:33:49 +0100 Message-Id: <20241126123349.24798-3-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241126123349.24798-1-jack@suse.cz> References: <20241126123349.24798-1-jack@suse.cz> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1122; i=jack@suse.cz; h=from:subject; bh=EwKrdYK/wuwy4Lq8gR/dyraqGdVWk+4V2eTIlbC8jMQ=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBnRcAsNONEPnjIYZJxMwC3QPUvsDGHSjzQeC8rYCHl 095SkHiJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZ0XALAAKCRCcnaoHP2RA2QLAB/ 0RLd9lgptKwyBvdabFVG/6fXWcJKhlEV5NKrDkOhzdi8Kj7Jl8egwno5l5uz0hcq0DAMbNsL1EbqGg cUwq/xHpAllhNrrSUdDq7gk8tp8nd1ViVamb1C40Se4qmrfikf04PBu3sQqJ0kwE4WEtFXxpAnhCI8 fgkVuzfuLLDD3XgRFiWhwJ0CLN2LA8HHjNqNMh1flFH8ROaBXCrDw3fKwEJvbf5Rir73YyssQ/0Sck mdwcf/lvcCoNIHDJsPCcHFJjSO7l74c4btoIZ3uuYE6uEVLG15rptaemRS7X05DVxyCGkv6MW0VATL U1wItvuLtJDDcX4+uaW1ddfTjrHESP X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Queue-Id: 3CF371F745 X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[3ff7365dc04a6bcafa66]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[suse.cz:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Flag: NO During rename, we are updating link counts of various inodes either when rename deletes target or when moving directory across directories. Verify involved link counts are sane so that we don't trip warnings in VFS. Reported-by: syzbot+3ff7365dc04a6bcafa66@syzkaller.appspotmail.com Signed-off-by: Jan Kara --- fs/udf/namei.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 2be775d30ac1..2cb49b6b0716 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -791,8 +791,18 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir, retval = -ENOTEMPTY; if (!empty_dir(new_inode)) goto out_oiter; + retval = -EFSCORRUPTED; + if (new_inode->i_nlink != 2) + goto out_oiter; } + retval = -EFSCORRUPTED; + if (old_dir->i_nlink < 3) + goto out_oiter; is_dir = true; + } else if (new_inode) { + retval = -EFSCORRUPTED; + if (new_inode->i_nlink < 1) + goto out_oiter; } if (is_dir && old_dir != new_dir) { retval = udf_fiiter_find_entry(old_inode, &dotdot_name,