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: <20110902181818.GD17970@ghostprotocols.net>
Date:	Fri, 2 Sep 2011 15:18:19 -0300
From:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>
To:	David Ahern <dsahern@...il.com>
Cc:	linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
	mingo@...e.hu, peterz@...radead.org, fweisbec@...il.com,
	paulus@...ba.org, tglx@...utronix.de, anton@...ba.org
Subject: Re: [PATCH v2] perf tool: fix endianness handling of u32 data in
 samples

Em Fri, Sep 02, 2011 at 10:03:46AM -0600, David Ahern escreveu:
>  	if (type & PERF_SAMPLE_RAW) {
> -		u32 *p = (u32 *)array;
> +		u.val64 = *array;
> +		if (swapped) {
> +			static bool show_warn = true;
> +
> +			/* undo swap of u64, then swap on individual u32s */
> +			u.val64 = bswap_64(u.val64);
> +			u.val32[0] = bswap_32(u.val32[0]);
> +			u.val32[1] = bswap_32(u.val32[1]);
> +
> +			if (show_warn) {
> +				pr_warning("Endianness of raw data not corrected!\n");
> +				show_warn = false;
> +			}
> +		}

Can you use WARN_ONCE? Would become:
	
		if (WARN_ONCE(swapped, "Endianness of raw data not corrected!\n")) {
			/* undo swap of u64, then swap on individual u32s */
			u.val64 = bswap_64(u.val64);
			u.val32[0] = bswap_32(u.val32[0]);
			u.val32[1] = bswap_32(u.val32[1]);
		}

We have that and its the usual idiom in the kernel proper :-)

See tools/perf/util/include/asm/bug.h and net/can/af_can.c can_rcv for
an example.

Thanks,

- Arnaldo
--
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