public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] getrusage sucks
@ 2005-11-10 22:34 Claudio Scordino
  2005-11-11  5:06 ` David Wagner
  2005-11-12 17:45 ` How to quickly detect the mode change of a hard disk? Hui Cheng
  0 siblings, 2 replies; 10+ messages in thread
From: Claudio Scordino @ 2005-11-10 22:34 UTC (permalink / raw)
  To: linux-kernel, kernelnewbies

Does exist any _real_ reason why getrusage can't be invoked by a task to know 
statistics of another task ?

The changes would be very trivial, as shown by the following patch.

              Claudio


diff --git a/kernel/sys.c b/kernel/sys.c
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1746,9 +1746,13 @@ int getrusage(struct task_struct *p, int

 asmlinkage long sys_getrusage(int who, struct rusage __user *ru)
 {
-  if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
-     return -EINVAL;
-  return getrusage(current, who, ru);
+  if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN) {
+      struct task_struct* tsk = find_task_by_pid(who);
+      if (tsk == NULL)
+        return -EINVAL;
+     return getrusage(tsk, RUSAGE_SELF, ru);
+   } else
+     return getrusage(current, who, ru);
 }

 asmlinkage long sys_umask(int mask)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] getrusage sucks
  2005-11-10 22:34 [PATCH] getrusage sucks Claudio Scordino
@ 2005-11-11  5:06 ` David Wagner
  2005-11-11 19:09   ` Lee Revell
  2005-11-12 17:45 ` How to quickly detect the mode change of a hard disk? Hui Cheng
  1 sibling, 1 reply; 10+ messages in thread
From: David Wagner @ 2005-11-11  5:06 UTC (permalink / raw)
  To: linux-kernel

Claudio Scordino  wrote:
>Does exist any _real_ reason why getrusage can't be invoked by a task to know 
>statistics of another task ?

Probably only super-user should be permitted to read the usage information
about other processes.  Allowing anyone to read anyone else's rusage would
open up a bunch of side channels that sound pretty dangerous.  For instance,
user #1 might be able to mount a timing attack against crypto code being
executed by user #2, and that doesn't sound good.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] getrusage sucks
  2005-11-11  5:06 ` David Wagner
@ 2005-11-11 19:09   ` Lee Revell
  2005-11-11 19:13     ` David Wagner
  0 siblings, 1 reply; 10+ messages in thread
From: Lee Revell @ 2005-11-11 19:09 UTC (permalink / raw)
  To: David Wagner; +Cc: linux-kernel

On Fri, 2005-11-11 at 05:06 +0000, David Wagner wrote:
> Claudio Scordino  wrote:
> >Does exist any _real_ reason why getrusage can't be invoked by a task to know 
> >statistics of another task ?
> 
> Probably only super-user should be permitted to read the usage information
> about other processes.  Allowing anyone to read anyone else's rusage would
> open up a bunch of side channels that sound pretty dangerous.  For instance,
> user #1 might be able to mount a timing attack against crypto code being
> executed by user #2, and that doesn't sound good.

Why restrict it to root?  Why not just prevent users from reading other
users rusage.  How could it be a security hole for joeuser's process be
able to read the rusage of joeuser's other processes?

Lee


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] getrusage sucks
  2005-11-11 19:09   ` Lee Revell
@ 2005-11-11 19:13     ` David Wagner
  0 siblings, 0 replies; 10+ messages in thread
From: David Wagner @ 2005-11-11 19:13 UTC (permalink / raw)
  To: linux-kernel

Lee Revell  wrote:
>On Fri, 2005-11-11 at 05:06 +0000, David Wagner wrote:
>> Probably only super-user should be permitted to read the usage information
>> about other processes.
>
>Why restrict it to root?  Why not just prevent users from reading other
>users rusage.  How could it be a security hole for joeuser's process be
>able to read the rusage of joeuser's other processes?

Sorry; you're absolutely right.  I agree.  I overlooked that case.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* How to quickly detect the mode change of a hard disk?
  2005-11-10 22:34 [PATCH] getrusage sucks Claudio Scordino
  2005-11-11  5:06 ` David Wagner
@ 2005-11-12 17:45 ` Hui Cheng
  2005-11-13 15:10   ` Pavel Machek
  1 sibling, 1 reply; 10+ messages in thread
From: Hui Cheng @ 2005-11-12 17:45 UTC (permalink / raw)
  To: kernelnewbies; +Cc: linux-kernel

Hi,

I am currently doing a kernel module involves detecting/changing
disk mode among STANDBY and ACTIVE/IDLE. I used ide_cmd_wait() to issue
commands like WIN_IDLEIMMEDIATELY and WIN_STANDBYNOW1. The problem is, a
drive in standby mode will automatically awake whenever a disk operation
is requested and I need to know the mode change as soon as possible. (So I
donot want to periodically use the WIN_CHECKPOWERMODE to detect it). I was
wondering if the standby disk is waken by the kernel or by the disk
firmware? If it is not in the kernel, is there any good way to detect it?
Thanks,

Hui



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to quickly detect the mode change of a hard disk?
  2005-11-12 17:45 ` How to quickly detect the mode change of a hard disk? Hui Cheng
@ 2005-11-13 15:10   ` Pavel Machek
  2005-11-16 18:58     ` Alejandro Bonilla
  0 siblings, 1 reply; 10+ messages in thread
From: Pavel Machek @ 2005-11-13 15:10 UTC (permalink / raw)
  To: Hui Cheng; +Cc: kernelnewbies, linux-kernel

> I am currently doing a kernel module involves detecting/changing
> disk mode among STANDBY and ACTIVE/IDLE. I used ide_cmd_wait() to issue
> commands like WIN_IDLEIMMEDIATELY and WIN_STANDBYNOW1. The problem is, a
> drive in standby mode will automatically awake whenever a disk operation
> is requested and I need to know the mode change as soon as possible. (So I

AFAIK there's no nice way to get that info, but it is useful, so patch would
be welcome.
-- 
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to quickly detect the mode change of a hard disk?
  2005-11-13 15:10   ` Pavel Machek
@ 2005-11-16 18:58     ` Alejandro Bonilla
  2005-11-18 19:41       ` Hui Cheng
  0 siblings, 1 reply; 10+ messages in thread
From: Alejandro Bonilla @ 2005-11-16 18:58 UTC (permalink / raw)
  To: Pavel Machek, Hui Cheng; +Cc: kernelnewbies, linux-kernel

On Sun, 13 Nov 2005 15:10:56 +0000, Pavel Machek wrote
> > I am currently doing a kernel module involves detecting/changing
> > disk mode among STANDBY and ACTIVE/IDLE. I used ide_cmd_wait() to issue
> > commands like WIN_IDLEIMMEDIATELY and WIN_STANDBYNOW1. The problem is, a
> > drive in standby mode will automatically awake whenever a disk operation
> > is requested and I need to know the mode change as soon as possible. (So I
> 
> AFAIK there's no nice way to get that info, but it is useful, so 
> patch would be welcome.

I would check the hdparm man page again. Still, it sounds interesting.

Additionally, it could be cool if someone could finish up or make the option
for the HD freeze to use it with the HDAPS driver. ;-)

.Alejandro

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to quickly detect the mode change of a hard disk?
  2005-11-16 18:58     ` Alejandro Bonilla
@ 2005-11-18 19:41       ` Hui Cheng
  2005-11-19 23:44         ` Pavel Machek
  0 siblings, 1 reply; 10+ messages in thread
From: Hui Cheng @ 2005-11-18 19:41 UTC (permalink / raw)
  To: Alejandro Bonilla; +Cc: Pavel Machek, kernelnewbies, linux-kernel



On Wed, 16 Nov 2005, Alejandro Bonilla wrote:

> On Sun, 13 Nov 2005 15:10:56 +0000, Pavel Machek wrote
> > > I am currently doing a kernel module involves detecting/changing
> > > disk mode among STANDBY and ACTIVE/IDLE. I used ide_cmd_wait() to issue
> > > commands like WIN_IDLEIMMEDIATELY and WIN_STANDBYNOW1. The problem is, a
> > > drive in standby mode will automatically awake whenever a disk operation
> > > is requested and I need to know the mode change as soon as possible. (So I
> >
> > AFAIK there's no nice way to get that info, but it is useful, so
> > patch would be welcome.
>
> I would check the hdparm man page again. Still, it sounds interesting.
>
> Additionally, it could be cool if someone could finish up or make the option
> for the HD freeze to use it with the HDAPS driver. ;-)
>
> .Alejandro
>

Thanks for reply :) What I did to handle this problem is a little stupid
: Suppose the disk is now in a standby mode. In case that there is a
request sent to the disk drive, a kernel thread is awake to detect/update
the current disk power mode. The disk power mode is stored in the
ide_drive_t structure and be protected by lock. It seems to work fine in
my simple tests. But again, there should be better solutions.

Hui


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to quickly detect the mode change of a hard disk?
  2005-11-18 19:41       ` Hui Cheng
@ 2005-11-19 23:44         ` Pavel Machek
  2005-11-22 15:39           ` Hui Cheng
  0 siblings, 1 reply; 10+ messages in thread
From: Pavel Machek @ 2005-11-19 23:44 UTC (permalink / raw)
  To: Hui Cheng; +Cc: Alejandro Bonilla, Pavel Machek, kernelnewbies, linux-kernel

Hi!

> > > > I am currently doing a kernel module involves detecting/changing
> > > > disk mode among STANDBY and ACTIVE/IDLE. I used ide_cmd_wait() to issue
> > > > commands like WIN_IDLEIMMEDIATELY and WIN_STANDBYNOW1. The problem is, a
> > > > drive in standby mode will automatically awake whenever a disk operation
> > > > is requested and I need to know the mode change as soon as possible. (So I
> > >
> > > AFAIK there's no nice way to get that info, but it is useful, so
> > > patch would be welcome.
> >
> > I would check the hdparm man page again. Still, it sounds interesting.
> >
> > Additionally, it could be cool if someone could finish up or make the option
> > for the HD freeze to use it with the HDAPS driver. ;-)
> >
> > .Alejandro
> >
> 
> Thanks for reply :) What I did to handle this problem is a little stupid
> : Suppose the disk is now in a standby mode. In case that there is a
> request sent to the disk drive, a kernel thread is awake to detect/update
> the current disk power mode. The disk power mode is stored in the
> ide_drive_t structure and be protected by lock. It seems to work fine in
> my simple tests. But again, there should be better solutions.

Can we get the patch?
-- 
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to quickly detect the mode change of a hard disk?
  2005-11-19 23:44         ` Pavel Machek
@ 2005-11-22 15:39           ` Hui Cheng
  0 siblings, 0 replies; 10+ messages in thread
From: Hui Cheng @ 2005-11-22 15:39 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Alejandro Bonilla, kernelnewbies, linux-kernel



On Sat, 19 Nov 2005, Pavel Machek wrote:
Hi,

> Hi!
>
> > > > > I am currently doing a kernel module involves detecting/changing
> > > > > disk mode among STANDBY and ACTIVE/IDLE. I used ide_cmd_wait() to issue
> > > > > commands like WIN_IDLEIMMEDIATELY and WIN_STANDBYNOW1. The problem is, a
> > > > > drive in standby mode will automatically awake whenever a disk operation
> > > > > is requested and I need to know the mode change as soon as possible. (So I
> > > >
> > > > AFAIK there's no nice way to get that info, but it is useful, so
> > > > patch would be welcome.
> > >
> > > I would check the hdparm man page again. Still, it sounds interesting.
> > >
> > > Additionally, it could be cool if someone could finish up or make the option
> > > for the HD freeze to use it with the HDAPS driver. ;-)
> > >
> > > .Alejandro
> > >
> >
> > Thanks for reply :) What I did to handle this problem is a little stupid
> > : Suppose the disk is now in a standby mode. In case that there is a
> > request sent to the disk drive, a kernel thread is awake to detect/update
> > the current disk power mode. The disk power mode is stored in the
> > ide_drive_t structure and be protected by lock. It seems to work fine in
> > my simple tests. But again, there should be better solutions.
>
> Can we get the patch?
> --

Sure. I will make the patch and test it again. But it may take a while
because I have an urgent task now...Thanks,

Hui


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-11-22 15:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-10 22:34 [PATCH] getrusage sucks Claudio Scordino
2005-11-11  5:06 ` David Wagner
2005-11-11 19:09   ` Lee Revell
2005-11-11 19:13     ` David Wagner
2005-11-12 17:45 ` How to quickly detect the mode change of a hard disk? Hui Cheng
2005-11-13 15:10   ` Pavel Machek
2005-11-16 18:58     ` Alejandro Bonilla
2005-11-18 19:41       ` Hui Cheng
2005-11-19 23:44         ` Pavel Machek
2005-11-22 15:39           ` Hui Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox