netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Tom Tucker <tom-/Yg/VP3ZvrM@public.gmane.org>
Cc: "J. Bruce Fields"
	<bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: question about map_read_chunks()
Date: Mon, 20 Feb 2012 12:50:19 +0300	[thread overview]
Message-ID: <20120220095019.GA21338@elgon.mountain> (raw)

I had a couple questions about some map_read_chunks().

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

   150          ch_bytes = ntohl(ch->rc_target.rs_length);
                ^^^^^^^^
It look like this is 32 bits from the network?

   151          head->arg.head[0] = rqstp->rq_arg.head[0];
   152          head->arg.tail[0] = rqstp->rq_arg.tail[0];
   153          head->arg.pages = &head->pages[head->count];
   154          head->hdr_count = head->count; /* save count of hdr pages */
   155          head->arg.page_base = 0;
   156          head->arg.page_len = ch_bytes;
   157          head->arg.len = rqstp->rq_arg.len + ch_bytes;
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Can overflow.
   158          head->arg.buflen = rqstp->rq_arg.buflen + ch_bytes;
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Same.  I didn't follow it through to see if an overflow matters.  Does
it?

   159          head->count++;
   160          chl_map->ch[0].start = 0;
   161          while (byte_count) {
   162                  rpl_map->sge[sge_no].iov_base =
   163                          page_address(rqstp->rq_arg.pages[page_no]) + page_off;
   164                  sge_bytes = min_t(int, PAGE_SIZE-page_off, ch_bytes);
                                          ^^^
This is the wrong cast to use.  A large ch_bytes would be counted as a
negative value and get around the cap here.

   165                  rpl_map->sge[sge_no].iov_len = sge_bytes;

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2012-02-20  9:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-20  9:50 Dan Carpenter [this message]
2013-09-27 12:21 ` question about map_read_chunks() Dan Carpenter
2013-09-27 15:23   ` Tom Tucker
     [not found]     ` <5245A2DE.9020307-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
2013-09-27 20:15       ` J. Bruce Fields

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=20120220095019.GA21338@elgon.mountain \
    --to=dan.carpenter-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tom-/Yg/VP3ZvrM@public.gmane.org \
    /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).