mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: "Ваторопин Андрей" <a.vatoropin@crpt.ru>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Sudhakar Panneerselvam <sudhakar.panneerselvam@oracle.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"target-devel@vger.kernel.org" <target-devel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] scsi: target: reset t_task_cdb pointer in error case
Date: Tue, 18 Nov 2025 13:57:31 -0600	[thread overview]
Message-ID: <d8d6830a-76f9-46d8-8643-69aec7ffb399@oracle.com> (raw)
In-Reply-To: <20251118084014.324940-1-a.vatoropin@crpt.ru>

On 11/18/25 2:42 AM, Ваторопин Андрей wrote:
> From: Andrey Vatoropin <a.vatoropin@crpt.ru>
> 
> If allocation of cmd->t_task_cdb fails, it remains NULL but is later
> dereferenced at the 'err' path.
> 
> In case of error reset NULL t_task_cdb value to point at the default
> fixed-size buffer.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 9e95fb805dc0 ("scsi: target: Fix NULL pointer dereference")
> Cc: stable@vger.kernel.org
> Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru>
> ---
>  drivers/target/target_core_transport.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index 0a76bdfe5528..88544c911949 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -1524,6 +1524,7 @@ target_cmd_init_cdb(struct se_cmd *cmd, unsigned char *cdb, gfp_t gfp)
>  	if (scsi_command_size(cdb) > sizeof(cmd->__t_task_cdb)) {
>  		cmd->t_task_cdb = kzalloc(scsi_command_size(cdb), gfp);
>  		if (!cmd->t_task_cdb) {
> +			cmd->t_task_cdb = &cmd->__t_task_cdb[0];
>  			pr_err("Unable to allocate cmd->t_task_cdb"
>  				" %u > sizeof(cmd->__t_task_cdb): %lu ops\n",
>  				scsi_command_size(cdb),


Reviewed-by: Mike Christie <michael.christie@oracle.com>

      reply	other threads:[~2025-11-18 19:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-18  8:42 Ваторопин Андрей
2025-11-18 19:57 ` Mike Christie [this message]

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=d8d6830a-76f9-46d8-8643-69aec7ffb399@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=a.vatoropin@crpt.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=martin.petersen@oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=sudhakar.panneerselvam@oracle.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®