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 DAA062F46 for ; Tue, 7 Jan 2025 00:33:03 +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=1736209983; cv=none; b=unoeDqiCfsoLtBl7nLEnZBVwM9NgfFginqKptrrGaD/KQHSltm5EiZEuQRTDSd6sK9q6hVa7GkXsnFgfcYXy6p5cYK2eUJbBdVUp2J0y/tlKNSfMm9YriykFBBPugCJcpygkGPi92of658Kman4CvP9WmnrEApL6AuLqTBIOQMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736209983; c=relaxed/simple; bh=+SaxVyF0sDaOL5ucJoWX7gQz6ZovelaAlkLAFovtLbU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dGByUgv+qrHrNtzkIv4bdbYAsR0pIqDqdNtA82pBE6N8a9Gb+4DhbnKPibEvecZ7N+7nALej5WGB2Gbi9+TXnRtI6NHEUUUlu12ECC/PJ/5oEyorFEXbhtQdQS8tPT6Dd8iz2u12/4MjwAj0je7baEa5DoQsKIn/xS/h33ETURQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fD0zzdrP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fD0zzdrP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7160BC4CED2; Tue, 7 Jan 2025 00:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736209983; bh=+SaxVyF0sDaOL5ucJoWX7gQz6ZovelaAlkLAFovtLbU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fD0zzdrP5XtsKepZgkisYvjUvC5x/a85ZYM2YcnrF85V8UhC8Zw17wV6NJNiwBEoi vWmjhDobHEL3pkkNkVQ4K02qTt9aBg4qhuRxvXeFeiKRYdYUovcs5otyE9IiA3eb8T tylmv9gah9QBKG1Bk7jU+NiYbsSQYjEL9yB6Sl9BrgSeseOFnzuQqcYiHScE/neOM+ fvtlqsHWkUZpJ7fwU49wicSU07gwydydfUGTDEEyY+oNIyGjIIvy2iEgequaS3Pb9B NCWsMPsVo4BFPAiZA78xOiPUOr5rnvyIm+Du56uYSgu1byPumfPtAI81XFU2B9riCg s5bfz/jPjZ4/g== Date: Mon, 6 Jan 2025 16:33:00 -0800 From: Kees Cook To: Steven Rostedt Cc: LKML , Linus Torvalds , Andrew Morton , Petr Mladek , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky Subject: Re: [RFC][PATCH] printf: Harden accessing pointer dereference in vsprintf() Message-ID: <202501061632.76CF72FC@keescook> References: <20250106172722.5b6032e5@gandalf.local.home> 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-Disposition: inline In-Reply-To: <20250106172722.5b6032e5@gandalf.local.home> On Mon, Jan 06, 2025 at 05:27:22PM -0500, Steven Rostedt wrote: > From: Steven Rostedt > > For extra safety from crashing the kernel, add a > copy_from_kernel_nofault() in check_pointer_msg(). If it fails to read the > memory, then return "(efault)". > > This isn't full proof, as the length of the pointer being read could > possibly go into bad memory, but this should catch the majority of errors. > > Linus had suggested adding this kind of check[1]. This is a bit different > than Linus's solution as it utilizes copy_from_kernel_nofault() and doesn't > require calls to pagefault_disable() and extra labels. > > [1] https://lore.kernel.org/all/CAHk-=wh3cUC2a=yJv42HTjDLCp6VM+GTky+q65vV_Q33BeoxAg@mail.gmail.com/ > > Signed-off-by: Steven Rostedt (Google) Seems reasonable to me. Reviewed-by: Kees Cook -Kees -- Kees Cook