linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oded Gabbay <oded.gabbay@gmail.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: "Linux-Kernel@Vger. Kernel. Org" <linux-kernel@vger.kernel.org>,
	Olof Johansson <olof@lixom.net>,
	Mike Rapoport <rppt@linux.ibm.com>,
	ogabbay@habana.ai, Arnd Bergmann <arnd@arndb.de>,
	Joe Perches <joe@perches.com>
Subject: Re: [PATCH v3 05/15] habanalabs: add command buffer module
Date: Fri, 8 Feb 2019 21:53:27 +0200	[thread overview]
Message-ID: <CAFCwf13hn+qEqv_CcR+O8fynUrz9Mma7mKzQr6COv48kTMoO=Q@mail.gmail.com> (raw)
In-Reply-To: <20190208120639.GA23483@kroah.com>

On Fri, Feb 8, 2019 at 2:06 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Mon, Feb 04, 2019 at 10:32:44PM +0200, Oded Gabbay wrote:
> > +int hl_cb_ioctl(struct hl_fpriv *hpriv, void *data)
> > +{
> > +     union hl_cb_args *args = data;
> > +     struct hl_device *hdev = hpriv->hdev;
> > +     u64 handle;
> > +     int rc;
> > +
> > +     switch (args->in.op) {
> > +     case HL_CB_OP_CREATE:
> > +             rc = hl_cb_create(hdev, &hpriv->cb_mgr, args->in.cb_size,
> > +                                     &handle, hpriv->ctx->asid);
>
> so cb_size comes from userspace, ok, you check for the value to be too
> small, but not too big.  That means someone can try to allocate too much
> memory, possibly crashing things, not good :(
Yes, correct, but even if I limit a single allocation to, let's say,
1MB, what's stopping a userspace process from allocating multiple CBs
and draining the system memory ? I'm counting on the oom module to
kill that process if it mis-behaves.
And, btw, I assumed there is hard limit of 4MB on a single
dma_alloc_coherent. i.e. I was never able to allocate more then 4MB
through that API. So I never thought I need to check for max size
because of that hard limit.
Am I missing something here ?

>
>
> > +             memset(args, 0, sizeof(*args));
> > +             args->out.cb_handle = handle;
> > +             break;
> > +     case HL_CB_OP_DESTROY:
> > +             rc = hl_cb_destroy(hdev, &hpriv->cb_mgr,
> > +                                     args->in.cb_handle);
> > +             memset(args, 0, sizeof(*args));
>
> Why zero this if it's not copied back to userspace?
Fixed
>
>
>
> > +             break;
> > +     default:
> > +             rc = -EINVAL;
>
> -ENOTTY is normally the "invalid ioctl value", right?
Fixed
>
> > +             break;
> > +     }
> > +
> > +     return rc;
> > +}
>
> thanks,
>
> greg k-h

  reply	other threads:[~2019-02-08 19:53 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04 20:32 [PATCH v3 00/15] Habana Labs kernel driver Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 01/15] habanalabs: add skeleton driver Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 03/15] habanalabs: add basic Goya support Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 04/15] habanalabs: add context and ASID modules Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 05/15] habanalabs: add command buffer module Oded Gabbay
2019-02-08 12:06   ` Greg KH
2019-02-08 19:53     ` Oded Gabbay [this message]
2019-02-09  9:09       ` Greg KH
2019-02-04 20:32 ` [PATCH v3 06/15] habanalabs: add basic Goya h/w initialization Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 07/15] habanalabs: add h/w queues module Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 08/15] habanalabs: add event queue and interrupts Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 09/15] habanalabs: add sysfs and hwmon support Oded Gabbay
2019-02-08 12:14   ` Greg KH
2019-02-08 21:18     ` Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 10/15] habanalabs: add device reset support Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 11/15] habanalabs: add command submission module Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 12/15] habanalabs: add virtual memory and MMU modules Oded Gabbay
2019-02-06 15:14   ` Mike Rapoport
2019-02-07 13:15     ` Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 13/15] habanalabs: implement INFO IOCTL Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 14/15] habanalabs: add debugfs support Oded Gabbay
2019-02-06 15:16   ` Mike Rapoport
2019-02-08 12:16   ` Greg KH
2019-02-08 21:24     ` Oded Gabbay
2019-02-04 20:32 ` [PATCH v3 15/15] Update MAINTAINERS and CREDITS with habanalabs info Oded Gabbay
2019-02-06 11:52 ` [PATCH v3 00/15] Habana Labs kernel driver Mike Rapoport
2019-02-08 21:33   ` Oded Gabbay
2019-02-08 21:43     ` Joe Perches
2019-02-08 21:44       ` Oded Gabbay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFCwf13hn+qEqv_CcR+O8fynUrz9Mma7mKzQr6COv48kTMoO=Q@mail.gmail.com' \
    --to=oded.gabbay@gmail.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ogabbay@habana.ai \
    --cc=olof@lixom.net \
    --cc=rppt@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).