Bug 1317238 - possible ld-linux.so.2 misbehaviour detected
Summary: possible ld-linux.so.2 misbehaviour detected
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Carlos O'Donell
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-03-13 09:20 UTC by Ali Akcaagac
Modified: 2016-03-13 11:41 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-03-13 11:41:30 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Ali Akcaagac 2016-03-13 09:20:24 UTC
Let's assume following use case (one that I have):

Hot-Swapping a Linux System

I keep a backup of my Fedora installation in:

/.fedora

The other directories of the root remain as they are

/bin
/boot
/etc
...

I usually Hot-Swap the system every now and then by rebooting Fedora and applying systemd.target=emergency.service to the Kernel line before loading up.

This allows me to operate on the correct Filesystem rather than e.g. the initrd.

After logging in I run "midnight commander" straight away and move all directories of the root in a subdirectory and then move all directories from /.fedora to the root directory. (there are a few exceptions like dev, proc, run, sys)

I exit "midnight commander", run ldconfig, grub2-install /somedev, reboot, done.

Running "midnight commander" will also load all shared libraries that "midnight commander" depend on into memory, therefore no issues with operation as long as you don't quit the program - I know this is slightly risky - until now this has never failed!

Now I wanted to automate this process within a script.

running "mv" to move the same directories into a temp directory and then running "mv" again to move all backup directories back to the root.

The "run again" is an issue because once all root directories are moved to a temp directory the root basicly has no directories anymore. Thus also means lib → usr/lib is missing. This means even ld-linux.so.2 is missing, to load all dynamical libraries a file depend on.

What I tried was this:

LD_LIBRARY_PATH="/.fedora/usr/lib" mv

---- failed because of the dynamic loader.

What should work - at least from the manuals - is this:

/.fedora/usr/lib/ld-linux.so.2 --library-path /.fedora/usr/lib mv

---- sadly this fails with errors in the object files.

No matter what shared file I point at it. They all fail. From what I understand is, that running ld-linux.so.2 (and some command after it) should make the program pointing at it run → at least the small ones like "mv" "rm" ...

Any ideas what's wrong or what I might be missing here ?

Comment 1 Florian Weimer 2016-03-13 10:05:41 UTC
(In reply to Ali Akcaagac from comment #0)
> What should work - at least from the manuals - is this:
> 
> /.fedora/usr/lib/ld-linux.so.2 --library-path /.fedora/usr/lib mv

Please capture the output of:

LD_DEBUG=all /.fedora/usr/lib/ld-linux.so.2 --library-path /.fedora/usr/lib mv

We also need the exact versions (NVRs) of the glibc libraries involved.

Comment 2 Ali Akcaagac 2016-03-13 11:41:30 UTC
(In reply to Florian Weimer from comment #1)
> We also need the exact versions (NVRs) of the glibc libraries involved.

I have to apologize! This was my fault!

During hot-swap there was no PATH set to /.fedora/bin, therefore the ld-linux.so.2 loader wasn't able to load any of the commands, because it couldn't find them.

The glibc and the files involved are all from the glibc-2.21-13.fc22.i686 package.

The solution was to either export or set a PATH or using absolute path within the ld.so call.

My *crude* but valid solution from this morning looks like this:

;--- begin test.sh ---
ROOT1="/"
PATH1="/.cdrom"
PATH2="/.cdrom-"

LDSO1="${PATH1}/usr/lib/ld-linux.so.2 --library-path ${PATH1}/usr/lib"
FILE1="${PATH1}/usr/bin/rm --force --recursive"
FILE2="${PATH1}/usr/bin/mv --force --verbose"
FILE3="${ROOT1}/usr/bin/rm --force --recursive"
FILE4="${ROOT1}/usr/bin/mv --force --verbose"

LIST1="${ROOT1}/bin ${ROOT1}/boot ${ROOT1}/etc ${ROOT1}/home ${ROOT1}/lib
       ${ROOT1}/lost+found ${ROOT1}/media ${ROOT1}/mnt ${ROOT1}/opt ${ROOT1}/root
       ${ROOT1}/sbin ${ROOT1}/srv ${ROOT1}/tmp ${ROOT1}/usr ${ROOT1}/var
       ${ROOT1}/.autorelabel ${ROOT1}/.readahead"

LIST2="${PATH1}/bin ${PATH1}/boot ${PATH1}/etc ${PATH1}/home ${PATH1}/lib
       ${PATH1}/lost+found ${PATH1}/media ${PATH1}/mnt ${PATH1}/opt ${PATH1}/root
       ${PATH1}/sbin ${PATH1}/srv ${PATH1}/tmp ${PATH1}/usr ${PATH1}/var
       ${PATH1}/.autorelabel ${PATH1}/.readahead"

${LDSO1} ${FILE1}          ${LIST1}
${LDSO1} ${FILE2} ${LIST2} ${ROOT1}

${FILE3}          ${PATH1}
${FILE4} ${PATH2} ${PATH1}
;--- end test.sh ---


Note You need to log in before you can comment on or make changes to this bug.