NetBSD Problem Report #56441

From www@netbsd.org  Tue Oct  5 16:24:43 2021
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 7CB6B1A921F
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  5 Oct 2021 16:24:43 +0000 (UTC)
Message-Id: <20211005162442.19A4A1A9239@mollari.NetBSD.org>
Date: Tue,  5 Oct 2021 16:24:42 +0000 (UTC)
From: david@netascale.com
Reply-To: david@netascale.com
To: gnats-bugs@NetBSD.org
Subject: puffs(4) has error-check wrong way around for poll(2) ops
X-Send-Pr-Version: www-1.0

>Number:         56441
>Category:       kern
>Synopsis:       puffs(4) has error-check wrong way around for poll(2) ops
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 05 16:25:00 +0000 2021
>Originator:     David MacKay
>Release:        9.2
>Organization:
>Environment:
NetBSD netbsd.fritz.box 9.2 NetBSD 9.2 (GENERIC) #0: Wed May 12 13:15:55 UTC 2021  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
An error check in the PUFFS code for poll() ops is the wrong way around. If there is an error returned by the PUFFS userland server, the kernel code sets revents to what the userland server delivered, if not, it sets revents to POLLERR. It should do the opposite.

This means that if your PUFFS filesystem returns 0 from its poll operation, you will unexpectedly get a POLLERR delivered to any poll()'ers, but if your PUFFS filesystem returns an error from its poll op, your poll()'ers will get the expected events.

See sys/fs/puffs/puffs_subr.c line 148 
>How-To-Repeat:
Implement a poll() op in a PUFFS filesystem. Set revents in it and return 0. Anyone poll()ing that file will get a POLLERR event. Return an error instead, and anyone poll()ing that file will instead get the expected events as you set.
>Fix:
Change
> if (error)
to instead read
> if (error == 0)

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.