Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2131571ybg; Fri, 5 Jun 2020 06:27:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHXTWGnSoO/fHUfsFnjFL5J2tyNQgAJ0llOs7R3bAYUTivQXH5lNDs+eInOTIDxoMhHb1l X-Received: by 2002:a17:906:a889:: with SMTP id ha9mr9110088ejb.429.1591363675960; Fri, 05 Jun 2020 06:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591363675; cv=none; d=google.com; s=arc-20160816; b=doYnzo3ivRsRZF7zZaoj4WZse7YGUiSZStv33aZm0oMTlG1k3tlTqDTTuLcSVFjZqU xh1d53O58CSnpp/5mm8+jj4ulezoUeY1+KyjuRGOFAZ0HA73OzGl/M6MNNT8BeWD/GHd COlNr9DHKLjqlw/iHFrLceL+W1dV/2oOh8fwvhFH4wtS3R6KLYkTu1iqJNCxGyHGWPIT J/qQfWbg1Fo2pEQSz57CLiAcgF8VBQ/2nyBAhrl6fE6cm/CsJUe5FW9RURanr9w5YuD8 S2hHGsmKWFzAW9YQv55WuG952bXIkLEDcxXl5HzBBBnsmSE5iLKCMpRXtAEADXxQ76ON WamQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=TVw/ClUtBTBwwLBETeMkywt1V08xduiqK7/sUhmkc5E=; b=KQ8xOUg66joZZFyAMOyX3YFtQ+sDHMI3uPrBGQ4FCUVrZesyy4JWvLvsxPWGQhbDld BOOZrw/8vqIVt0PpSBFZV/VEN7TKSeu7w+hC+qDfkaM8przhUMUL24B875/cXo9R6qf7 r+TMBDdDpS1LTegK06SiqFfQEy9vGoOJW0EcN9B37IHHnvoL9abdlP3+lpyL5DFFBlg3 koGSj/VPQYF42A11OVgl/1clOyduOR6V2aFMmVJ0hoIhc7A92TnP6pYkRBdBuhH0GVFO 66pf0NzHS1lvsjm7ULhq3+KbkJhVl69w1Yu+1Uph24Q8Ht6FRA2ejTZ60XYp7/mG3hXm Ekbw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt16si4948573ejc.525.2020.06.05.06.27.32; Fri, 05 Jun 2020 06:27:55 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727002AbgFENZo (ORCPT + 99 others); Fri, 5 Jun 2020 09:25:44 -0400 Received: from verein.lst.de ([213.95.11.211]:58491 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbgFENZo (ORCPT ); Fri, 5 Jun 2020 09:25:44 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id EB3AC6736F; Fri, 5 Jun 2020 15:25:41 +0200 (CEST) Date: Fri, 5 Jun 2020 15:25:41 +0200 From: Christoph Hellwig To: Sven Schnelle Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, Masami Hiramatsu Subject: Re: kprobes string reading broken on s390 Message-ID: <20200605132541.GB31829@lst.de> References: <20200605110533.GA57038@tuxmaker.boeblingen.de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200605110533.GA57038@tuxmaker.boeblingen.de.ibm.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Yes, this looks correct. You probably want to write a small changelog and add a Fixes tag, though. On Fri, Jun 05, 2020 at 01:05:34PM +0200, Sven Schnelle wrote: > Hi Christoph, > > 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 >/sys/kernel/tracing/events/kprobes/testprobe/enable > cat /sys/kernel/tracing/trace > > it will just show > > test.sh-519 [012] .... 18.580625: testprobe: (_do_fork+0x0/0x3c8) comm=(fault) > > Looking at d411a9c4e95a ("tracing/kprobes: handle mixed kernel/userspace probes > better") 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 i would > think that fetch_store_string() should use strncpy_from_kernel_nofault(). > However, i'm not sure about the exact semantics of fetch_store_string(), > as there where a lot of wrong assumptions in the past, especially since > on x86 you usually don't fail if you use the same function for accessing kernel > and userspace although it's technically wrong. > > Regards, > Sven > > commit 81408eab8fcc79dc0871a95462b13176d3446f5e > Author: Sven Schnelle > Date: Fri Jun 5 13:01:24 2020 +0200 > > kprobes: use strncpy_from_kernel_nofault() in fetch_store_string() > > Signed-off-by: Sven Schnelle > > 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); > ---end quoted text---