mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Drokin, Oleg" <oleg.drokin@intel.com>
To: Julia Lawall <julia.lawall@lip6.fr>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Dhere, Chaitanya (C.)" <cvijaydh@visteon.com>,
	"Dilger, Andreas" <andreas.dilger@intel.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	"Xiong, Jinshan" <jinshan.xiong@intel.com>,
	"aybuke.147@gmail.com" <aybuke.147@gmail.com>,
	"Hammond, John" <john.hammond@intel.com>,
	"HPDD-discuss@lists.01.org" <HPDD-discuss@ml01.01.org>,
	"<devel@driverdev.osuosl.org>" <devel@driverdev.osuosl.org>,
	"<linux-kernel@vger.kernel.org> Mailing List" 
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging: lustre: replace kzalloc with copy_from_user with memdup_user
Date: Tue, 31 Mar 2015 22:45:10 +0000	[thread overview]
Message-ID: <A7B00F94-83B4-4B13-941F-90591B4BC218@intel.com> (raw)
In-Reply-To: <20150331155756.GA12842@kroah.com>


On Mar 31, 2015, at 11:57 AM, gregkh@linuxfoundation.org wrote:

> On Tue, Mar 31, 2015 at 05:15:23PM +0200, Julia Lawall wrote:
>> On Tue, 31 Mar 2015, Dhere, Chaitanya (C.) wrote:
>> 
>>> This patch replaces kzalloc and copy_from_user with memdup_user call
>>> This change was detected with coccinelle tool
>>> 
>>> Signed-off-by: Chaitanya Dhere <cvijaydh@visteon.com>
>>> ---
>>> drivers/staging/lustre/lustre/llite/file.c |   11 +++--------
>>> 1 file changed, 3 insertions(+), 8 deletions(-)
>>> 
>>> diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
>>> index 85e74d1..85b5567 100644
>>> --- a/drivers/staging/lustre/lustre/llite/file.c
>>> +++ b/drivers/staging/lustre/lustre/llite/file.c
>>> @@ -2368,14 +2368,9 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>>> 		struct hsm_state_set	*hss;
>>> 		int			 rc;
>>> 
>>> -		hss = kzalloc(sizeof(*hss), GFP_NOFS);
>>> -		if (!hss)
>>> -			return -ENOMEM;
>>> -
>>> -		if (copy_from_user(hss, (char *)arg, sizeof(*hss))) {
>>> -			OBD_FREE_PTR(hss);
>>> -			return -EFAULT;
>>> -		}
>>> +		hss = memdup_user((char *)arg, sizeof(*hss));
>> 
>> memdup_user will use the flag GFP_KERNEL, ie (__GFP_WAIT | __GFP_IO |
>> __GFP_FS), rather than the flag GFP_NOFS, ie (__GFP_WAIT | __GFP_IO), that
>> is specified.  I don't know if this is a problem here.
> 
> Yes, this is a filesystem, so this can't be changed, as we can't have
> the allocation go out and ask for more filesystem accesses in the middle
> of trying to do a filesystem access :)

Technically in this place we are not really holding any locks or anything else of value to cause a deadlock,
so we might be fine here.
More importantly, I totally missed this OBD_ALLOC replacement with kzalloc when it happened.
In theory all OBD_ALLOC() calls add up all allocated memory in a counter and then OBD_FREE() calls
subtract freed memory (for a poor man's memory leak detection and tracing).
Now since it's out of match, there should have been tons of very loud warnings about it, but I don't see
any in my logs and I wonder why.

Julia, I wonder if you happen to have a bunch of other patches to get rid of the rest of OBD_ALLOC and OBD_FREE stuff by any chance?

Bye,
    Oleg

  reply	other threads:[~2015-03-31 22:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-31 15:10 Dhere, Chaitanya (C.)
2015-03-31 15:15 ` Julia Lawall
2015-03-31 15:57   ` gregkh
2015-03-31 22:45     ` Drokin, Oleg [this message]
2015-04-02 10:18       ` Julia Lawall
2015-04-03 18:56         ` Drokin, Oleg
2015-04-03 19:51           ` Julia Lawall

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=A7B00F94-83B4-4B13-941F-90591B4BC218@intel.com \
    --to=oleg.drokin@intel.com \
    --cc=HPDD-discuss@ml01.01.org \
    --cc=andreas.dilger@intel.com \
    --cc=aybuke.147@gmail.com \
    --cc=cvijaydh@visteon.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jinshan.xiong@intel.com \
    --cc=john.hammond@intel.com \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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®