Thread (12 messages) flat view 12 messages, 3 authors, 2025-08-10

Re: [PATCH net] rds: Fix endian annotations across various assignments

From: Al Viro <viro@zeniv.linux.org.uk>
Date: 2025-08-10 18:27:55
Also in: linux-rdma, lkml

On Sun, Aug 10, 2025 at 07:25:06PM +0100, Al Viro wrote:
On Sun, Aug 10, 2025 at 06:47:05PM +0100, Al Viro wrote:
quoted
quoted
 		switch (type) {
 		case RDS_EXTHDR_NPATHS:
 			conn->c_npaths = min_t(int, RDS_MPATH_WORKERS,
-					       be16_to_cpu(buffer.rds_npaths));
+					      (__force __u16)buffer.rds_npaths);
No.  It will break on little-endian.  That's over-the-wire data you are
dealing with; it's *NOT* going to be host-endian.  Fix the buggered
annotations instead.
PS: be16_to_cpu() is not the same thing as a cast.  On a big-endian box,
a 16bit number 1000 (0x3e8) is stored as {3, 0xe8}; on a little-endian it's
{3, 0xe8} instead; {0xe8, 3} means 59395 there (0xe8 * 256 + 3).
  ^^^^^^^^           ^^^^^^^^^
  {0xe8, 3}          {3, 0xe8}

Sorry, buggered editing.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help