Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2793888imb; Mon, 4 Mar 2019 14:32:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwIpllXDywaKymsJQilWB4h6wgjYRN38JflssWwO21zYUZalFytZbuWccMB4Y7jAnCgueZr X-Received: by 2002:a17:902:e50b:: with SMTP id ck11mr23050179plb.25.1551738746849; Mon, 04 Mar 2019 14:32:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551738746; cv=none; d=google.com; s=arc-20160816; b=WsIw61wlVb2wupPHTIsI4qG2ACB9b3nKfLxFWy/IpSELJVPo6/wEtGaX7ywY9FR9SZ Vs/JUpHE0gXJFocpEf6KEY6ooKVrwSQpaRmLlEWqay61u/MnMK2Z/eV/7mHnI27gDrBW J8sawWwEuaXLUx4bDQL4Hm48buMn/Ru1wzzyf1YbYOZz2FkACtDsMEOLV9zemZBLjOlm RR1gfO9GNqC9AgJdypQhoZz+SzJaPatuQmHOJWhts63tBDNyVjdstr8yMqEQBNPZAwGU h8GeIir2HrPmu5KhTYVUPfTM7NyeatUQF+TE82QcDTdVrHwVMQ8SwCHZOkJxxleEDq4e t4hw== 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=UzEwgidNZNQFdVqkA+IjHQSTx4yA3fhDrPN4dl9dOzM=; b=Cd43qpbDrTUvzewZo8xzoyLO25ZsGiyRBb1QHWnkduyuT2ndwZ1DHyGIzZKTfKAjqr zxyVTsgdIZmpu6BMDbkB1HYlGZeQYxp/28Stid57FYf7usszM/iHv5mTe8NtEPVoXIJh +fMIoznQFGfI3eC6WFy44WLbyqtlHFbr9u0TWlzhGqyGURZsp8ZTisFvkJFK0ToFE7QO K4TBjR3ynAWw6lN/aJvmFoZ+dGsPVnzhAPphTIIG/o0v3yDBem0lshW9fge+Xpc8vPg+ rNtNCoyZCa0ma5w+ztweC/Bn/o6bIiNPIwyNOPcqEAw+PpTQQLeWSgiV+0oDs02+TTDN MCIA== 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 m2si6392825pfj.111.2019.03.04.14.32.10; Mon, 04 Mar 2019 14:32:26 -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 S1726355AbfCDWbm (ORCPT + 99 others); Mon, 4 Mar 2019 17:31:42 -0500 Received: from mga11.intel.com ([192.55.52.93]:60965 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbfCDWbm (ORCPT ); Mon, 4 Mar 2019 17:31:42 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2019 14:31:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,441,1544515200"; d="scan'208";a="122613464" Received: from cdbrown-mobl.amr.corp.intel.com ([10.254.61.64]) by orsmga008.jf.intel.com with ESMTP; 04 Mar 2019 14:31:40 -0800 Message-ID: <5c978b4b0d629e5a914c512c14f99f6a24241407.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:31:40 -0600 In-Reply-To: <5643a1971831ce2d01a947f0f07cefa002bbdc25.camel@linux.intel.com> References: <50c35ae1267d64eee975b8125e151e600071d4dc.1549309756.git.tom.zanussi@linux.intel.com> <20190304165000.0ce0fbdd@gandalf.local.home> <20190304165653.17699f9f@gandalf.local.home> <5643a1971831ce2d01a947f0f07cefa002bbdc25.camel@linux.intel.com> 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:22 -0600, Tom Zanussi wrote: > 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. Never mind, yeah, it would make sense to do this, will create another patch... Tom > > Tom > > > -- Steve