public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ryao at gentoo dot org" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug nptl/17478] Fix off-by-one error in pthread_setname_np()
Date: Thu, 16 Oct 2014 05:10:00 -0000	[thread overview]
Message-ID: <bug-17478-131-jmZaHA7Qe0@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-17478-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=17478

Richard Yao <ryao at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from Richard Yao <ryao at gentoo dot org> ---
Andreas, the kernel defines the length to include the NULL terminating
character while strlen() defines the length to exclude it. This causes a
off-by-one error because the concept of how long a string can be is literally
off-by-one. If you pass a string of length 16 according to strlen(), the kernel
will interpret this as a string of length 17 and reject it with EINVAL. The
kernel field is 16 bytes, but in reality, you can only use 15 bytes because the
kernel code for copying the field ensures that the last byte is *ALWAYS* NULL.

I am certain that I am *NOT* setting the name on a different process (although
it is on a different thread). The program that I modified to use this is ZFS'
ztest. It works when I use strncpy() to copy a 16-byte string (according to
`strlen()`) to a 16 byte buffer and then pass that to `pthread_setname_np()`,
but it does not work when I pass the string directly to `pthread_setname_np()`.
If this were another process, it should return EINVAL no matter what the length
of the string is.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


  reply	other threads:[~2014-10-16  5:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-11 21:37 [Bug nptl/17478] New: " ryao at gentoo dot org
2014-10-16  5:10 ` ryao at gentoo dot org [this message]
2014-10-16  5:24 ` [Bug nptl/17478] " ryao at gentoo dot org
2014-10-16  5:24 ` ryao at gentoo dot org
2014-10-16  5:26 ` ryao at gentoo dot org
2014-10-16  7:35 ` schwab@linux-m68k.org
2014-10-16 14:44 ` ryao at gentoo dot org
2014-10-16 14:51 ` ryao at gentoo dot org
2014-10-16 14:52 ` schwab@linux-m68k.org
2014-10-16 15:06 ` ryao at gentoo dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-17478-131-jmZaHA7Qe0@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).