s390/qeth: Check CAP_NET_ADMIN for private ioctls
Subsystems (5)
Aswin Karuvally
maintainerPATCH 1/1 s390/qeth: Check CAP_NET_ADMIN for private ioctls
Gate the SIOCDEVPRIVATE ioctl commands SIOC_QETH_ADP_SET_SNMP_CONTROL, SIOC_QETH_GET_CARD_TYPE and SIOC_QETH_QUERY_OAT with CAP_NET_ADMIN capable check to ensure unprivileged users cannot invoke them.
--- drivers/s390/net/qeth_core_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/s390/net/qeth_core_main.c +3 -0
@@ -6525,6 +6525,9 @@ int qeth_siocdevprivate(struct net_device *dev, struct ifreq *rq, void __user *dstruct qeth_card *card = dev->ml_priv;int rc =0 ; +if (!capable (CAP_NET_ADMIN )) +return -EPERM ; +switch (cmd) {case SIOC_QETH_ADP_SET_SNMP_CONTROL : rc =qeth_snmp_command (card, data);
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] An integer underflow in the buffer size check allows privileged users to cause a kernel heap buffer overflow. --
--- Patch [1]: [PATCH net] s390/qeth: Check CAP_NET_ADMIN for private ioctls --- commit 3ec90fe5fb86d5d8d0432c2487ad687ef4d3e227
Author: Aswin Karuvally <[email protected]>
s390/qeth: Check CAP_NET_ADMIN for private ioctls
This commit adds a CAP_NET_ADMIN capability check to the SIOC_QETH_ADP_SET_SNMP_CONTROL, SIOC_QETH_GET_CARD_TYPE, and SIOC_QETH_QUERY_OAT private ioctls. This ensures that these commands cannot be invoked by unprivileged users.
Quoted 5 lines
drivers/s390/net/qeth_core_main.c +0
-0
drivers/s390/net/qeth_core_main.c int qeth_siocdevprivate(struct net_device *dev, struct ifreq *rq, void __user *d · line 6533
Quoted 9 lines
drivers/s390/net/qeth_core_main.c +3
-0@@ -6525,6 +6525,9 @@ int qeth_siocdevprivate(struct net_device *dev, struct ifreq *rq, void __user *dstruct qeth_card *card = dev->ml_priv;int rc =0 ; +if (!capable (CAP_NET_ADMIN )) +return -EPERM ; +switch (cmd) {case SIOC_QETH_ADP_SET_SNMP_CONTROL : rc =qeth_snmp_command (card, data);
[Severity: High]
This is a pre-existing issue, but does qeth_snmp_command() allow an integer underflow that leads to a heap buffer overflow?
If a user provides a udata_len smaller than sizeof(struct qeth_snmp_ureq_hdr) (16 bytes), the unsigned subtraction in the callback underflows:
drivers/s390/net/qeth_core_main.c:qeth_snmp_command() {
...
if (get_user(qinfo.udata_len, &ureq->hdr.data_len) ||
...
qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL);
...
qinfo.udata_offset = sizeof(struct qeth_snmp_ureq_hdr);
...
}drivers/s390/net/qeth_core_main.c:qeth_snmp_command_cb() {
...
if ((qinfo->udata_len - qinfo->udata_offset) < data_len) {
...
}The underflow would bypass the available space check, leading to an out-of-bounds memcpy into the allocated heap buffer.
The same integer underflow pattern appears to exist in qeth_l3_arp_query_cb() for the SIOC_QETH_ARP_QUERY_INFO ioctl.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Jakub Kicinski
maintainerQuoted 3 lines · On Thu, 23 Jul 2026 16:00:50 +0200 Aswin Karuvally wrote:
Gate the SIOCDEVPRIVATE ioctl commands
SIOC_QETH_ADP_SET_SNMP_CONTROL,SIOC_QETH_GET_CARD_TYPEandSIOC_QETH_QUERY_OATwithCAP_NET_ADMINcapable check to ensure unprivileged users cannot invoke them.
No need to make this netns-aware, I assume?
Aswin Karuvally
maintainerQuoted 6 lines · Jakub Kicinski
Quoted 3 lines · On Thu, 23 Jul 2026 16:00:50 +0200 Aswin Karuvally wrote:
Gate the SIOCDEVPRIVATE ioctl commands
SIOC_QETH_ADP_SET_SNMP_CONTROL,SIOC_QETH_GET_CARD_TYPEandSIOC_QETH_QUERY_OATwithCAP_NET_ADMINcapable check to ensure unprivileged users cannot invoke them.No need to make this netns-aware, I assume?
Hi Jakub,
Thank you for accepting the patch!
It was concluded that the tools that make use of these calls are strictly meant for IBM OSA cards on an LPAR, which find very limited use within environments that make use of network namespaces, eg. containers. Thus stuck with capable().
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 4 lines · On Thu, 23 Jul 2026 16:00:50 +0200 you wrote:
Gate the SIOCDEVPRIVATE ioctl commands
SIOC_QETH_ADP_SET_SNMP_CONTROL,SIOC_QETH_GET_CARD_TYPEandSIOC_QETH_QUERY_OATwithCAP_NET_ADMINcapable check to ensure unprivileged users cannot invoke them.
Quoted 8 lines
Fixes 18787eeebd71 ("qeth: use ndo_siocdevprivate")Suggested-by Christian Borntraeger <[email protected]>Reviewed-by Christian Borntraeger <[email protected]>Reviewed-by Alexandra Winter <[email protected]>Signed-off-by Aswin Karuvally <[email protected]>[...]
Here is the summary with links:
- [net] s390/qeth: Check CAP_NET_ADMIN for private ioctls
https://git.kernel.org/netdev/net/c/d211028bac1b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html