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
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1220282455.3866.35.camel@localhost.localdomain>
Date:	Mon, 01 Sep 2008 17:20:55 +0200
From:	Denys Vlasenko <dvlasenk@...hat.com>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ulrich Drepper <drepper@...hat.com>
Subject: Re: [PATCH] make setpriority POSIX compliant; introduce
	PRIO_THREAD extension

On Mon, 2008-09-01 at 17:08 +0200, Peter Zijlstra wrote:
> On Mon, 2008-09-01 at 16:42 +0200, Denys Vlasenko wrote:
> > 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.
> > 
> > Looks like Evolution word-wrapped the patch. Let me try again.
> 
> Patch looks simple enough, although a few comments below.
> Also, I guess the glibc people (Ulrich added to CC) might have an
> opinion.
> 
> > Signed-off-by: Denys Vlasenko <dvlasenk@...hat.com>
> > --
> > vda
> > 
> > 
> > diff --git a/include/linux/resource.h b/include/linux/resource.h
> > index aaa423a..f292690 100644
> > --- a/include/linux/resource.h
> > +++ b/include/linux/resource.h
> > @@ -51,6 +51,7 @@ struct rlimit {
> >  #define	PRIO_PROCESS	0
> >  #define	PRIO_PGRP	1
> >  #define	PRIO_USER	2
> > +#define	PRIO_THREAD	3
> >  
> >  /*
> >   * Limit the stack by to some sane default: root can always
> > diff --git a/kernel/sys.c b/kernel/sys.c
> > index 038a7bc..d339c1a 100644
> > --- a/kernel/sys.c
> > +++ b/kernel/sys.c
> > @@ -142,9 +142,9 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
> >  	struct task_struct *g, *p;
> >  	struct user_struct *user;
> >  	int error = -EINVAL;
> > -	struct pid *pgrp;
> > +	struct pid *pgrp, *pid;
> >  
> > -	if (which > PRIO_USER || which < PRIO_PROCESS)
> > +	if (which > PRIO_THREAD || which < PRIO_PROCESS)
> >  		goto out;
> >  
> >  	/* normalize: avoid signed division (rounding problems) */
> > @@ -156,7 +156,7 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
> >  
> >  	read_lock(&tasklist_lock);
> >  	switch (which) {
> > -		case PRIO_PROCESS:
> > +		case PRIO_THREAD:
> >  			if (who)
> >  				p = find_task_by_vpid(who);
> >  			else
> > @@ -164,6 +164,19 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
> >  			if (p)
> >  				error = set_one_prio(p, niceval, error);
> >  			break;
> > +		case PRIO_PROCESS:
> > +			if (who)
> > +				pid = find_vpid(who);
> > +			else {
> > +				pid = task_pid(current);
> > +				who = current->pid;
> > +			}
> > +			do_each_pid_thread(pid, PIDTYPE_PID, p) {
> > +				if (who == p->pid || who == p->tgid) {
> > +					error = set_one_prio(p, niceval, error);
> > +				}
> > +			} while_each_pid_thread(pid, PIDTYPE_PID, p);
> 
> I worry about destroying the return value here, support one thread
> fails, but the next succeeds, should we still report failure?

Hmm. I think we should fail only if they all failed.
I don't feel strongly either way. Ulrich what do you prefer?

> > +		case PRIO_PROCESS:
> > +			if (who)
> > +				pid = find_vpid(who);
> > +			else {
> > +				pid = task_pid(current);
> > +				who = current->pid;
> > +			}
> > +			do_each_pid_thread(pid, PIDTYPE_PID, p) {
> > +				if (who == p->pid || who == p->tgid) {
> > +					niceval = 20 - task_nice(p);
> > +					if (niceval > retval)
> > +						retval = niceval;
> > +				}
> > +			} while_each_pid_thread(pid, PIDTYPE_PID, p);
> 
> So we basically return the highest prio amongst the threads?

Yes. This is analogous to what happens with PRIO_USER etc,
no surprises here.
--
vda


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ