Bug 2112857 - s390utils: please consider stop using liblockfile
Summary: s390utils: please consider stop using liblockfile
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: s390utils
Version: 37
Hardware: s390x
OS: Linux
low
low
Target Milestone: ---
Assignee: Dan Horák
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-08-01 10:30 UTC by Lakshmi Ravichandran
Modified: 2022-11-28 01:15 UTC (History)
9 users (show)

Fixed In Version: s390utils-2.24.0-1.fc38 s390utils-2.24.0-1.fc36 s390utils-2.24.0-1.fc37
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-11-28 01:01:23 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
IBM Linux Technology Center 199362 0 None None None 2022-08-11 10:41:37 UTC

Description Lakshmi Ravichandran 2022-08-01 10:30:59 UTC
Description of problem:

currently, s390Utils needs liblockfile-devel for building ap-check .

on the other hand, recently, liblockfile package has introduced setting a special gId to /usr/bin/dotlockfile for purpose of mailgroup which breaks setgid tests for Fedora - rawhide in s390x.

So, we need to split out liblockfile-devel.

Version-Release number of selected component (if applicable):
Fedora - rawhide


How reproducible:
Run setgid tests from the fedora kola suite wihtout considering the gID set to /usr/bin/dotlockfile and see it fail.

Comment 1 Dan Horák 2022-08-01 12:59:38 UTC
If a test is failing, then the test needs to be updated. There is nothing to do on the s390utils side if we don't want to disable the functionality provided by liblockfile in ap-check. Which we don't, I believe. You might ask the liblockfile maintainers to put the binary into a separate subpackage, but in such small package it makes no sense.

Comment 2 Lakshmi Ravichandran 2022-08-02 16:34:24 UTC
Dear liblockfile team, is it possible to move the binary to a separate subpackage and have the library part of liblockfile in a package by itself ?
in FCOS, we donot use the binary but rather the rest of the library. Thank you.

Comment 3 Dusty Mabe 2022-08-03 01:54:47 UTC
I feel like it's important to add more context to this request..

Dan (s390utils) and Richard (liblockfile) bear with us for a moment.

We (the Fedora CoreOS and Red Hat CoreOS teams) are trying to identify and qualify any new setuid or setgid binaries that come into Fedora CoreOS and Red Hat CoreOS. We have a test that notifies when any new/unexpected setuid or setgid binaries show up. After the recent s390utils build, which pulls in liblockfile, we started a discussion [1] in our upstream tracker that eventually lead to this request.

We've done some analysis [2] and determined that s390utils doesn't use `dotlockfile` and it may even be served better by using a different (more generic, and not specific to mail applications) locking library so that it no longer requires liblockfile.

This request is to inform liblockfile of the potential non-mail application of liblockfile and to try to discuss with both parties (s390utils and liblockfile) potential solutions.

Thanks for any input you can provide here!

[1] https://github.com/coreos/fedora-coreos-tracker/issues/1253
[2] https://github.com/coreos/fedora-coreos-tracker/issues/1253#issuecomment-1202989926

Comment 4 Dan Horák 2022-08-03 08:23:58 UTC
I wonder if lockfile-progs wouldn't be a better place for the dotlockfile utility. Or perhaps it's even redundant ...

Comment 5 Dan Horák 2022-08-04 11:30:19 UTC
Joe, this might be relevant from the enterprise point of view as well.

Comment 6 Joe Orton 2022-08-04 12:02:10 UTC
It is the purpose of liblockfile that the library execs the /usr/bin/dotlockfile binary to deal with the setgid mail case, rather than the app needing to be setgid itself.

So it doesn't make sense moving the executable into a subpackage AFAICT.

Comment 7 Joe Orton 2022-08-04 12:08:18 UTC
Right, this https://github.com/coreos/fedora-coreos-tracker/issues/1253#issuecomment-1202989926 is spot on, thanks Dusty.

If you just need a lockfile in /run just use open/O_EXCL, it seems way overkill to pull in liblockfile for that case.

Comment 8 Dan Horák 2022-08-04 12:20:08 UTC
The use case is more complex, it involves udev rules and mediated devices (mdevctl) and a pass-thru for crypto devices into guests ... But if there would exist some other solution I believe upstream would not be opposed ...

Comment 9 Richard Lescak 2022-08-04 13:27:51 UTC
Hi guys.


Problem with separating dotlockfile, as Joe stated, is that library uses the dotlockfile binary for some of its functionality. For that I think that it is undesirable to try separate them.

Because of this and a fact that in a relatively recent past we had a bug related to a functionality of dotlockfile I think we can't say that the binary is redundant.

Also the way gID is set for dotlockfile is implemented purposefully, therefore changing that is not a good option.

Comment 10 Dusty Mabe 2022-08-04 14:10:43 UTC
Thanks Richard.

I'll switch the component back to s390utils for now so we can further discuss the use of this library in s390utils in this BZ.

Comment 11 Dan Horák 2022-08-04 15:05:22 UTC
My assumption is that the library is used to avoid race conditions in the udev rules for the vfio-ap feature. So it would be risky to build s390utils without liblockfile. I would recommend opening an upstream issue to discuss the use of liblockfile and possible alternatives.

Comment 12 Timothée Ravier 2022-08-05 09:55:04 UTC
Suggestion to split the liblockfile package while keeping compatibility:
- Add a sub-package with only the setgid binary
- Have the library recommend the sub-package
- Have applications that truly need the setgid functionality explicitly depend on the sub-package

This enables applications to depend only on the library if they don't need the functionality provided by the setgid binary.
This also solves the issue for us as we don't enable recommends by default.

Comment 13 Joe Orton 2022-08-05 10:27:20 UTC
Having library behaviour contingent on a weak dep like that is not a good idea, there is no way to guarantee the "real" dependency is in place from the API caller.

Comment 14 Richard Lescak 2022-08-05 12:34:37 UTC
I think that it is not as much question of other packages dependencies to liblockfile as the fact that people would expect fully functional library.
General Upstream info about liblockfile says this:

This library implements a number of functions found in -lmail on SysV
systems. These functions are designed to lock the standard mailboxes in
/var/mail (or wherever the system puts them).

In additions, this library adds a number of functions to create,
manage and remove generic lockfiles.


So it is more like locking/unlocking of mails is primary function which could be expected out of the box instead as additional functionality obtained by subpackage.
Dotlockfile is essential part of this functionality as can be also seen in Makefile:

liblockfile.so: solockfile.o
		$(CC) $(LDFLAGS) -fPIC -shared -Wl,-soname,liblockfile.so.1 \
			-o liblockfile.so solockfile.o -lc

solockfile.o:	lockfile.c
		$(CC) $(CFLAGS) -DLIB -DLOCKPROG=\"$(bindir)/dotlockfile\" \
			-c lockfile.c -o solockfile.o

With this said, I'm not very inclined to this solution.

Comment 15 Dusty Mabe 2022-08-05 16:55:49 UTC
(In reply to Richard Lescak from comment #14)
> I think that it is not as much question of other packages dependencies to
> liblockfile as the fact that people would expect fully functional library.
> General Upstream info about liblockfile says this:
> 
> This library implements a number of functions found in -lmail on SysV
> systems. These functions are designed to lock the standard mailboxes in
> /var/mail (or wherever the system puts them).
> 
> In additions, this library adds a number of functions to create,
> manage and remove generic lockfiles.
> 

I think what we've identified is that this "additional functionality" is useful on its own (i.e. it could actually be a new dependency that gets pulled in by liblockfile itself and other non-mail focused apps could use it), but we should probably look for other solutions to that problem.

Thank you Richard for having this discussion with us.

Comment 16 Ben Cotton 2022-08-09 13:37:20 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 37 development cycle.
Changing version to 37.

Comment 17 Luca BRUNO 2022-08-11 14:04:28 UTC
Hi all. I did the quick initial analysis in https://github.com/coreos/fedora-coreos-tracker/issues/1253#issuecomment-1202989926 and I was observing the progress of the discussion in this ticket.

At this point, I think it would be useful to move this discussion upstream to see whether the s390-tools developers would be ok with dropping the liblockfile dependency and implement that logic internally instead.
I tried to quickly assemble something compatible with the current logic, and a non-intrusive patch seems overall feasible.

I'll now try to summarize this discussion into a github ticket, and post my current code there too.

Comment 18 Luca BRUNO 2022-08-11 14:20:16 UTC
The upstream ticket is at https://github.com/ibm-s390-linux/s390-tools/issues/142.

For reference, my current patch attempt is at https://github.com/lucab/s390-tools/pull/1.

Comment 19 Luca BRUNO 2022-11-10 15:47:53 UTC
Upstream fixed this in https://github.com/ibm-s390-linux/s390-tools/commit/25a70ac5a81ec0b3fa74715e30cc3675d2f018d8.

The fix got released in https://github.com/ibm-s390-linux/s390-tools/releases/tag/v2.24.0.

Once packaged in Fedora, that should allow dropping the liblockfile dependency in Fedora.

Comment 20 Joe Orton 2022-11-10 16:15:47 UTC
Thanks Luca for taking on that work.

Comment 21 Dan Horák 2022-11-10 16:58:56 UTC
s390utils 2.24.0 has been built for rawhide, F-37 and F-36 builds will follow next week

Comment 22 Fedora Update System 2022-11-11 17:39:57 UTC
FEDORA-2022-5a9600e505 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2022-5a9600e505

Comment 23 Fedora Update System 2022-11-13 02:34:39 UTC
FEDORA-2022-5a9600e505 has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2022-5a9600e505`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-5a9600e505

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 24 Fedora Update System 2022-11-13 02:39:11 UTC
FEDORA-2022-6c49fb07f9 has been pushed to the Fedora 36 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2022-6c49fb07f9`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-6c49fb07f9

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 25 Fedora Update System 2022-11-28 01:01:23 UTC
FEDORA-2022-6c49fb07f9 has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 26 Fedora Update System 2022-11-28 01:15:01 UTC
FEDORA-2022-5a9600e505 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.


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