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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250212163555.000025ca@huawei.com>
Date: Wed, 12 Feb 2025 16:35:55 +0000
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Zaid Alali <zaidal@...amperecomputing.com>
CC: <rafael@...nel.org>, <lenb@...nel.org>, <james.morse@....com>,
	<tony.luck@...el.com>, <bp@...en8.de>, <robert.moore@...el.com>,
	<dan.j.williams@...el.com>, <Benjamin.Cheatham@....com>,
	<Avadhut.Naik@....com>, <viro@...iv.linux.org.uk>, <arnd@...db.de>,
	<ira.weiny@...el.com>, <dave.jiang@...el.com>,
	<sthanneeru.opensrc@...ron.com>, <linux-acpi@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, <acpica-devel@...ts.linux.dev>
Subject: Re: [PATCH v3 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse
 warning

On Mon, 10 Feb 2025 10:36:59 -0800
Zaid Alali <zaidal@...amperecomputing.com> wrote:

> This patch fixes the kernel test robot warning reported here:
> https://lore.kernel.org/all/202410241620.oApALow5-lkp@intel.com/
> 
> Signed-off-by: Zaid Alali <zaidal@...amperecomputing.com>

Hi Zaid,

Why in the read direction use structures on the stack, but in the
write direction kmalloc them? I think they could all just be 
stack variables as they are all pretty small.

Jonathan

>  }
> @@ -444,8 +453,10 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
>  		return rc;
>  	apei_exec_ctx_set_input(&ctx, type);
>  	if (acpi5) {
> -		struct set_error_type_with_address *v5param = einj_param;
> +		struct set_error_type_with_address *v5param;
>  
> +		v5param = kmalloc(sizeof(*v5param), GFP_KERNEL);
As below. Not sure why you can't just use the stack for this.
It's not very big.

> +		memcpy_fromio(v5param, einj_param, sizeof(*v5param));
>  		v5param->type = type;
>  		if (type & ACPI5_VENDOR_BIT) {
>  			switch (vendor_flags) {
> @@ -490,15 +501,21 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
>  				break;
>  			}
>  		}
> +		memcpy_toio(einj_param, v5param, sizeof(*v5param));
> +		kfree(v5param);
>  	} else {
>  		rc = apei_exec_run(&ctx, ACPI_EINJ_SET_ERROR_TYPE);
>  		if (rc)
>  			return rc;
>  		if (einj_param) {
> -			struct einj_parameter *v4param = einj_param;
> +			struct einj_parameter *v4param;

Why kmalloc rather than on stack as you did for the reads?

>  
> +			v4param = kmalloc(sizeof(*v4param), GFP_KERNEL);
> +			memcpy_fromio(v4param, einj_param, sizeof(*v4param));
>  			v4param->param1 = param1;
>  			v4param->param2 = param2;
> +			memcpy_toio(einj_param, v4param, sizeof(*v4param));
> +			kfree(v4param);
>  		}
>  	}
>  	rc = apei_exec_run(&ctx, ACPI_EINJ_EXECUTE_OPERATION);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ