Skip to contentSkip to conversation

virtio-vsock: add max payload size config field

PATCH Superseded Laura Loghin 3 participants 5 messages Apr 21, 2022 – Jun 13, 2022

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 virtio-vsock: add max payload size config field

Added a new field to the vsock device config space that is limiting the size of the packet payload. This way the driver is not allowed to allocate huge buffers, and potentially fill up the entire memory.
Also defined a new feature bit for this, VIRTIO_VSOCK_F_SIZE_MAX, in order to keep backwards compatibility.

---
 virtio-vsock.tex | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
virtio-vsock.tex +24 -0
index d79984d..5db6110 100644
@@ -23,6 +23,10 @@ \subsection{Feature bits}\label{sec:Device Types / Socket Device / Feature bits}
 \begin{description}
 \item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported.
 \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported.
+\item[VIRTIO_VSOCK_F_SIZE_MAX (2)] Maximum size of the packet payload is in
+	\field{data_max_size}. If offered by the device, device advises driver
+	about the value of its maximum payload size. If negotiated, the driver uses
+	\field{data_max_size} as the maximum packet payload size value.
 \end{description}
 
 \subsection{Device configuration layout}\label{sec:Device Types / Socket Device / Device configuration layout}
@@ -32,6 +36,7 @@ \subsection{Device configuration layout}\label{sec:Device Types / Socket Device
 \begin{lstlisting}
 struct virtio_vsock_config {
 	le64 guest_cid;
+	le32 data_max_size;
 };
 \end{lstlisting}
 
@@ -57,6 +62,25 @@ \subsection{Device configuration layout}\label{sec:Device Types / Socket Device
 \hline
 \end{tabular}
 
+The following driver-read-only field, \field{data_max_size} only exists if
+VIRTIO_VSOCK_F_SIZE_MAX is set. This field specifies the maximum packet payload
+size for the driver to use.
+
+\devicenormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}
+
+The device MUST NOT change the value exposed through \field{data_max_size}.
+
+\drivernormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}
+
+A driver SHOULD negotiate VIRTIO_VSOCK_F_SIZE_MAX if the device offers it.
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, the receive buffers it
+supplies for a packet MUST have a total size that doesn't exceed the size
+\field{data_max_size} (plus header length).
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST  NOT transmit packets
+of size exceeding the value of \field{data_max_size} (plus header length).
+
 \subsection{Device Initialization}\label{sec:Device Types / Socket Device / Device Initialization}
 
 \begin{enumerate}
Signature · 23 lines
2.17.1




Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/
Reviewed-by on v3 1/1
#1 lore raw
Quoted 11 lines · Laura Loghin

Added a new field to the vsock device config space that is limiting the size of the packet payload. This way the driver is not allowed to allocate huge buffers, and potentially fill up the entire memory.
Also defined a new feature bit for this, VIRTIO_VSOCK_F_SIZE_MAX, in order to keep backwards compatibility.

---
virtio-vsock.tex | 24 ++++++++++++++++++++++++

1 file changed, 24 insertions(+)
Quoted 49 lines
virtio-vsock.tex +0 -0
index d79984d..5db6110 100644
@@ -23,6 +23,10 @@ \subsection{Feature bits}\label{sec:Device Types / Socket Device / Feature bits}
 \begin{description}

\item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported. \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported. +\item[VIRTIO_VSOCK_F_SIZE_MAX (2)] Maximum size of the packet payload is in

virtio-vsock.tex +3 -0
+	\field{data_max_size}. If offered by the device, device advises driver
+	about the value of its maximum payload size. If negotiated, the driver uses
+	\field{data_max_size} as the maximum packet payload size value.

\end{description}

\subsection{Device configuration layout}\label{sec:Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +1 -0
@@ -32,6 +36,7 @@ \subsection{Device configuration layout}\label{sec:Device Types / Socket Device
 \begin{lstlisting}
 struct virtio_vsock_config {
 	le64 guest_cid;
+	le32 data_max_size;
 };
 \end{lstlisting}
 
@@ -57,6 +62,25 @@ \subsection{Device configuration layout}\label{sec:Device Types / Socket Device

\hline
\end{tabular}

virtio-vsock.tex +19 -0
+The following driver-read-only field, \field{data_max_size} only exists if
+VIRTIO_VSOCK_F_SIZE_MAX is set. This field specifies the maximum packet payload
+size for the driver to use.
+
+\devicenormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}
+
+The device MUST NOT change the value exposed through \field{data_max_size}.
+
+\drivernormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}
+
+A driver SHOULD negotiate VIRTIO_VSOCK_F_SIZE_MAX if the device offers it.
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, the receive buffers it
+supplies for a packet MUST have a total size that doesn't exceed the size
+\field{data_max_size} (plus header length).
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST  NOT transmit packets
+of size exceeding the value of \field{data_max_size} (plus header length).
+

\subsection{Device Initialization}\label{sec:Device Types / Socket Device / Device Initialization}

Quoted 26 lines

\begin{enumerate}

Signature · 23 lines
2.17.1




Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

This publicly archived list offers a means to provide input to the OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and to minimize spam in the list archive, subscription is required before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

#2 lore raw
Quoted 119 lines · Stefano Garzarella

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.

Quoted 11 lines · Laura Loghin

Added a new field to the vsock device config space that is limiting the size of the packet payload. This way the driver is not allowed to allocate huge buffers, and potentially fill up the entire memory.
Also defined a new feature bit for this, VIRTIO_VSOCK_F_SIZE_MAX, in order to keep backwards compatibility.

---
virtio-vsock.tex | 24 ++++++++++++++++++++++++

1 file changed, 24 insertions(+)
Quoted 65 lines
virtio-vsock.tex +0 -0
index d79984d..5db6110 100644
@@ -23,6 +23,10 @@ \subsection{Feature bits}\label{sec:Device Types / 
 Socket Device / Feature bits}
 \begin{description}

\item[VIRTIO_VSOCK_F_STREAM (0)] stream socket type is supported. \item[VIRTIO_VSOCK_F_SEQPACKET (1)] seqpacket socket type is supported. +\item[VIRTIO_VSOCK_F_SIZE_MAX (2)] Maximum size of the packet payload is in
+      \field{data_max_size}. If offered by the device, device advises driver
+      about the value of its maximum payload size. If negotiated, the driver uses
+      \field{data_max_size} as the maximum packet payload size value. \end{description}

\subsection{Device configuration layout}\label{sec:Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +0 -0
@@ -32,6 +36,7 @@ \subsection{Device configuration 

layout}\label{sec:Device Types / Socket Device
\begin{lstlisting}
struct virtio_vsock_config {
      le64 guest_cid;
+      le32 data_max_size;
};
\end{lstlisting}

virtio-vsock.tex +0 -0
@@ -57,6 +62,25 @@ \subsection{Device configuration 

layout}\label{sec:Device Types / Socket Device
\hline
\end{tabular}

+The following driver-read-only field, \field{data_max_size} only exists if
+VIRTIO_VSOCK_F_SIZE_MAX is set. This field specifies the maximum packet payload

virtio-vsock.tex +3 -0
+size for the driver to use.
+
+\devicenormative{\subsubsection}{Device configuration layout}{Device 

Types / Socket Device / Device configuration layout}

virtio-vsock.tex +2 -0
+
+The device MUST NOT change the value exposed through 

\field{data_max_size}.
+
+\drivernormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +2 -0
+
+A driver SHOULD negotiate VIRTIO_VSOCK_F_SIZE_MAX if the device 

offers it.

virtio-vsock.tex +2 -0
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, the receive 

buffers it
+supplies for a packet MUST have a total size that doesn't exceed the size
+\field{data_max_size} (plus header length).

virtio-vsock.tex +2 -0
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST  NOT 

transmit packets
+of size exceeding the value of \field{data_max_size} (plus header
length).
+
\subsection{Device Initialization}\label{sec:Device Types / Socket Device / Device Initialization}

Quoted 26 lines

\begin{enumerate}

Signature · 23 lines
2.17.1




Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

This publicly archived list offers a means to provide input to the OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and to minimize spam in the list archive, subscription is required before posting.

Quoted 9 lines

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

Requesting a vote.
Fixes: https://github.com/oasis-tcs/virtio-spec/issues/140

Thank you,
Laura

Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.

#3 lore raw
In reply to Laura Loghin
Quoted 20 lines · Laura Loghin

Added a new field to the vsock device config space that is limiting the size of the packet payload. This way the driver is not allowed to allocate huge buffers, and potentially fill up the entire memory.
Also defined a new feature bit for this, VIRTIO_VSOCK_F_SIZE_MAX, in order to keep backwards compatibility.

---
 virtio-vsock.tex | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

+\devicenormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +7 -0
+
+The device MUST NOT change the value exposed through \field{data_max_size}.
+
+\drivernormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}
+
+A driver SHOULD negotiate VIRTIO_VSOCK_F_SIZE_MAX if the device offers it.
+

virtio-vsock.tex \subsection{Device configuration layout}\label{sec:Device Types / Socket Device · line 86

Quoted 10 lines
virtio-vsock.tex +7 -0
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, the receive buffers it
+supplies for a packet MUST have a total size that doesn't exceed the size
+\field{data_max_size} (plus header length).
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST  NOT transmit packets
+of size exceeding the value of \field{data_max_size} (plus header length).
+
 \subsection{Device Initialization}\label{sec:Device Types / Socket Device / Device Initialization}
 
 \begin{enumerate}

I think you need to hook up the two new sections in conformance.tex.

This publicly archived list offers a means to provide input to the OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and to minimize spam in the list archive, subscription is required before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

#4 lore raw
Quoted 35 lines · Cornelia Huck

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.

Quoted 29 lines · Laura Loghin

Added a new field to the vsock device config space that is limiting the size of the packet payload. This way the driver is not allowed to allocate huge buffers, and potentially fill up the entire memory.
Also defined a new feature bit for this, VIRTIO_VSOCK_F_SIZE_MAX, in order to keep backwards compatibility.

---
  virtio-vsock.tex | 24 ++++++++++++++++++++++++
  1 file changed, 24 insertions(+)

+\devicenormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}

virtio-vsock.tex +14 -0
+
+The device MUST NOT change the value exposed through \field{data_max_size}.
+
+\drivernormative{\subsubsection}{Device configuration layout}{Device Types / Socket Device / Device configuration layout}
+
+A driver SHOULD negotiate VIRTIO_VSOCK_F_SIZE_MAX if the device offers it.
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, the receive buffers it
+supplies for a packet MUST have a total size that doesn't exceed the size
+\field{data_max_size} (plus header length).
+
+If the driver negotiates VIRTIO_VSOCK_F_SIZE_MAX, it MUST  NOT transmit packets
+of size exceeding the value of \field{data_max_size} (plus header length).
+
  \subsection{Device Initialization}\label{sec:Device Types / Socket Device / Device Initialization}
Quoted 3 lines
Quoted 1 line

\begin{enumerate}

I think you need to hook up the two new sections in conformance.tex.

Hi,

Sorry, I was on vacation. Fixed inhttps://lists.oasis-open.org/archives/virtio-comment/202206/msg00030.html.

Thanks,

Laura

Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.