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] [day] [month] [year] [list]
Message-ID: <4E78E824.4080209@gmail.com>
Date:	Tue, 20 Sep 2011 13:23:16 -0600
From:	David Ahern <dsahern@...il.com>
To:	Stephane Eranian <eranian@...gle.com>
CC:	linux-kernel@...r.kernel.org, peterz@...radead.org,
	acme@...hat.com, mingo@...e.hu
Subject: Re: [PATCH] perf: fix perf.data endianness detection

On 09/20/2011 01:02 PM, Stephane Eranian wrote:
>>> +static int check_magic_endian(u64 *magic, struct perf_file_header *header,
>>> +                           struct perf_header *ph)
>>> +{
>>> +     int ret;
>>> +
>>> +     /* check for legacy format */
>>> +     ret = memcmp(magic, __perf_magic1, sizeof(*magic));
>>> +     if (ret == 0) {
>>> +             pr_debug("legacy perf.data format\n");
>>> +             if (!header)
>>> +                     return -1;
>>> +
>>> +             if (header->attr_size != sizeof(struct perf_file_attr)) {
>>> +                     u64 attr_size = bswap_64(header->attr_size);
>>> +
>>> +                     if (attr_size != sizeof(struct perf_file_attr))
>>> +                             return -1;
>>> +
>>> +                     mem_bswap_64(header, offsetof(struct perf_file_header,
>>> +                                             adds_features));
>>> +                     ph->needs_swap = true;
>>> +             }
>>> +             return 0;
>>> +     }
>>> +
>>> +     /* check for our magic (same endianness) */
>>> +     if (*magic == __perf_magic2)
>>> +             return 0;
>>> +
>>> +     /* check for our magic (opposite endianness) */
>>> +     if (*magic != __perf_magic2_sw)
>>> +             return -1;
>>> +
>>> +     ph->needs_swap = true;

-->  goes here too
|
|

>>> +
>>> +     return 0;
>>> +}
>>> +
>>>  int perf_file_header__read(struct perf_file_header *header,
>>>                          struct perf_header *ph, int fd)
>>>  {
>>> +     int ret;
>>> +
>>>       lseek(fd, 0, SEEK_SET);
>>>
>>> -     if (readn(fd, header, sizeof(*header)) <= 0 ||
>>> -         memcmp(&header->magic, __perf_magic, sizeof(header->magic)))
>>> +     ret = readn(fd, header, sizeof(*header));
>>> +     if (ret <= 0)
>>>               return -1;
>>>
>>> -     if (header->attr_size != sizeof(struct perf_file_attr)) {
>>> -             u64 attr_size = bswap_64(header->attr_size);
>>> -
>>> -             if (attr_size != sizeof(struct perf_file_attr))
>>> -                     return -1;
>>> -
>>> -             mem_bswap_64(header, offsetof(struct perf_file_header,
>>> -                                         adds_features));

|
|---- the mem_bswap_64()


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