linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	"libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org"
	<libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org>
Cc: Linux API <linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: Seccomp implications for glibc wrapper function changes
Date: Tue, 7 Nov 2017 19:14:54 -0200	[thread overview]
Message-ID: <be4cc7fc-90c2-4370-2eab-8948d0ba75be@linaro.org> (raw)
In-Reply-To: <CAKgNAkixA6T7J_1Gs=5+riq6i=dr9XP4ZCGu67YVcuDNg3cT4g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>



On 07/11/2017 18:35, Michael Kerrisk (man-pages) wrote:
> Hello,
> 
> I was recently testing some code I'd written a while back that makes
> use of seccomp filters to control which system calls a process can
> make, and I got a surpise when someone showed the code no longer
> worked in on a system that had glibc 2.26.
> 
> The behavior change resulted from Adhemerval's glibc commit
> 
>      commit b41152d716ee9c5ba34495a54e64ea2b732139b5
>      Author: Adhemerval Zanella <adhemerval.zanella-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>      Date:   Fri Nov 11 15:00:03 2016 -0200
> 
>         Consolidate Linux open implementation
>             [...]
>             3. Use __NR_openat as default syscall for open{64}.
> 
> The commit in question changed the glibc open() wrapper to swtcch from
> use the kernel's open() system call to using the kernel's openat()
> system call.
> 
> This change broke my code that was doing seccomp filtering for the
> open() system call number (__NR_open). The breakage in question is not
> serious, since this was really just demonstration code. However, I
> want to raise awareness that these sorts of changes have the potential
> to possibly cause breakages for some code using seccomp, and note that
> I think such changes should not be made lightly or gratuitously. (In
> the above commit, it's not clear why the switch was made to using
> openat(): there's no mention of the reasoning in the commit message,
> nor is there anything that is obvious from reading through the code
> change itself.)

Your code would 'break' if you run with on a new architecture that does
not implement __NR_open, which it is the default for new architecture
on Linux.

In fact I hardly consider this is a 'break' since the user API we
export does not have any constraint which underlying syscall we use.
For instance, a user can seccomp gettimeofday syscall on a system
without vDSO just to found out it is 'broken' on a vDSO kernel.

I think we should not constraint for this specific usercase; if one
is doing syscall filtering it is expected system level knowledge to
handle all possible syscalls related.  For instance, I would expect
that if the idea is to filtering open() libc implementation the
program should also filter __NR_openat and __NR_openat2 since it
is semantically possible to implement open() with __NR_openat2 if
the syscall is available.

Now for the reasoning of using __NR_openat is since we have support
for it on all architecture it meant less logic to handle possible
architecture differences. 

  parent reply	other threads:[~2017-11-07 21:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07 20:35 Seccomp implications for glibc wrapper function changes Michael Kerrisk (man-pages)
     [not found] ` <CAKgNAkixA6T7J_1Gs=5+riq6i=dr9XP4ZCGu67YVcuDNg3cT4g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-07 21:14   ` Adhemerval Zanella [this message]
     [not found]     ` <be4cc7fc-90c2-4370-2eab-8948d0ba75be-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-11-07 21:47       ` Michael Kerrisk (man-pages)
     [not found]         ` <CAKgNAkiRFsUigsV1OCrrjUzq8MO3wwtsT2SGuOJth56OcqCTcA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-08  1:18           ` Adhemerval Zanella
     [not found]             ` <2884aeec-a7ba-937a-4f77-7225dd4ef00c-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-11-09  7:15               ` Michael Kerrisk (man-pages)
2017-11-08  6:24   ` Florian Weimer
2017-11-09  7:17     ` Michael Kerrisk (man-pages)
     [not found]       ` <CAKgNAkhLsBNVO9axSxwH8VNxBW1QPWjaEOS_ubu-nUZ7_gsn7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-09 11:58         ` Michael Kerrisk (man-pages)
     [not found]           ` <CAKgNAkjAbRN7gVuErpmBZ2YtkYfRSAdnWVdRR1B34BvszRZ0-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-09 12:02             ` Florian Weimer
     [not found]               ` <c2965313-404b-71fb-0686-bd13fde2b975-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 12:14                 ` Adhemerval Zanella
2017-11-09 17:27                   ` Michael Kerrisk (man-pages)
2017-11-09 13:37                 ` Michael Kerrisk (man-pages)
     [not found]                   ` <CAKgNAki9m460sOw8KP9unnBU_ANctXj4H=gUEiRgRhUHFGjDbQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-13 22:44                     ` Kees Cook
     [not found]                       ` <CAGXu5jJwgavx5jNpMGdR5D4rAv4GxtrERgGgi-FQDaROOTocLw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-14  7:00                         ` Michael Kerrisk (man-pages)

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=be4cc7fc-90c2-4370-2eab-8948d0ba75be@linaro.org \
    --to=adhemerval.zanella-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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 NNTP newsgroup(s).