Obscure error messages caused by ubuntu patch

Bug #1031718 reported by Tuomas Silen
136
This bug affects 38 people
Affects Status Importance Assigned to Milestone
libjpeg-turbo (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Environment:
Description: Ubuntu 12.04 LTS
Release: 12.04
libjpeg-turbo8 1.1.90+svn733-0ubuntu4.1

Ubuntu's own patch (FixLibraryStartup.patch) causes obscure "Error opening file for reading: Permission denied" error messages.

The patch adds some auxv related stuff to the library init that attempt to read /proc/self/auxv. If it fails the above error is printed usually ending up to application's log that's using the library. Looking at the log it's completely unclear where that error came from and what file was it trying to read.

The /proc/self/auxv has 0400 permissions and is owned by the user who started the process. If the process drops privileges and setuid()'s to another user, the file is no longer readable.

description: updated
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in libjpeg-turbo (Ubuntu):
status: New → Confirmed
Revision history for this message
Sergio Callegari (callegar) wrote :

This causes an "Error opening file for reading: Permission denied" when starting VirtualBox. See Bug #1014487

Revision history for this message
Paul Jackson (pj-usa) wrote :

The opening post in Bug #1014487 (which has been duplicated to this present bug now) contains some
suggested code which might be adapted for use in libjpeg-turbo8 to accomplish what the '/proc/self/auxv'
access that is presently failing with this open error:

Revision history for this message
Matthias Klose (doko) wrote :

Paul, I don't see any suggested code in the other report. please repeat it here.

Two proposals for fixing this:
 - Don't call libjpeg_arch_specific_init if get_auxv return 0
 - use gcc's ifunc feature to initialize the processor specific funtions

Revision history for this message
Paul Jackson (pj-usa) wrote :
Download full text (4.4 KiB)

Matthias wrote "Paul, I don't see any suggested code in the other report. please repeat it here."

Well ... I'm not sure how you missed it, since the bulk of the opening post of Bug #1014487 consists of this suggested CODE :).

Here it is again, copied and pasted from Bug #1014487:

====================== Begin CODE and comments ======================
Looking about the web, I see that virtualbox is apparently trying to open /proc/self/auxv in order to determine some system capabilities, and that it is realized that this is not a reliable method -- auxv may or may not be readable.

In my situation, auxv is reliably NOT readable .

The following shell command reliably shows the contents of what is, I suspect, the desired auxv information:

[CODE]LD_SHOW_AUXV=1 /bin/true[/CODE]

For example on my Kubuntu 12.04 amd64 system, it shows:

[CODE]
AT_SYSINFO_EHDR: 0x7fffcd7c4000
AT_HWCAP: bfebfbff
AT_PAGESZ: 4096
AT_CLKTCK: 100
AT_PHDR: 0x400040
AT_PHENT: 56
AT_PHNUM: 9
AT_BASE: 0x7ffc2640c000
AT_FLAGS: 0x0
AT_ENTRY: 0x401134
AT_UID: 1000
AT_EUID: 1000
AT_GID: 1000
AT_EGID: 1000
AT_SECURE: 0
AT_RANDOM: 0x7fffcd772489
AT_EXECFN: /bin/true
AT_PLATFORM: x86_64
[/CODE]

The following code might provide a useful and reliable means of parsing this auxv information:

[CODE]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/*
 * The following flgets() and examine_auxv() routines are Copyright
 * 2006 and 2012 respectively by Paul Jackson <email address hidden>.
 *
 * These routines are free software; you can redistribute them and/or
 * modify them under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You may obtain a copy of this license from: <http://www.gnu.org/licenses/>.
 */

/*
 * char *flgets(char *buf, int buflen, FILE *fp)
 *
 * Obtain one line from input file fp. Copy up to first
 * buflen-1 chars of line into buffer buf, discarding rest
 * of line. Stop reading at newline, discarding newline.
 * Nul terminate result and return pointer to buffer buf
 * on success, or NULL if nothing more to read or failure.
 *
 * Paul Jackson
 * <email address hidden>
 * 20 Feb 2006
 */

static char *flgets(char *buf, int buflen, FILE * fp)
{
    int c = -1;
    char *bp;

    bp = buf;
    while ((--buflen > 0) && ((c = getc(fp)) >= 0)) {
        if (c == '\n')
            goto newline;
        *bp++ = c;
    }
    if ((c < 0) && (bp == buf))
        return NULL;

    if (c > 0) {
        while ((c = getc(fp)) >= 0) {
            if (c == '\n')
                break;
        }
    }

newline:
    *bp++ = '\0';
    return buf;
}

/*
 * int examine_auxv(const char *pattern, char *buf, int buflen)
 *
 * Examine /proc/self/auxv, as formatted in the manner
 * seen by running the command:
 * LD_SHOW_AUXV=1 /bin/true
 * Return the first line that has some substring matching
 * the input "pattern". Retu...

Read more...

Revision history for this message
Michael Basse (michael-alpha-unix) wrote :

Dont know if it helps, i am facing the duplicate of this bug (Virtualbox)

I removed virtualbox and then reinstalled it

sudo apt-get remove virtualbox
sudo apt-get install virtualbox

and after the new installation i was facing this bug.

The remove and install was using the same version, so there was no virtualbox update in that time window.

iI cant find virtualbox in the unity-search-thing anymore, i can just start virtualbox by

 michael@bestbuntu:~$ virtualbox
Error opening file for reading: Keine Berechtigung

its working fine then but i cant stick it to the unity launcher, everytime i start virtualbox again a new unity-launcher is created and the old ones cant be used.

Revision history for this message
Michael Basse (michael-alpha-unix) wrote :

Additonal:
I am using Ubuntu 12.04 AMD64

virtualbox:
  Installiert: 4.1.12-dfsg-2ubuntu0.2
  Kandidat: 4.1.12-dfsg-2ubuntu0.2
  Versionstabelle:
 *** 4.1.12-dfsg-2ubuntu0.2 0
        500 http://de.archive.ubuntu.com/ubuntu/ precise-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ precise-security/universe amd64 Packages
        100 /var/lib/dpkg/status
     4.1.12-dfsg-2 0
        500 http://de.archive.ubuntu.com/ubuntu/ precise/universe amd64 Packages

Revision history for this message
Thomas Dreibholz (dreibh) wrote :

I can confirm the message "Error opening file for reading: Permission denied" for VirtualBox as well as for VBoxHeadless. The latter one is particularly annoying, since it produces unnecessary error logs into my server logs when starting remote virtual machines.

Revision history for this message
Roland Hughes (original-seasoned-geek) wrote :

QT C++ programmers can "work around" the bug in this manner.

In main.cpp

create your application

create your main window

(don't display anything yet)

call routine to set your capabilities and drop your ownership.

Now you exec.

Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

A simple workaround is to make libjpeg-turbo load before the application with the error has a change to change users:
 LD_PRELOAD=libjpeg.so.8 /usr/bin/myapplication
OR
 export LD_PRELOAD=libjpeg.so.8

Revision history for this message
Martin von Gagern (gagern) wrote :

Any chances of getting this fixed before the LTS “support” ends?

I notice that quantal is already without this patch. So I wonder, was it dropped because some other change made it unneccessary, or was it dropped simply because it broke more than it fixed. If the latter, then please drop the patch for precise as well, and publish an update. If the former, then please identify that change and backport it.

I do hope that devs have some secret location where they can find out about why this change to the series file happened. Looking at the debian changelog in the package sources, I see no mention of the patch at all. None of the changes between precise and quantal mentions anything close to this patch. But perhaps devs have the means to figure out the rationale here.

While you are at it, you might as well get rid of that patch completely. Having a patch in the debian patches directory but its line commented out in the series is very confusing, I think. If you want to keep old stuff around, use a proper VCS please.

Revision history for this message
Carlos R Laguna Mendoza (carlosla1987) wrote :

Any chance of fixing this already, 2 years since was reported. Thanks for your effort and time.

Revision history for this message
Walter (wdoekes) wrote :

So. Apparently this has been "fixed" somewhere along the road to Ubuntu 14.04.

The patch is commented out in the debian/patches/series file in version 1.3.0-0ubuntu2.
However, the debian/changelog doesn't tell me when that happened (or when it was added, for that matter).

Changed in libjpeg-turbo (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.