Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754121AbbLFDkZ (ORCPT ); Sat, 5 Dec 2015 22:40:25 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:25150 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753712AbbLFDkX (ORCPT ); Sat, 5 Dec 2015 22:40:23 -0500 Subject: Re: [PATCH v4 01/11] stm class: Introduce an abstraction for System Trace Module devices To: Alexander Shishkin , Greg Kroah-Hartman References: <1442926040-15150-1-git-send-email-alexander.shishkin@linux.intel.com> <1442926040-15150-2-git-send-email-alexander.shishkin@linux.intel.com> Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, peter.lachner@intel.com, norbert.schulz@intel.com, keven.boell@intel.com, yann.fouassier@intel.com, laurent.fert@intel.com, linux-api@vger.kernel.org From: Sasha Levin Message-ID: <5663AE1A.2080808@oracle.com> Date: Sat, 5 Dec 2015 22:40:10 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1442926040-15150-2-git-send-email-alexander.shishkin@linux.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1077 Lines: 36 On 09/22/2015 08:47 AM, Alexander Shishkin wrote: > +static ssize_t stm_char_write(struct file *file, const char __user *buf, > + size_t count, loff_t *ppos) > +{ > + struct stm_file *stmf = file->private_data; > + struct stm_device *stm = stmf->stm; > + char *kbuf; > + int err; > + > + /* > + * if no m/c have been assigned to this writer up to this > + * point, use "default" policy entry > + */ > + if (!stmf->output.nr_chans) { > + err = stm_file_assign(stmf, "default", 1); > + /* > + * EBUSY means that somebody else just assigned this > + * output, which is just fine for write() > + */ > + if (err && err != -EBUSY) > + return err; > + } > + > + kbuf = kmalloc(count + 1, GFP_KERNEL); This bit allows for user-controllable kmalloc() allocation lengths, including a possible overflow. Thanks, Sasha -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/