Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp407940pxu; Tue, 1 Dec 2020 14:30:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJySjzymZPwBJpEokv4KRFPN0QDSbtIskTp2ZTeFN1Y/TRNDj9kwImPpsZrM1XX7cv/9ouGW X-Received: by 2002:a17:906:9a07:: with SMTP id ai7mr4138687ejc.216.1606861846363; Tue, 01 Dec 2020 14:30:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861846; cv=none; d=google.com; s=arc-20160816; b=QNlpU+i2KfiuuLwInD67SJ0BeMQsOiWzvXY5MCbygiJhNv10AyNwSvQwg4bJLm2Taz KYv5+OxRUN4OaWYCEN476jxOjThvR2KNObGx1Xxh1nEUfjWtzc6/sKmcBtioMvlsp0ZU mkoCmHIGUD8zwsj+8ZDADzpZr0KaYBjCwTKg1c0xVlQ732yas9Ewx661JyxeWPnKPzfP pCULyybmv4/GbjxIJ+UXPDFfL464xJznp+iL367n/a7Xk/SQIeYjV/cc28w0UNG/Y8gp zsFfMGcGmkljp8igPzOlNN+T8D6bQfn2MhIE9eEc0S8ChZJE8YYBWtljX83JNFQrnEwE 1AaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IrredCH1s8F4wx20+MNDr6iPeztT2qAci/VLSqyKZlg=; b=L2QzGtDaRbpwBeIm6a+HC13MdTCbWkry/KHwtNTn/Eg/rg6R23nUo9GJEftnmhtgnE O+qqow1A10ucTE6kaR3QPz9Y1wM8E9UvVziLJEzB7bGAx/BdxZfBjvMtDX4/ekavdHAJ IJMvpgrhQH3veN2Lv+daBqMH3slXitiF6sGHVsJ0piikg+lqGC98+JP3kBrc+BKl0CgG ylzYAKc67VXR7NIQ7Q+uDQED8GbiMB1Oejp0KT2UkqvEbt4ZC6o7ipKRrIJhTuKJc50+ QUH18c7WHC3u/nHqJCFh4w2FQ6UoTp5GRp5ElXNPKDRuv43paNF5+t5POQ55GKXAAakz 9e3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qOwGbA6P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cc10si853097edb.156.2020.12.01.14.30.23; Tue, 01 Dec 2020 14:30:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qOwGbA6P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389275AbgLAJVh (ORCPT + 99 others); Tue, 1 Dec 2020 04:21:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:45484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389286AbgLAJIk (ORCPT ); Tue, 1 Dec 2020 04:08:40 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 37A6521D7F; Tue, 1 Dec 2020 09:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813704; bh=FDqi7GVRDaVprswKxrpQLS/dzxc++ezJZEF3BKbbrfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qOwGbA6PPkmMK6JXIVCkOZDInM8OSbGFQo1t0GUxL0AA4zpUy6JMWJyd5pDB2k8dB 8YjN32ytrZFeEOS6xp9Xs5uqY64/5FVI+TJr3wuHa00azLyXpGXanAoIu1piWc6z8/ rxvvKfzPgUUjYwEVo99hHir9uVuvMFbPu/TOJePg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Steven Rostedt (VMware)" , Tejun Heo , Hui Su , Jan Kara Subject: [PATCH 5.9 030/152] trace: fix potenial dangerous pointer Date: Tue, 1 Dec 2020 09:52:25 +0100 Message-Id: <20201201084715.845414259@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084711.707195422@linuxfoundation.org> References: <20201201084711.707195422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hui Su commit fdeb17c70c9ecae655378761accf5a26a55a33cf upstream. The bdi_dev_name() returns a char [64], and the __entry->name is a char [32]. It maybe dangerous to TP_printk("%s", __entry->name) after the strncpy(). CC: stable@vger.kernel.org Link: https://lore.kernel.org/r/20201124165205.GA23937@rlk Acked-by: Steven Rostedt (VMware) Acked-by: Tejun Heo Signed-off-by: Hui Su Signed-off-by: Jan Kara Signed-off-by: Greg Kroah-Hartman --- include/trace/events/writeback.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/include/trace/events/writeback.h +++ b/include/trace/events/writeback.h @@ -190,7 +190,7 @@ TRACE_EVENT(inode_foreign_history, ), TP_fast_assign( - strncpy(__entry->name, bdi_dev_name(inode_to_bdi(inode)), 32); + strscpy_pad(__entry->name, bdi_dev_name(inode_to_bdi(inode)), 32); __entry->ino = inode->i_ino; __entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc); __entry->history = history; @@ -219,7 +219,7 @@ TRACE_EVENT(inode_switch_wbs, ), TP_fast_assign( - strncpy(__entry->name, bdi_dev_name(old_wb->bdi), 32); + strscpy_pad(__entry->name, bdi_dev_name(old_wb->bdi), 32); __entry->ino = inode->i_ino; __entry->old_cgroup_ino = __trace_wb_assign_cgroup(old_wb); __entry->new_cgroup_ino = __trace_wb_assign_cgroup(new_wb); @@ -252,7 +252,7 @@ TRACE_EVENT(track_foreign_dirty, struct address_space *mapping = page_mapping(page); struct inode *inode = mapping ? mapping->host : NULL; - strncpy(__entry->name, bdi_dev_name(wb->bdi), 32); + strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32); __entry->bdi_id = wb->bdi->id; __entry->ino = inode ? inode->i_ino : 0; __entry->memcg_id = wb->memcg_css->id; @@ -285,7 +285,7 @@ TRACE_EVENT(flush_foreign, ), TP_fast_assign( - strncpy(__entry->name, bdi_dev_name(wb->bdi), 32); + strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32); __entry->cgroup_ino = __trace_wb_assign_cgroup(wb); __entry->frn_bdi_id = frn_bdi_id; __entry->frn_memcg_id = frn_memcg_id;