Skip to content

Commit 31642e7

Browse files
edumazetkuba-moo
authored andcommitted
netrom: fix info-leak in nr_write_internal()
Simon Kapadia reported the following issue: <quote> The Online Amateur Radio Community (OARC) has recently been experimenting with building a nationwide packet network in the UK. As part of our experimentation, we have been testing out packet on 300bps HF, and playing with net/rom. For HF packet at this baud rate you really need to make sure that your MTU is relatively low; AX.25 suggests a PACLEN of 60, and a net/rom PACLEN of 40 to go with that. However the Linux net/rom support didn't work with a low PACLEN; the mkiss module would truncate packets if you set the PACLEN below about 200 or so, e.g.: Apr 19 14:00:51 radio kernel: [12985.747310] mkiss: ax1: truncating oversized transmit packet! This didn't make any sense to me (if the packets are smaller why would they be truncated?) so I started investigating. I looked at the packets using ethereal, and found that many were just huge compared to what I would expect. A simple net/rom connection request packet had the request and then a bunch of what appeared to be random data following it: </quote> Simon provided a patch that I slightly revised: Not only we must not use skb_tailroom(), we also do not want to count NR_NETWORK_LEN twice. Fixes: 1da177e ("Linux-2.6.12-rc2") Co-Developed-by: Simon Kapadia <[email protected]> Signed-off-by: Simon Kapadia <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Tested-by: Simon Kapadia <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ffb3322 commit 31642e7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/netrom/nr_subr.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void nr_write_internal(struct sock *sk, int frametype)
123123
unsigned char *dptr;
124124
int len, timeout;
125125

126-
len = NR_NETWORK_LEN + NR_TRANSPORT_LEN;
126+
len = NR_TRANSPORT_LEN;
127127

128128
switch (frametype & 0x0F) {
129129
case NR_CONNREQ:
@@ -141,15 +141,16 @@ void nr_write_internal(struct sock *sk, int frametype)
141141
return;
142142
}
143143

144-
if ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL)
144+
skb = alloc_skb(NR_NETWORK_LEN + len, GFP_ATOMIC);
145+
if (!skb)
145146
return;
146147

147148
/*
148149
* Space for AX.25 and NET/ROM network header
149150
*/
150151
skb_reserve(skb, NR_NETWORK_LEN);
151152

152-
dptr = skb_put(skb, skb_tailroom(skb));
153+
dptr = skb_put(skb, len);
153154

154155
switch (frametype & 0x0F) {
155156
case NR_CONNREQ:

0 commit comments

Comments
 (0)