lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <07831891-58ab-1147-e5b0-a62cca243769@huawei.com>
Date:   Tue, 8 Dec 2020 18:10:37 +0000
From:   John Garry <john.garry@...wei.com>
To:     Xiaohui Zhang <ruc_zhangxiaohui@....com>,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        <linux-scsi@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] hisi_sas: Fix possible buffer overflows in
 prep_ssp_v3_hw

On 08/12/2020 16:40, Xiaohui Zhang wrote:
> From: Zhang Xiaohui <ruc_zhangxiaohui@....com>
> 
> prep_ssp_v3_hw() calls memcpy() without checking the
> destination size may trigger a buffer overflower, which a
> local user could use to cause denial of service or the
> execution of arbitrary code.
> Fix it by putting the length check before calling memcpy().
> 
> Signed-off-by: Zhang Xiaohui <ruc_zhangxiaohui@....com>
> ---
>   drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
> index 7133ca859..2664c36d3 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
> @@ -1267,7 +1267,8 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
>   	memcpy(buf_cmd, &task->ssp_task.LUN, 8);
>   	if (!tmf) {
>   		buf_cmd[9] = ssp_task->task_attr | (ssp_task->task_prio << 3);
> -		memcpy(buf_cmd + 12, scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
> +		memcpy(buf_cmd + 12, scsi_cmnd->cmnd,
> +		       min_t(unsigned short, scsi_cmnd->cmd_len, strlen(buf_cmd)-12));

buf_cmd is not a NULL-terminated string, it's actually a pointer to a 
structure.

And you can see that we set buf_cmd[9] previously (which could set as 
0), so how can you possibly rely on a strlen(buf_cmd) - 12 being sane?

Thanks,
john

>   	} else {
>   		buf_cmd[10] = tmf->tmf;
>   		switch (tmf->tmf) {
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ