linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] wifi: wext: propagate metadata on -E2BIG for GET ioctls
@ 2025-08-07 13:10 Callan Huang
  2025-08-25  7:33 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Callan Huang @ 2025-08-07 13:10 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, linux-kernel, luvings

When GET ioctls encounter insufficient buffer (-E2BIG),
preserve u.data.length metadata in iwreq structure for size detection

Typical usage in userspace tools like 'iwlist wlan0 scanning':
- Detect required buffer size via u.data.length
- Implement retry logic with proper allocation

Signed-off-by: Callan Huang <luvings@qq.com>
---
 net/wireless/wext-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
index c32a7c690..b4f72a49f 100644
--- a/net/wireless/wext-core.c
+++ b/net/wireless/wext-core.c
@@ -1075,7 +1075,7 @@ int wext_handle_ioctl(struct net *net, unsigned int cmd, void __user *arg)
 	ret = wext_ioctl_dispatch(net, &iwr, cmd, &info,
 				  ioctl_standard_call,
 				  ioctl_private_call);
-	if (ret >= 0 &&
+	if ((ret >= 0 || ret == -E2BIG) &&
 	    IW_IS_GET(cmd) &&
 	    copy_to_user(arg, &iwr, sizeof(struct iwreq)))
 		return -EFAULT;
@@ -1138,7 +1138,7 @@ int compat_wext_handle_ioctl(struct net *net, unsigned int cmd,
 				  compat_standard_call,
 				  compat_private_call);
 
-	if (ret >= 0 &&
+	if ((ret >= 0 || ret == -E2BIG) &&
 	    IW_IS_GET(cmd) &&
 	    copy_to_user(argp, &iwr, sizeof(struct iwreq)))
 		return -EFAULT;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] wifi: wext: propagate metadata on -E2BIG for GET ioctls
  2025-08-07 13:10 [PATCH v1] wifi: wext: propagate metadata on -E2BIG for GET ioctls Callan Huang
@ 2025-08-25  7:33 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2025-08-25  7:33 UTC (permalink / raw)
  To: Callan Huang; +Cc: linux-wireless, linux-kernel

On Thu, 2025-08-07 at 21:10 +0800, Callan Huang wrote:
> When GET ioctls encounter insufficient buffer (-E2BIG),
> preserve u.data.length metadata in iwreq structure for size detection
> 
> Typical usage in userspace tools like 'iwlist wlan0 scanning':
> - Detect required buffer size via u.data.length
> - Implement retry logic with proper allocation

If you'd sent this patch 15 years ago I probably would've taken it, but
honestly, at this point ... no. Just use nl80211, or large buffers in
the userspace to start with. There's a very small buffer limit _anyway_,
so that getting the full scan list in busy environments is actually
impossible with wext.

johannes

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-25  8:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 13:10 [PATCH v1] wifi: wext: propagate metadata on -E2BIG for GET ioctls Callan Huang
2025-08-25  7:33 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).