lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Mon, 01 Sep 2008 16:17:58 +0200 From: Denys Vlasenko <dvlasenk@...hat.com> To: linux-kernel@...r.kernel.org Cc: Andrew Morton <akpm@...ux-foundation.org> Subject: Re: [PATCH] make setpriority POSIX compliant; introduce PRIO_THREAD extension On Mon, 2008-09-01 at 16:12 +0200, Denys Vlasenko wrote: > Patch is run tested. I will post test program etc as a reply. Test program is attached. Build with "gcc -o prio_vda3 prio_vda3.c -lpthread". Output: start test program CHILD1: TID:3269 getpriority:0 CHILD1: PID:3269 getpriority:0 setpriority(PRIO_PROCESS, 3269, -10) THREAD CHILD: TID:3270 getpriority:-2 THREAD CHILD: PID:3269 getpriority:-10 THREAD CHILD: TID:3271 getpriority:-4 THREAD CHILD: PID:3269 getpriority:-10 THREAD CHILD: TID:3272 getpriority:-6 THREAD CHILD: PID:3269 getpriority:-10 THREAD CHILD: TID:3273 getpriority:-8 THREAD CHILD: PID:3269 getpriority:-10 CHILD2: TID:3269 getpriority:-10 CHILD2: PID:3269 getpriority:-10 Joined! Joined! Joined! Joined! log of instrumented kernel: (no threads created yet, only one tid exists) getpriority: PRIO_PROCESS: pid 3269 tgid 3269: niceval=20 PRIO_PROCESS: returning retval=20 PRIO_PROCESS: pid 3269 tgid 3269: niceval=20 PRIO_PROCESS: returning retval=20 (5 threads are created) setpriority(PRIO_PROCESS, pid, -10): setting prio of pid 3269 tgid 3269 to -10 setting prio of pid 3270 tgid 3269 to -10 setting prio of pid 3271 tgid 3269 to -10 setting prio of pid 3272 tgid 3269 to -10 setting prio of pid 3273 tgid 3269 to -10 setpriority(3 /*PRIO_THREAD*/, syscall(SYS_gettid), -1); setting prio of pid 3270 tgid 3269 to -1 setpriority(PRIO_PROCESS, syscall(SYS_gettid), -2); setting prio of pid 3270 tgid 3269 to -2 Above you see how setpriority(PRIO_PROCESS) can set prio for all threads or only for one. prio = getpriority(PRIO_PROCESS, tid); PRIO_PROCESS: pid 3270 tgid 3269: niceval=22 PRIO_PROCESS: returning retval=22 prio = getpriority(PRIO_PROCESS, pid); PRIO_PROCESS: pid 3269 tgid 3269: niceval=30 PRIO_PROCESS: pid 3270 tgid 3269: niceval=22 PRIO_PROCESS: pid 3271 tgid 3269: niceval=30 PRIO_PROCESS: pid 3272 tgid 3269: niceval=30 PRIO_PROCESS: pid 3273 tgid 3269: niceval=30 PRIO_PROCESS: returning retval=30 Same for getpriority. The rest is analogous: setting prio of pid 3271 tgid 3269 to -3 setting prio of pid 3271 tgid 3269 to -4 PRIO_PROCESS: pid 3271 tgid 3269: niceval=24 PRIO_PROCESS: returning retval=24 PRIO_PROCESS: pid 3269 tgid 3269: niceval=30 PRIO_PROCESS: pid 3271 tgid 3269: niceval=24 PRIO_PROCESS: pid 3272 tgid 3269: niceval=30 PRIO_PROCESS: pid 3273 tgid 3269: niceval=30 PRIO_PROCESS: returning retval=30 setting prio of pid 3272 tgid 3269 to -5 setting prio of pid 3272 tgid 3269 to -6 PRIO_PROCESS: pid 3272 tgid 3269: niceval=26 PRIO_PROCESS: returning retval=26 PRIO_PROCESS: pid 3269 tgid 3269: niceval=30 PRIO_PROCESS: pid 3272 tgid 3269: niceval=26 PRIO_PROCESS: pid 3273 tgid 3269: niceval=30 PRIO_PROCESS: returning retval=30 setting prio of pid 3273 tgid 3269 to -7 setting prio of pid 3273 tgid 3269 to -8 PRIO_PROCESS: pid 3273 tgid 3269: niceval=28 PRIO_PROCESS: returning retval=28 PRIO_PROCESS: pid 3269 tgid 3269: niceval=30 PRIO_PROCESS: pid 3273 tgid 3269: niceval=28 PRIO_PROCESS: returning retval=30 PRIO_PROCESS: pid 3269 tgid 3269: niceval=30 PRIO_PROCESS: returning retval=30 PRIO_PROCESS: pid 3269 tgid 3269: niceval=30 PRIO_PROCESS: returning retval=30 Patch with instrumentation is attached too. -- vda View attachment "prio_vda3.c" of type "text/x-csrc" (1632 bytes) View attachment "setprio_POSIX_instrumented.diff" of type "text/x-patch" (1673 bytes)
Powered by blists - more mailing lists