From: Michael Neuling <mikey@neuling.org>
To: manoj@linux.vnet.ibm.com
Cc: "Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
linux-scsi@vger.kernel.org,
James.Bottomley@HansenPartnership.com, nab@linux-iscsi.org,
brking@linux.vnet.ibm.com, wenxiong@linux.vnet.ibm.com,
hch@infradead.org, imunsie@au1.ibm.com, dja@ozlabs.au.ibm.com
Subject: Re: [PATCH v4 3/3] cxlflash: Virtual LUN support
Date: Wed, 12 Aug 2015 13:24:11 +1000 [thread overview]
Message-ID: <1439349851.28873.48.camel@neuling.org> (raw)
In-Reply-To: <55CA71FB.7090705@linux.vnet.ibm.com>
> > Be good to do some clear sanity check the "struct dk_cxlflash_resize *resize"
> > here. It's passed from userspace but then gets propogated to a bunch of other
> > things here like nsectors, get_context etc who will all now be responsible for
> > handling any dodgy data passed in.
> >
> > Same with all the other ioctl calls. Sanity check the parameters ASAP. Don't
> > propagate potentially dodgy values all over the code base.
> >
>
> The ioctls have a standard header structure, with version etc. that are
> sanity checked before we get here. The other fields are sanity checked
> where they are used, i.e. in get_context().
That was my point. Let's do it upfront so it's clear they've been
checked.
> >> + /*
> >> + * The requested size (req_size) is always assumed to be in 4k blocks,
> >> + * so we have to convert it here from 4k to chunk size.
> >> + */
> >> + nsectors = (resize->req_size * CXLFLASH_BLOCK_SIZE) / gli->blk_len;
> >> + new_size = DIV_ROUND_UP(nsectors, MC_CHUNK_SIZE);
> >
> > Like here. resize->req_size => new_size => grow_lxt() now grow_lxt() need to
> > sanity check new_size.
>
>
> This is a best effort allocator. If an allocation request y, cannot be
> satisfied because of insufficient space in the LUN (i.e. only x amount
> of space is available), then the allocator returns the remaining space
> (x). This best effort allocation mechanism avoids having to sanity check
> the size parameter.
Sounds delicate to me.
>
>
> >> + struct dk_cxlflash_uvirtual *virt = (struct dk_cxlflash_uvirtual *)arg;
> >
> > Again, this should be sanity checked.
>
> Same as comment above.
>
> >> + /* Resize even if requested size is 0 */
> >> + marshal_virt_to_resize(virt, &resize);
> >
> > Virt has not been sanity checked. So now resize can contain bad data.
> >
> >
> >> + resize.rsrc_handle = rsrc_handle;
>
> Same as above. As mentioned earlier, the size is immaterial. The rest of
> the parameters are set here (rsrc_handle).
Humm.
> >> +#define LXT_LUNIDX_SHIFT 8 /* LXT entry, shift for LUN index */
> >> +#define LXT_PERM_SHIFT 4 /* LXT entry, shift for permission bits */
> >
> > What is LXT?
>
> LXT = lun translation table. There is one LXT entry per set of
> contiguous blocks for a virtual LUN (known both to the host and to the
> AFU). Will clarify this with inline comments.
Please document this acronym before using it.
Mikey
next prev parent reply other threads:[~2015-08-12 3:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-10 17:09 [PATCH v4 3/3] cxlflash: Virtual LUN support Matthew R. Ochs
2015-08-11 10:54 ` Michael Neuling
2015-08-11 22:06 ` Manoj Kumar
2015-08-12 3:24 ` Michael Neuling [this message]
2015-08-12 20:00 ` Manoj Kumar
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=1439349851.28873.48.camel@neuling.org \
--to=mikey@neuling.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=brking@linux.vnet.ibm.com \
--cc=dja@ozlabs.au.ibm.com \
--cc=hch@infradead.org \
--cc=imunsie@au1.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=manoj@linux.vnet.ibm.com \
--cc=mrochs@linux.vnet.ibm.com \
--cc=nab@linux-iscsi.org \
--cc=wenxiong@linux.vnet.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.