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 890572590 for ; Sun, 22 Jan 2023 15:17:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D66FC433EF; Sun, 22 Jan 2023 15:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1674400629; bh=eTjgamK+yx3q1F5he2qH1mGtxQr3KywMO2f6moXsJ94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nD68L9sTfrvRkLw7JGjnk71KyBT+K2ChLJkZ9Z8q/cGwT3Ztk60xMQiJnxJabOUzv LzfGXu3ajHUNNBvNGsopW5CSue153dUt6Qg4A9ZijnMnbgJJ7lYilvGQs+AQYtdGOn +EClO89TjcW/S5w6odEHU7P69IoTh8uTG7j9F+Pg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jordy Zomer , Linus Torvalds Subject: [PATCH 5.15 049/117] prlimit: do_prlimit needs to have a speculation check Date: Sun, 22 Jan 2023 16:03:59 +0100 Message-Id: <20230122150234.788511541@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230122150232.736358800@linuxfoundation.org> References: <20230122150232.736358800@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman commit 739790605705ddcf18f21782b9c99ad7d53a8c11 upstream. do_prlimit() adds the user-controlled resource value to a pointer that will subsequently be dereferenced. In order to help prevent this codepath from being used as a spectre "gadget" a barrier needs to be added after checking the range. Reported-by: Jordy Zomer Tested-by: Jordy Zomer Suggested-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/sys.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1575,6 +1575,8 @@ int do_prlimit(struct task_struct *tsk, if (resource >= RLIM_NLIMITS) return -EINVAL; + resource = array_index_nospec(resource, RLIM_NLIMITS); + if (new_rlim) { if (new_rlim->rlim_cur > new_rlim->rlim_max) return -EINVAL;