This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug dynamic-link/20172] New: ld.so: add possibility to suppress LD_PRELOAD warnings


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

            Bug ID: 20172
           Summary: ld.so: add possibility to suppress LD_PRELOAD warnings
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: christian+glibc at iwakd dot de
  Target Milestone: ---

Created attachment 9292
  --> https://sourceware.org/bugzilla/attachment.cgi?id=9292&action=edit
Have ld.so support LD_PRELOAD_IGNORE_ERRORS

If LD_PRELOAD fails to load a library, it will print an error message (which is
actually just a warning), and then will continue to proceed as if the specific
object hadn't been specified at all.

However, there is no possibility to suppress the warning, which may clutter the
console needlessly in some cases, and may cause programs that interpret error
output (such as certain build systems and/or test infrastructures) to choke on
that.

Use cases:

 - Use LD_PRELOAD when running a binary of one architecture, which in turn
   then loads a binary of another architecture, where the preloaded library
   is only in fact needed for the first binary.
 - Having a LD_PRELOAD active in a shell (or something similar), and calling
   a privileged program. I know it works if you install the library with
   setuid bit in a system location, but maybe you only need LD_PRELOAD for
   non-privileged programs? Or you don't have root on that system but don't
   always want to get an error message if you run e.g. ping, just because you
   preload something.
 - When running chroot under LD_PRELOAD (think e.g. eatmydata), unless the
   library is also installed in the chroot, all programs called within the
   chroot will fail.

I've attached a patch against current git master that introduces a new
environment variable LD_PRELOAD_IGNORE_ERRORS, which can contain a list of
objects for which LD_PRELOAD errors are to be ignored.

Important: in order for this to not have any security impact, just adding
something to LD_PRELOAD_IGNORE_ERRORS will not (!) cause the object to be
preloaded, it also has to be added to LD_PRELOAD itself.

This means:

 - LD_PRELOAD=foo <LD_PRELOAD_IGNORE_ERRORS unset>
     shows current behavior
 - LD_PRELOAD=foo:bar LD_PRELOAD_IGNORE_ERRORS=foo:baz
     errors for foo will not be printed, but errors for bar will be
 - <LD_PRELOAD unset> LD_PRELOAD_IGNORE_ERRORS=foo
     nothing will be preloaded, LD_PRELOAD_IGNORE_ERRORS will have no effect
     (other than being inherited by child processes, and so potentially
     affecting those if they choose to set LD_PRELOAD)

I've tested this in a chroot, and the patch is very simple.

It would be great if the next glibc version could include this improvement.

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]