All of lore.kernel.org
 help / color / mirror / Atom feed
From: Solar Designer <solar@openwall.com>
To: Julio Auto <mindvortex@gmail.com>
Cc: Willy Tarreau <w@1wt.eu>, linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: Re: [PATCH] loop.c: kernel_thread() retval check - 2.6.17.9
Date: Mon, 28 Aug 2006 07:55:56 +0400	[thread overview]
Message-ID: <20060828035556.GA27902@openwall.com> (raw)
In-Reply-To: <18d709710608232341x491b4bf6g87f74ef830a203@mail.gmail.com>

On Thu, Aug 24, 2006 at 03:41:00AM -0300, Julio Auto wrote:
> this is my porting (to 2.6.x) of the loop.c issue reported and patched
> by Solar Designer, to whom all credits of the original idea to the
> patch go (more info in the original "[PATCH] loop.c: kernel_thread()
> retval check" e-mail thread).

The patch looks good to me, although I did not test it.

> Honestly, I couldn't test it on other computers, but mine. But the
> tests were made against a stock (unmodified) 2.6.17.9 kernel and the
> patch works like it should. Nevertheless, a second thought/review is
> always appreciated.

I think that testing this on a single machine is fine, but it is
preferable that you also check for any resource leaks.  That is, replace
the kernel_thread() call with -EAGAIN, then run losetup in a loop and
see whether the system possibly leaks a resource.  I did apply this sort
of testing to my original 2.4 patch.

> Signed-off-by: Julio Auto <mindvortex@gmail.com>

Acked-by: Solar Designer <solar@openwall.com>

> --- drivers/block/loop.c.orig	2006-08-23 11:44:51.000000000 -0700
> +++ drivers/block/loop.c	2006-08-24 00:33:54.000000000 -0700
> @@ -841,10 +841,20 @@ static int loop_set_fd(struct loop_devic
> 
> 	error = kernel_thread(loop_thread, lo, CLONE_KERNEL);
> 	if (error < 0)
> -		goto out_putf;
> +		goto out_clr;
> 	wait_for_completion(&lo->lo_done);
> 	return 0;
> 
> + out_clr:
> +	lo->lo_device = NULL;
> +	lo->lo_flags = 0;
> +	lo->lo_backing_file = NULL;
> +	set_capacity(disks[lo->lo_number], 0);
> +	invalidate_bdev(bdev, 0);
> +	bd_set_size(bdev, 0);
> +	mapping_set_gfp_mask(mapping, lo->old_gfp_mask);
> +	lo->lo_state = Lo_unbound;
> +
>  out_putf:
> 	fput(file);
>  out:

Thanks,

Alexander

  reply	other threads:[~2006-08-28  3:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-24  6:41 [PATCH] loop.c: kernel_thread() retval check - 2.6.17.9 Julio Auto
2006-08-28  3:55 ` Solar Designer [this message]
2006-08-28  4:41   ` Andrew Morton
2006-08-28  5:03     ` Julio Auto
2006-08-28 12:50       ` Serge E. Hallyn
2006-08-28  4:52   ` Julio Auto

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=20060828035556.GA27902@openwall.com \
    --to=solar@openwall.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mindvortex@gmail.com \
    --cc=w@1wt.eu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.