diff mbox series

rfkill: return ENOTTY on invalid ioctl

Message ID 20231101-rfkill-ioctl-enosys-v1-1-5bf374fabffe@weissschuh.net (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series rfkill: return ENOTTY on invalid ioctl | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1344 this patch: 1344
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1369 this patch: 1369
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1369 this patch: 1369
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Thomas Weißschuh Nov. 1, 2023, 7:41 p.m. UTC
For unknown ioctls the correct error is
ENOTTY "Inappropriate ioctl for device".

ENOSYS as returned before should only be used to indicate that a syscall
is not available at all.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 net/rfkill/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


---
base-commit: 7d461b291e65938f15f56fe58da2303b07578a76
change-id: 20231101-rfkill-ioctl-enosys-00a2bb0a4ab1

Best regards,

Comments

Przemek Kitszel Nov. 2, 2023, 8:57 a.m. UTC | #1
On 11/1/23 20:41, Thomas Weißschuh wrote:
> For unknown ioctls the correct error is
> ENOTTY "Inappropriate ioctl for device".

For sure!

I would like to learn more of why this is not an UAPI breaking change?

> 
> ENOSYS as returned before should only be used to indicate that a syscall
> is not available at all.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>   net/rfkill/core.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index 14cc8fe8584b..c3feb4f49d09 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -1351,11 +1351,11 @@ static long rfkill_fop_ioctl(struct file *file, unsigned int cmd,
>   			     unsigned long arg)
>   {
>   	struct rfkill_data *data = file->private_data;
> -	int ret = -ENOSYS;
> +	int ret = -ENOTTY;
>   	u32 size;
>   
>   	if (_IOC_TYPE(cmd) != RFKILL_IOC_MAGIC)
> -		return -ENOSYS;
> +		return -ENOTTY;
>   
>   	mutex_lock(&data->mtx);
>   	switch (_IOC_NR(cmd)) {
> 
> ---
> base-commit: 7d461b291e65938f15f56fe58da2303b07578a76
> change-id: 20231101-rfkill-ioctl-enosys-00a2bb0a4ab1
> 
> Best regards,
Thomas Weißschuh Nov. 2, 2023, 7:14 p.m. UTC | #2
Hi!

On 2023-11-02 09:57:45+0100, Przemek Kitszel wrote:
> On 11/1/23 20:41, Thomas Weißschuh wrote:
> > For unknown ioctls the correct error is
> > ENOTTY "Inappropriate ioctl for device".
> 
> For sure!
> 
> I would like to learn more of why this is not an UAPI breaking change?

"break" would mean that some user application worked correctly before
but does not do so anymore with this change.

This seems highly unlikely and I was not able to find such an
application via Debian code search.

In general I did *not* mark this change for stable so if some
application would indeed break it gets detected before the patch hits
a release.

> > 
> > ENOSYS as returned before should only be used to indicate that a syscall
> > is not available at all.
> > 
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > ---
> >   net/rfkill/core.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> > index 14cc8fe8584b..c3feb4f49d09 100644
> > --- a/net/rfkill/core.c
> > +++ b/net/rfkill/core.c
> > @@ -1351,11 +1351,11 @@ static long rfkill_fop_ioctl(struct file *file, unsigned int cmd,
> >   			     unsigned long arg)
> >   {
> >   	struct rfkill_data *data = file->private_data;
> > -	int ret = -ENOSYS;
> > +	int ret = -ENOTTY;
> >   	u32 size;
> >   	if (_IOC_TYPE(cmd) != RFKILL_IOC_MAGIC)
> > -		return -ENOSYS;
> > +		return -ENOTTY;
> >   	mutex_lock(&data->mtx);
> >   	switch (_IOC_NR(cmd)) {
> > 
> > ---
> > base-commit: 7d461b291e65938f15f56fe58da2303b07578a76
> > change-id: 20231101-rfkill-ioctl-enosys-00a2bb0a4ab1
> > 
> > Best regards,
>
Przemek Kitszel Nov. 6, 2023, 10:30 a.m. UTC | #3
On 11/2/23 20:14, Thomas Weißschuh wrote:
> Hi!
> 
> On 2023-11-02 09:57:45+0100, Przemek Kitszel wrote:
>> On 11/1/23 20:41, Thomas Weißschuh wrote:
>>> For unknown ioctls the correct error is
>>> ENOTTY "Inappropriate ioctl for device".
>>
>> For sure!
>>
>> I would like to learn more of why this is not an UAPI breaking change?
> 
> "break" would mean that some user application worked correctly before
> but does not do so anymore with this change.
> 
> This seems highly unlikely and I was not able to find such an
> application via Debian code search.
> 
> In general I did *not* mark this change for stable so if some
> application would indeed break it gets detected before the patch hits
> a release.
> 
>>>
>>> ENOSYS as returned before should only be used to indicate that a syscall
>>> is not available at all.
>>>
>>> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
>>> ---
>>>    net/rfkill/core.c | 4 ++--
>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
>>> index 14cc8fe8584b..c3feb4f49d09 100644
>>> --- a/net/rfkill/core.c
>>> +++ b/net/rfkill/core.c
>>> @@ -1351,11 +1351,11 @@ static long rfkill_fop_ioctl(struct file *file, unsigned int cmd,
>>>    			     unsigned long arg)
>>>    {
>>>    	struct rfkill_data *data = file->private_data;
>>> -	int ret = -ENOSYS;
>>> +	int ret = -ENOTTY;
>>>    	u32 size;
>>>    	if (_IOC_TYPE(cmd) != RFKILL_IOC_MAGIC)
>>> -		return -ENOSYS;
>>> +		return -ENOTTY;
>>>    	mutex_lock(&data->mtx);
>>>    	switch (_IOC_NR(cmd)) {
>>>
>>> ---
>>> base-commit: 7d461b291e65938f15f56fe58da2303b07578a76
>>> change-id: 20231101-rfkill-ioctl-enosys-00a2bb0a4ab1
>>>
>>> Best regards,
>>

Thanks!

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
diff mbox series

Patch

diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 14cc8fe8584b..c3feb4f49d09 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -1351,11 +1351,11 @@  static long rfkill_fop_ioctl(struct file *file, unsigned int cmd,
 			     unsigned long arg)
 {
 	struct rfkill_data *data = file->private_data;
-	int ret = -ENOSYS;
+	int ret = -ENOTTY;
 	u32 size;
 
 	if (_IOC_TYPE(cmd) != RFKILL_IOC_MAGIC)
-		return -ENOSYS;
+		return -ENOTTY;
 
 	mutex_lock(&data->mtx);
 	switch (_IOC_NR(cmd)) {