From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from terminus.zytor.com ([2001:1868:205::10] helo=mail.zytor.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WwfjS-0006TU-Gi for kexec@lists.infradead.org; Mon, 16 Jun 2014 22:50:31 +0000 Message-ID: <539F7488.9040900@zytor.com> Date: Mon, 16 Jun 2014 15:49:44 -0700 From: "H. Peter Anvin" MIME-Version: 1.0 Subject: Re: [PATCH 07/13] kexec: Implementation of new syscall kexec_file_load References: <20140609053538.GA2874@dhcp-17-89.nay.redhat.com> <20140609154137.GD22049@redhat.com> <20140613075011.GA4751@pd.tnic> <20140613124609.GC5871@redhat.com> <20140613153620.GG4751@pd.tnic> <20140616173823.GC4515@redhat.com> <20140616200526.GF8170@pd.tnic> <20140616205331.GA13257@redhat.com> <20140616210927.GJ8170@pd.tnic> <539F60B3.1040509@zytor.com> <20140616214313.GB1870@redhat.com> In-Reply-To: <20140616214313.GB1870@redhat.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Vivek Goyal Cc: mjg59@srcf.ucam.org, bhe@redhat.com, jkosina@suse.cz, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Borislav Petkov , ebiederm@xmission.com, greg@kroah.com, akpm@linux-foundation.org, Dave Young , WANG Chao On 06/16/2014 02:43 PM, Vivek Goyal wrote: >> >> Borislav and I talked about this briefly over IRC. A key part of that >> is that if userspace could manipulate this system call to consume an >> unreasonable amount of memory, we would have a problem, for example if >> this code used vzalloc() instead of kzalloc(). However, since >> kmalloc/kzalloc implies a relatively restrictive limit on the memory >> allocation size anyway, well short of anything that could cause OOM >> problems, that pretty much solves the problem. > > Actually currently I am using vzalloc() for command line buffer > allocation. > > image->cmdline_buf = vzalloc(cmdline_len); > if (!image->cmdline_buf) > goto out; > > Should I switch to using kzalloc() instead? > Yes. There is absolutely no valid reason to use vzalloc() for an object that small, and if someone manipulates the header to allow for a crazily large command line then you can trick the kernel into allocating arbitrary amounts of memory. -hpa _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec