public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: "Frank Ch. Eigler" <fche@redhat.com>
Cc: elfutils-devel@sourceware.org, amerey@redhat.com
Subject: Re: patch 2/2 debuginfod server etc.
Date: Mon, 18 Nov 2019 14:17:00 -0000	[thread overview]
Message-ID: <c5adf263d267e711d83e1bf74a94cb2d7887c8ea.camel@klomp.org> (raw)
In-Reply-To: <20191114122953.GC873@redhat.com>

Hi,

On Thu, 2019-11-14 at 07:29 -0500, Frank Ch. Eigler wrote:
> > > -bin_PROGRAMS = debuginfod-find
> > > +bin_PROGRAMS = debuginfod debuginfod-find
> > > +debuginfod_SOURCES = debuginfod.cxx
> > > +debuginfod_cxx_CXXFLAGS = -Wno-unused-functions
> > 
> > Should that be debuginfod_CXXFLAGS?
> > Why are there unused functions are there?
> 
> I don't think there are in debuginfod itself.

OK, lets get rid of this then.

> > > +# g++ 4.8 on rhel7 otherwise errors gthr-default.h /
> > > __gthrw2(__gthrw_(__pthread_key_create) undefs
> > 
> > Could you explain this comment a bit more?
> 
> Not sure, these might have been notes from diagnosing
> the argp.h bug that messed with function attributes,
> or something else.

Lets remove it then. It is somewhat confusing.

> > [...]
> > So you give it directories with executables and directories with debug
> > files. They are indexed if they have a build-id. You never provide a
> > sources dir, but if something is indexed as a debug file then any
> > source file referenced from it can be requested.
> 
> Yes.
> 
> > In theory you only need to provide the executable dirs, from that you
> > can normally get the separate .debug files.
> 
> That's if those debug files are installed in the proper system 
> location.  A build tree mid-strippinng is not like that.  And
> in the case of RPMs, it's not an option at all.
> 
> > Why didn't you do that (only providing executable dirs)?
> > And why do you allow sources to be found indirectly?
> 
> Because there's no need to search/index source files.  We can already
> tell instantly whether they exist (when we parse the dwarf file) via a
> stat(2).  We index debuginfo/source rpms for their content because
> that instant check is not possible.
> 
> > Would it make sense to restrict the sources (prefix) dir?
> 
> I don't see any reason, because ...
> 
> > The questions above are simply because it makes me nervous that some,
> > but not all, files that can be requested can indirectly be found
> > anywhere. If you have an explicit debug dir, then it might make sense
> > to also have an explicit sources dir.
> 
> If the executables we find are trusted, then the source file paths
> inside are trustworthy too.  (We don't have an explicit debug dir.)
>
> > In general I think it would be good to think about a selinux security
> > context for debuginfod. This is not urgent, but I think we should see
> > if we can get someone to do a security audit.
> 
> Will keep it in mind.
>
> > One concern I have is that if a process is run in a restricted security
> > context in which it might not be able to access certain files, but it
> > might have access to a local socket to debuginfod, then it can get
> > access to files it normally wouldn't. 
> 
> Note that the systemd service runs under an unprivileged userid.
> 
> > And if it could somehow write into any directory that debuginfod
> > reads then it could construct a .debug file that points to any file
> > on the system by adding it to the DWARF debug_lines file list. All
> > this might be unlikely because this is all locally running
> > processes. But it would be good to have someone who is a bit
> > paranoid take a look if we aren't accidentally "leaking" files.
> 
> I see where you're going with it, it's a reasonable concern.  For now,
> we can consider it covered by the "debuginfod should be given
> trustworthy binaries" general rule.

This does keep me slightly worried. Even "trustworthy binaries" could
be produced by buggy compilers. I really think we should have some way
to restrict which files on the file system can be served up. IMHO the
default should be that no files outside directories explicit given to
debuginfod should be allowed to be provided to the client. So it makes
sense providing any extra source dirs, so you can check that any
references to source files are actually correct/intended.

> > > +.B "\-I REGEX"  "\-\-include=REGEX"  "\-X REGEX"  "\-\-exclude=REGEX"
> > > +Govern the inclusion and exclusion of file names under the search
> > > +paths.  [...]
> > 
> > Could/Should this default to -I/all/paths/given/* so only files from
> > under those paths are included and no files from outside the search
> > paths?
> 
> fullpath(3) canonicalization (and in a later patch, symlink following
> mode) would mess that up.  I know you're probably thinking about the
> evil-source-file-escape problem, but I wouldn't handle that with an
> index-time constraint like this.  I envisioned using this more for
> optimization purposes, if for example one wants to index only .x86_64.
> rpms in a tree that has other architectures.

Aha, yes, this is at a different level/time than what I was thinking
of.

> > > +and means that only one initial scan should performed.  The default
> > > +rescan time is 300 seconds.  Receiving a SIGUSR1 signal triggers a new
> > > +scan, independent of the rescan time (including if it was zero).
> > 
> > 300 seconds seem somewhat arbitrary. But I don't have a better number
> > :)
> 
> I was thinkinng it's about right for a developer's live build tree.

OK, but those aren't included by default. It isn't that I think it is a
bad default, it just seems a bit short if the default is just for
installed binaries/debuginfo, which will not change that often.

> > > +.TP
> > > +.B "\-G"
> > > +Run an extraordinary maximal-grooming pass at debuginfod startup.
> > > +This pass can take considerable time, because it tries to remove any
> > > +debuginfo-unrelated content from the RPM-related parts of the index.
> > > +It should not be run if any recent RPM-related indexing operations
> > > +were aborted early.  It can take considerable space, because it
> > > +finishes up with an sqlite "vacuum" operation, which repacks the
> > > +database file by triplicating it temporarily.  The default is not to
> > > +do maximal-grooming.  See also the \fIDATA MANAGEMENT\fP section.
> > 
> > So basically never, ever use this? :)
> > Can you add a hint when you should use it?
> 
> See also the DATA MANAGEMENT section. :-)

Which says:

   There is also an optional one-shot \fImaximal grooming\fP pass is
   available.  It removes information debuginfo-unrelated data from the
   RPM content index, but it is slow and temporarily requires up to
   twice the database size as free space.  Worse: it may result in
   missing source-code info if the RPM traversals were
   interrupted.  Use it rarely to polish a complete index.

Which suggest to use it to polish by removing debuginfo-unrelated data.
I am still not sure what that unrelated data is or when I really want
to do this. It doesn't really list any quantifiable benefits.

> > > [...]  Relative path names commonly appear in the DWARF
> > > +file's source directory, but these paths are relative to
> > > +individual compilation unit AT_comp_dir paths, and yet an executable
> > > +is made up of multiple CUs.  Therefore, to disambiguate, debuginfod
> > > +expects source queries to prefix relative path names with the CU
> > > +compilation-directory.
> > 
> > Note a subtlety with DWARF4 vs DWARF5. In both cases debug line index
> > zero refers to the compile unit directory. But in DWARF5 that directory
> > should actually be in the line table (so you don't have to look it up
> > through the associated CU in the debug_info DIE tree).
> 
> Right, but do you think this subtlety should be elaborated to
> debuginfod clients or administrators?  As far as a debugger tool is
> concerned, the compilation directory is the compilation directory, no
> matter which line table and which slot it is in.  Can you suggest a
> wording tweak?

I think I would simply say something like "Relative path should always
be prefixed with the (absolute) directory table entry or compile unit
directory they are relative to."

And then maybe some advise on how to combine them when the directory
path ends with a slash (see also below).

> > I agree this is needed because it is how the data/paths are represented
> > in DWARF. But it does concern me there is no /../ processing done to
> > make sure something isn't requested outside the source paths.
> 
> I love your security mindset.  In this case, the /../ stuff doesn't
> matter because the resulting string is only used as search key in the
> database, not used verbatim against the filesystem.

Yes, thanks. I am confusing various paths in my head.
Still pondering whether we would need/want to canonicalize everything.
We kind of depend on any client just passing through what is the
DW_AT_comp_dir and line table dir/sources lists unaltered.

The documentation currently explicitly says:

   Note: you should not elide \fB../\fP or \fB/./\fP sorts of relative
   path components in the directory names, because if this is how those
   names appear in the DWARF files, that is what debuginfod needs to
   see too.

That is good, but maybe give guidance on how to combine a dir and
(relative) path. e.g. should a / always be added in between, even when
the dir already ends with a /?

> > > +You should ensure that ample disk space remains available.  (The flood
> > > +of error messages on -ENOSPC is ugly and nagging.  But, like for most
> > > +other errors, debuginfod will resume when resources permit.)  If
> > > +necessary, debuginfod can be stopped, the database file moved or
> > > +removed, and debuginfod restarted.
> > 
> > Do we need and/or can we add some option to limit the disk space used?
> 
> We can't really limit it.  The groom cycle messages include a
> database-size report field, so ... I suppose we could quit when the
> database gets large enough, but that wouldn't help anyone.  Or could
> stop indexing early ... but really the Proper solution is to rely on a
> size-quota'd cachedir which is harmless if it hits ENOSPC, if it is
> brought to the sysadmin's attention by our errors and by system
> monitoring tools.

Yeah. OK. I guess it isn't different from any other cache.

> > Same question as with the client. Does it use the standard trust
> > database for certificate verification with HTTPS?
> 
> The text says that debuginfod does not provide https service at all,
> so this is not relevant.  A front-end https reverse-proxy would have
> to deal with this stuff.  I plan to cover this in a blog post later
> on, and probably in the form of software baked into a container image.

But debuginfod might use HTTPS services itself for fallback. I think it
is important to describe how/if those https ssl/tls connections are
authenticated.

Cheers,

Mark

  reply	other threads:[~2019-11-18 14:17 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-28 19:04 patch 0/2 debuginfod submission Frank Ch. Eigler
2019-10-28 19:06 ` patch 1/2 debuginfod client Frank Ch. Eigler
2019-10-28 19:09   ` patch 2/2 debuginfod server etc Frank Ch. Eigler
2019-11-04 21:48     ` patch 3/3 debuginfod client interruptability Frank Ch. Eigler
2019-11-07  9:07       ` patch 4 debuginfod: symlink following mode Frank Ch. Eigler
2019-11-07  9:08         ` patch 5 debuginfod: prometheus metrics Frank Ch. Eigler
2019-11-15 17:26           ` Mark Wielaard
2019-11-15 17:58             ` Frank Ch. Eigler
2019-11-18 16:20               ` Mark Wielaard
2019-11-18 16:48                 ` Frank Ch. Eigler
2019-11-19 16:13                   ` Mark Wielaard
2019-11-15 16:49         ` patch 4 debuginfod: symlink following mode Mark Wielaard
2019-11-15 18:31           ` Frank Ch. Eigler
2019-11-18 16:27             ` Mark Wielaard
2019-11-15 16:16       ` patch 3/3 debuginfod client interruptability Mark Wielaard
2019-11-15 17:03         ` Aaron Merey
2019-11-15 17:35           ` Mark Wielaard
2019-11-15 18:14             ` Pedro Alves
2019-11-17 23:44               ` Mark Wielaard
2019-11-18  2:50                 ` Frank Ch. Eigler
2019-11-18  9:24                   ` Pedro Alves
2019-11-19 12:58                   ` Mark Wielaard
2019-11-13 17:22     ` patch 2/2 debuginfod server etc Mark Wielaard
2019-11-14 11:54       ` Frank Ch. Eigler
2019-11-16  1:31         ` Mark Wielaard
2019-11-13 23:19     ` Mark Wielaard
2019-11-14 12:30       ` Frank Ch. Eigler
2019-11-18 14:17         ` Mark Wielaard [this message]
2019-11-18 18:41           ` Frank Ch. Eigler
2019-11-19 15:41             ` Mark Wielaard
2019-11-19 16:13               ` Frank Ch. Eigler
2019-11-19 20:11                 ` Mark Wielaard
2019-11-19 21:15                   ` Frank Ch. Eigler
2019-11-20 11:53                     ` Mark Wielaard
2019-11-20 12:29                       ` Frank Ch. Eigler
2019-11-21 14:16                       ` Mark Wielaard
2019-11-21 15:40                         ` Mark Wielaard
2019-11-21 16:01                           ` Frank Ch. Eigler
2019-11-21 15:58                         ` Frank Ch. Eigler
2019-11-21 16:37                           ` Mark Wielaard
2019-11-21 17:18                             ` Frank Ch. Eigler
2019-11-21 20:42                               ` Mark Wielaard
2019-11-22 12:08                                 ` Mark Wielaard
2019-11-14 20:45     ` Mark Wielaard
2019-11-15 11:03       ` Mark Wielaard
2019-11-15 21:00       ` Frank Ch. Eigler
2019-11-18 15:01         ` Mark Wielaard
2019-11-15 14:40     ` Mark Wielaard
2019-11-15 19:54       ` Frank Ch. Eigler
2019-11-18 15:31         ` Mark Wielaard
2019-11-18 15:49           ` Frank Ch. Eigler
2019-11-12 11:12   ` patch 1/2 debuginfod client Mark Wielaard
2019-11-12 15:14     ` Frank Ch. Eigler
2019-11-12 21:59       ` Mark Wielaard
2019-11-14  0:33         ` Frank Ch. Eigler
2019-11-15 21:33       ` Mark Wielaard
2019-11-12 21:25   ` Mark Wielaard
2019-11-13 23:25     ` Frank Ch. Eigler
2019-11-16  0:46       ` Mark Wielaard
2019-11-16 18:53         ` Frank Ch. Eigler
2019-11-18 17:17           ` Mark Wielaard
2019-11-18 20:33             ` Frank Ch. Eigler
2019-11-19 15:57               ` Mark Wielaard
2019-11-19 16:20                 ` Frank Ch. Eigler
2019-11-19 20:16                   ` Mark Wielaard
2019-11-19 21:22                     ` Frank Ch. Eigler
2019-11-20 12:50                       ` Mark Wielaard
2019-11-20 13:30                         ` Frank Ch. Eigler
2019-11-21 14:02                           ` Mark Wielaard
2019-11-13 13:57   ` Mark Wielaard
2019-11-14 11:24     ` Frank Ch. Eigler
2019-11-16  0:52       ` Mark Wielaard
2019-11-16  2:28         ` Frank Ch. Eigler
2019-10-30 11:04 ` patch 0/2 debuginfod submission Mark Wielaard
2019-10-30 13:40   ` Frank Ch. Eigler
2019-10-30 14:12     ` Mark Wielaard
2019-10-30 18:11       ` Frank Ch. Eigler
2019-10-31 11:18         ` Mark Wielaard

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=c5adf263d267e711d83e1bf74a94cb2d7887c8ea.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=amerey@redhat.com \
    --cc=elfutils-devel@sourceware.org \
    --cc=fche@redhat.com \
    /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).