[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <17a1b72e-2c2a-8492-cb92-4dec36a6531d@acm.org>
Date: Mon, 1 Nov 2021 20:06:38 -0700
From: Bart Van Assche <bvanassche@....org>
To: dgilbert@...erlog.com, Tadeusz Struk <tadeusz.struk@...aro.org>,
linux-scsi@...r.kernel.org
Cc: Christoph Hellwig <hch@....de>,
"James E . J . Bottomley" <jejb@...ux.ibm.com>,
"Martin K . Petersen" <martin.petersen@...cle.com>,
linux-kernel@...r.kernel.org, stable@...r.kernel.org,
syzbot+5516b30f5401d4dcbcae@...kaller.appspotmail.com
Subject: Re: [PATCH] scsi: core: initialize cmd->cmnd before it is used
On 11/1/21 18:56, Douglas Gilbert wrote:
> On 2021-11-01 4:20 p.m., Bart Van Assche wrote:
>> One of the functions in the call stack in the first message of this email
>> thread is sg_io(). I am not aware of any documentation that specifies
>> whether
>> it is valid to set cmd_len in the sg_io header to zero. My opinion is
>> that
>> the SG_IO implementation should either reject cmd_len == 0 or set cmd_len
>> to a valid value if it is zero.
>
> For the sg driver in production, the v3 interface users (including
> ioctl(<sg_fd>, SG_IO,) ) have this check:
>
> if ((!hp->cmdp) || (hp->cmd_len < 6) || (hp->cmd_len > sizeof
> (cmnd))) {
> sg_remove_request(sfp, srp);
> return -EMSGSIZE;
> }
Hi Doug,
Thanks for having taken a look. I found the above check in
sg_new_write(). To me that function seems to come from a code path that
is unrelated to sg_io(), the function shown in the call stack in the
email at the start of this thread. Maybe I overlooked something but I
haven't found a minimum size check for hdr->cmd_len in sg_io() before
the blk_execute_rq() call. Should such a check perhaps be added?
Thanks,
Bart.
Powered by blists - more mailing lists