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: <iofg6cidwvbewldlwy7rz67jljs24unnszv6kdat6tvafkrl6f@4shqyxjid6ev>
Date: Fri, 18 Oct 2024 14:30:49 -0500
From: Lucas De Marchi <lucas.demarchi@...el.com>
To: Peter Zijlstra <peterz@...radead.org>
CC: <linux-kernel@...r.kernel.org>, <dri-devel@...ts.freedesktop.org>, "Ingo
 Molnar" <mingo@...hat.com>, Arnaldo Carvalho de Melo <acme@...nel.org>, Umesh
 Nerlige Ramappa <umesh.nerlige.ramappa@...el.com>, Ian Rogers
	<irogers@...gle.com>, Tvrtko Ursulin <tvrtko.ursulin@...lia.com>
Subject: Re: [PATCH 1/5] perf: Add dummy pmu module

On Wed, Oct 16, 2024 at 10:51:02AM +0200, Peter Zijlstra wrote:
>On Tue, Oct 08, 2024 at 01:34:57PM -0500, Lucas De Marchi wrote:
>> +static int parse_device(const char __user *ubuf, size_t size, u32 *instance)
>> +{
>> +	char buf[16];
>> +	ssize_t len;
>> +
>> +	if (size > sizeof(buf) - 1)
>> +		return -E2BIG;
>> +
>> +	len = strncpy_from_user(buf, ubuf, sizeof(buf));
>> +	if (len < 0 || len >= sizeof(buf) - 1)
>> +		return -E2BIG;
>> +
>> +	if (kstrtou32(buf, 0, instance))
>> +		return -EINVAL;
>> +
>> +	return size;
>> +}
>
>I had to change this to:
>
>+static int parse_device(const char __user *ubuf, size_t size, u32 *instance)
>+{
>+       int ret = kstrtouint_from_user(ubuf, size, 0, instance);
>+       if (ret) {
>+               printk("suckage: %d\n", ret);
>+               return ret;
>+       }
>+       return size;
>+}
>
>because otherwise it didn't want to work for me; I kept getting garbage
>at the end and things failing. Specifically, it looked like the string
>presented by userspace was not '\0' terminated, ubuf was pointing to
>"1...garbage..." and size was 1.

oh... it's the sysfs (that PCI drivers use) that is guaranteed to be
nul-terminated. debugfs is not. And it probably worked for me because of
CONFIG_INIT_STACK_ALL_ZERO=y that comes from my distro.

and this version is also shorter and simpler.

thanks
Lucas De Marchi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ