getsolus / getsolus/packages

attr: mv segfaults if moving files from selinux install to non-selinux install

Open
#1,127 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Priority: Low
Dominant language
Python
Stars
141
Forks
146
Avg merge
11h 7m
Merged PRs (30d)
407

Description

Summary

Files created on a selinux-enabled system have the security.selinux xattr and mv will segfault if you try to move those files when booted into a non-selinux kernel. It appears that the attr stateless patch is at fault as it prints an error message instead if attr is recompiled without that patch. Likely the stateless patch just needs to be adjusted

Steps to reproduce
  1. Create a filesystem on a selinux-enabled distro (like Fedora).
  2. Mount that FS on Solus
  3. Try to mv a file to the Solus root fs.
Expected result

Error message like so:

mv: setting attribute 'security.selinux' for 'security.selinux': Operation not permitted
Actual result

Segfault:

#0  __GI__IO_fread (buf=buf@entry=0x5586fb6b5ec0, size=size@entry=1, count=count@entry=4096, fp=fp@entry=0x0) at iofread.c:37
#1  0x00007f0d4ef9e1dd in attr_parse_attr_conf (ctx=<optimized out>) at libattr/attr_copy_action.c:81
#2  attr_copy_action (name=0x7fff1ab453d0 "security.selinux", ctx=0x7fff1ab45480) at libattr/attr_copy_action.c:163
#3  0x00007f0d4ef9e51a in attr_copy_check_permissions (name=<optimized out>, ctx=<optimized out>) at libattr/attr_copy_check.c:29
#4  0x00007f0d4ef9e5f3 in attr_copy_fd (src_path=0x7fff1ab46ffa ".kube/config", src_fd=src_fd@entry=4, dst_path=dst_path@entry=0x5586fb6b5cb0 "/home/reilly/.kube/config", dst_fd=dst_fd@entry=5, 
    check=0x7f0d4ef9e510 <attr_copy_check_permissions>, ctx=0x7fff1ab45480) at libattr/attr_copy_fd.c:108
#5  0x00005586fad8e453 in copy_attr (src_path=src_path@entry=0x7fff1ab46ffa ".kube/config", src_fd=src_fd@entry=4, dst_path=dst_path@entry=0x5586fb6b5cb0 "/home/reilly/.kube/config", 
    dst_fd=dst_fd@entry=5, x=x@entry=0x7fff1ab45d50) at src/copy.c:792
#6  0x00005586fad90e8b in copy_reg (src_name=src_name@entry=0x7fff1ab46ffa ".kube/config", dst_name=dst_name@entry=0x5586fb6b5cb0 "/home/reilly/.kube/config", dst_dirfd=dst_dirfd@entry=3, 
    dst_relname=dst_relname@entry=0x5586fb6b5cc3 "config", x=x@entry=0x7fff1ab45d50, dst_mode=dst_mode@entry=384, omitted_permissions=0, new_dst=0x7fff1ab4580f, src_sb=0x7fff1ab45990)
    at src/copy.c:1662
#7  0x00005586fad937d9 in copy_internal (src_name=src_name@entry=0x7fff1ab46ffa ".kube/config", dst_name=0x5586fb6b5cb0 "/home/reilly/.kube/config", dst_name@entry=0x7fff1ab45bf0 "", dst_dirfd=3, 
    dst_dirfd@entry=1323190176, dst_relname=<optimized out>, nonexistent_dst=<optimized out>, nonexistent_dst@entry=0, parent=parent@entry=0x0, ancestors=0x0, x=0x7fff1ab45d50, 
    command_line_arg=true, first_dir_created_per_command_line_arg=<optimized out>, copy_into_self=<optimized out>, rename_succeeded=<optimized out>) at src/copy.c:3106
#8  0x00005586fad979ce in copy (nonexistent_dst=0, rename_succeeded=0x7fff1ab45bea, copy_into_self=0x7fff1ab45beb, options=0x7fff1ab45d50, nonexistent_dst=0, dst_relname=0x5586fb6b5cc3 "config", 
    dst_dirfd=1323190176, dst_name=0x7fff1ab45bf0 "", src_name=0x7fff1ab46ffa ".kube/config") at src/copy.c:3421
#9  do_move (source=source@entry=0x7fff1ab46ffa ".kube/config", dest=dest@entry=0x5586fb6b5cb0 "/home/reilly/.kube/config", dest_dirfd=dest_dirfd@entry=3, 
    dest_relname=dest_relname@entry=0x5586fb6b5cc3 "config", x=x@entry=0x7fff1ab45d50) at src/mv.c:172
#10 0x00005586fad8a91e in main (argc=<optimized out>, argv=<optimized out>) at src/mv.c:545
Environment
  • Is system up to date?
Repo

Shannon (stable)

Desktop Environment

Plasma

System details

N/A

Other comments

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with libattr/attr_copy_action.c around attr_parse_attr_conf and the stack trace, then trace the callers through src/copy.c and src/mv.c. Reproduce the cross-filesystem move with a security.selinux xattr on a non-SELinux kernel. Done means mv reports the expected Operation not permitted error instead of segfaulting.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
operating-systems, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.