All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tudor Cretu <tudor.cretu@arm.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 0/3] safe_macros: Fix undefined behaviour in vararg handling
Date: Wed, 23 Nov 2022 14:47:43 +0000	[thread overview]
Message-ID: <20221123144746.590890-1-tudor.cretu@arm.com> (raw)

Accessing elements in an empty va_list results in undefined behaviour[0]
that can include accessing arbitrary stack memory. While typically this
doesn't raise a fault, some new more security-oriented architectures
(e.g. CHERI[1] or Morello[2]) don't allow it.

Therefore, remove the variadicness from safe_* wrappers that always call
the functions with the optional argument included.

Adapt the respective SAFE_* macros to handle the change by passing a
default argument if they're omitted.

[0]: [ISO/IEC 9899:2011] Programming Languages—C, 3rd ed, paragraph 7.16.1.1
[1]: https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/
[2]: https://www.morello-project.org/

Tudor Cretu (3):
  safe_open: Fix undefined behaviour in vararg handling
  safe_openat: Fix undefined behaviour in vararg handling
  safe_semctl: Fix undefined behaviour in vararg handling

 include/old/safe_macros.h   |  6 ++++--
 include/safe_macros_fn.h    |  3 ++-
 include/tst_safe_file_at.h  | 10 ++++++----
 include/tst_safe_macros.h   |  6 ++++--
 include/tst_safe_sysv_ipc.h | 14 +++++++++-----
 lib/safe_macros.c           | 13 +------------
 lib/tst_cgroup.c            |  2 +-
 lib/tst_safe_file_at.c      | 11 +++--------
 lib/tst_safe_sysv_ipc.c     | 10 +---------
 9 files changed, 31 insertions(+), 44 deletions(-)

-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2022-11-23 14:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 14:47 Tudor Cretu [this message]
2022-11-23 14:47 ` [LTP] [PATCH 1/3] safe_open: Fix undefined behaviour in vararg handling Tudor Cretu
2022-11-23 14:47 ` [LTP] [PATCH 2/3] safe_openat: " Tudor Cretu
2022-11-23 14:47 ` [LTP] [PATCH 3/3] safe_semctl: " Tudor Cretu
2022-11-29 11:01 ` [LTP] [PATCH 0/3] safe_macros: " Petr Vorel
2022-11-29 11:06   ` Petr Vorel
2022-11-29 11:11     ` Richard Palethorpe
2022-11-29 11:27       ` Richard Palethorpe
2022-11-29 11:32         ` Petr Vorel
2022-11-29 11:46           ` Tudor Cretu
2022-11-29 12:01             ` Richard Palethorpe
2022-11-29 11:45   ` Tudor Cretu
2022-11-29 11:48 ` Cyril Hrubis

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=20221123144746.590890-1-tudor.cretu@arm.com \
    --to=tudor.cretu@arm.com \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.