linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dm: ioctl: prevent double freeing
@ 2015-09-04 11:22 Sudip Mukherjee
  2015-09-15  7:53 ` Sudip Mukherjee
  2015-09-15 16:18 ` [dm-devel] " Darrick J. Wong
  0 siblings, 2 replies; 4+ messages in thread
From: Sudip Mukherjee @ 2015-09-04 11:22 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, dm-devel, Neil Brown
  Cc: linux-kernel, linux-raid, Sudip Mukherjee

DM_PARAMS_KMALLOC and DM_PARAMS_VMALLOC should never be set together in
param_flags. We are setting these flags while allocating so we know that
there is almost no chance of having these two set together but still we
can have some additional safety.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/md/dm-ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 80a4395..aaad74e 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1680,7 +1680,7 @@ static void free_params(struct dm_ioctl *param, size_t param_size, int param_fla
 
 	if (param_flags & DM_PARAMS_KMALLOC)
 		kfree(param);
-	if (param_flags & DM_PARAMS_VMALLOC)
+	else if (param_flags & DM_PARAMS_VMALLOC)
 		vfree(param);
 }
 
-- 
1.9.1


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

* Re: [PATCH] dm: ioctl: prevent double freeing
  2015-09-04 11:22 [PATCH] dm: ioctl: prevent double freeing Sudip Mukherjee
@ 2015-09-15  7:53 ` Sudip Mukherjee
  2015-09-15 16:18 ` [dm-devel] " Darrick J. Wong
  1 sibling, 0 replies; 4+ messages in thread
From: Sudip Mukherjee @ 2015-09-15  7:53 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, dm-devel, Neil Brown
  Cc: linux-kernel, linux-raid

On Fri, Sep 04, 2015 at 04:52:39PM +0530, Sudip Mukherjee wrote:
> DM_PARAMS_KMALLOC and DM_PARAMS_VMALLOC should never be set together in
> param_flags. We are setting these flags while allocating so we know that
> there is almost no chance of having these two set together but still we
> can have some additional safety.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
A gentle ping.

regards
sudip

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

* Re: [dm-devel] [PATCH] dm: ioctl: prevent double freeing
  2015-09-04 11:22 [PATCH] dm: ioctl: prevent double freeing Sudip Mukherjee
  2015-09-15  7:53 ` Sudip Mukherjee
@ 2015-09-15 16:18 ` Darrick J. Wong
  2015-09-15 18:13   ` Mike Snitzer
  1 sibling, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2015-09-15 16:18 UTC (permalink / raw)
  To: device-mapper development
  Cc: Alasdair Kergon, Mike Snitzer, Neil Brown, linux-raid,
	linux-kernel, Sudip Mukherjee

On Fri, Sep 04, 2015 at 04:52:39PM +0530, Sudip Mukherjee wrote:
> DM_PARAMS_KMALLOC and DM_PARAMS_VMALLOC should never be set together in
> param_flags. We are setting these flags while allocating so we know that
> there is almost no chance of having these two set together but still we
> can have some additional safety.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>  drivers/md/dm-ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
> index 80a4395..aaad74e 100644
> --- a/drivers/md/dm-ioctl.c
> +++ b/drivers/md/dm-ioctl.c
> @@ -1680,7 +1680,7 @@ static void free_params(struct dm_ioctl *param, size_t param_size, int param_fla
>  
>  	if (param_flags & DM_PARAMS_KMALLOC)
>  		kfree(param);
> -	if (param_flags & DM_PARAMS_VMALLOC)
> +	else if (param_flags & DM_PARAMS_VMALLOC)

Wouldn't you also want a WARN_ON to complain about both flags being set?

--D

>  		vfree(param);
>  }
>  
> -- 
> 1.9.1
> 
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel

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

* Re: dm: ioctl: prevent double freeing
  2015-09-15 16:18 ` [dm-devel] " Darrick J. Wong
@ 2015-09-15 18:13   ` Mike Snitzer
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Snitzer @ 2015-09-15 18:13 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: device-mapper development, linux-kernel, Neil Brown, linux-raid,
	Sudip Mukherjee, Alasdair Kergon

On Tue, Sep 15 2015 at 12:18pm -0400,
Darrick J. Wong <darrick.wong@oracle.com> wrote:

> On Fri, Sep 04, 2015 at 04:52:39PM +0530, Sudip Mukherjee wrote:
> > DM_PARAMS_KMALLOC and DM_PARAMS_VMALLOC should never be set together in
> > param_flags. We are setting these flags while allocating so we know that
> > there is almost no chance of having these two set together but still we
> > can have some additional safety.
> > 
> > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> > ---
> >  drivers/md/dm-ioctl.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
> > index 80a4395..aaad74e 100644
> > --- a/drivers/md/dm-ioctl.c
> > +++ b/drivers/md/dm-ioctl.c
> > @@ -1680,7 +1680,7 @@ static void free_params(struct dm_ioctl *param, size_t param_size, int param_fla
> >  
> >  	if (param_flags & DM_PARAMS_KMALLOC)
> >  		kfree(param);
> > -	if (param_flags & DM_PARAMS_VMALLOC)
> > +	else if (param_flags & DM_PARAMS_VMALLOC)
> 
> Wouldn't you also want a WARN_ON to complain about both flags being set?

No, this is getting rediculous now.  Please stop the insanity.

DM_PARAMS_KMALLOC and DM_PARAMS_VMALLOC are mutually exclussive --
always will be.  Sprinkling defensive code around isn't high on my list
of changes I'm interested in.

At some point I'll stage the original change from Sudip for 4.4 but I'm
re-writing the subject and header to not be so alarmist (this is more to
do with eliminating a conditional than anything else).  There is _zero_
potential for a double-free with the current code.

Mike

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

end of thread, other threads:[~2015-09-15 18:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-04 11:22 [PATCH] dm: ioctl: prevent double freeing Sudip Mukherjee
2015-09-15  7:53 ` Sudip Mukherjee
2015-09-15 16:18 ` [dm-devel] " Darrick J. Wong
2015-09-15 18:13   ` Mike Snitzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).