Message ID | 20240221200901.242eb6e0@gandalf.local.home |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-75752-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1394520dyc; Wed, 21 Feb 2024 17:07:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVa+0Nl7eIVUcaWT1i40fAHxCbu8GeBs2rSdGPCiNvaCiznel/JS4fBwLHC2il8VTMJTHKYR/KcltH47QOZCQrGZSKQDA== X-Google-Smtp-Source: AGHT+IHehX7chrPQd1KiP3cDgrvap8zRlMWP8Am5ZJTpFd+a1ph/LXNanhLD2PXGFZDCrgonBvq3 X-Received: by 2002:a05:6402:7c9:b0:564:e278:60d2 with SMTP id u9-20020a05640207c900b00564e27860d2mr3266839edy.2.1708564045978; Wed, 21 Feb 2024 17:07:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708564045; cv=pass; d=google.com; s=arc-20160816; b=0DU8j4KtwRz2CjGjn+9fA39z5l6xOhBEX5i8xoEc7Iga3KM9Rjm5dspiYUf7wJcbXb TBWHBVvmy+xiFznxl3DFllmmQsujpDQsuiInp24tBBhwYfveJx1B77AQgnni0EZznTeE KquaS90LPM4G1Eg9J7Ez8wHMOfzP2r6fMT7CmrsZqUlqPrYS6Cr3MCQrDkuNxY4qrzT+ ai2cLvg/jSCNkd6fGYnk35LLrKtU0OTFw17r+0lgTyhUhzcB4L66GhiNI68VdFzQ//CY xxNAQ6nROHT2yZuX4KWThofZA30pybkRhbRFdY6VajLqYVpx12cznAnjexf6MawbU8wu V0XQ== 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:message-id:subject:cc:to:from :date; bh=oLiuFPsx1NCVpMrSQKVp2EesNuXSYuw5ApvDTCIybug=; fh=ECxIr4+a6Y41w+SzfzAe11sAa71NT1OLl/a0Xy6AzPg=; b=JNK9m9lTFwHyS/RWNAZ1+nHFkpnhEVhQXtLDEYEsMKB/DimbCgV6CtGjtB+cSLHR9Z v8RFCZPkDMyK//t6msW4tPPK9WaDdxzREECa5aMZAfFtkXG6SMcevICiLhLTl7PDKT5g j8ouqddyZ0xnUZ+ZWqb7hzgM33+ro/h0UVKWhq45pgshArpO0fbDVp/5oP5maj+FxIhs NPbaOuZV3o6n4W0kSJq0ek6agixH7A+VGc418yNm5VH+sC9b0txcMlvJUC/MJGvjGdWx GzAfy6v33XJxjLmDMBfLO39X8Ln6mMaDeWXIA9nZCKYmGz53Haons2/A4j9u/scmMk0s YuFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-75752-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75752-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z94-20020a509e67000000b00564511b6b51si3747616ede.589.2024.02.21.17.07.25 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 17:07:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75752-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-75752-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75752-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 93B751F218E1 for <ouuuleilei@gmail.com>; Thu, 22 Feb 2024 01:07:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21665111A1; Thu, 22 Feb 2024 01:07:16 +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 A398511724 for <linux-kernel@vger.kernel.org>; Thu, 22 Feb 2024 01:07:14 +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=1708564034; cv=none; b=sbMa8/BCTStql4GAMZInksZEi3PdR8w9pf0DalpT3kiCUtLL15VEyXfIAKhQPbbWrhmCJopKIVtoTCjCBE6KCMt0hO88sfffGWrayw++rMUcL79tqXw3Y79KhFyUCl2KHqYYYoSTcMHJ4tBgNuGE/cvi6TnBQw7KcV8MZyPz/DA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708564034; c=relaxed/simple; bh=1VaxxzkOjNlNPknS6Jq3eEShJah4/V3IV/jcUNjEdMc=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=PGtisDQAHJLMMkcfM1YteD8BLfwdLnjT34UJBTyGKDkxPubU9BSNPXNrHeHe6vwyWPBXm0u1+mCE3dnGLu07oZ0ug1r1CSmrdY66VgZkr6LLWie39cgp4xHHhBim/OnF4Vm6o0IVO/t3Zy9in4IlEUgxaEm/20FyS3OQH+CkLaY= 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 78B01C433F1; Thu, 22 Feb 2024 01:07:13 +0000 (UTC) Date: Wed, 21 Feb 2024 20:09:01 -0500 From: Steven Rostedt <rostedt@goodmis.org> To: LKML <linux-kernel@vger.kernel.org> Cc: Masami Hiramatsu <mhiramat@kernel.org>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Subject: [for-linus][PATCH] ring-buffer: Do not let subbuf be bigger than write mask Message-ID: <20240221200901.242eb6e0@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: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791559253307930446 X-GMAIL-MSGID: 1791559253307930446 |
Series |
[for-linus] ring-buffer: Do not let subbuf be bigger than write mask
|
|
Commit Message
Steven Rostedt
Feb. 22, 2024, 1:09 a.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org> The data on the subbuffer is measured by a write variable that also contains status flags. The counter is just 20 bits in length. If the subbuffer is bigger than then counter, it will fail. Make sure that the subbuffer can not be set to greater than the counter that keeps track of the data on the subbuffer. Link: https://lore.kernel.org/linux-trace-kernel/20240220095112.77e9cb81@gandalf.local.home Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Fixes: 2808e31ec12e5 ("ring-buffer: Add interface for configuring trace sub buffer size") Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/trace/ring_buffer.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index fd4bfe3ecf01..0699027b4f4c 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -5877,6 +5877,10 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order) if (psize <= BUF_PAGE_HDR_SIZE) return -EINVAL; + /* Size of a subbuf cannot be greater than the write counter */ + if (psize > RB_WRITE_MASK + 1) + return -EINVAL; + old_order = buffer->subbuf_order; old_size = buffer->subbuf_size;