linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: Asias He <asias@redhat.com>
Cc: Ben Hutchings <ben@decadent.org.uk>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	target-devel <target-devel@vger.kernel.org>
Subject: Re: [ 04/21] target/pscsi: Fix page increment
Date: Mon, 18 Mar 2013 14:00:34 -0700	[thread overview]
Message-ID: <1363640434.3156.36.camel@haakon2.linux-iscsi.org> (raw)
In-Reply-To: <20130318053519.GE6232@hj.localdomain>

On Mon, 2013-03-18 at 13:35 +0800, Asias He wrote:
> On Sat, Mar 16, 2013 at 02:10:22AM +0000, Ben Hutchings wrote:
> > On Tue, 2013-03-12 at 15:44 -0700, Greg Kroah-Hartman wrote:
> > > 3.0-stable review patch.  If anyone has any objections, please let me know.
> > > 
> > > ------------------
> > > 
> > > From: Asias He <asias@redhat.com>
> > > 
> > > commit 472b72f2db7831d7dbe22ffdff4adee3bd49b05d upstream.
> > > 
> > > The page++ is wrong. It makes bio_add_pc_page() pointing to a wrong page
> > > address if the 'while (len > 0 && data_len > 0) { ... }' loop is
> > > executed more than one once.
> > > 
> > > Signed-off-by: Asias He <asias@redhat.com>
> > > Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > 
> > > ---
> > >  drivers/target/target_core_pscsi.c |    1 -
> > >  1 file changed, 1 deletion(-)
> > > 
> > > --- a/drivers/target/target_core_pscsi.c
> > > +++ b/drivers/target/target_core_pscsi.c
> > > @@ -1210,7 +1210,6 @@ static int __pscsi_map_task_SG(
> > >  				bio = NULL;
> > >  			}
> > >  
> > > -			page++;
> > >  			len -= bytes;
> > >  			data_len -= bytes;
> > >  			off = 0;
> > 
> > So in case a fragment crosses a page boundary, we wrap around to the
> > beginning of the same page?  That doesn't look right.
> 
> If the fragment crosses a page boundary, what is the correct page
> for it?
> 
> Nicholas, can we assume sg->length + sg->offset should be less than PAGE_SIZE here?
> 

sg->length + sg->offset can be less than or equal to PAGE_SIZE here.

For everything other than tcm_loop + tcm_vhost using externally
allocated SGLs, we can expect fragments to never cross the page
boundary.

For tcm_loop + tcm_vhost, there are a few special cases with control CDB
paylaods (usually going through scsi-generic) where we can have a non
zero sg->offset, but at least in the cases I've seen this is still not
using SGL elements that exceed PAGE_SIZE.

So, I think this logic is OK for SGLs that cross page boundries, given
that it's done outside of the inner loop where *page is set during each
for_each_sg().  The case where this logic is broken, and that the 'page
++' was addressing is when sg->length > PAGE_SIZE.

--nab


  reply	other threads:[~2013-03-18 21:00 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-12 22:44 [ 00/21] 3.0.69-stable review Greg Kroah-Hartman
2013-03-12 22:44 ` [ 01/21] ARM: VFP: fix emulation of second VFP instruction Greg Kroah-Hartman
2013-03-12 22:44 ` [ 02/21] ARM: fix scheduling while atomic warning in alignment handling code Greg Kroah-Hartman
2013-03-12 22:44 ` [ 03/21] SCSI: dc395x: uninitialized variable in device_alloc() Greg Kroah-Hartman
2013-03-12 22:44 ` [ 04/21] target/pscsi: Fix page increment Greg Kroah-Hartman
2013-03-16  2:10   ` Ben Hutchings
2013-03-18  5:35     ` Asias He
2013-03-18 21:00       ` Nicholas A. Bellinger [this message]
2013-03-18 23:30         ` Ben Hutchings
2013-03-19  0:56           ` Asias He
2013-03-19  1:18             ` Ben Hutchings
2013-03-19  3:18               ` Nicholas A. Bellinger
2013-03-12 22:44 ` [ 05/21] btrfs: Init io_lock after cloning btrfs device struct Greg Kroah-Hartman
2013-03-12 22:44 ` [ 06/21] cifs: ensure that cifs_get_root() only traverses directories Greg Kroah-Hartman
2013-03-12 22:44 ` [ 07/21] SUNRPC: Dont start the retransmission timer when out of socket space Greg Kroah-Hartman
2013-03-12 22:44 ` [ 08/21] hw_random: make buffer usable in scatterlist Greg Kroah-Hartman
2013-03-12 22:44 ` [ 09/21] ath9k: fix RSSI dummy marker value Greg Kroah-Hartman
2013-03-12 22:44 ` [ 10/21] md: raid0: fix error return from create_stripe_zones Greg Kroah-Hartman
2013-03-12 22:44 ` [ 11/21] hwmon: (sht15) Check return value of regulator_enable() Greg Kroah-Hartman
2013-03-16  4:15   ` Ben Hutchings
2013-03-16 13:33     ` Guenter Roeck
2013-03-12 22:44 ` [ 12/21] drm/radeon: add primary dac adj quirk for R200 board Greg Kroah-Hartman
2013-03-12 22:44 ` [ 13/21] ALSA: ice1712: Initialize card->private_data properly Greg Kroah-Hartman
2013-03-12 22:44 ` [ 14/21] ALSA: vmaster: Fix slave change notification Greg Kroah-Hartman
2013-03-12 22:44 ` [ 15/21] e1000e: fix pci-device enable-counter balance Greg Kroah-Hartman
2013-03-12 22:44 ` [ 16/21] keys: fix race with concurrent install_user_keyrings() Greg Kroah-Hartman
2013-03-12 22:44 ` [ 17/21] vfs: fix pipe counter breakage Greg Kroah-Hartman
2013-03-12 22:44 ` [ 18/21] Fix memory leak in cpufreq stats Greg Kroah-Hartman
2013-03-12 22:44 ` [ 19/21] ftrace: Update the kconfig for DYNAMIC_FTRACE Greg Kroah-Hartman
2013-03-12 22:44 ` [ 20/21] decnet: Fix disappearing sysctl entries Greg Kroah-Hartman
     [not found]   ` <B401117D-23F6-4911-8D72-344EE1A022F6@usgs.gov>
2013-03-12 23:04     ` Eric W. Biederman
     [not found]       ` <3EDA829E-3898-4626-9C17-CCE31E8C0554@usgs.gov>
2013-03-13 20:05         ` Eric W. Biederman
2013-03-12 23:06     ` Greg Kroah-Hartman
2013-03-12 22:44 ` [ 21/21] dmi_scan: fix missing check for _DMI_ signature in smbios_present() Greg Kroah-Hartman
2013-03-13  3:56 ` [ 00/21] 3.0.69-stable review Shuah Khan

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=1363640434.3156.36.camel@haakon2.linux-iscsi.org \
    --to=nab@linux-iscsi.org \
    --cc=asias@redhat.com \
    --cc=ben@decadent.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=target-devel@vger.kernel.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).