public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: pgowda cve <pgowda.cve@gmail.com>
To: libc-help@sourceware.org
Subject: Race observed in if_nametoindex function (not MT-Safe)
Date: Mon, 13 Sep 2021 19:43:52 +0530	[thread overview]
Message-ID: <CALY4984bu_GywXu_h1isRf1DxAX33x6kiFAHo1FNBxHYC9h=yw@mail.gmail.com> (raw)

Hi,

The race and assert-triggering was observed in if_nametoindex function.
It calls __opensock, which contains two static variables (last_type,
last_family)
that can race, triggering an assert on line 63 of opensock.c.
The variables are set in the reverse order to which they are checked.
Since there is no synchronization between these variables, should the function
not be made MT-Safe.

The patch was originally posted at:-
https://sourceware.org/pipermail/libc-alpha/2014-January/048052.html
It mentions the function as MT-Safe but race was observed.

We may need a memory barrier (atomic_[read|write]_barrier() ? ) to
ensure that the
compiler doesn't re-order assembly instructions and has last_family be
set before last_type.

Environment
Observed during a system restart when the processes start up and
software calls if_nametoindex from multiple threads.
GLIBC was dynamically Linked.

Regards,
pgowda

             reply	other threads:[~2021-09-13 14:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13 14:13 pgowda cve [this message]
2021-09-19 12:46 ` Adhemerval Zanella

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='CALY4984bu_GywXu_h1isRf1DxAX33x6kiFAHo1FNBxHYC9h=yw@mail.gmail.com' \
    --to=pgowda.cve@gmail.com \
    --cc=libc-help@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).