Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup largefile define #31419

Merged
merged 2 commits into from Feb 21, 2024
Merged

Conversation

AdrianVovk
Copy link
Contributor

Fixes #31417

Also makes the error messages include the flags that are invalid, for easier debugging in the future, and defines a macro that declares what flags are safe to use (since there's > 1 consumer of this nowadays, and more coming with #26826)

This value is actually arch-specific, so this commit defines it for all
the arches that set it to some custom value

Fixes systemd#31417
Adds a SAFE_FD_FLAGS define to list out all the safe FD flags, and also
an UNSAFE_FD_FLAGS() macro to strip out the safe flags and leave only
the unsafe flags. This can be used to quickly check if any unsafe flags
are set and print them for diagnostic purposes
@mrc0mmand
Copy link
Member

I tried this on both ppc64le and aarch64 and the issue seems to be indeed gone, thanks!

Also, just out of curiosity, I tried this on armv7l as well, but there the test doesn't get far:

[1216026.467820] testsuite-46.sh[61]: + mount -t tmpfs tmpfs /home -o size=290M
[1216026.481155] testsuite-46.sh[61]: + NEWPASSWORD=xEhErW0ndafV4s
[1216026.481155] testsuite-46.sh[61]: + homectl create test-user --disk-size=min --luks-discard=yes --image-path=/home/test-user.home --luks-pbkdf-type=pbkdf2 --luks-pbkdf-time-cost=1ms
[1216026.486666] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/home_2emount interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=23 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.488123] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/home_2emount interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=24 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.489369] systemd[1]: home.mount: Changed dead -> mounted
[1216026.491048] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/home_2emount interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=25 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.492273] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/home_2emount interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=26 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.493456] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/swap_2etarget interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=27 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.494637] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/umount_2etarget interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=28 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.495790] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/local_2dfs_2dpre_2etarget interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=29 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.496956] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/local_2dfs_2etarget interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=30 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216027.126558] systemd-homed[53]: Got message type=method_call sender=:1.5 destination=org.freedesktop.home1 path=/org/freedesktop/home1 interface=org.freedesktop.home1.Manager member=CreateHomeEx  cookie=2 reply_cookie=0 signature=sa{sh}t error-name=n/a error-message=n/a
[1216027.128567] systemd-homed[53]: Sent message type=error sender=n/a destination=:1.5 path=n/a interface=n/a member=n/a cookie=5 reply_cookie=2 signature=s error-name=org.freedesktop.DBus.Error.NotSupported error-message=Provided flags are unsupported.
[1216027.130249] systemd-homed[53]: Failed to process message type=method_call sender=:1.5 destination=org.freedesktop.home1 path=/org/freedesktop/home1 interface=org.freedesktop.home1.Manager member=CreateHomeEx cookie=2 reply_cookie=0 signature=sa{sh}t error-name=n/a error-message=n/a: Provided flags are unsupported.
[1216027.131788] homectl[66]: Operation on home test-user failed: Provided flags are unsupported.

mrc0mmand added a commit to mrc0mmand/systemd that referenced this pull request Feb 20, 2024
Otherwise weird stuff happens on the other side:

[1217111.957263] testsuite-46.sh[61]: + homectl create test-user --disk-size=min --luks-discard=yes --image-path=/home/test-user.home --luks-pbkdf-type=pbkdf2 --luks-pbkdf-time-cost=1ms
[1217112.598219] homectl[66]: Operation on home test-user failed: Provided flags are unsupported (0ad2578000000000).

(taken from TEST-46-HOME run on armv7l)

Fixes issue mentioned in systemd#31419 (comment).
@mrc0mmand
Copy link
Member

Also, just out of curiosity, I tried this on armv7l as well, but there the test doesn't get far:

[1216026.467820] testsuite-46.sh[61]: + mount -t tmpfs tmpfs /home -o size=290M
[1216026.481155] testsuite-46.sh[61]: + NEWPASSWORD=xEhErW0ndafV4s
[1216026.481155] testsuite-46.sh[61]: + homectl create test-user --disk-size=min --luks-discard=yes --image-path=/home/test-user.home --luks-pbkdf-type=pbkdf2 --luks-pbkdf-time-cost=1ms
[1216026.486666] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/home_2emount interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=23 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.488123] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/home_2emount interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=24 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.489369] systemd[1]: home.mount: Changed dead -> mounted
[1216026.491048] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/home_2emount interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=25 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.492273] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/home_2emount interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=26 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.493456] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/swap_2etarget interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=27 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.494637] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/umount_2etarget interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=28 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.495790] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/local_2dfs_2dpre_2etarget interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=29 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216026.496956] systemd[1]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/systemd1/unit/local_2dfs_2etarget interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=30 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
[1216027.126558] systemd-homed[53]: Got message type=method_call sender=:1.5 destination=org.freedesktop.home1 path=/org/freedesktop/home1 interface=org.freedesktop.home1.Manager member=CreateHomeEx  cookie=2 reply_cookie=0 signature=sa{sh}t error-name=n/a error-message=n/a
[1216027.128567] systemd-homed[53]: Sent message type=error sender=n/a destination=:1.5 path=n/a interface=n/a member=n/a cookie=5 reply_cookie=2 signature=s error-name=org.freedesktop.DBus.Error.NotSupported error-message=Provided flags are unsupported.
[1216027.130249] systemd-homed[53]: Failed to process message type=method_call sender=:1.5 destination=org.freedesktop.home1 path=/org/freedesktop/home1 interface=org.freedesktop.home1.Manager member=CreateHomeEx cookie=2 reply_cookie=0 signature=sa{sh}t error-name=n/a error-message=n/a: Provided flags are unsupported.
[1216027.131788] homectl[66]: Operation on home test-user failed: Provided flags are unsupported.

-> #31420

mrc0mmand added a commit to mrc0mmand/systemd that referenced this pull request Feb 20, 2024
Otherwise weird stuff happens on the other side:

[1217111.957263] testsuite-46.sh[61]: + homectl create test-user --disk-size=min --luks-discard=yes --image-path=/home/test-user.home --luks-pbkdf-type=pbkdf2 --luks-pbkdf-time-cost=1ms
[1217112.598219] homectl[66]: Operation on home test-user failed: Provided flags are unsupported (0ad2578000000000).

(taken from TEST-46-HOME run on armv7l)

Fixes issue mentioned in systemd#31419 (comment).
@yuwata yuwata added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed homed homed, homectl, pam_homed and removed please-review PR is ready for (re-)review by a maintainer labels Feb 20, 2024
* This ensures that clients can't trick a privileged service into giving access to a file the client
* doesn't already have access to (especially via something like O_PATH).
*
* O_NOFOLLOW: For some reason the kernel will return this flag from fcntl; it doesn't go away immediately
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, this is new w/ this PR. Just double checking that this was noticed

return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "FD for %s has unexpected flags set", filename);
if (UNSAFE_FD_FLAGS(flags) != 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
"FD for %s has unexpected flags set: 0%o",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think this is probably too verbose to be included in bus error. We should add a helper that does log_debug internally. But I'll merge this as-is and submit a follow-up.

@YHNdnzj YHNdnzj merged commit e404ca3 into systemd:main Feb 21, 2024
48 of 49 checks passed
@github-actions github-actions bot removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Feb 21, 2024
YHNdnzj added a commit to YHNdnzj/systemd that referenced this pull request Feb 21, 2024
YHNdnzj added a commit to YHNdnzj/systemd that referenced this pull request Feb 21, 2024
bluca pushed a commit that referenced this pull request Feb 21, 2024
Otherwise weird stuff happens on the other side:

[1217111.957263] testsuite-46.sh[61]: + homectl create test-user --disk-size=min --luks-discard=yes --image-path=/home/test-user.home --luks-pbkdf-type=pbkdf2 --luks-pbkdf-time-cost=1ms
[1217112.598219] homectl[66]: Operation on home test-user failed: Provided flags are unsupported (0ad2578000000000).

(taken from TEST-46-HOME run on armv7l)

Fixes issue mentioned in #31419 (comment).
YHNdnzj added a commit to YHNdnzj/systemd that referenced this pull request Feb 21, 2024
YHNdnzj added a commit to YHNdnzj/systemd that referenced this pull request Feb 21, 2024
YHNdnzj added a commit to YHNdnzj/systemd that referenced this pull request Feb 21, 2024
@AdrianVovk AdrianVovk deleted the fixup-largefile-define branch February 21, 2024 19:31
YHNdnzj added a commit to YHNdnzj/systemd that referenced this pull request Feb 21, 2024
ayhamthemayhem pushed a commit to neighbourhoodie/nh-systemd that referenced this pull request Mar 25, 2024
Otherwise weird stuff happens on the other side:

[1217111.957263] testsuite-46.sh[61]: + homectl create test-user --disk-size=min --luks-discard=yes --image-path=/home/test-user.home --luks-pbkdf-type=pbkdf2 --luks-pbkdf-time-cost=1ms
[1217112.598219] homectl[66]: Operation on home test-user failed: Provided flags are unsupported (0ad2578000000000).

(taken from TEST-46-HOME run on armv7l)

Fixes issue mentioned in systemd#31419 (comment).
ayhamthemayhem pushed a commit to neighbourhoodie/nh-systemd that referenced this pull request Mar 25, 2024
chunyi-wu pushed a commit to chunyi-wu/systemd that referenced this pull request Apr 3, 2024
Otherwise weird stuff happens on the other side:

[1217111.957263] testsuite-46.sh[61]: + homectl create test-user --disk-size=min --luks-discard=yes --image-path=/home/test-user.home --luks-pbkdf-type=pbkdf2 --luks-pbkdf-time-cost=1ms
[1217112.598219] homectl[66]: Operation on home test-user failed: Provided flags are unsupported (0ad2578000000000).

(taken from TEST-46-HOME run on armv7l)

Fixes issue mentioned in systemd#31419 (comment).
chunyi-wu pushed a commit to chunyi-wu/systemd that referenced this pull request Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
homed homed, homectl, pam_homed journal util-lib
5 participants