From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98087C43217 for ; Wed, 12 Oct 2022 12:42:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbiJLMmc (ORCPT ); Wed, 12 Oct 2022 08:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbiJLMmb (ORCPT ); Wed, 12 Oct 2022 08:42:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06957C895E; Wed, 12 Oct 2022 05:42:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A92A9B81A84; Wed, 12 Oct 2022 12:42:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39C66C433D7; Wed, 12 Oct 2022 12:42:24 +0000 (UTC) Date: Wed, 12 Oct 2022 08:42:24 -0400 From: Steven Rostedt To: David Laight Cc: "linux-kernel@vger.kernel.org" , Masami Hiramatsu , Andrew Morton , Tom Zanussi , "stable@vger.kernel.org" Subject: Re: [PATCH v2 2/3] tracing: Add "(fault)" name injection to kernel probes Message-ID: <20221012084224.114c9e12@rorschach.local.home> In-Reply-To: <13544aa157fc4083a59127bbc5a2bb1e@AcuMS.aculab.com> References: <20221012104055.421393330@goodmis.org> <20221012104534.644803645@goodmis.org> <13544aa157fc4083a59127bbc5a2bb1e@AcuMS.aculab.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Wed, 12 Oct 2022 12:34:45 +0000 David Laight wrote: > > @@ -13,8 +15,16 @@ static nokprobe_inline int > > kern_fetch_store_strlen_user(unsigned long addr) > > { > > const void __user *uaddr = (__force const void __user *)addr; > > + int ret; > > > > - return strnlen_user_nofault(uaddr, MAX_STRING_SIZE); > > + ret = strnlen_user_nofault(uaddr, MAX_STRING_SIZE); > > + /* > > + * strnlen_user_nofault returns zero on fault, insert the > > + * FAULT_STRING when that occurs. > > + */ > > + if (ret <= 0) > > + return strlen(FAULT_STRING) + 1; > > + return ret; > > } > > Isn't that going to do the wrong thing if the user > string is valid memory but just zero length?? I thought so at first (and was in the process of changing things because of that) until I saw the comment above this code: /* Return the length of string -- including null terminal byte */ And looking the function of strnlen_user_nofault(): * Returns the size of the string INCLUDING the terminating NUL. That is, it returns 1 on a zero length string and 0 on fault :-p Yes, I think we should fix that API, but that's another story. -- Steve