Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2789447imb; Mon, 4 Mar 2019 14:23:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwpB+31xutP0K5XmWwYjy/AXUfCgcp3Yis2J8i9qpvc7PaPPSyC9EctUIvnh2YmZV2U4gV5 X-Received: by 2002:a17:902:d88c:: with SMTP id b12mr5966504plz.339.1551738236016; Mon, 04 Mar 2019 14:23:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551738236; cv=none; d=google.com; s=arc-20160816; b=IHLNkoYMdKiag/1w4NCtqjF3RZyNfmC75mCXL5qX4fxfzUPZebPjTSvBk6t8LZVUEM VklMO7kNf3DBWIVeEY9MQ5YlLOWb1tiQagQs+vwZznYFsr4FdrlfP4C5cOX6MXdu9D7g BkVIaZymCw1kLWfiqJk8HWHZ4w1TsXIhOHbVpD1cEDvCOP63H9uSUtmrJ3+fEDqi2AIT 3jkFKhFXlPAC4pZU5VDPDt27BeJUXMf1MZ7FXHxfYsBTlszQt/YxmeUTaXFfzVSr+PKm 1ioYKbfmuJX5PVfdpUg56+3UNwOT2C/GJ5FJGphTnFvicu/kk97wXuUfWmDG+SzHlKlF FxfQ== 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:date:cc:to:from:subject:message-id; bh=A+zf/MyNY3AourqAABaTahdtGgkq0ZrJxzcxCcuoGJE=; b=hXDWAuxd+RREglApVhTTU7GU/1lMORU/BxHA47gbz3Rvn7r7NArpebV7tI/YyggXIN hoTyTG11tzlbWMr3x34ViB0+3MzY9/GO3n5QXv54ZUlmUqI1m0yfZ6SLHhey6gJRcKV1 yiU9V86LQmVO/DNPc/R9EClrXfzlmw/pnlzwT85ADqeZVUNuyG4IldMnA+89SlSNg5OG 5pri8YXEvF2pNIDl4t9TylvH9U8RPwDOZ1EmIHLr6dErzZl7CGYDvRvUMJz6WEv3LThf HfhhErM24lJpl+iOaNhJHbUU0Tn639BkEwWH9acPaR/VmYWiAjWjo2YLnx7tu9JPFdWy dICw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z18si6283655pgf.66.2019.03.04.14.23.27; Mon, 04 Mar 2019 14:23:56 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726111AbfCDWWz (ORCPT + 99 others); Mon, 4 Mar 2019 17:22:55 -0500 Received: from mga12.intel.com ([192.55.52.136]:21877 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbfCDWWy (ORCPT ); Mon, 4 Mar 2019 17:22:54 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2019 14:22:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,441,1544515200"; d="scan'208";a="149224348" Received: from cdbrown-mobl.amr.corp.intel.com ([10.254.61.64]) by fmsmga004.fm.intel.com with ESMTP; 04 Mar 2019 14:22:53 -0800 Message-ID: <5643a1971831ce2d01a947f0f07cefa002bbdc25.camel@linux.intel.com> Subject: Re: [PATCH 2/2] tracing: Use strncpy instead of memcpy for string keys in hist triggers From: Tom Zanussi To: Steven Rostedt , Tom Zanussi Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Namhyung Kim Date: Mon, 04 Mar 2019 16:22:52 -0600 In-Reply-To: <20190304165653.17699f9f@gandalf.local.home> References: <50c35ae1267d64eee975b8125e151e600071d4dc.1549309756.git.tom.zanussi@linux.intel.com> <20190304165000.0ce0fbdd@gandalf.local.home> <20190304165653.17699f9f@gandalf.local.home> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-1.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steve, On Mon, 2019-03-04 at 16:56 -0500, Steven Rostedt wrote: > On Mon, 4 Mar 2019 16:50:00 -0500 > Steven Rostedt wrote: > > > > +++ b/kernel/trace/trace_events_hist.c > > > @@ -4695,9 +4695,10 @@ static inline void add_to_key(char > > > *compound_key, void *key, > > > /* ensure NULL-termination */ > > > if (size > key_field->size - 1) > > > size = key_field->size - 1; > > > - } > > > > > > - memcpy(compound_key + key_field->offset, key, size); > > > + strncpy(compound_key + key_field->offset, (char *)key, > > > size); > > > + } else > > > + memcpy(compound_key + key_field->offset, key, size); > > > } > > > > > > > Shouldn't we use strncpy() in save_comm() too. Feels safer. > > Note, if that is changed, it can be another patch. This one is fine > as > is. I just was looking at other use cases of memcpy() in that file. > Hmm, I don't think it's really necessary - it's not used in a key so don't care about anything after the null, and TASK_COMM_LEN is used in the memcpy. Tom > -- Steve