public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Bodo Stroesser <bostroesser@gmail.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>,
	linux-scsi@vger.kernel.org, martin.petersen@oracle.com,
	jejb@linux.vnet.ibm.com, hare@suse.de, bvanassche@acm.org
Subject: Re: [PATCH 1/5] sgl_alloc_order: remove 4 GiB limit
Date: Mon, 24 Oct 2022 14:32:25 -0300	[thread overview]
Message-ID: <Y1bMKU5nq5DXYdbw@ziepe.ca> (raw)
In-Reply-To: <665f8dee-6688-60d1-5097-49f9726c38ec@gmail.com>

On Mon, Oct 24, 2022 at 04:32:30PM +0200, Bodo Stroesser wrote:
> > +struct scatterlist *sgl_alloc_order(size_t length, unsigned int order,
> > +				    bool chainable, gfp_t gfp, size_t *nent_p)
> >   {
> >   	struct scatterlist *sgl, *sg;
> >   	struct page *page;
> > -	unsigned int nent, nalloc;
> > +	size_t nent, nalloc;
> >   	u32 elem_len;
> > -	nent = round_up(length, PAGE_SIZE << order) >> (PAGE_SHIFT + order);
> > -	/* Check for integer overflow */
> > -	if (length > (nent << (PAGE_SHIFT + order)))
> > -		return NULL;
> > +	nent = length >> (PAGE_SHIFT + order);
> > +	if (length % (1 << (PAGE_SHIFT + order)))
> 
> This might end up doing a modulo operation for divisor 0, if caller
> specifies a too high order parameter, right?

If that happens then the first >> will be busted too and this is all
broken..

We assume the caller will pass a valid order paramter it seems, it is
not userspace controlled.

Jason

  reply	other threads:[~2022-10-24 19:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24  1:02 [PATCH 0/5] scatterlist: add operations for scsi_debug Douglas Gilbert
2022-10-24  1:02 ` [PATCH 1/5] sgl_alloc_order: remove 4 GiB limit Douglas Gilbert
2022-10-24 12:21   ` Jason Gunthorpe
2022-10-24 14:32     ` Bodo Stroesser
2022-10-24 17:32       ` Jason Gunthorpe [this message]
2022-10-24 19:58         ` Douglas Gilbert
2022-10-25 12:19           ` Jason Gunthorpe
2022-10-25 10:46         ` Bodo Stroesser
2022-10-25 12:18           ` Jason Gunthorpe
2022-10-24  1:02 ` [PATCH 2/5] scatterlist: add sgl_copy_sgl() function Douglas Gilbert
2022-10-24  1:02 ` [PATCH 3/5] scatterlist: add sgl_equal_sgl() function Douglas Gilbert
2022-10-24  1:02 ` [PATCH 4/5] scatterlist: add sgl_memset() Douglas Gilbert
2022-10-24  1:02 ` [PATCH 5/5] scsi_debug: change store from vmalloc to sgl Douglas Gilbert
2022-10-24 15:08   ` Bodo Stroesser

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=Y1bMKU5nq5DXYdbw@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=bostroesser@gmail.com \
    --cc=bvanassche@acm.org \
    --cc=dgilbert@interlog.com \
    --cc=hare@suse.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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