Netdev List
 help / color / mirror / Atom feed
From: Hayes Wang <hayeswang@realtek.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "palmer@sifive.com" <palmer@sifive.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	nic_swsd <nic_swsd@realtek.com>
Subject: skb_to_sgvec() casuses sg_pcopy_to_buffer() wrong
Date: Thu, 20 Jun 2019 06:17:10 +0000	[thread overview]
Message-ID: <0835B3720019904CB8F7AA43166CEEB2F189FDF5@RTITMBSVM03.realtek.com.tw> (raw)

Use skb_to_sgvec() to set scatter list, and sometime we would get a
sg->offset which is more than PAGE_SIZE. Call sg_pcopy_to_buffer()
with this scatter list would get wrong data.

In sg_miter_get_next_page(), you would get wrong miter->__remaining,
when the sg->offset is more than PAGE_SIZE.

static bool sg_miter_get_next_page(struct sg_mapping_iter *miter)
{
	if (!miter->__remaining) {
		struct scatterlist *sg;
		unsigned long pgoffset;

		if (!__sg_page_iter_next(&miter->piter))
			return false;

		sg = miter->piter.sg;
		pgoffset = miter->piter.sg_pgoffset;

		miter->__offset = pgoffset ? 0 : sg->offset;
		miter->__remaining = sg->offset + sg->length -
				(pgoffset << PAGE_SHIFT) - miter->__offset;
		miter->__remaining = min_t(unsigned long, miter->__remaining,
					   PAGE_SIZE - miter->__offset);
	}

	return true;
}

Best Regards,
Hayes


                 reply	other threads:[~2019-06-20  6:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=0835B3720019904CB8F7AA43166CEEB2F189FDF5@RTITMBSVM03.realtek.com.tw \
    --to=hayeswang@realtek.com \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.com \
    --cc=palmer@sifive.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