Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1526529 > unrolled thread

[PATCH v2] infiniband: remove WARN that is not kernel bug

Started byDmitry Vyukov <dvyukov@google.com>
First post2016-11-21 11:20 +0100
Last post2016-11-21 12:50 +0100
Articles 8 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] infiniband: remove WARN that is not kernel bug Dmitry Vyukov <dvyukov@google.com> - 2016-11-21 11:20 +0100
    Re: [PATCH v2] infiniband: remove WARN that is not kernel bug Miroslav Benes <mbenes@suse.cz> - 2016-11-21 11:30 +0100
      Re: [PATCH v2] infiniband: remove WARN that is not kernel bug Dmitry Vyukov <dvyukov@google.com> - 2016-11-21 11:40 +0100
        Re: [PATCH v2] infiniband: remove WARN that is not kernel bug Dmitry Vyukov <dvyukov@google.com> - 2016-11-21 12:50 +0100
          Re: [PATCH v2] infiniband: remove WARN that is not kernel bug Leon Romanovsky <leon@kernel.org> - 2016-11-21 13:20 +0100
            Re: [PATCH v2] infiniband: remove WARN that is not kernel bug Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-21 18:00 +0100
              Re: [PATCH v2] infiniband: remove WARN that is not kernel bug Leon Romanovsky <leon@kernel.org> - 2016-11-21 18:40 +0100
        Re: [PATCH v2] infiniband: remove WARN that is not kernel bug Leon Romanovsky <leon@kernel.org> - 2016-11-21 12:50 +0100

#1526529 — [PATCH v2] infiniband: remove WARN that is not kernel bug

FromDmitry Vyukov <dvyukov@google.com>
Date2016-11-21 11:20 +0100
Subject[PATCH v2] infiniband: remove WARN that is not kernel bug
Message-ID<sFTRE-8lZ-33@gated-at.bofh.it>
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.

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: linux-rdma@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: syzkaller@googlegroups.com

---
Changes since v1:
 - added printk_once
---
 drivers/infiniband/core/ucma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 9520154..405d0ce 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -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;
-- 
2.8.0.rc3.226.g39d4020

[toc] | [next] | [standalone]


#1526533

FromMiroslav Benes <mbenes@suse.cz>
Date2016-11-21 11:30 +0100
Message-ID<sFU1k-8p7-19@gated-at.bofh.it>
In reply to#1526529
On Mon, 21 Nov 2016, Dmitry Vyukov wrote:

> 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.
> 
> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
> Cc: Doug Ledford <dledford@redhat.com>
> Cc: Sean Hefty <sean.hefty@intel.com>
> Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: linux-rdma@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: syzkaller@googlegroups.com
> 
> ---
> Changes since v1:
>  - added printk_once
> ---
>  drivers/infiniband/core/ucma.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
> index 9520154..405d0ce 100644
> --- a/drivers/infiniband/core/ucma.c
> +++ b/drivers/infiniband/core/ucma.c
> @@ -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;

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

[toc] | [prev] | [next] | [standalone]


#1526551

FromDmitry Vyukov <dvyukov@google.com>
Date2016-11-21 11:40 +0100
Message-ID<sFUb0-8sg-33@gated-at.bofh.it>
In reply to#1526533
On Mon, Nov 21, 2016 at 11:25 AM, Miroslav Benes <mbenes@suse.cz> wrote:
> On Mon, 21 Nov 2016, Dmitry Vyukov wrote:
>
>> 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.
>>
>> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
>> Cc: Doug Ledford <dledford@redhat.com>
>> Cc: Sean Hefty <sean.hefty@intel.com>
>> Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
>> Cc: Leon Romanovsky <leon@kernel.org>
>> Cc: linux-rdma@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> Cc: syzkaller@googlegroups.com
>>
>> ---
>> Changes since v1:
>>  - added printk_once
>> ---
>>  drivers/infiniband/core/ucma.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
>> index 9520154..405d0ce 100644
>> --- a/drivers/infiniband/core/ucma.c
>> +++ b/drivers/infiniband/core/ucma.c
>> @@ -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;
>
> 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?


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.

[toc] | [prev] | [next] | [standalone]


#1526591

FromDmitry Vyukov <dvyukov@google.com>
Date2016-11-21 12:50 +0100
Message-ID<sFVgJ-C3-1@gated-at.bofh.it>
In reply to#1526551
On Mon, Nov 21, 2016 at 12:44 PM, Leon Romanovsky <leon@kernel.org> wrote:
> On Mon, Nov 21, 2016 at 11:30:21AM +0100, Dmitry Vyukov wrote:
>> On Mon, Nov 21, 2016 at 11:25 AM, Miroslav Benes <mbenes@suse.cz> wrote:
>> > On Mon, 21 Nov 2016, Dmitry Vyukov wrote:
>> >
>> >> 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.
>> >>
>> >> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
>> >> Cc: Doug Ledford <dledford@redhat.com>
>> >> Cc: Sean Hefty <sean.hefty@intel.com>
>> >> Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
>> >> Cc: Leon Romanovsky <leon@kernel.org>
>> >> Cc: linux-rdma@vger.kernel.org
>> >> Cc: linux-kernel@vger.kernel.org
>> >> Cc: syzkaller@googlegroups.com
>> >>
>> >> ---
>> >> Changes since v1:
>> >>  - added printk_once
>> >> ---
>> >>  drivers/infiniband/core/ucma.c | 5 ++++-
>> >>  1 file changed, 4 insertions(+), 1 deletion(-)
>> >>
>> >> diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
>> >> index 9520154..405d0ce 100644
>> >> --- a/drivers/infiniband/core/ucma.c
>> >> +++ b/drivers/infiniband/core/ucma.c
>> >> @@ -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;
>> >
>> > 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?
>>
>>
>> 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.

[toc] | [prev] | [next] | [standalone]


#1526623

FromLeon Romanovsky <leon@kernel.org>
Date2016-11-21 13:20 +0100
Message-ID<sFVJM-15x-33@gated-at.bofh.it>
In reply to#1526591

[Multipart message — attachments visible in raw view] — view raw

On Mon, Nov 21, 2016 at 12:48:35PM +0100, Dmitry Vyukov wrote:
> On Mon, Nov 21, 2016 at 12:44 PM, Leon Romanovsky <leon@kernel.org> wrote:
> > On Mon, Nov 21, 2016 at 11:30:21AM +0100, Dmitry Vyukov wrote:
> >> On Mon, Nov 21, 2016 at 11:25 AM, Miroslav Benes <mbenes@suse.cz> wrote:
> >> > On Mon, 21 Nov 2016, Dmitry Vyukov wrote:
> >> >
> >> >> 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.
> >> >>
> >> >> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
> >> >> Cc: Doug Ledford <dledford@redhat.com>
> >> >> Cc: Sean Hefty <sean.hefty@intel.com>
> >> >> Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
> >> >> Cc: Leon Romanovsky <leon@kernel.org>
> >> >> Cc: linux-rdma@vger.kernel.org
> >> >> Cc: linux-kernel@vger.kernel.org
> >> >> Cc: syzkaller@googlegroups.com
> >> >>
> >> >> ---
> >> >> Changes since v1:
> >> >>  - added printk_once
> >> >> ---
> >> >>  drivers/infiniband/core/ucma.c | 5 ++++-
> >> >>  1 file changed, 4 insertions(+), 1 deletion(-)
> >> >>
> >> >> diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
> >> >> index 9520154..405d0ce 100644
> >> >> --- a/drivers/infiniband/core/ucma.c
> >> >> +++ b/drivers/infiniband/core/ucma.c
> >> >> @@ -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;
> >> >
> >> > 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?
> >>
> >>
> >> 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",

I did it intentionally to have the same errors for all flows.

>
> Otherwise looks good. Thanks.

[toc] | [prev] | [next] | [standalone]


#1526907

FromJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Date2016-11-21 18:00 +0100
Message-ID<sG06K-3IM-7@gated-at.bofh.it>
In reply to#1526623
On Mon, Nov 21, 2016 at 02:14:08PM +0200, Leon Romanovsky wrote:
> >
> > In ib_ucm_write function 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

[toc] | [prev] | [next] | [standalone]


#1526948

FromLeon Romanovsky <leon@kernel.org>
Date2016-11-21 18:40 +0100
Message-ID<sG0Js-4aC-29@gated-at.bofh.it>
In reply to#1526907

[Multipart message — attachments visible in raw view] — view raw

On Mon, Nov 21, 2016 at 09:52:53AM -0700, Jason Gunthorpe wrote:
> On Mon, Nov 21, 2016 at 02:14:08PM +0200, Leon Romanovsky wrote:
> > >
> > > In ib_ucm_write function 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

[toc] | [prev] | [next] | [standalone]


#1526597

FromLeon Romanovsky <leon@kernel.org>
Date2016-11-21 12:50 +0100
Message-ID<sFVgJ-C3-3@gated-at.bofh.it>
In reply to#1526551

[Multipart message — attachments visible in raw view] — view raw

On Mon, Nov 21, 2016 at 11:30:21AM +0100, Dmitry Vyukov wrote:
> On Mon, Nov 21, 2016 at 11:25 AM, Miroslav Benes <mbenes@suse.cz> wrote:
> > On Mon, 21 Nov 2016, Dmitry Vyukov wrote:
> >
> >> 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.
> >>
> >> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
> >> Cc: Doug Ledford <dledford@redhat.com>
> >> Cc: Sean Hefty <sean.hefty@intel.com>
> >> Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
> >> Cc: Leon Romanovsky <leon@kernel.org>
> >> Cc: linux-rdma@vger.kernel.org
> >> Cc: linux-kernel@vger.kernel.org
> >> Cc: syzkaller@googlegroups.com
> >>
> >> ---
> >> Changes since v1:
> >>  - added printk_once
> >> ---
> >>  drivers/infiniband/core/ucma.c | 5 ++++-
> >>  1 file changed, 4 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
> >> index 9520154..405d0ce 100644
> >> --- a/drivers/infiniband/core/ucma.c
> >> +++ b/drivers/infiniband/core/ucma.c
> >> @@ -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;
> >
> > 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?
>
>
> I guess so.
> Can I ask somebody of infiniband maintainers to take care of this?

Please see below,
Hope it helps.


> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web