Skip to content

Commit 31ec70a

Browse files
dhowellskuba-moo
authored andcommitted
rxrpc: Fix over large frame size warning
Under some circumstances, the compiler will emit the following warning for rxrpc_send_response(): net/rxrpc/output.c: In function 'rxrpc_send_response': net/rxrpc/output.c:974:1: warning: the frame size of 1160 bytes is larger than 1024 bytes This occurs because the local variables include a 16-element scatterlist array and a 16-element bio_vec array. It's probably not actually a problem as this function is only called by the rxrpc I/O thread function in a kernel thread and there won't be much on the stack before it. Fix this by overlaying the bio_vec array over the kvec array in the rxrpc_local struct. There is one of these per I/O thread and the kvec array is intended for pointing at bits of a packet to be transmitted, typically a DATA or an ACK packet. As packets for a local endpoint are only transmitted by its specific I/O thread, there can be no race, and so overlaying this bit of memory should be no problem. Fixes: 5800b1c ("rxrpc: Allow CHALLENGEs to the passed to the app for a RESPONSE") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: Simon Horman <[email protected]> cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3ef0743 commit 31ec70a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

net/rxrpc/ar-internal.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,15 @@ struct rxrpc_local {
361361
struct list_head new_client_calls; /* Newly created client calls need connection */
362362
spinlock_t client_call_lock; /* Lock for ->new_client_calls */
363363
struct sockaddr_rxrpc srx; /* local address */
364-
/* Provide a kvec table sufficiently large to manage either a DATA
365-
* packet with a maximum set of jumbo subpackets or a PING ACK padded
366-
* out to 64K with zeropages for PMTUD.
367-
*/
368-
struct kvec kvec[1 + RXRPC_MAX_NR_JUMBO > 3 + 16 ?
369-
1 + RXRPC_MAX_NR_JUMBO : 3 + 16];
364+
union {
365+
/* Provide a kvec table sufficiently large to manage either a
366+
* DATA packet with a maximum set of jumbo subpackets or a PING
367+
* ACK padded out to 64K with zeropages for PMTUD.
368+
*/
369+
struct kvec kvec[1 + RXRPC_MAX_NR_JUMBO > 3 + 16 ?
370+
1 + RXRPC_MAX_NR_JUMBO : 3 + 16];
371+
struct bio_vec bvec[3 + 16];
372+
};
370373
};
371374

372375
/*

net/rxrpc/output.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ void rxrpc_send_response(struct rxrpc_connection *conn, struct sk_buff *response
924924
{
925925
struct rxrpc_skb_priv *sp = rxrpc_skb(response);
926926
struct scatterlist sg[16];
927-
struct bio_vec bvec[16];
927+
struct bio_vec *bvec = conn->local->bvec;
928928
struct msghdr msg;
929929
size_t len = sp->resp.len;
930930
__be32 wserial;
@@ -938,6 +938,9 @@ void rxrpc_send_response(struct rxrpc_connection *conn, struct sk_buff *response
938938
if (ret < 0)
939939
goto fail;
940940
nr_sg = ret;
941+
ret = -EIO;
942+
if (WARN_ON_ONCE(nr_sg > ARRAY_SIZE(conn->local->bvec)))
943+
goto fail;
941944

942945
for (int i = 0; i < nr_sg; i++)
943946
bvec_set_page(&bvec[i], sg_page(&sg[i]), sg[i].length, sg[i].offset);

0 commit comments

Comments
 (0)