mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Garry <john.g.garry@oracle.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>,
	Bryam Vargas <hexlabsecurity@proton.me>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Mike Christie <michael.christie@oracle.com>,
	Maurizio Lombardi <mlombard@redhat.com>,
	David Disseldorp <ddiss@suse.de>,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] scsi: target: copy iSCSI ISID before unmapping the PR OUT buffer
Date: Tue, 9 Jun 2026 13:14:25 +0100	[thread overview]
Message-ID: <6b6ebec8-0e92-41bd-8001-0608ee6e804b@oracle.com> (raw)
In-Reply-To: <239dd72a5ee388486f60eff7e6b025d130e08266.camel@HansenPartnership.com>

On 09/06/2026 12:36, James Bottomley wrote:
> On Tue, 2026-06-09 at 09:50 +0100, John Garry wrote:
>>> @@ -1808,9 +1809,11 @@ core_scsi3_decode_spec_i_port(
>>>     		core_scsi3_tpg_undepend_item(dest_tpg);
>>>     	}
>>>
>>> +	kfree(iport_ptr);
>>>     	return 0;
>>>     out_unmap:
>>>     	transport_kunmap_data_sg(cmd);
>>> +	kfree(iport_ptr);
>>
>> sorry for suggesting this change, but this is worse than what you had
>> originally, as we have so many paths to call kfree() [which means
>> more bugs possible]
>>
>> it's hard to make good suggestions for this target code as the
>> functions are so large and complex.
> 
> Given that it's allocated in a function called by the routine but never
> actually retained by anything what about defining it as
> 
> chat *iport_ptr __free(kfree) = NULL;
> 
> ?  That way we don't need to care about freeing it in the error legs.

It's not just freed in the error legs, as 
core_scsi3_decode_spec_i_port() calls target_parse_pr_out() in a loop

while (tpdl > 0) {

...

	spin_lock(&dev->se_port_lock);
	list_for_each_entry(tmp_lun, &dev->dev_sep_list, lun_dev_link) {
		...

		kfree(iport_ptr);
		iport_ptr = NULL;
		tid_found = target_parse_pr_out_transport_id(tmp_tpg,
				ptr, &tid_len, &iport_ptr, i_str);
		if (!tid_found)
			continue;

....

	kfree(iport_ptr);
out_unmap:
	kfree(iport_ptr);
out:
	...

If __free(kfree) attr can still handle this sort of flow, then ok.

I still think that it would be simpler to keep the mapping in place for 
longer (to avoid all of this), if possible.

Thanks,
John

  reply	other threads:[~2026-06-09 12:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09  0:59 Bryam Vargas
2026-06-09  8:50 ` John Garry
2026-06-09 11:36   ` James Bottomley
2026-06-09 12:14     ` John Garry [this message]
2026-06-09 12:27       ` James Bottomley
2026-06-10  4:22         ` Bryam Vargas

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=6b6ebec8-0e92-41bd-8001-0608ee6e804b@oracle.com \
    --to=john.g.garry@oracle.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=ddiss@suse.de \
    --cc=hexlabsecurity@proton.me \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=michael.christie@oracle.com \
    --cc=mlombard@redhat.com \
    --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

all inboxes | Powered by JetHome®