public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/26636] New: 32-bit shmctl(IPC_INFO) crashes when shminfo struct is at the end of a memory mapping
@ 2020-09-19 12:07 robert at ocallahan dot org
  2020-09-19 12:40 ` [Bug libc/26636] " robert at ocallahan dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: robert at ocallahan dot org @ 2020-09-19 12:07 UTC (permalink / raw)
  To: glibc-bugs

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

            Bug ID: 26636
           Summary: 32-bit shmctl(IPC_INFO) crashes when shminfo struct is
                    at the end of a memory mapping
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: robert at ocallahan dot org
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

Created attachment 12851
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12851&action=edit
Test program

This is a regression caused by commit ffd178c651b827f24acead02284abbb12f3f723b.

Compile attached test program:
gcc -m32 -o ~/tmp/test ~/tmp/test.c

It should print something like "max=2147483647". With the above glibc commit,
it crashes.

The problem is that __shmctl calls shmid_to_shmid64 on the input buffer even
when cmd is IPC_INFO. sizeof(shmid_ds) is 84, but sizeof(shminfo) is only 36.
Thus, if the shminfo is immediately followed by unmapped memory,
shmid_to_shmid64 will read past its end into unmapped memory and crash.

This causes an rr test failure: https://github.com/mozilla/rr/issues/2681

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/26636] 32-bit shmctl(IPC_INFO) crashes when shminfo struct is at the end of a memory mapping
  2020-09-19 12:07 [Bug libc/26636] New: 32-bit shmctl(IPC_INFO) crashes when shminfo struct is at the end of a memory mapping robert at ocallahan dot org
@ 2020-09-19 12:40 ` robert at ocallahan dot org
  2020-09-19 13:33 ` robert at ocallahan dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: robert at ocallahan dot org @ 2020-09-19 12:40 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #1 from Robert O'Callahan <robert at ocallahan dot org> ---
I guess SHM_INFO has the same problem.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/26636] 32-bit shmctl(IPC_INFO) crashes when shminfo struct is at the end of a memory mapping
  2020-09-19 12:07 [Bug libc/26636] New: 32-bit shmctl(IPC_INFO) crashes when shminfo struct is at the end of a memory mapping robert at ocallahan dot org
  2020-09-19 12:40 ` [Bug libc/26636] " robert at ocallahan dot org
@ 2020-09-19 13:33 ` robert at ocallahan dot org
  2020-09-28 14:46 ` adhemerval.zanella at linaro dot org
  2020-10-14 14:59 ` adhemerval.zanella at linaro dot org
  3 siblings, 0 replies; 5+ messages in thread
From: robert at ocallahan dot org @ 2020-09-19 13:33 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #2 from Robert O'Callahan <robert at ocallahan dot org> ---
Actually SHM_INFO doesn't work at all now in 32-bit. The code that copies back
and converts the result to the user's buffer doesn't handle SHM_INFO:

  switch (cmd)
    {
      case IPC_INFO:
      case IPC_STAT:
      case SHM_STAT:
      case SHM_STAT_ANY:
       shmid64_to_shmid (buf, buf64);
    }

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/26636] 32-bit shmctl(IPC_INFO) crashes when shminfo struct is at the end of a memory mapping
  2020-09-19 12:07 [Bug libc/26636] New: 32-bit shmctl(IPC_INFO) crashes when shminfo struct is at the end of a memory mapping robert at ocallahan dot org
  2020-09-19 12:40 ` [Bug libc/26636] " robert at ocallahan dot org
  2020-09-19 13:33 ` robert at ocallahan dot org
@ 2020-09-28 14:46 ` adhemerval.zanella at linaro dot org
  2020-10-14 14:59 ` adhemerval.zanella at linaro dot org
  3 siblings, 0 replies; 5+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2020-09-28 14:46 UTC (permalink / raw)
  To: glibc-bugs

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

Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |adhemerval.zanella at linaro dot o
                   |                            |rg
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2020-09-28
     Ever confirmed|0                           |1
           Assignee|unassigned at sourceware dot org   |adhemerval.zanella at linaro dot o
                   |                            |rg

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libc/26636] 32-bit shmctl(IPC_INFO) crashes when shminfo struct is at the end of a memory mapping
  2020-09-19 12:07 [Bug libc/26636] New: 32-bit shmctl(IPC_INFO) crashes when shminfo struct is at the end of a memory mapping robert at ocallahan dot org
                   ` (2 preceding siblings ...)
  2020-09-28 14:46 ` adhemerval.zanella at linaro dot org
@ 2020-10-14 14:59 ` adhemerval.zanella at linaro dot org
  3 siblings, 0 replies; 5+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2020-10-14 14:59 UTC (permalink / raw)
  To: glibc-bugs

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

Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |2.33

--- Comment #3 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
Fixed on 2.33 (a49d7fd4f764e97ccaf922e433046590ae52fce9).

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-14 14:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-19 12:07 [Bug libc/26636] New: 32-bit shmctl(IPC_INFO) crashes when shminfo struct is at the end of a memory mapping robert at ocallahan dot org
2020-09-19 12:40 ` [Bug libc/26636] " robert at ocallahan dot org
2020-09-19 13:33 ` robert at ocallahan dot org
2020-09-28 14:46 ` adhemerval.zanella at linaro dot org
2020-10-14 14:59 ` adhemerval.zanella at linaro dot org

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