From mboxrd@z Thu Jan 1 00:00:00 1970 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 6610381A; Sun, 3 Dec 2023 04:15:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93E80C433C8; Sun, 3 Dec 2023 04:15:01 +0000 (UTC) Date: Sat, 2 Dec 2023 23:15:24 -0500 From: Steven Rostedt To: Dominique Martinet Cc: Christian Schoenebeck , JP Kobryn , ericvh@kernel.org, lucho@ionkov.net, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, v9fs@lists.linux.dev, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH] 9p: prevent read overrun in protocol dump tracepoint Message-ID: <20231202231524.4ce1d342@gandalf.local.home> In-Reply-To: References: <20231202030410.61047-1-inwardvessel@gmail.com> <1881630.VfuOzHrogK@silver> <20231202201409.10223677@rorschach.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-trace-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 Sun, 3 Dec 2023 10:33:32 +0900 Dominique Martinet wrote: > > TP_printk("clnt %lu %s(tag = %d)\n%.3x: %16ph\n%.3x: %16ph\n", > > (unsigned long)__entry->clnt, show_9p_op(__entry->type), > > __entry->tag, 0, __get_dynamic_array(line), 16, > > __get_dynamic_array(line) + 16) > > This was just printing garbage in the previous version but %16ph with a > dynamic alloc would be out of range (even the start of the next buffer, > _get_dynamic_array(line) + 16, can be out of range) > > Also, for custom tracepoints e.g. bpftrace the program needs to know how > many bytes can be read safely even if it's just for dumping -- unless > dynamic_array is a "fat pointer" that conveys its own size? > (Sorry didn't take the time to check) Yes, there's also a __get_dynamic_array_len(line) that will return the allocated length of the line. Is that what you need? -- Steve