public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] elf: ldconfig should skip temporary files created by package managers
Date: Fri, 20 Oct 2023 16:41:27 +0200	[thread overview]
Message-ID: <87ttqlxso8.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <5ab3884a-8fbc-4007-a310-a603bc349873@linaro.org> (Adhemerval Zanella Netto's message of "Fri, 20 Oct 2023 09:48:53 -0300")

* Adhemerval Zanella Netto:

> On 20/10/23 09:29, Florian Weimer wrote:
>> This avoids crashes due to partially written files, after a package
>> update is interrupted.
>
> It seems kinda unreliable a tool create temporary files on the libdir,
> although we alrady handle for prelinkk so it makes sense to extend to
> other program as well.  Maybe another option would to proper parse the 
> file header and only handle ELF files, so ldconfig is not bounded to
> name patterns.

The files look like ELF files, but a truncated, so that we get SIGBUS
because the mapping we access is only halfway there.

>> +  /* Skip temporary files created by dpkg.  */
>> +  if (len > 4 && memcmp (name + len - 4, ".tmp", 4) == 0)
>
> Wouldn't this potentially read out the bounds for sizes [5, 8)? Maybe
> just use strcmp?

I don't see how.

   ABCDE
        ^ name + len
    ^ name + len - 4
    .tmp

Looks okay to me?

Thanks,
Florian


  reply	other threads:[~2023-10-20 14:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-20 12:29 Florian Weimer
2023-10-20 12:48 ` Adhemerval Zanella Netto
2023-10-20 14:41   ` Florian Weimer [this message]
2023-10-20 15:15     ` Adhemerval Zanella Netto
2023-10-20 21:33 ` Guillem Jover
2023-10-21 22:14   ` Florian Weimer
2023-10-21 11:37 ` Cristian Rodríguez
2023-10-21 22:20   ` Florian Weimer
2023-11-14 23:34 ` DJ Delorie
2023-11-15  5:02   ` Florian Weimer
2023-11-15  6:39     ` Florian Weimer
2023-11-15 16:18       ` DJ Delorie

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=87ttqlxso8.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).