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]
Date:	Fri, 27 Mar 2015 11:32:43 +0100
From:	Borislav Petkov <bp@...e.de>
To:	Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:	Ingo Molnar <mingo@...nel.org>, linux-kernel@...r.kernel.org,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	David Ahern <dsahern@...il.com>,
	Don Zickus <dzickus@...hat.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Namhyung Kim <namhyung@...nel.org>,
	Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 14/25] perf symbols: Save DSO loading errno to better
 report errors

On Tue, Mar 24, 2015 at 01:19:29PM -0300, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@...hat.com>
> 
> Before, when some problem happened while trying to load the kernel
> symtab, 'perf top' would show:
> 
>       ┌─Warning:───────────────────────────┐
>       │The vmlinux file can't be used.     │
>       │Kernel samples will not be resolved.│
>       │                                    │
>       │                                    │
>       │Press any key...                    │
>       └────────────────────────────────────┘
> 
> Now, it reports:
> 
>   # perf top --vmlinux /dev/null
> 
>       ┌─Warning:───────────────────────────────────────────┐
>       │The /tmp/passwd file can't be used: Invalid ELF file│
>       │Kernel samples will not be resolved.                │
>       │                                                    │
>       │                                                    │
>       │Press any key...                                    │
>       └────────────────────────────────────────────────────┘
> 
> This is possible because we now register the reason for not being able
> to load the symtab in the dso->load_errno member, and provide a
> dso__strerror_load() routine to format this error into a strerror like
> string with a short reason for the error while loading.
> 
> That can be just forwarding the dso__strerror_load() call to
> strerror_r(), or, for a separate errno range providing a custom message.
> 
> Reported-by: Ingo Molnar <mingo@...nel.org>
> Acked-by: Jiri Olsa <jolsa@...nel.org>
> Cc: Adrian Hunter <adrian.hunter@...el.com>
> Cc: Borislav Petkov <bp@...e.de>
> Cc: David Ahern <dsahern@...il.com>
> Cc: Don Zickus <dzickus@...hat.com>
> Cc: Frederic Weisbecker <fweisbec@...il.com>
> Cc: Namhyung Kim <namhyung@...nel.org>
> Cc: Stephane Eranian <eranian@...gle.com>
> Link: http://lkml.kernel.org/n/tip-u5rb5uq63xqhkfb8uv2lxd5u@git.kernel.org
> Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>

...

> @@ -1137,3 +1137,36 @@ enum dso_type dso__type(struct dso *dso, struct machine *machine)
>  
>  	return dso__type_fd(fd);
>  }
> +
> +int dso__strerror_load(struct dso *dso, char *buf, size_t buflen)
> +{
> +	int idx, errnum = dso->load_errno;
> +	/*
> +	 * This must have a same ordering as the enum dso_load_errno.
> +	 */
> +	static const char *dso_load__error_str[] = {
> +	"Internal tools/perf/ library error",
> +	"Invalid ELF file",
> +	"Can not read build id",
> +	"Mismatching build id",
> +	"Decompression failure",
> +	};

You could define this str array by using the dso_load_errno defines so
that they're always in sync:

	static const char *dso_load__error_str[] = {
		[DSO_LOAD_ERRNO__INTERNAL_ERROR - __DSO_LOAD_ERRNO__START] = "Internal tools/perf/ library error",
		[DSO_LOAD_ERRNO__INVALID_ELF - __DSO_LOAD_ERRNO__START] = "Invalid ELF file",
		...

and even use a small macro to hide the __DSO_LOAD_ERRNO__START thing.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ