NetBSD Problem Report #58210

From www@netbsd.org  Sun Apr 28 15:29:45 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 5B1891A9238
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 28 Apr 2024 15:29:45 +0000 (UTC)
Message-Id: <20240428152944.56E801A923A@mollari.NetBSD.org>
Date: Sun, 28 Apr 2024 15:29:44 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: linux_sync_file missing struct file::f_data initialization
X-Send-Pr-Version: www-1.0

>Number:         58210
>Category:       kern
>Synopsis:       linux_sync_file missing struct file::f_data initialization
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 28 15:30:00 +0000 2024
>Last-Modified:  Sun Apr 28 15:40:01 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10
>Organization:
Sync Linux/kNetBSD Fileoperations
>Environment:
>Description:
sync_file_create doesn't record a pointer from the struct file to the struct sync_file state -- it just initializes some other members:

     60 	fp->f_type = DTYPE_MISC;
     61 	fp->f_flag = FREAD | FWRITE;
     62 	fp->f_ops = &sync_file_ops;

https://nxr.netbsd.org/xref/src/sys/external/bsd/drm2/linux/linux_sync_file.c?r=1.2#47

So when other operations like sync_file_poll and sync_file_close try to use it, well, it doesn't work very well:

     67 static int
     68 sync_file_close(struct file *fp)
     69 {
     70 	struct sync_file *sf = fp->f_data;
     71 
     72 	if (sf->sf_polling)

https://nxr.netbsd.org/xref/src/sys/external/bsd/drm2/linux/linux_sync_file.c?r=1.2#67

(This linux_sync_file.c draft hasn't seen a lot of use, apparently.)
>How-To-Repeat:
do something that involves sync_files
>Fix:
fp->f_data = sf

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58210 CVS commit: src/sys/external/bsd/drm2/linux
Date: Sun, 28 Apr 2024 15:35:39 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Sun Apr 28 15:35:39 UTC 2024

 Modified Files:
 	src/sys/external/bsd/drm2/linux: linux_sync_file.c

 Log Message:
 linux_sync_file: Fix missing init/fini steps.

 Noted by rjs@.

 PR kern/58210


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/linux/linux_sync_file.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.