mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Lyashkov <shadow@psoft.net>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: possible kernel bug in signal transit.
Date: Sun, 14 Mar 2004 06:39:19 +0200	[thread overview]
Message-ID: <1079239159.8186.24.camel@berloga.shadowland> (raw)
In-Reply-To: <20040313171856.37b32e52.akpm@osdl.org>

В Вск, 14.03.2004, в 03:18, Andrew Morton пишет:
> Alex Lyashkov <shadow@psoft.net> wrote:
> >
> > Hello All
> > 
> > I analyze kernel vanila 2.6.4 and found one possible bug in
> > __kill_pg_info function.
> > 
> >         for_each_task_pid(pgrp, PIDTYPE_PGID, p, l, pid) {
> >                 err = group_send_sig_info(sig, info, p);
> >                 if (retval)
> >                         retval = err;
> >         }
> > but I think if (retval) is incorrect check. possible this cycle must be
> >         for_each_task_pid(pgrp, PIDTYPE_PGID, p, l, pid) {
> >                 err = group_send_sig_info(sig, info, p);
> >                 if (ret) {
> >                         retval = err;
> > 			break;
> > 		}
> >         }
> > because in original variant me assign to retval only first value from
> > ret and other be ignored if this value be 0.
> > 
> 
> No, the code's OK, albeit undesirably obscure.  It will return -ESRCH if
> none of the tasks had a matching pgrp and will return the result of the
> final non-zero-returning group_send_sig_info() if one or more of the
> group_send_sig_info() calls failed, and will return zero if all of the
> group_send_sig_info() calls returned zero.
> 
> Thanks for checking though..
No. it can`t return final non-zero-returning group_send_sig_info() if
first call group_send_sig_info return 0.
Example me have 3 groups it will return
1 - zero
2 - nonzero (example -1)
3 - nonzero (example -2)
original code will return zero.
but you say it will return last non zero - "-2" in example.
(do only first assignment after it retval is zero and no assignments
does.)
For her logic me can write.
=====
	int retval = 0;
	int err = -1;
        for_each_task_pid(pgrp, PIDTYPE_PGID, p, l, pid) {
                 err = group_send_sig_info(sig, info, p);
		if( err )
			retval = err;

         }
	return err==-1 ? -ESRCH : retval;
===
If me not enter to this cycle - retval = -ESRCH, and last non zero err
if cycle is worked or zero if all group_send_sig_info() return zero.


-- 
Alex Lyashkov <shadow@psoft.net>
PSoft

  reply	other threads:[~2004-03-14  4:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-13 17:02 Alex Lyashkov
2004-03-14  1:18 ` Andrew Morton
2004-03-14  4:39   ` Alex Lyashkov [this message]
2004-03-14  5:00     ` Andrew Morton
2004-03-14  5:21       ` Alex Lyashkov
2004-03-14  5:47         ` Andrew Morton
2004-03-14  5:56           ` Alex Lyashkov
2004-03-14  6:09             ` Andrew Morton
2004-03-14  6:26               ` Alex Lyashkov
2004-03-14  6:37                 ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1079239159.8186.24.camel@berloga.shadowland \
    --to=shadow@psoft.net \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®