[PATCH] selftests/powerpc: Add a test of sigreturn vs VDSO

Nathan Lynch nathanl at linux.ibm.com
Sat Mar 7 05:31:12 AEDT 2020


Nathan Lynch <nathanl at linux.ibm.com> writes:
> Michael Ellerman <mpe at ellerman.id.au> writes:
>
>> +static int search_proc_maps(char *needle, unsigned long *low, unsigned long *high)
>
>                                ^^ const?
>                                
>> +{
>> +	unsigned long start, end;
>> +	static char buf[4096];
>> +	char name[128];
>> +	FILE *f;
>> +	int rc = -1;
>> +
>> +	f = fopen("/proc/self/maps", "r");
>> +	if (!f) {
>> +		perror("fopen");
>> +		return -1;
>> +	}
>> +
>> +	while (fgets(buf, sizeof(buf), f)) {
>> +		rc = sscanf(buf, "%lx-%lx %*c%*c%*c%*c %*x %*d:%*d %*d %127s\n",
>> +			    &start, &end, name);
>
> I suspect it doesn't matter in practice for this particular test, but
> since this looks like a generally useful function that could gain users
> in the future: does this spuriously fail if the matching line straddles
> a 4096-byte boundary? Maybe fscanf(3) should be used instead?

Or maybe I should read the fgets man page more closely :-)

  "Reading stops after an EOF or a newline."

Sorry for the noise.


More information about the Linuxppc-dev mailing list