Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 6F6F82F067E for ; Thu, 19 Feb 2026 12:04:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771502689; cv=none; b=Cxn4GgKYTK/JrrM4iP6y8RTci05bF8GfdWUwCeISMHFYlDzUk45nUEh6caNmOmppy8gJOpFcZDQ1zvS+21DGQpxfdAMEtrCG5/84aezvyPZUU5cBR4xZBoXELDbXDESeUjFgW+6Y5ym7Wjo+Kxz1NTelopZj+SiQdYd6DWKVXNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771502689; c=relaxed/simple; bh=/8hfK/BtS7DH+CZu+D7W5pnZBl3+KC23GO3mrFnfrHk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RZ/7kV/APM4Q4zg56SOWRWo5TgvoXfyLnqrmm5mnFPl/481mFO2qW+q0eggfA8sy8kastgE0psr9nIpXUadHXvTgETg3mAbxfM+VFl8IzxBE1rYn+U0Z9iBFBFvhpi6MJvI4F6wMy+9o45rpACwKzMbHEuekxdOH561EvYQYLaQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WTpwunSP; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WTpwunSP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771502687; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=t1mmqpR0edyHsebNjx1C92XDYMVNnYLEaiSrjhOGHBI=; b=WTpwunSPNdKJJ7JR9FoEzJA27G/RraaKz88fFhTT2W3LbX3pGHp0a/sAroiVC+X+jxMsGj SYqTqStN0JqLgBdzQMptVoVjO40rLjtCCNb/kss4b50lTOGrhcHhq+q28wyxkSm6XPGUyF m0rbqj7kMYtxPgMjpcmJyMHcXuLB6Rc= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-YbDLcfI8M16HNRW5PxZsRw-1; Thu, 19 Feb 2026 07:04:43 -0500 X-MC-Unique: YbDLcfI8M16HNRW5PxZsRw-1 X-Mimecast-MFC-AGG-ID: YbDLcfI8M16HNRW5PxZsRw_1771502682 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B71531956089; Thu, 19 Feb 2026 12:04:42 +0000 (UTC) Received: from idlethread.mad.redhat.com (unknown [10.32.160.145]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B44D21800349; Thu, 19 Feb 2026 12:04:41 +0000 (UTC) From: Roberto Bergantinos Corpas To: linux-nfs@vger.kernel.org Cc: trondmy@kernel.org, neil@brown.name Subject: [PATCH] nfs: return EISDIR on nfs3_proc_create if d_alias is a dir Date: Thu, 19 Feb 2026 13:04:40 +0100 Message-ID: <20260219120440.766178-1-rbergant@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 If we found an alias through nfs3_do_create/nfs_add_or_obtain /d_splice_alias which happens to be a dir dentry, we don't return any error, and simply forget about this alias, but the original dentry we were adding and passed as parameter remains negative. This later causes an oops on nfs_atomic_open_v23/finish_open since we supply a negative dentry to do_dentry_open. This has been observed running lustre-racer, where dirs and files are created/removed concurrently with the same name and O_EXCL is not used to open files (frequent file redirection). While d_splice_alias typically returns a directory alias or NULL, we explicitly check d_is_dir() to ensure that we don't attempt to perform file operations (like finish_open) on a directory inode, which triggers the observed oops. Fixes: 7c6c5249f061 ("NFS: add atomic_open for NFSv3 to handle O_TRUNC correctly.") Reviewed-by: Olga Kornievskaia Reviewed-by: Scott Mayhew Signed-off-by: Roberto Bergantinos Corpas --- fs/nfs/nfs3proc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 1181f9cc6dbd..f8bc9bffdad9 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -392,8 +392,13 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, if (status != 0) goto out_release_acls; - if (d_alias) + if (d_alias) { + if (d_is_dir(d_alias)) { + status = -EISDIR; + goto out_dput; + } dentry = d_alias; + } /* When we created the file with exclusive semantics, make * sure we set the attributes afterwards. */ -- 2.45.0