Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BCA3C43381 for ; Thu, 14 Feb 2019 13:39:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCE142229F for ; Thu, 14 Feb 2019 13:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550151566; bh=sJeluh8v3ABIWaTy+k4Vu6kufbMvjXYcP2T1ub9jkY8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=hoXMsqcWDIWFOT4q8IY/HnQwLR8nLRZzE8HjIZkdBKc2qcS823HoDNAsvccvkqVlY k4ItKj01LOhvC+NEZU9yj0hfcWpBiCKRiLVlRyPYm7NYNj53V+Z6yXUcZyvaXTqa2B KaH4vth2Sos0k2fVc/16kAW51hNCECugEhiZ/RKE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390652AbfBNNj0 (ORCPT ); Thu, 14 Feb 2019 08:39:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:51168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387696AbfBNNj0 (ORCPT ); Thu, 14 Feb 2019 08:39:26 -0500 Received: from devbox (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (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 110DE2080A; Thu, 14 Feb 2019 13:39:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550151565; bh=sJeluh8v3ABIWaTy+k4Vu6kufbMvjXYcP2T1ub9jkY8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RbYNf9ghy8CJfFY98xHpJPCwsTaOMKNzfRc4qllJ5J7AOm7E0jbP0yV+uFsJzpPPx cB+D2+hMhz/NqNlA1NtZhHvjrNHFdqhW36ilm6TtC/d2aJfwy/sTATPv6cJ4wkP+bi yyBtIkq6ouJDN/ISytnNNqL361mRcQB1tPeTzwP8= Date: Thu, 14 Feb 2019 22:39:23 +0900 From: Masami Hiramatsu To: Andreas Ziegler Cc: stable@vger.kernel.org, mingo@redhat.com, rostedt@goodmis.org Subject: Re: [PATCH stable-4.19] tracing/uprobes: Fix output for multiple string arguments Message-Id: <20190214223923.3b068eafda0114870580e48d@kernel.org> In-Reply-To: <567dfdfb-98ac-a463-0bfc-757d68b282d0@fau.de> References: <1550065662253148@kroah.com> <155014874796.22619.10907647977472908008.stgit@devbox> <567dfdfb-98ac-a463-0bfc-757d68b282d0@fau.de> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Hi Andreas, On Thu, 14 Feb 2019 14:00:03 +0100 Andreas Ziegler wrote: > Hi, > > > > > diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c > > index e696667da29a..04c1769a8c7c 100644 > > --- a/kernel/trace/trace_uprobe.c > > +++ b/kernel/trace/trace_uprobe.c > > @@ -142,6 +142,13 @@ static void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs, > > ret = strncpy_from_user(dst, src, maxlen); > > if (ret == maxlen) > > dst[--ret] = '\0'; > > + else if (ret >= 0) > > with this fix the maxlen case still decrements ret by one which does not > include the terminating \0 (and leaves maxlen = 1 in > store_trace_args()). Usually this only happens with the last element but > I still feel that it's inconsistent... Yes, I found that too. And I thought it was another fix. > > Would'nt it be easier to simply add a '+ 1' to to the make_rloc_data() > statement, like this: Hmm, in that case, I would like to make "--ret" to "ret - 1" as the latest kernel does. Keeping the final code similar will help us if we need another fix to backport. Any thought? Thank you, > > diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c > index e696667da29a..ca0051a84ce8 100644 > --- a/kernel/trace/trace_uprobe.c > +++ b/kernel/trace/trace_uprobe.c > @@ -147,7 +147,7 @@ static void FETCH_FUNC_NAME(memory, string)(struct > pt_regs *regs, > ((u8 *)get_rloc_data(dest))[0] = '\0'; > *(u32 *)dest = make_data_rloc(0, get_rloc_offs(rloc)); > } else { > - *(u32 *)dest = make_data_rloc(ret, get_rloc_offs(rloc)); > + *(u32 *)dest = make_data_rloc(ret + 1, get_rloc_offs(rloc)); > } > } > > > + /* > > + * Include the terminating null byte. In this case it > > + * was copied by strncpy_from_user but not accounted > > + * for in ret. > > + */ > > + ret++; > > > > if (ret < 0) { /* Failed to fetch string */ > > ((u8 *)get_rloc_data(dest))[0] = '\0'; > > > > Regards, > > Andreas -- Masami Hiramatsu