re: CVS commit: src/usr.bin/ldd

2022-10-25 Thread Ryo ONODERA
Hi,

matthew green  writes:

>> With this change, ldd /lib/libc.so.12.220 fails under NetBSD/amd64 9.99.101.
>>
>>
>> /lib/libc.so.12.220:
>> ldd: /lib/libc.so.12.220: invalid ELF class 2, expected 1
>>
>> It seems that elf32_ldd() fails.
>>
>> Builds of some pkgsrc packages that use gobject introspection and meson fails
>> because they uses ldd command during build.
>
> this should be fixed now.  sorry for the failure..

I am sorry. I have missed your email.
Thanks for your quick fix!!!

> .mrg.

-- 
Ryo ONODERA // r...@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3


re: CVS commit: src/usr.bin/ldd

2022-10-18 Thread matthew green
> With this change, ldd /lib/libc.so.12.220 fails under NetBSD/amd64 9.99.101.
>
>
> /lib/libc.so.12.220:
> ldd: /lib/libc.so.12.220: invalid ELF class 2, expected 1
>
> It seems that elf32_ldd() fails.
>
> Builds of some pkgsrc packages that use gobject introspection and meson fails
> because they uses ldd command during build.

this should be fixed now.  sorry for the failure..


.mrg.


Re: CVS commit: src/usr.bin/ldd

2022-10-18 Thread Ryo ONODERA
Hi,

With this change, ldd /lib/libc.so.12.220 fails under NetBSD/amd64 9.99.101.

/lib/libc.so.12.220:
ldd: /lib/libc.so.12.220: invalid ELF class 2, expected 1

It seems that elf32_ldd() fails.

Builds of some pkgsrc packages that use gobject introspection and meson fails 
because they uses ldd command during build.

Thank you.

-- 
Ryo ONODERA // r...@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3

> On Oct 15, 2022, at 14:55, matthew green  wrote:
> 
> Module Name:src
> Committed By:mrg
> Date:Sat Oct 15 05:55:46 UTC 2022
> 
> Modified Files:
>src/usr.bin/ldd: ldd.1 ldd.c
> 
> Log Message:
> ldd(1): add a -v option to display all errors not just the latest.
> 
> ldd on a go binary currently fails with an error that basically
> says "not elf32 class".  this is a true statement, as it is an
> elf64 class object, but it's not useful.  it happens because
> ldd_elf64() is called, fails in _rtld_map_object(), and then
> ldd_elf32() is called, and it fails because the class is wrong,
> and only this error is returned.  (this problem remains.  the
> call to map the object fails due to there being 3 instead of 2
> elf segments in the file.  i guess we need similar code in
> ld.elf_so/map_objects.c as the kernel gained some time ago.)
> 
> perhaps the first error, not the last error, should be used if
> everything fails, but this allows all failures to be see and
> would be useful even if the error string handling changed.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.20 -r1.21 src/usr.bin/ldd/ldd.1
> cvs rdiff -u -r1.25 -r1.26 src/usr.bin/ldd/ldd.c
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
> 
> Modified files: Index: src/usr.bin/ldd/ldd.1 diff -u 
> src/usr.bin/ldd/ldd.1:1.20 src/usr.bin/ldd/ldd.1:1.21 --- 
> src/usr.bin/ldd/ldd.1:1.20 Mon Dec 25 05:08:49 2017 +++ src/usr.bin/ldd/ldd.1 
> Sat Oct 15 05:55:45 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: ldd.1,v 1.20 
> 2017/12/25 05:08:49 maya Exp $ +.\" $NetBSD: ldd.1,v 1.21 2022/10/15 05:55:45 
> mrg Exp $ .\" .\" Copyright (c) 1998 The NetBSD Foundation, Inc. .\" All 
> rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF 
> THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" 
> -.Dd December 25, 2017 +.Dd October 15, 2022 .Dt LDD 1 .Os .Sh NAME @@ -35,7 
> +35,7 @@ .Nd list dynamic object dependencies .Sh SYNOPSIS .Nm -.Op Fl o +.Op 
> Fl ov .Op Fl f Ar format .Ar program ... .Sh DESCRIPTION @@ -105,6 +105,10 @@ 
> which makes .Nm behave analogously to .Ic nm Fl o . +.Pp +The +.Fl v +option 
> turns on verbose mode. .Sh EXIT STATUS .Ex -std .Sh SEE ALSO @@ -118,9 +122,3 
> @@ A utility first appeared in SunOS 4.0, it appeared in its current form in 
> .Nx 0.9a . -.Sh BUGS -The -a.out -.Nm -actually runs the program it has been 
> requested to analyze which in specially -constructed environments can have 
> security implications. Index: src/usr.bin/ldd/ldd.c diff -u 
> src/usr.bin/ldd/ldd.c:1.25 src/usr.bin/ldd/ldd.c:1.26 --- 
> src/usr.bin/ldd/ldd.c:1.25 Fri Jul 23 04:20:05 2021 +++ src/usr.bin/ldd/ldd.c 
> Sat Oct 15 05:55:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ldd.c,v 1.25 2021/07/23 
> 04:20:05 martin Exp $ */ +/* $NetBSD: ldd.c,v 1.26 2022/10/15 05:55:45 mrg 
> Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -62,7 
> +62,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ldd.c,v 1.25 2021/07/23 
> 04:20:05 martin Exp $"); +__RCSID("$NetBSD: ldd.c,v 1.26 2022/10/15 05:55:45 
> mrg Exp $"); #endif /* not lint */ #include @@ -124,11 +124,12 @@ main(int 
> argc, char **argv) const char *fmt1 = NULL, *fmt2 = NULL; int c, exit_status 
> = EXIT_SUCCESS; char cwd[MAXPATHLEN], path[MAXPATHLEN]; + bool verbose = 
> false, failed = false; #ifdef DEBUG debug = 1; #endif - while ((c = 
> getopt(argc, argv, "f:o")) != -1) { + while ((c = getopt(argc, argv, "f:ov")) 
> != -1) { switch (c) { case 'f': if (fmt1) { @@ -143,6 +144,9 @@ main(int 
> argc, char **argv) errx(1, "Cannot use -o and -f together"); fmt1 = 
> "%a:-l%o.%m => %p\n"; break; + case 'v': + verbose = true; + break; default: 
> usage(); /*NOTREACHED*/ @@ -174,17 +178,31 @@ main(int argc, char **argv) 
> warn("%s", *argv); continue; } - if (elf_ldd(fd, *argv, path, fmt1, fmt2) == 
> -1 - /* Alpha never had 32 bit support. */ + if (elf_ldd(fd, *argv, path, 
> fmt1, fmt2) == -1) { + if (verbose) + warnx("%s", error_message); + failed = 
> true; + } + /* Alpha never had 32 bit support. */ #if (defined(_LP64) && 
> !defined(ELF64_ONLY)) || defined(MIPS_N32) - && elf32_ldd(fd, *argv, path, 
> fmt1, fmt2) == -1 + if (elf32_ldd(fd, *argv, path, fmt1, fmt2) == -1) { + if 
> (verbose) + warnx("%s", error_message); + failed = true; + } #if 
> defined(__mips__) && 0 /* XXX this is still hosed for some reason */ - && 
> elf32_ldd_compat(fd, *argv, path, fmt1, fmt2) == -1 + if 
> (elf32_ldd_compat(fd, *argv, path, fmt1, 

Re: CVS commit: src/usr.bin/ldd

2018-06-22 Thread Kamil Rytarowski
On 22.06.2018 15:38, matthew green wrote:
> "Kamil Rytarowski" writes:
>> Module Name: src
>> Committed By:kamil
>> Date:Thu Jun 21 10:41:46 UTC 2018
>>
>> Modified Files:
>>  src/usr.bin/ldd/build: Makefile
>>  src/usr.bin/ldd/elf32: Makefile
>>  src/usr.bin/ldd/elf32_compat: Makefile
>>  src/usr.bin/ldd/elf64: Makefile
>>
>> Log Message:
>> Disable SANITIZER for ldd(1)
>>
>> These utilities (elf32, elf32_compat, elf64, liblldb) share code with the
>> ELF dynamic loader that is not being sanitized and its symbols are
>> installed into sanitized programs (in particular __tls_get_addr()).
>>
>> Additionally libldd is used in rescue that is not expected to be sanitized
>> as of today.
> 
> i'm not sure i understand.  ldd itself should be able to be
> sanitized.  even with shared code with ld.elf_so, this copy
> shouldn't be doing anything but reading data and outputting
> the various linkages found, but never executing anything not
> in ldd binary itself.  (this is unlike traditional ldd(1)
> in most implementations, which often makes the dynamic
> linker do the real work of ldd.)
> 
> what's the specific issue?  perhaps we can fix it..
> 

The first conflict is with __tls_get_addr(). This symbol could be renamed.

I'm in the process of designing a macro to rename conflicting symbols,
dedicated for programs in external/ and those reusing source code from
non-stanitized libraries like libc.

The current list of manual renames is specified here:
http://netbsd.org/~kamil/patch-00055-rename-symbols-clash-with-sanitizers.txt

Once I will get an installable release image under ASan, I will present
the macro and we can reevaluate ldd(1).

My current progress is being on the installboot(8) stage:

http://netbsd.org/~kamil/mksanitizer-reports/0020-installboot-ffsv2.txt

> 
> .mrg.
> 




signature.asc
Description: OpenPGP digital signature