Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp37264lqs; Mon, 4 Mar 2024 14:12:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWI7RceHBQqBCcgaG755kuA3bZ2FlSl3fvnaDtVw7wa2LHGxsdc7CyTEW5hJSx/l69UInda5IQrMdxz6xHs32S1kaE19mz10kjMsy6eHQ== X-Google-Smtp-Source: AGHT+IHC16X3d0+MBvzAV4x7d2zkU2SgPsTXiijouId/yejyvHhu7MGfDVYzEyl+aLHq8LNLWMJq X-Received: by 2002:a05:6a20:1612:b0:1a1:20c0:907a with SMTP id l18-20020a056a20161200b001a120c0907amr128195pzj.29.1709590331842; Mon, 04 Mar 2024 14:12:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709590331; cv=pass; d=google.com; s=arc-20160816; b=kQuDgyyD3SLjvIWRz6zR9hRWeaaIG7GiQ+EASMW824leMP7pkEqSTvqTvVBLrOZWbG TmbXNXAPapHlgmC7W8PJWiaKfEKt99HmHTVS/frSWB/k0OC7nvtfbtD7WFoAgS1MNZ12 wImhIuksU0geJtIdvDjYgp1tWA8DnKqHEgrAtEHPdh988iD7Wt5/BjXIPWB3AvIfGonp GPpNO9YYvM6NBISORZ2eQzYjw1a1QdIfWpZsTSNvDvfwVDDyfPK8TU9Cm428WtjEs2eJ mx82Q3UEfRHQvtyKE/E/AKr/ccg+hEzFZNt6EingZRJ6WHa5Ai3YOulIQETRe9hjPP3d 9WuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=NJfV48pgAuMMCpOx3VTZWR6yiU0uGzRCVaPMsGr/i0g=; fh=Z4tsOB/IV38gOyR2qPehPYRd6/PjJOdZwylA30ksxfw=; b=oscs6wx+NRVL9bHMSVr1DiO1F9+WX53QYW+41qt/8YPgmKoxRm7U3Q9RKVQdlcW5JQ 1N4LJ11LPsRnqC7M3eWaKnyjwsPVuu5Te9msKE/jvocIwh9YLG9xwlhM43twoY57rFiY 9OWzlPs0B6Cmp09rbdlj1BPV6SRfEQPfbAprJFcdpi4ADCF0oBO8XCV0v8InzT2u6t2u dAZOTJNOLmMO2isqwoBNHOwRyc1NZRp1bkMSSt5wdVLoc6oNwJZ1Z+0odXF9ID6bPDZg qStqJo/j0fp4sAGpkrYD1jQLWUILRS+qTWreViG71WZfnDDtFoimCOWOKpaA0Ze+MD4f 3VDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91345-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91345-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p16-20020a62ab10000000b006e559c83504si8776650pff.360.2024.03.04.14.12.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 14:12:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91345-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91345-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91345-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2281B281C98 for ; Mon, 4 Mar 2024 22:12:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC9217F7C3; Mon, 4 Mar 2024 22:08:47 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68A727BAFD for ; Mon, 4 Mar 2024 22:08:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709590127; cv=none; b=YpfCVnpnh4dtqcExsoXaaOdVS7HEPCwkfnkwV8lBsCcdRkMqfb9H6IelsXNhCdlbmFoEXYa2axSMLz4nahueIOu9VfSWJ0Xy8nAnuE+LaKzTcHCMB+8+mdq9YpK8K/vYyWiRxeXoi5rZTv9BuwlAE8/1t2YILYbJMDAdq+jly34= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709590127; c=relaxed/simple; bh=troFpq8k35BWXLnesXmRO+Fl54Smbk9Y7MSRfar35pw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M6WprVTvADXNjLAKv0kM6WEOeW0pzWH4fGFlSBBl1FDGx+L8KVE7V0Lmk2tFzB2tgAP4jo9IKQfQ9w9aZgJu1Q/J29HefF0rTyMFMP5rqPq9gp+rNir/dTMreBDhug/ipwazNQI04iEU33TzIbWVrxYdUzcPc2bkQjtvwUSAnW8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56449C433C7; Mon, 4 Mar 2024 22:08:46 +0000 (UTC) Date: Mon, 4 Mar 2024 17:10:34 -0500 From: Steven Rostedt To: Linus Torvalds Cc: LKML , Masami Hiramatsu , Mathieu Desnoyers , Sachin Sant Subject: Re: [GIT PULL] tracing: Prevent trace_marker being bigger than unsigned short Message-ID: <20240304171034.08d037aa@gandalf.local.home> In-Reply-To: References: <20240302111244.3a1674be@gandalf.local.home> <20240302145958.05aabdd2@rorschach.local.home> <20240302154713.71e29402@rorschach.local.home> <20240303075937.36fc6043@rorschach.local.home> <20240303140705.0f655e36@rorschach.local.home> <20240303160024.458d4f91@rorschach.local.home> <20240304164205.3245608a@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 4 Mar 2024 13:50:13 -0800 Linus Torvalds wrote: > On Mon, 4 Mar 2024 at 13:40, Steven Rostedt wrote: > > > > As I mentioned that the design is based on that the allocated buffer size is > > the string length rounded up to the word size, all I need to do is to make > > sure that there's a nul terminating byte within the last word of the > > allocated buffer. Then "%s" is all I need. > > Please don't add pointless code that helps nothing. > > > Would this work for you? > > No. This code only adds debug code, and doesn't actually improve anything. > > We *have* debug code already. Things like KASAN already find array > overruns, and your ex-tempore debug code adds zero actual value. Sorry I thought debug code was OK. But I guess I was mistaken. KASAN isn't run in the field, where this would trigger. But I get your point. If it's passing my tests (which I do run with KASAN), I guess that's good enough for you. > > That, btw, is why your old stupid precision code was not only > triggering warnings, but was ACTIVELY DETRIMENTAL. > > All that precision code could ever do was to potentially hide bugs if > the string wasn't NUL-terminated. > > So no. I absolutely do NOT want you to write more code to hide bugs or > do half-arsed checking. Well, it wouldn't hide it. It would trigger a big fat warning if it was missing a nul terminator. > > I want you to *simplify* the code, and put proper limits in place for strings. > > I want to see the code that actually notices when somebody generates a > crazy string, and stops that garbage in its tracks. > > What I do *not* want to see is more ad-hoc code that tries to deal > with the symptoms of you not having done so. This warning is just making sure the code is nul terminated. It has nothing to do with size. The bug that triggered when I was working on other code was a miscalculation of the input. I didn't write the entire string into the ring buffer which meant that the terminating nul was also missing. On reading the string, it crashed the kernel. I put in the precision when debugging the code, and that's where I found the mismatch in string size vs writing to the buffer. I then kept the precision just in case I hit a similar bug. Which is what you have issues with. Fine, I'll just remove the precision as that's not needed. There was no other overflows involved here. -- Steve