Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932597AbbH0WeP (ORCPT ); Thu, 27 Aug 2015 18:34:15 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:47735 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753860AbbH0WeL (ORCPT ); Thu, 27 Aug 2015 18:34:11 -0400 Date: Thu, 27 Aug 2015 15:34:09 -0700 (PDT) Message-Id: <20150827.153409.893765406170260565.davem@davemloft.net> To: ast@plumgrid.com Cc: mingo@kernel.org, rostedt@goodmis.org, wangnan0@huawei.com, hekuang@huawei.com, daniel@iogearbox.net, brendan.d.gregg@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] bpf: add support for %s specifier to bpf_trace_printk() From: David Miller In-Reply-To: <1440656819-25622-1-git-send-email-ast@plumgrid.com> References: <1440656819-25622-1-git-send-email-ast@plumgrid.com> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Thu, 27 Aug 2015 15:34:10 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 848 Lines: 25 From: Alexei Starovoitov Date: Wed, 26 Aug 2015 23:26:59 -0700 > +/* similar to strncpy_from_user() but with extra checks */ > +static void probe_read_string(char *buf, int size, long unsafe_ptr) > +{ > + char dst[4]; > + int i = 0; > + > + size--; > + for (;;) { > + if (probe_kernel_read(dst, (void *) unsafe_ptr, 4)) > + break; I don't think this does the right thing when the string is not a multiple of 3 and ends at the last byte of a page that ends a valid region of kernel memory. Seeing this kind of error makes me skeptical to the overall value of optimizing this :-/ -- 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/