Received: by 10.213.65.68 with SMTP id h4csp396325imn; Fri, 30 Mar 2018 07:36:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ZajA+cQk1ADSWKUcCkFnuNFRMxWUiz0FR56Z2oRJcJV3NfjYpBcI85jwhI/ftEsAGk8q/ X-Received: by 2002:a17:902:5222:: with SMTP id z31-v6mr11357005plh.145.1522420572856; Fri, 30 Mar 2018 07:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522420572; cv=none; d=google.com; s=arc-20160816; b=UWBqoAabNdY6AjfeGBxEPvpVTmI41H3WWlV4rJu3P8rgeWmvpBLsAMPMv+aOI6by+7 qtD4kg57ki1jZ2Jomxqd+vrTYW6jC4xwgV6X/sis6f09OYaGqaqAUt5QNYRH34gTGnlc TW9MKWE1gCMySVFVSRVSZgnL3fx5ASQSqKzuApGCgpzbk/UbhmzBxvpBiz6HPEhiZvbS IsCo1AlajzMtyke6kS8F4wnv4VnqENUGzVK8+bCIgvdglSVRnSaoOJKQEra+gUjx1Hre /VcxRHH9w1o4nM8Wpvo4HjNZ6mmuIlQesNKNF1HcxhFXy+vqOm9+5nqEwgWMjloQPxER dz2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=HyTRJb/l+mgWEH4Y4SQsbmMlY1ZvozekgDku9k9wyuA=; b=uj7q2qNRBxV/A/WBUpaTYmHtxVYvZdeq/jvunCYoTOE8y0E6eqFr9WuMs89KgVUJwd 1FV1FYrSlVzJZdJeeNv8vV6zIFMpJzEuhGcyIId6yb1rOCcNtiNlRrUZi1ZJfl1ayT/a wThbUA3E1dVpmjbwgmMamA4ToWucII2wNaASXdVSaEGj5Ws8WXrA0pv9RkxJiREhg8Ya /qh1cvu+39Aw/2nYPnVGaBbHr0twYbn83Z60fNBwiFv02zYKTsiMzoLvJaSydKs2ZofS S1JaNfNHRQhLi5Y6dFNLInbOpZ/gR/sUa5zJUKJPeYowG4ey6wM+v1CdtO1NtcPHwHqd 1QAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 99-v6si8450359pla.468.2018.03.30.07.35.59; Fri, 30 Mar 2018 07:36:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752156AbeC3OeP (ORCPT + 99 others); Fri, 30 Mar 2018 10:34:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:33596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751250AbeC3OeO (ORCPT ); Fri, 30 Mar 2018 10:34:14 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BEAB3217A8; Fri, 30 Mar 2018 14:34:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEAB3217A8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Fri, 30 Mar 2018 10:34:11 -0400 From: Steven Rostedt To: Salvatore Mesoraca Cc: linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Ingo Molnar , Kees Cook Subject: Re: [v2] ftrace: drop a VLA in module_exists() Message-ID: <20180330103411.5ed25f43@gandalf.local.home> In-Reply-To: <1522399988-8815-1-git-send-email-s.mesoraca16@gmail.com> References: <1522399988-8815-1-git-send-email-s.mesoraca16@gmail.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Mar 2018 10:53:08 +0200 Salvatore Mesoraca wrote: Couple of things. First, "PATCH" was dropped from the subject. If my inbox was busy today, I probably would have missed this email. > Avoid a VLA[1] by using a real constant expression instead of a variable. > The compiler should be able to optimize the original code and avoid using > an actual VLA. Anyway this change is useful because it will avoid a false > positive with -Wvla, it might also help the compiler generating better > code. > > [1] https://lkml.org/lkml/2018/3/7/621 Second, do not use lkml.org, use http://lkml.kernel.org/r/ Search for "Link:" tags in git log to see examples. Other than that, the patch looks fine to me and I can pull it for the next merge window. -- Steve > > Signed-off-by: Salvatore Mesoraca > --- > kernel/trace/ftrace.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index eac9ce2..16bbf06 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -3902,14 +3902,13 @@ static bool module_exists(const char *module) > { > /* All modules have the symbol __this_module */ > const char this_mod[] = "__this_module"; > - const int modname_size = MAX_PARAM_PREFIX_LEN + sizeof(this_mod) + 1; > - char modname[modname_size + 1]; > + char modname[MAX_PARAM_PREFIX_LEN + sizeof(this_mod) + 2]; > unsigned long val; > int n; > > - n = snprintf(modname, modname_size + 1, "%s:%s", module, this_mod); > + n = snprintf(modname, sizeof(modname), "%s:%s", module, this_mod); > > - if (n > modname_size) > + if (n > sizeof(modname) - 1) > return false; > > val = module_kallsyms_lookup_name(modname);