Skip to contentSkip to conversation

rfkill: return ENOTTY on invalid ioctl

PATCH In review Thomas Weißschuh 2 participants 4 messages Nov 1, 2023 – Nov 6, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rfkill: return ENOTTY on invalid ioctl

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.

---
 net/rfkill/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/rfkill/core.c +2 -2
index 14cc8fe8584b..c3feb4f49d09 100644
@@ -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,

Signature · 1 line
Thomas Weißschuh <[email protected]>
#1 lore raw
Quoted 2 lines · Thomas Weißschuh

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?

Quoted 33 lines

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

---
  net/rfkill/core.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
net/rfkill/core.c +2 -3
index 14cc8fe8584b..c3feb4f49d09 100644
@@ -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,

#2 lore raw

Hi!

Quoted 7 lines · Przemek Kitszel
Quoted 2 lines · Thomas Weißschuh

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.

Quoted 32 lines
Quoted 31 lines

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

---
  net/rfkill/core.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
net/rfkill/core.c +2 -3
index 14cc8fe8584b..c3feb4f49d09 100644
@@ -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,

Reviewed-by
#3 lore raw
Quoted 14 lines · Thomas Weißschuh

Hi!

Quoted 7 lines · Przemek Kitszel
Quoted 2 lines · Thomas Weißschuh

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.

Quoted 39 lines

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.

Quoted 32 lines
Quoted 31 lines

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

---
   net/rfkill/core.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
net/rfkill/core.c +2 -3
index 14cc8fe8584b..c3feb4f49d09 100644
@@ -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!