From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from r3-23.sinamail.sina.com.cn (r3-23.sinamail.sina.com.cn [202.108.3.23]) (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 AD20F37FF71 for ; Tue, 12 May 2026 21:17:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.108.3.23 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778620645; cv=none; b=V3j2B7L9+zDlZnAzfEtYG4U9T4tNsQR5TsawSFRMy8YIpefWhuL2ib82bcai43f1gL6ugj3kKELIVTy0E/fPqsbRmy4gcMaujDo3gIc17mxdHalJ8S+QYpjZ4zjekDXJwLzdDvAdvMYUtVjUG3p/cNzZpoZpuR2x+exOydP+ikM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778620645; c=relaxed/simple; bh=gccVOIGdvgE9SfcEEOd/j1N8DpHbSLHLlR4XVbwdLcY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NawRLh2sEpB22PHBFnh3+4dZ8xuNjhiqwJJ3VZw1j5HJn5ZOpqUIsZy9YFuDhCyLBHa4zEFM2w3g1dkdIFL8CLdmxrTRImpVn2F6Hhd865YthzdQHChREBt+rW31iV7EoCtTZcwELXOAdqJ5QPfqGYrPfsa4tqDilMjRMq3r0/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b=Keso7m/S; arc=none smtp.client-ip=202.108.3.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b="Keso7m/S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1778620641; bh=SS5bWnWfOFv5IQdHFnfR5zRc59lEFqAEIk7pRDFZ60s=; h=From:Subject:Date:Message-ID; b=Keso7m/SnZYPzXsPTezuf1GKah0irIYDK3pxT7kWcqHQt4S7EuJ7WGXWkrn92yEOX 6dfKsBrRbHk/E0vXiIO9w0lMFOOLt4NA4Fb1SLUXpOKTjrIzzkrn3Qr5pQEqmAL/6q Avl+vIPFZVC15ptuQrUcPbcSZbu4KNcdgA0cn+VA= X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([114.249.62.144]) by sina.com (10.54.253.31) with ESMTP id 6A0398D5000073A9; Tue, 13 May 2026 05:17:11 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 2271356816234 X-SMAIL-UIID: F1D9970D2BAF4047BD5CD9CAA2142F5C-20260513-051711-1 From: Hillf Danton To: syzbot Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [dri?] WARNING in drm_prime_destroy_file_private (3) Date: Wed, 13 May 2026 05:17:11 +0800 Message-ID: <20260512211712.554-1-hdanton@sina.com> In-Reply-To: <6a0385f1.a00a0220.3890a0.0002.GAE@google.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit > Date: Tue, 12 May 2026 12:56:33 -0700 [thread overview] > Hello, > > syzbot found the following issue on: > > HEAD commit: 81d6f7807536 Merge tag 'v7.1-rc3-smb3-client-fixes' of git.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=159b10c8580000 > kernel config: https://syzkaller.appspot.com/x/.config?x=59da38148f3a3d24 > dashboard link: https://syzkaller.appspot.com/bug?extid=d7c9eed171647e421013 > compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12332a73980000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=161a3dba580000 Test Edward's fix. #syz test --- x/drivers/gpu/drm/drm_gem.c +++ y/drivers/gpu/drm/drm_gem.c @@ -374,14 +374,8 @@ drm_gem_object_release_handle(int id, vo if (obj->funcs->close) obj->funcs->close(obj, file_priv); - mutex_lock(&file_priv->prime.lock); - drm_prime_remove_buf_handle(&file_priv->prime, id); - - mutex_unlock(&file_priv->prime.lock); - drm_vma_node_revoke(&obj->vma_node, file_priv); - drm_gem_object_handle_put_unlocked(obj); return 0; @@ -401,13 +395,16 @@ drm_gem_handle_delete(struct drm_file *f { struct drm_gem_object *obj; + mutex_lock(&filp->prime.lock); spin_lock(&filp->table_lock); /* Check if we currently have a reference on the object */ obj = idr_replace(&filp->object_idr, NULL, handle); spin_unlock(&filp->table_lock); - if (IS_ERR_OR_NULL(obj)) + if (IS_ERR_OR_NULL(obj)) { + mutex_unlock(&filp->prime.lock); return -EINVAL; + } /* Release driver's reference and decrement refcount. */ drm_gem_object_release_handle(handle, obj, filp); @@ -416,6 +413,7 @@ drm_gem_handle_delete(struct drm_file *f spin_lock(&filp->table_lock); idr_remove(&filp->object_idr, handle); spin_unlock(&filp->table_lock); + mutex_unlock(&filp->prime.lock); return 0; } @@ -1030,17 +1028,18 @@ int drm_gem_change_handle_ioctl(struct d return -EINVAL; handle = args->new_handle; + mutex_lock(&file_priv->prime.lock); obj = drm_gem_object_lookup(file_priv, args->handle); - if (!obj) + if (!obj) { + mutex_unlock(&file_priv->prime.lock); return -ENOENT; + } if (args->handle == handle) { ret = 0; - goto out; + goto out_unlock; } - mutex_lock(&file_priv->prime.lock); - spin_lock(&file_priv->table_lock); /* When create_tail allocs an obj idr, it needs to first alloc as NULL, @@ -1092,9 +1091,8 @@ int drm_gem_change_handle_ioctl(struct d spin_unlock(&file_priv->table_lock); out_unlock: - mutex_unlock(&file_priv->prime.lock); -out: drm_gem_object_put(obj); + mutex_unlock(&file_priv->prime.lock); return ret; } @@ -1126,8 +1124,10 @@ drm_gem_open(struct drm_device *dev, str void drm_gem_release(struct drm_device *dev, struct drm_file *file_private) { + mutex_lock(&file_private->prime.lock); idr_for_each(&file_private->object_idr, &drm_gem_object_release_handle, file_private); + mutex_unlock(&file_private->prime.lock); idr_destroy(&file_private->object_idr); } --