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: <aAKp1c5oDUICkTkf@agluck-desk3>
Date: Fri, 18 Apr 2025 12:36:53 -0700
From: "Luck, Tony" <tony.luck@...el.com>
To: Zaid Alali <zaidal@...amperecomputing.com>
Cc: rafael@...nel.org, lenb@...nel.org, james.morse@....com, bp@...en8.de,
	robert.moore@...el.com, Jonathan.Cameron@...wei.com,
	ira.weiny@...el.com, Benjamin.Cheatham@....com,
	dan.j.williams@...el.com, arnd@...db.de, Avadhut.Naik@....com,
	u.kleine-koenig@...gutronix.de, john.allen@....com,
	linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
	acpica-devel@...ts.linux.dev
Subject: Re: [PATCH v6 5/9] ACPI: APEI: EINJ: Enable the discovery of EINJv2
 capabilities

On Thu, Apr 17, 2025 at 03:00:15PM -0700, Zaid Alali wrote:
> +static ssize_t error_type_set(struct file *file, const char __user *buf,
> +				size_t count, loff_t *ppos)
>  {
>  	int rc;
> +	u64 val;
> +
> +	memset(einj_buf, 0, sizeof(einj_buf));
> +	if (copy_from_user(einj_buf, buf, count))
> +		return -EFAULT;
> +
> +	if (strncmp(einj_buf, "V2_", 3) == 0) {

It's twice as common in Linux kernel code to see string equality checked with:

	if (!strncmp(einj_buf, "V2_", 3))

> +		if (!sscanf(einj_buf, "V2_%llx", &val))

More comprehensive error checking with this:

		ret = kstrtoull(einj_buf + 3, 16, &val);
		if (!ret)
			return -EINVAL;

> +			return -EINVAL;
> +	} else {
> +		if (!sscanf(einj_buf, "%llx", &val))

Ditto kstrtoull() use.

> +			return -EINVAL;
> +	}
>  
>  	rc = einj_validate_error_type(val);
>  	if (rc)
> @@ -722,11 +767,13 @@ static int error_type_set(void *data, u64 val)
>  
>  	error_type = val;
>  
> -	return 0;
> +	return count;
>  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ