infiniband: remove WARN that is not kernel bug
PATCH v2 1/1 infiniband: remove WARN that is not kernel bug
WARNINGs mean kernel bugs.
The one in ucma_write() points to user programming error or a malicious attempt. This is not a kernel bug, remove it.
BUG/WARNs that are not kernel bugs hinder automated testing effots.
---
Changes since v1:
- added printk_once
--- drivers/infiniband/core/ucma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/core/ucma.c +4 -1
@@ -1584,8 +1584,11 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,struct rdma_ucm_cmd_hdr hdr;ssize_t ret; -if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +printk_once ("ucma_write: process %d (%s) tried to do something hinky\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }if (len <sizeof (hdr))return -EINVAL ;
Signature · 1 line
2.8.0.rc3.226.g39d4020
Quoted 29 lines · Dmitry Vyukov
WARNINGs mean kernel bugs.
The one inucma_write()points to user programming error or a malicious attempt. This is not a kernel bug, remove it.BUG/WARNs that are not kernel bugs hinder automated testing effots.
Signed-off-by Dmitry Vyukov <[email protected]>Cc Doug Ledford <[email protected]>Cc Sean Hefty <[email protected]>Cc Hal Rosenstock <[email protected]>Cc Leon Romanovsky <[email protected]>---
Changes since v1:
- addedprintk_once--- drivers/infiniband/core/ucma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/infiniband/core/ucma.c +0
-0@@ -1584,8 +1584,11 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,struct rdma_ucm_cmd_hdr hdr;ssize_t ret;
drivers/infiniband/core/ucma.c static ssize_t ucma_write(struct file *filp, const char __user *buf, · line 1594
Quoted 10 lines
drivers/infiniband/core/ucma.c +4
-1-if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +printk_once ("ucma_write: process %d (%s) tried to do something hinky\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }if (len <sizeof (hdr))return -EINVAL ;
FWIW, WARN_ON_ONCE came with commit e6bd18f57aad ("IB/security: Restrict use of the write() interface"). Would it make sense to change the other places as well?
Regards,
Miroslav
Quoted 39 lines · Miroslav Benes
Quoted 37 lines · Dmitry Vyukov
WARNINGs mean kernel bugs.
The one inucma_write()points to user programming error or a malicious attempt. This is not a kernel bug, remove it.BUG/WARNs that are not kernel bugs hinder automated testing effots.
Signed-off-by Dmitry Vyukov <[email protected]>Cc Doug Ledford <[email protected]>Cc Sean Hefty <[email protected]>Cc Hal Rosenstock <[email protected]>Cc Leon Romanovsky <[email protected]>Cc syzkaller-/[email protected]---
Changes since v1:
- addedprintk_once--- drivers/infiniband/core/ucma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/infiniband/core/ucma.c +4
-1@@ -1584,8 +1584,11 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,struct rdma_ucm_cmd_hdr hdr;ssize_t ret; -if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +printk_once ("ucma_write: process %d (%s) tried to do something hinky\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }
Quoted 6 lines
drivers/infiniband/core/ucma.c static ssize_t ucma_write(struct file *filp, const char __user *buf, · line 1594
Quoted 2 lines
drivers/infiniband/core/ucma.c +0
-0if (len <sizeof (hdr))return -EINVAL ;FWIW,
WARN_ON_ONCEcame with commite6bd18f57aad("IB/security: Restrict use of thewrite()interface"). Would it make sense to change the other places as well?
I guess so.
Can I ask somebody of infiniband maintainers to take care of this? I just hit the warning in my automated testing environment when a thread executed key_add in between open and write, then spent some time debugging to figure out that this is an "invalid user input" rather than a kernel bug.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 48 lines · Dmitry Vyukov
Quoted 39 lines · Miroslav Benes
Quoted 37 lines · Dmitry Vyukov
WARNINGs mean kernel bugs.
The one inucma_write()points to user programming error or a malicious attempt. This is not a kernel bug, remove it.BUG/WARNs that are not kernel bugs hinder automated testing effots.
Signed-off-by Dmitry Vyukov <[email protected]>Cc Doug Ledford <[email protected]>Cc Sean Hefty <[email protected]>Cc Hal Rosenstock <[email protected]>Cc Leon Romanovsky <[email protected]>Cc syzkaller-/[email protected]---
Changes since v1:
- addedprintk_once--- drivers/infiniband/core/ucma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/infiniband/core/ucma.c +4
-1@@ -1584,8 +1584,11 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,struct rdma_ucm_cmd_hdr hdr;ssize_t ret; -if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +printk_once ("ucma_write: process %d (%s) tried to do something hinky\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }Quoted 6 lines
drivers/infiniband/core/ucma.c static ssize_t ucma_write(struct file *filp, const char __user *buf, · line 1594
Quoted 2 lines
drivers/infiniband/core/ucma.c +0
-0if (len <sizeof (hdr))return -EINVAL ;FWIW,
WARN_ON_ONCEcame with commite6bd18f57aad("IB/security: Restrict use of thewrite()interface"). Would it make sense to change the other places as well?
Quoted 2 lines
I guess so.
Can I ask somebody of infiniband maintainers to take care of this?
Please see below,
Hope it helps.
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
From e0bfe4771591f9ffbcaa4e66d6257ed95e2d7188 Mon Sep 17 00:00:00 2001
From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>
Date: Mon, 21 Nov 2016 13:30:59 +0200
Subject: [PATCH] IB/{core, qib}: Remove WARN that is not kernel bug
WARNINGs mean kernel bugs, in this case, they are placed to mark programming errors and/or malicious attempts.
BUG/WARNs that are not kernel bugs hinder automated testing efforts.
--- drivers/infiniband/core/ucm.c | 5 ++++- drivers/infiniband/core/ucma.c | 5 ++++- drivers/infiniband/core/uverbs_main.c | 5 ++++- drivers/infiniband/hw/qib/qib_file_ops.c | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-)
drivers/infiniband/core/ucm.c +4 -1
@@ -1104,8 +1104,11 @@ static ssize_t ib_ucm_write(struct file *filp, const char __user *buf,struct ib_ucm_cmd_hdr hdr;ssize_t result; -if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +pr_err_once ("ucm_write: process %d (%s) tried to do something hinky\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }if (len <sizeof (hdr))return -EINVAL ;
drivers/infiniband/core/ucma.c +4 -1
@@ -1584,8 +1584,11 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,struct rdma_ucm_cmd_hdr hdr;ssize_t ret; -if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +pr_err_once ("ucma_write: process %d (%s) tried to do something hinky\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }if (len <sizeof (hdr))return -EINVAL ;
drivers/infiniband/core/uverbs_main.c +4 -1
@@ -746,8 +746,11 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,int srcu_key;ssize_t ret; -if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +pr_err_once ("uverbs_write: process %d (%s) tried to do something hinky\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }if (count <sizeof hdr)return -EINVAL ;
drivers/infiniband/hw/qib/qib_file_ops.c +4 -1
@@ -2066,8 +2066,11 @@ static ssize_t qib_write(struct file *fp, const char __user *data,ssize_t ret =0 ;void *dest; -if (WARN_ON_ONCE (!ib_safe_file_access (fp))) +if (!ib_safe_file_access (fp)) { +pr_err_once ("qib_write: process %d (%s) tried to do something hinky\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }if (count <sizeof (cmd.type)) { ret = -EINVAL ;
--
2.7.4
Quoted 49 lines · Leon Romanovsky
Quoted 48 lines · Dmitry Vyukov
Quoted 45 lines · Miroslav Benes
Quoted 29 lines · Dmitry Vyukov
WARNINGs mean kernel bugs.
The one inucma_write()points to user programming error or a malicious attempt. This is not a kernel bug, remove it.BUG/WARNs that are not kernel bugs hinder automated testing effots.
Signed-off-by Dmitry Vyukov <[email protected]>Cc Doug Ledford <[email protected]>Cc Sean Hefty <[email protected]>Cc Hal Rosenstock <[email protected]>Cc Leon Romanovsky <[email protected]>---
Changes since v1:
- addedprintk_once--- drivers/infiniband/core/ucma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/infiniband/core/ucma.c +0
-0@@ -1584,8 +1584,11 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,struct rdma_ucm_cmd_hdr hdr;ssize_t ret;drivers/infiniband/core/ucma.c static ssize_t ucma_write(struct file *filp, const char __user *buf, · line 1594
Quoted 10 lines
drivers/infiniband/core/ucma.c +4
-1-if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +printk_once ("ucma_write: process %d (%s) tried to do something hinky\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }if (len <sizeof (hdr))return -EINVAL ;FWIW,
WARN_ON_ONCEcame with commite6bd18f57aad("IB/security: Restrict use of thewrite()interface"). Would it make sense to change the other places as well?
Quoted 5 lines
Quoted 2 lines
I guess so.
Can I ask somebody of infiniband maintainers to take care of this?Please see below,
Hope it helps.
In ib_ucm_write function there is a wrong prefix:
+ pr_err_once("ucm_write: process %d (%s) tried to do something hinky\n",
Otherwise looks good. Thanks.
Quoted 53 lines · Dmitry Vyukov
Quoted 52 lines · Leon Romanovsky
Quoted 50 lines · Dmitry Vyukov
Quoted 39 lines · Miroslav Benes
Quoted 37 lines · Dmitry Vyukov
WARNINGs mean kernel bugs.
The one inucma_write()points to user programming error or a malicious attempt. This is not a kernel bug, remove it.BUG/WARNs that are not kernel bugs hinder automated testing effots.
Signed-off-by Dmitry Vyukov <[email protected]>Cc Doug Ledford <[email protected]>Cc Sean Hefty <[email protected]>Cc Hal Rosenstock <[email protected]>Cc Leon Romanovsky <[email protected]>Cc syzkaller-/[email protected]---
Changes since v1:
- addedprintk_once--- drivers/infiniband/core/ucma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/infiniband/core/ucma.c +4
-1@@ -1584,8 +1584,11 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,struct rdma_ucm_cmd_hdr hdr;ssize_t ret; -if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +printk_once ("ucma_write: process %d (%s) tried to do something hinky\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }Quoted 6 lines
drivers/infiniband/core/ucma.c static ssize_t ucma_write(struct file *filp, const char __user *buf, · line 1594
Quoted 2 lines
drivers/infiniband/core/ucma.c +0
-0if (len <sizeof (hdr))return -EINVAL ;FWIW,
WARN_ON_ONCEcame with commite6bd18f57aad("IB/security: Restrict use of thewrite()interface"). Would it make sense to change the other places as well?I guess so.
Can I ask somebody of infiniband maintainers to take care of this?
Quoted 6 lines
Quoted 2 lines
Please see below,
Hope it helps.In
ib_ucm_writefunction there is a wrong prefix:+ pr_err_once("ucm_write: process %d (%s) tried to do something hinky\n",
I did it intentionally to have the same errors for all flows.
Quoted 2 lines
Otherwise looks good. Thanks.
Quoted 6 lines · Leon Romanovsky
Quoted 4 lines
In
ib_ucm_writefunction there is a wrong prefix:+ pr_err_once("ucm_write: process %d (%s) tried to do something hinky\n",
I did it intentionally to have the same errors for all flows.
Lets actually use a good message too please?
pr_err_once("ucm_write: process %d (%s) changed security contexts after opening FD, this is not allowed.\n",
Jason
Quoted 6 lines · Jason Gunthorpe
Quoted 5 lines · Leon Romanovsky
Quoted 4 lines
In
ib_ucm_writefunction there is a wrong prefix:+ pr_err_once("ucm_write: process %d (%s) tried to do something hinky\n",
Quoted 7 lines
Quoted 1 line
I did it intentionally to have the same errors for all flows.
Lets actually use a good message too please?
pr_err_once("ucm_write: process %d (%s) changed security contexts after opening FD, this is not allowed.\n",
Jason
From 70f95b2d35aea42e5b97e7d27ab2f4e8effcbe67 Mon Sep 17 00:00:00 2001
From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>
Date: Mon, 21 Nov 2016 13:30:59 +0200
Subject: [PATCH rdma-next V2] IB/{core, qib}: Remove WARN that is not kernel bug
WARNINGs mean kernel bugs, in this case, they are placed to mark programming errors and/or malicious attempts.
BUG/WARNs that are not kernel bugs hinder automated testing efforts.
---
* Improved error prints.
--- drivers/infiniband/core/ucm.c | 5 ++++- drivers/infiniband/core/ucma.c | 5 ++++- drivers/infiniband/core/uverbs_main.c | 5 ++++- drivers/infiniband/hw/qib/qib_file_ops.c | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-)
drivers/infiniband/core/ucm.c +4 -1
@@ -1104,8 +1104,11 @@ static ssize_t ib_ucm_write(struct file *filp, const char __user *buf,struct ib_ucm_cmd_hdr hdr;ssize_t result; -if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +pr_err_once ("ucm_write: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }if (len <sizeof (hdr))return -EINVAL ;
drivers/infiniband/core/ucma.c +4 -1
@@ -1584,8 +1584,11 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,struct rdma_ucm_cmd_hdr hdr;ssize_t ret; -if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +pr_err_once ("ucma_write: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }if (len <sizeof (hdr))return -EINVAL ;
drivers/infiniband/core/uverbs_main.c +4 -1
@@ -746,8 +746,11 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,int srcu_key;ssize_t ret; -if (WARN_ON_ONCE (!ib_safe_file_access (filp))) +if (!ib_safe_file_access (filp)) { +pr_err_once ("uverbs_write: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }if (count <sizeof hdr)return -EINVAL ;
drivers/infiniband/hw/qib/qib_file_ops.c +4 -1
@@ -2066,8 +2066,11 @@ static ssize_t qib_write(struct file *fp, const char __user *data,ssize_t ret =0 ;void *dest; -if (WARN_ON_ONCE (!ib_safe_file_access (fp))) +if (!ib_safe_file_access (fp)) { +pr_err_once ("qib_write: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n" , +task_tgid_vnr (current), current->comm);return -EACCES ; + }if (count <sizeof (cmd.type)) { ret = -EINVAL ;
--
2.7.4
Doug Ledford
AppliedQuoted 7 lines · Leon Romanovsky
Quoted 6 lines · Jason Gunthorpe
Quoted 5 lines · Leon Romanovsky
Quoted 4 lines
In
ib_ucm_writefunction there is a wrong prefix:+ pr_err_once("ucm_write: process %d (%s) tried to do something hinky\n",
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
I did it intentionally to have the same errors for all flows.
Lets actually use a good message too please?
pr_err_once("ucm_write: process %d (%s) changed security contexts after opening FD, this is not allowed.\n",
Jason
I applied Leon's reworked version of this patch, thanks.
Signature · 2 lines
Doug Ledford <[email protected]> GPG Key ID: 0E572FDD
Quoted 10 lines · Doug Ledford
Quoted 9 lines · Leon Romanovsky
Quoted 8 lines · Jason Gunthorpe
Quoted 6 lines · Leon Romanovsky
Quoted 4 lines
In
ib_ucm_writefunction there is a wrong prefix:+ pr_err_once("ucm_write: process %d (%s) tried to do something hinky\n",
I did it intentionally to have the same errors for all flows.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Lets actually use a good message too please?
pr_err_once("ucm_write: process %d (%s) changed security contexts after opening FD, this is not allowed.\n",
Jason
I applied Leon's reworked version of this patch, thanks.
Thanks Doug,
I already forgot about it :)
Quoted 5 lines
--
Doug Ledford <[email protected]>
GPG Key ID: 0E572FDD