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

linprocfs: Add support for proc/sysvipc/{msg,sem,shm} v2 #1232

Merged
merged 6 commits into from
May 22, 2024

Conversation

ricardobranco777
Copy link
Contributor

Add support for proc/sysvipc/{msg,sem,shm}

Tracking in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278812

Retry of #1218

sys/compat/linprocfs/linprocfs.c Outdated Show resolved Hide resolved
sys/compat/linprocfs/linprocfs.c Outdated Show resolved Hide resolved
sys/compat/linprocfs/linprocfs.c Outdated Show resolved Hide resolved
sys/compat/linprocfs/linprocfs.c Outdated Show resolved Hide resolved
sys/compat/linprocfs/linprocfs.c Outdated Show resolved Hide resolved
sys/compat/linprocfs/linprocfs.c Outdated Show resolved Hide resolved
@bsdimp
Copy link
Member

bsdimp commented May 16, 2024

This is dependent on kib's changes to export this data.

@ricardobranco777
Copy link
Contributor Author

Copy link
Member

@kostikbel kostikbel left a comment

Choose a reason for hiding this comment

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

So you did not updated the PR to use the new functions. I want to commit my change after it is verified somehow.

sys/compat/linprocfs/linprocfs.c Outdated Show resolved Hide resolved
@ricardobranco777
Copy link
Contributor Author

ricardobranco777 commented May 16, 2024

So you did not updated the PR to use the new functions. I want to commit my change after it is verified somehow.

Wouldn't it be easier to test by also patching the sysctl function called by ipcs?

Will test your changes and report back.

@kostikbel
Copy link
Member

So you did not updated the PR to use the new functions. I want to commit my change after it is verified somehow.

Wouldn't it be easier to test by also patching the sysctl function called by ipcs?
No, the functions I provided are bad fit for the sysctls. They do not handle COMPAT32, they allocate large chunk of memory which is not needed for sysctl.

Will test your changes and report back.
I will commit my bits after your confirmation.

@ricardobranco777
Copy link
Contributor Author

I will commit my bits after your confirmation.

It works for SHM. I can see the same information in 32 & 64-bits Linux chroot. It works both for /proc/sysvshm/shm & ipcs. But I can't see MSG & SEM, even after I changed security.bsd.see_other_uids, security.bsd.see_other_gids & security.bsd.see_jail_proc to 1.

$ sudo chroot /compat/ubuntu32 ipcs -a

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages    

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0xd7dda8b0 65536      1000       644        4096       0                       

------ Semaphore Arrays --------
key        semid      owner      perms      nsems     

$ sudo chroot /compat/ubuntu32 cat /proc/sysvipc/shm
       key      shmid perms                  size  cpid  lpid nattch   uid   gid  cuid  cgid      atime      dtime      ctime                   rss                  swap
-673339216      65536  4644                  4096 43204     0      0  1000  1000  1000  1000 0 0 1715879396      

$ sudo chroot /compat/ubuntu cat /proc/sysvipc/shm
       key      shmid perms                  size  cpid  lpid nattch   uid   gid  cuid  cgid      atime      dtime      ctime                   rss                  swap
-673339216      65536  4644                  4096 43204     0      0  1000  1000  1000  1000 0 0 1715879396                     0                     0

$ ipcs -a
Message Queues:
T           ID          KEY MODE        OWNER    GROUP    CREATOR  CGROUP                 CBYTES                 QNUM               QBYTES        LSPID        LRPID STIME    RTIME    CTIME   
q        65536    909169119 --rw-r--r-- ricardo  ricardo  ricardo  ricardo             0            0                 2048            0            0 no-entry no-entry 19:09:56

Shared Memory:
T           ID          KEY MODE        OWNER    GROUP    CREATOR  CGROUP         NATTCH        SEGSZ         CPID         LPID ATIME    DTIME    CTIME   
m        65536   -673339216 --rw-r--r-- ricardo  ricardo  ricardo  ricardo             0         4096        43204            0 no-entry no-entry 19:09:56

Semaphores:
T           ID          KEY MODE        OWNER    GROUP    CREATOR  CGROUP          NSEMS OTIME    CTIME   
s        65536  -1803737408 --rw-r--r-- ricardo  ricardo  ricardo  ricardo             1 no-entry 19:09:56

ehem and others added 6 commits May 21, 2024 17:52
…unction

Using a variadic macro allows passing everything properly to printf().
Using the do { } while(0) construct ensures the macro acts like any
other single statement.  This shows just how long some of this has
existed.

Reviewed by: imp,jhb
Pull Request: freebsd#1224
Rather than hard-code the function name, use __func__ instead.  Apply
some style and adjust indentation as appropriate.  Remove the no longer
required braces.

Reviewed by: imp,jhb
Pull Request: freebsd#1224
…b665

Not once has rman_reserve_resource_bound() ever been used.  There are
though several uses of RF_ALIGNMENT.  In light of this remove this
extra and leave the actually used portion in place.

This partially reverts commit 13fb665.

Reviewed by: imp,jhb
Pull Request: freebsd#1224
The flsl() function makes use of hardware functionality to compute the
value faster than this loop.  The only deviation from flsl() is at 0.

Reviewed by: imp,jhb
Pull Request: freebsd#1224
The arguments are left completely unchanged by these functions.  This
allows passing constant pointers for verifying ownership, but not
modifying the contents.

Reviewed by: imp,jhb
Pull Request: freebsd#1224
@freebsd-git freebsd-git merged commit 25a0452 into freebsd:main May 22, 2024
6 of 9 checks passed
@ricardobranco777 ricardobranco777 deleted the linprocfs_sysvipc2 branch May 24, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants