From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 52960385C301; Fri, 17 Feb 2023 10:59:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52960385C301 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676631578; bh=WQEJdp3Upg8Z5Qxb0b24848sQWaJbl4MS/h/NTOdvck=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EwbJgZ8nA6vb/dzkrXzD7vz0QdiX1z5FznL1bqYrEDcqZBlsngqR7EvD6HAr+djuV YMK8smTG1/ngqMyEVHDicjw9erWG571sW95E+Fsb7Nup/3xq8K6J31Brs5dLjpSJLv k8/5rmQMPBng4YgTANbKk47oNhGoWnjdehiLb1fU= From: "stsp at users dot sourceforge.net" To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/30127] [rfe]: enable ld audit at run-time Date: Fri, 17 Feb 2023 10:59:37 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: 2.38 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: stsp at users dot sourceforge.net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30127 --- Comment #11 from Stas Sergeev --- (In reply to Florian Weimer from comment #10) > I think for experimentation, you can use the link map as a dlopen handle > directly, and pass it to dlsym, for example. That finally works, thank you. So with that and the patches already posted to ML, I can at least start prototyping some code. > We need to gather consensus that this is the way to do it, and document i= t. > Presently, it's an undocumented implementation detail. >=20 > We also need to use a dedicated link map allocator which only reuses, but > not frees, the underlying storiage, so that it becomes safe to traverse t= he > _r_debug lists, despite concurrent dlopen/dlcose operation. But I hope the traversal of _r_debug list will not became the official solution, just as well as using linkmap pointers directly. So maybe you don't need such an allocator, but of course I am not aware of a use-case you are referring to. > There should also be a way to obtain a stable handle from a link map > pointer. Using dlopen with RTLD_NOLOAD seems about right for that. So do you want this patch to get that working right here right now: --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -872,7 +872,8 @@ no more namespaces available for dlmopen()")); DL_NNS is 1 and so any NSID !=3D 0 is invalid. */ || DL_NNS =3D=3D 1 || GL(dl_ns)[nsid]._ns_nloaded =3D=3D 0 - || GL(dl_ns)[nsid]._ns_loaded->l_auditing)) + || (GL(dl_ns)[nsid]._ns_loaded->l_auditing && + !(mode & RTLD_NOLOAD)))) _dl_signal_error (EINVAL, file, NULL, N_("invalid target namespace in dlmopen()")); I tested that patch and it works. Test-suit shows no regressions. Also what do you think about the aforementioned void *dlaudit_load_module(const char *path, int flags); void *dlopen_audit(const char *path, int flags, void *cookie); extensions? They are orthogonal to these namespace problems, and in my case would allow to get rid of all those _r_debug, fpic and lmpointer hacks, and get a good use of the "cookie" audit functionality. I can even code them up myself if there is an interest in such functionality. --=20 You are receiving this mail because: You are on the CC list for the bug.=