Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp96734lqs; Mon, 4 Mar 2024 16:42:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWbVG/L9dGPwhwjukTkIFsZ+q8W020bFmyZQ0syiunFMxTpHzRgXWFndjlqlvmwnoC3tmTVWoln9IvdG6f6p+JYlQ38OfKunLGiPek9DQ== X-Google-Smtp-Source: AGHT+IEYaPpkHUaUTab0BM+KMoDicgUb5uh8jGzCNYnSc5VQ8o3n+H1IfyYI1fRwCYSK5UGl7O/q X-Received: by 2002:a81:8482:0:b0:608:8f22:d6ad with SMTP id u124-20020a818482000000b006088f22d6admr9788082ywf.47.1709599322206; Mon, 04 Mar 2024 16:42:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709599322; cv=pass; d=google.com; s=arc-20160816; b=iZm3TcMUfTjegJCRoU1TytBWewvcVzAHYooSuvx7wy9e2XvC7xm3ebXV3gHAqU39yM NxzfL0XqqVuMYeBiS3lHVAVnqifjq747X7tijinWR43ecJVA6YoeXhrKMmsPaIGHL9zT gR5I9m0wJQeLbolYzusvUrrbWMA75TBLJfzlMVp/zh1X6vmwloj0KUOJkeArdByS9UzJ vHGDvn3eZiw4eNBJeWtG2S0G7iVks3OoEVxeGYIUE5HJRASCMGoOgpzW/JcJ/jh0zDxj j6Jh8ELLD2p2We89jn57XhFu9TWytSOb30s2tasJ96o3/ScQb5cQU8eSSP0Q0WGY9TFv tiPw== 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=0nZqscWNNjhaj71Lw7tgjabbpCsh6V74ihrPJr1EcCY=; fh=Z4tsOB/IV38gOyR2qPehPYRd6/PjJOdZwylA30ksxfw=; b=DFdHWxqewNi7j8tPHmcXI63o23/VpK4OrEUKw0LcxNmJFmuEFnTCtfCtHAvr0C93p1 o4d949M5nXL+DpRbdp0VLBqVW8iDYHDzoYubmkHP7uj0wdmKiDW1z60SA0cELtP3TPBs q5YkmbBXlJAkTDTY2jAxTgmq+8//En068v+jQ1Pvp3wur7dH0KqWfr8OAfFZQ4zQ4OOZ rdaWNAD1mqHWKQvpxjhTSB0O5B03dcjKmESu9pldOK7g+XfwAniBrscTDh+lmD9oaVPz e6BeVL37PFpdfXikExUyAftIot5V8Xy2YE1C4kCsOEhbU4Wuv9HlzMOXLgNEK+N8/l8Q H6dg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91463-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91463-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w1-20020a05622a190100b0042e165bf31dsi11307487qtc.93.2024.03.04.16.42.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 16:42:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91463-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-91463-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91463-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E95C11C21CB9 for ; Tue, 5 Mar 2024 00:42:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 796175664; Tue, 5 Mar 2024 00:41:56 +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 05F687F for ; Tue, 5 Mar 2024 00:41:55 +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=1709599316; cv=none; b=gNv71uf8ALI46JFBmwxjpAzNFAAOioREvyi+w0iuB/nA560k7pKWkzNTtEc3yMS3DMeXD+9lC4WJrm0mrjJyc4t6oS3UPha0CsK4vZzzIgnR/bKsMk4GQoOy1//FNX+SgO0zDDScUNxGfA7YBp2nkM669GwXTyGX+9Fw5M+4vk8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709599316; c=relaxed/simple; bh=Dc18/apb56vqF2V4XntLx89qjNsL7O94p6W8krjQ2+I=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V4luMyP8Lt70xugngLqGk0NEFqSCAOntFpc2SRXLAu1wvisDVwr9mChTX4NnatKkwZ+ZydLSBRL/XdaZSPpSsjqIwR3ZjjUMvJZfT3SOAcziFADTWUjZ7xlRjjmcJ7ClQ8dxBDucN3wYYfvGCMUYQulYuU7MDLelSXJMfEX5vc4= 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 DE5DFC433C7; Tue, 5 Mar 2024 00:41:54 +0000 (UTC) Date: Mon, 4 Mar 2024 19:43:43 -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: <20240304194343.57a6a541@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> <20240304171034.08d037aa@gandalf.local.home> <20240304184725.55449e70@gandalf.local.home> <20240304185241.7ce42097@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 16:17:15 -0800 Linus Torvalds wrote: > On Mon, 4 Mar 2024 at 15:50, Steven Rostedt wrote: > > > > But this still isn't fixing anything. It's just adding a limit. > > Limiting things to a common maximum size is a good thing. The kernel > limits much more important things for very good reasons. > > The kernel really shouldn't have big strings. EVER. And it literally > shows in our kernel infrastructure. It showed in that vsnprintf > precision thing. It shows in our implementation choices, where we tend > to have simplistic implementations because doing things a byte at a > time is simple and cheap when the strings are limited in size (and we > don't want fancy and can't use vector state anyway). > > If something as core as a pathname can be limited to 4kB, then > something as unimportant as a trace string had better be limited too. > Because we simply DO NOT WANT to have to deal with longer strings in > the kernel. > So I made three patches that do basically what you want. And as a bonus, it's not really an arbitrary limit but based on trace_seq size. The first patch will be removing the precision check, as that's not needed. The second patch is to remove the dependency between trace_seq and PAGE_SIZE, as its size really can just be 8K for all architectures. Which has the side effect of limiting the size of trace_marker, as its size is limited by the trace_seq size. Finally, because the trace_seq defines the max output that a trace_event can write (for all its fields), the extra data of a print event could possibly overflow that, which will cause the event not to print, and just an "OVERFLOW" output would show in the trace buffer. So I used the TRACE_SEQ_SIZE / 2 as the max size that trace_marker can read, which happens to be 4K. -- Steve