2005-11-23 13:09:40

by Oleg Nesterov

[permalink] [raw]
Subject: [PATCH] kill_proc_info_as_uid: don't use hardcoded constants

Use symbolic names instead of hardcoded constants.

Signed-off-by: Oleg Nesterov <[email protected]>

--- 2.6.15-rc2/kernel/signal.c~1_KUID 2005-11-22 19:35:52.000000000 +0300
+++ 2.6.15-rc2/kernel/signal.c 2005-11-23 19:17:35.000000000 +0300
@@ -1163,8 +1163,7 @@ int kill_proc_info_as_uid(int sig, struc
ret = -ESRCH;
goto out_unlock;
}
- if ((!info || ((unsigned long)info != 1 &&
- (unsigned long)info != 2 && SI_FROMUSER(info)))
+ if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
&& (euid != p->suid) && (euid != p->uid)
&& (uid != p->suid) && (uid != p->uid)) {
ret = -EPERM;


2005-11-24 20:48:53

by Harald Welte

[permalink] [raw]
Subject: Re: [PATCH] kill_proc_info_as_uid: don't use hardcoded constants

On Wed, Nov 23, 2005 at 05:24:05PM +0300, Oleg Nesterov wrote:
> Use symbolic names instead of hardcoded constants.

I'm more than happy with that. Seems like the original code in
check_kill_permission() was changed in a similar way after I made that
_as_uid() function.

I don't think that I am a person with any say in the signal.c code,but
in case of doubt:

Acked-by: Harald Welte <[email protected]>

> Signed-off-by: Oleg Nesterov <[email protected]>
>
> --- 2.6.15-rc2/kernel/signal.c~1_KUID 2005-11-22 19:35:52.000000000 +0300
> +++ 2.6.15-rc2/kernel/signal.c 2005-11-23 19:17:35.000000000 +0300
> @@ -1163,8 +1163,7 @@ int kill_proc_info_as_uid(int sig, struc
> ret = -ESRCH;
> goto out_unlock;
> }
> - if ((!info || ((unsigned long)info != 1 &&
> - (unsigned long)info != 2 && SI_FROMUSER(info)))
> + if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
> && (euid != p->suid) && (euid != p->uid)
> && (uid != p->suid) && (uid != p->uid)) {
> ret = -EPERM;

--
- Harald Welte <[email protected]> http://gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)


Attachments:
(No filename) (1.29 kB)
(No filename) (189.00 B)
Download all attachments