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>] [day] [month] [year] [list]
Message-ID: <20101104213705.GA17485@Krystal>
Date:	Thu, 4 Nov 2010 17:37:05 -0400
From:	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To:	masami.hiramatsu.pt@...achi.com
Cc:	linux-kernel@...r.kernel.org
Subject: tracing: concurrency aware strncpy

Hi Masami,
This might help you out...

/*
 * ltt_relay_do_strncpy - copy a string up to a certain number of bytes
 * @dest: destination
 * @src: source
 * @len: max. length to copy
 * @terminated: output string ends with \0 (output)
 *
 * returns the number of bytes copied. Does not finalize with \0 if len is
 * reached.
 */
static __inline__
size_t ltt_relay_do_strncpy(void *dest, const void *src, size_t len,
                            int *terminated)
{
        size_t orig_len = len;

        *terminated = 0;
        /*
         * What we really want here is an __inline__ strncpy, but we
         * don't have constants, so gcc generally uses a function call.
         */
        for (; len > 0; len--) {
                *(u8 *)dest = ACCESS_ONCE(*(const u8 *)src);
                /* Check with dest, because src may be modified concurrently */
                if (*(const u8 *)dest == '\0') {
                        len--;
                        *terminated = 1;
                        break;
                }
                dest++;
                src++;
        }
        return orig_len - len;
}


-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
--
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