Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Apr 2010 16:33:30 -0700
From:      Alfred Perlstein <alfred@freebsd.org>
To:        d@delphij.net
Cc:        freebsd-arch@freebsd.org
Subject:   Re: _IOWR when errno != 0
Message-ID:  <20100412233330.GC19003@elvis.mu.org>
In-Reply-To: <4BC39E93.7060906@delphij.net>
References:  <4BC39E93.7060906@delphij.net>

next in thread | previous in thread | raw e-mail | index | archive | help
* Xin LI <delphij@delphij.net> [100412 15:28] wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> 
> Is there a sane way to copyout ioctl request when the returning errno !=
> 0?  Looking at the code, currently, in sys/kern/sys_generic.c, we have:
> 
> ===========
>         error = kern_ioctl(td, uap->fd, com, data);
> 
>         if (error == 0 && (com & IOC_OUT))
>                 error = copyout(data, uap->data, (u_int)size);
> ===========
> 
> Is there any objection if I change it to something like:
> 
> ===========
>         saved_error = kern_ioctl(td, uap->fd, com, data);
> 
>         if (com & IOC_OUT)
>                 error = copyout(data, uap->data, (u_int)size);
>         if (saved_error)
>                 error = saved_error;
> ===========

Is this for linux compat?

I'm not sure this would work, it might seriously break userland
compat.  Have you looked around/queiried what the expected outcome
is from a bad ioctl?  By default the buffer will be zero'd this
might be unexpected by apps.  (all or nothing)

-- 
- Alfred Perlstein
.- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250
.- FreeBSD committer



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100412233330.GC19003>