Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp3122836ybg; Sat, 6 Jun 2020 11:22:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAcke0a3dUtN9edqdJ9wMA3fygDmxdCEPgUR8mJMwo98i8M82T0h6s38hmZsR/yFctPmi5 X-Received: by 2002:aa7:c143:: with SMTP id r3mr15186507edp.203.1591467727463; Sat, 06 Jun 2020 11:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591467727; cv=none; d=google.com; s=arc-20160816; b=PJLeUoeBrDs+hWcRvIIeotxKM13ScyG3hAr2Y2tlA5ydjzgZ6EzDYfokks1YS8pp63 YOKFTdQm7LOS8OsDBh4irZcqOCa5Ext5mHs4Zqig5PrLJCiJRDwCcj2bw6sWlJ+q0mrS irUZMpDwrI7ZPV4zMP7vLUVpdR3ntGOahGfp31VTjlUGIB9GW6537L16/0meDE+vc26/ Yi/3NjhbOyIKw90n+2aWKXnxuEzeQ2zfp3++UjhoUE/NJ7IpvXl9RGzBFsQD30+ZSRJE QLsX+49+oqhJoGGQY2KHH8AHU8oxsOQFxvd9FdeANnkwrG55obE0pQVSd7Ur1vo4hB/V K1zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=X06gmjXofSwhbQtFfj7/KMAXcbxHehdyr299bx9mR/o=; b=RwOzt3VVOFPASKHgAbCoA79olq/Lj0Q2UhLvQkXSm6Ib0CY/e/5BVR+nfTnL0EEXB8 zdoYRWmmIPdhMyhcXgda9NV6qDNHOUkA6sOVd811AW28MMfdS6gYz++o0WA9V59hUyG8 Kh6WTk3Q3KKsn4qtsnCyaeBbu1r1EEt5v86/XwZXhHrwzLcKFoILAYBJYwTWOt7/y2qq M9Hlrar8iY7cKEC/gl9zCB8xaz37CnWS1UwOE53ElrP1a99801jVDj2baopfljotIMrT Pr7oqddsYVTm86ziPukd/LlYGrfeJDFwSPSI+PdCJpso/mXyXY+tLA+zPHoaLD8a3CwM D2xg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bf20si5862564edb.66.2020.06.06.11.21.44; Sat, 06 Jun 2020 11:22:07 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728876AbgFFST2 (ORCPT + 99 others); Sat, 6 Jun 2020 14:19:28 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:10046 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728812AbgFFST2 (ORCPT ); Sat, 6 Jun 2020 14:19:28 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 056I1ZOp063374; Sat, 6 Jun 2020 14:19:22 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 31g59q3rqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jun 2020 14:19:22 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 056IG2Hn006593; Sat, 6 Jun 2020 18:19:20 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04fra.de.ibm.com with ESMTP id 31g2s7rdaa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 06 Jun 2020 18:19:20 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 056IJIUK36110520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 6 Jun 2020 18:19:18 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AD8BA4057; Sat, 6 Jun 2020 18:19:18 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 08054A4053; Sat, 6 Jun 2020 18:19:18 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Sat, 6 Jun 2020 18:19:17 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id AAA26E0278; Sat, 6 Jun 2020 20:19:17 +0200 (CEST) From: Sven Schnelle To: Andrew Morton Cc: Masami Hiramatsu , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Sven Schnelle Subject: [PATCH] kprobes: use strncpy_from_kernel_nofault() in fetch_store_string() Date: Sat, 6 Jun 2020 20:19:03 +0200 Message-Id: <20200606181903.49384-1-svens@linux.ibm.com> X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-06_15:2020-06-04,2020-06-06 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 clxscore=1011 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 cotscore=-2147483648 bulkscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006060140 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the latest linux-next i noticed that some tests in the ftrace test suites are failing on s390, namely: [FAIL] Kprobe event symbol argument [FAIL] Kprobe event with comm arguments The following doesn't work anymore: cd /sys/kernel/tracing echo 'p:testprobe _do_fork comm=$comm ' >kprobe_events echo 1 >events/kprobes/testprobe/enable cat trace it will just show test.sh-519 [012] .... 18.580625: testprobe: (_do_fork+0x0/0x3c8) comm=(fault) Looking at the source i see that there are two helpers for reading strings: fetch_store_string_user() -> read string from user space fetch_store_string() -> read string from kernel space(?) but in the end both are using strncpy_from_user_nofault(), but fetch_store_string() should use strncpy_from_kernel_nofault(). Signed-off-by: Sven Schnelle Acked-by: Masami Hiramatsu Acked-by: Christoph Hellwig --- kernel/trace/trace_kprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index b1f21d558e45..ea8d0b094f1b 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -1278,7 +1278,7 @@ fetch_store_string(unsigned long addr, void *dest, void *base) * Try to get string again, since the string can be changed while * probing. */ - ret = strncpy_from_user_nofault(__dest, (void *)addr, maxlen); + ret = strncpy_from_kernel_nofault(__dest, (void *)addr, maxlen); if (ret >= 0) *(u32 *)dest = make_data_loc(ret, __dest - base); -- 2.17.1