From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 787CF32F770; Sat, 30 May 2026 18:35:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780166146; cv=none; b=R/f7qICFositiZCumPwxJV8Ydo07L3Pi3eWaWJ26QetQM4fl0YftuZacDDIPKokATBt+llOF/Tyzt8SrzsKkDzkch9OtRPm6cZBhua2kpA9MAKO1dNebFsG5tgJnl6Mvwz1WMa+5vYgeUnFpUEEzHK0KmSdJN+tpiZpfAwS2aHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780166146; c=relaxed/simple; bh=I9m4zj95Nvd7eJpphHBovcyztg/lrx2K+3BLglh6GMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GocRnrn/npUcOFGpwgtKiT8/wsgblzN4mUsYkP/mKxN1o6TLtcRODz3OQtTgKhiWh+0KQcsJfKSKUWRg6I/QMWKyceSrHlK5Vr4HpsqKca6gYYxRCf+XzU50+WuYvOMVYo7RISfVuYmkdjTFO76bw+xCTcfOV/intK+wS6CNi2A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fiiPlUfV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fiiPlUfV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAF871F00893; Sat, 30 May 2026 18:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780166145; bh=pyInA4EnVNpN8gqVpgU11ufGjPKdsoYq8A9riuBeOfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fiiPlUfVC7c+QR8mAX/d8dTHKLtIfcMy8kgIQosFcdI8FNOiKsY1Yyi1P3ni9PkHx LES70XE9K9DZQC7OLqekJ41P78NI82B3TUudPHV7rxMotlzMoc05MNsVV635EIMWcX pCASKN1Oq7xLxadV3QZI30/mBDuSIGCcYc2qTuyI= 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 5.10 288/589] vsock: fix buffer size clamping order Date: Sat, 30 May 2026 18:02:49 +0200 Message-ID: <20260530160232.512157171@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160224.570625122@linuxfoundation.org> References: <20260530160224.570625122@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 5.10-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 @@ -1642,12 +1642,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);