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] [thread-next>] [day] [month] [year] [list]
Message-ID: <716dc0b3-f663-b37d-6d97-fb3c3887a97b@huawei.com>
Date: Tue, 27 Aug 2024 19:12:23 +0800
From: "lihuisong (C)" <lihuisong@...wei.com>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
CC: <xuwei5@...ilicon.com>, <linux-kernel@...r.kernel.org>, <soc@...nel.org>,
	<linux-arm-kernel@...ts.infradead.org>, <krzk@...nel.org>,
	<wanghuiqiang@...wei.com>, <liuyonglong@...wei.com>
Subject: Re: [PATCH v2 3/6] soc: hisilicon: kunpeng_hccs: Add the check for
 base address and size of shared memory


在 2024/8/23 16:38, Jonathan Cameron 写道:
> On Fri, 23 Aug 2024 11:10:56 +0800
> Huisong Li <lihuisong@...wei.com> wrote:
>
>> If the shmem_base_addr from PCCT is zero, hccs_register_pcc_channel will
>> return success. And then driver will access to illegal address when send
>> PCC command. In addition, the size of shared memory used for communication
>> between driver and platform is fixed, namely 64 Bytes which is
>> unchangeable. So add the verification for them.
>>
> As with previous, make it clear if this hardening or fix
> fix to catch a problem on shipping hardware (I assume not, but you never
> know!)
Ack
>
> A comment on existing code inline.  Not a suggestion for a change
> in this series, but maybe for the future.  There are a lot
> of goto err_mbx_channel_Free in here already and this patch adds
> another.  The cleanup there is trivial so DEFINE_FREE() and __free
> usage will make this code quite a bit nicer to read.
Yeah, it's a good way to simplify code on error path.
I will take into account it. thanks for your good suggestion.
>
>> Signed-off-by: Huisong Li <lihuisong@...wei.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
>
>> ---
>>   drivers/soc/hisilicon/kunpeng_hccs.c | 24 +++++++++++++++---------
>>   1 file changed, 15 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/kunpeng_hccs.c
>> index 6e88f597f267..6055e5091cbd 100644
>> --- a/drivers/soc/hisilicon/kunpeng_hccs.c
>> +++ b/drivers/soc/hisilicon/kunpeng_hccs.c
>> @@ -170,15 +170,21 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev)
>>   		goto err_mbx_channel_free;
>>   	}
>>   
>> -	if (pcc_chan->shmem_base_addr) {
>> -		cl_info->pcc_comm_addr = ioremap(pcc_chan->shmem_base_addr,
>> -						 pcc_chan->shmem_size);
>> -		if (!cl_info->pcc_comm_addr) {
>> -			dev_err(dev, "Failed to ioremap PCC communication region for channel-%u.\n",
>> -				hdev->chan_id);
>> -			rc = -ENOMEM;
>> -			goto err_mbx_channel_free;
>> -		}
>> +	if (!pcc_chan->shmem_base_addr ||
>> +	    pcc_chan->shmem_size != HCCS_PCC_SHARE_MEM_BYTES) {
>> +		dev_err(dev, "The base address or size (%llu) of PCC communication region is invalid.\n",
>> +			pcc_chan->shmem_size);
>> +		rc = -EINVAL;
>> +		goto err_mbx_channel_free;
> Worth considering for the future: Maybe a DEFINE_FREE for pcc_mbox_free_channel) makes sense,
> though if you do you should only assign cl_info->pcc_chan after all possible error paths.
Ack
>
>> +	}
>> +
>> +	cl_info->pcc_comm_addr = ioremap(pcc_chan->shmem_base_addr,
>> +					 pcc_chan->shmem_size);
>> +	if (!cl_info->pcc_comm_addr) {
>> +		dev_err(dev, "Failed to ioremap PCC communication region for channel-%u.\n",
>> +			hdev->chan_id);
>> +		rc = -ENOMEM;
>> +		goto err_mbx_channel_free;
>>   	}
>>   
>>   	return 0;
> .

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ