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 C6A044BCACA; Fri, 15 May 2026 16:24: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=1778862295; cv=none; b=Yqy0Dsmzg7DQZz3/UlwttYiDu2JbxRSxoYNPCIjm4v9Lo97H1voXBpORpFHQweLe59IcPWVYcN+gKGRxyL74bqK0DPRlC+RgvUAlmjGHvK5sOlRPyqlUA1dl/Mx5P5kjXQvglIVM5T2g5tYrI691hm35/DDBMHVPCRPeYpQvcII= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778862295; c=relaxed/simple; bh=F7zsZIdCX7miWLSHzSaCCOJvWvuqRwtu9EbX7mYipzM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i1Dwhb5XfGmz8eEtM9Fi4/ntyZ8iYTbBzjm/FXtN0EcmgvEcIcwAPnY2zsLhh4yMghmyDVSL2+m51YgxhRGDqfFimMOlUhJSk7EsNtzJG78PRhFlmfJ9D1RJqAKxv2BO1mcARrDh0EqyNcyEPzbg11NSxDmkAyhqTbQG7L4UtA8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KwsJVQdG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="KwsJVQdG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51683C2BCF5; Fri, 15 May 2026 16:24:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778862295; bh=F7zsZIdCX7miWLSHzSaCCOJvWvuqRwtu9EbX7mYipzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KwsJVQdGt00yfsy9AiuWZKnU4ej9oAYHUmq/CsNxHRDOk+oibgNcowZ4gtkAfdhlE SS2Mlt0Odm/pRapNoo6NazCTr/hWAHKdQOSqSqruwrdjRs2V4k6RtBuosAc8PiUBys YegZ80LK7NATt87m6BpU1irwoVrjAFY16Ek2C6uQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stefano Garzarella , Norbert Szetei , Jakub Kicinski , Luigi Leonardi Subject: [PATCH 6.18 182/188] vsock: fix buffer size clamping order Date: Fri, 15 May 2026 17:49:59 +0200 Message-ID: <20260515154701.288496751@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154657.309489048@linuxfoundation.org> References: <20260515154657.309489048@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Norbert Szetei commit d114bfdc9b76bf93b881e195b7ec957c14227bab upstream. In vsock_update_buffer_size(), the buffer size was being clamped to the maximum first, and then to the minimum. If a user sets a minimum buffer size larger than the maximum, the minimum check overrides the maximum check, inverting the constraint. This breaks the intended socket memory boundaries by allowing the vsk->buffer_size to grow beyond the configured vsk->buffer_max_size. Fix this by checking the minimum first, and then the maximum. This ensures the buffer size never exceeds the buffer_max_size. Fixes: b9f2b0ffde0c ("vsock: handle buffer_size sockopts in the core") Suggested-by: Stefano Garzarella Signed-off-by: Norbert Szetei Reviewed-by: Stefano Garzarella Link: https://patch.msgid.link/180118C5-8BCF-4A63-A305-4EE53A34AB9C@doyensec.com Signed-off-by: Jakub Kicinski Cc: Luigi Leonardi Signed-off-by: Greg Kroah-Hartman --- net/vmw_vsock/af_vsock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1846,12 +1846,12 @@ static void vsock_update_buffer_size(str const struct vsock_transport *transport, u64 val) { - if (val > vsk->buffer_max_size) - val = vsk->buffer_max_size; - if (val < vsk->buffer_min_size) val = vsk->buffer_min_size; + if (val > vsk->buffer_max_size) + val = vsk->buffer_max_size; + if (val != vsk->buffer_size && transport && transport->notify_buffer_size) transport->notify_buffer_size(vsk, &val);