summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorChris Packham <judge.packham@gmail.com>2018-11-26 21:00:29 +1300
committerJoe Hershberger <joe.hershberger@ni.com>2019-01-24 11:35:30 -0600
commit67bb984249442378ebb6a0eb68b6b0dd67dfbe72 (patch)
tree0a7d701e1fb79d59c7093d95a21d738027377e3e /net
parent1a4af5c562fdb9f5a884a53f136f2b2075ffd1d8 (diff)
downloadu-boot-67bb984249442378ebb6a0eb68b6b0dd67dfbe72.tar.gz
net: remove CONFIG_MCAST_TFTP
No mainline board enables CONFIG_MCAST_TFTP and there have been compilation issues with the code for some time. Additionally, it has a potential buffer underrun issue (reported as a side note in CVE-2018-18439). Remove the multicast TFTP code but keep the driver API for the future addition of IPv6. Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Signed-off-by: Chris Packham <judge.packham@gmail.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'net')
-rw-r--r--net/eth-uclass.c2
-rw-r--r--net/eth_legacy.c4
-rw-r--r--net/net.c7
-rw-r--r--net/tftp.c219
4 files changed, 0 insertions, 232 deletions
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 91d861be41..2ef20df192 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -476,10 +476,8 @@ static int eth_post_probe(struct udevice *dev)
ops->free_pkt += gd->reloc_off;
if (ops->stop)
ops->stop += gd->reloc_off;
-#ifdef CONFIG_MCAST_TFTP
if (ops->mcast)
ops->mcast += gd->reloc_off;
-#endif
if (ops->write_hwaddr)
ops->write_hwaddr += gd->reloc_off;
if (ops->read_rom_hwaddr)
diff --git a/net/eth_legacy.c b/net/eth_legacy.c
index d2e16b8fa3..e250a430f3 100644
--- a/net/eth_legacy.c
+++ b/net/eth_legacy.c
@@ -291,7 +291,6 @@ int eth_initialize(void)
return num_devices;
}
-#ifdef CONFIG_MCAST_TFTP
/* Multicast.
* mcast_addr: multicast ipaddr from which multicast Mac is made
* join: 1=join, 0=leave.
@@ -310,9 +309,6 @@ int eth_mcast_join(struct in_addr mcast_ip, int join)
return eth_current->mcast(eth_current, mcast_mac, join);
}
-#endif
-
-
int eth_init(void)
{
struct eth_device *old_current;
diff --git a/net/net.c b/net/net.c
index e9f7a7d85e..58b0417cbe 100644
--- a/net/net.c
+++ b/net/net.c
@@ -131,10 +131,6 @@ struct in_addr net_dns_server;
struct in_addr net_dns_server2;
#endif
-#ifdef CONFIG_MCAST_TFTP /* Multicast TFTP */
-struct in_addr net_mcast_addr;
-#endif
-
/** END OF BOOTP EXTENTIONS **/
/* Our ethernet address */
@@ -1216,9 +1212,6 @@ void net_process_received_packet(uchar *in_packet, int len)
dst_ip = net_read_ip(&ip->ip_dst);
if (net_ip.s_addr && dst_ip.s_addr != net_ip.s_addr &&
dst_ip.s_addr != 0xFFFFFFFF) {
-#ifdef CONFIG_MCAST_TFTP
- if (net_mcast_addr != dst_ip)
-#endif
return;
}
/* Read source IP address for later use */
diff --git a/net/tftp.c b/net/tftp.c
index a9335b1b7e..8fab6d2650 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -140,36 +140,6 @@ static char tftp_filename[MAX_LEN];
static unsigned short tftp_block_size = TFTP_BLOCK_SIZE;
static unsigned short tftp_block_size_option = TFTP_MTU_BLOCKSIZE;
-#ifdef CONFIG_MCAST_TFTP
-#include <malloc.h>
-#define MTFTP_BITMAPSIZE 0x1000
-static unsigned *tftp_mcast_bitmap;
-static int tftp_mcast_prev_hole;
-static int tftp_mcast_bitmap_size = MTFTP_BITMAPSIZE;
-static int tftp_mcast_disabled;
-static int tftp_mcast_master_client;
-static int tftp_mcast_active;
-static int tftp_mcast_port;
-/* can get 'last' block before done..*/
-static ulong tftp_mcast_ending_block;
-
-static void parse_multicast_oack(char *pkt, int len);
-
-static void mcast_cleanup(void)
-{
- if (net_mcast_addr)
- eth_mcast_join(net_mcast_addr, 0);
- if (tftp_mcast_bitmap)
- free(tftp_mcast_bitmap);
- tftp_mcast_bitmap = NULL;
- net_mcast_addr.s_addr = 0;
- tftp_mcast_active = 0;
- tftp_mcast_port = 0;
- tftp_mcast_ending_block = -1;
-}
-
-#endif /* CONFIG_MCAST_TFTP */
-
static inline int store_block(int block, uchar *src, unsigned int len)
{
ulong offset = block * tftp_block_size + tftp_block_wrap_offset;
@@ -211,10 +181,6 @@ static inline int store_block(int block, uchar *src, unsigned int len)
memcpy(ptr, src, len);
unmap_sysmem(ptr);
}
-#ifdef CONFIG_MCAST_TFTP
- if (tftp_mcast_active)
- ext2_set_bit(block, tftp_mcast_bitmap);
-#endif
if (net_boot_file_size < newsize)
net_boot_file_size = newsize;
@@ -292,9 +258,6 @@ static void show_block_marker(void)
static void restart(const char *msg)
{
printf("\n%s; starting again\n", msg);
-#ifdef CONFIG_MCAST_TFTP
- mcast_cleanup();
-#endif
net_start_again();
}
@@ -349,12 +312,6 @@ static void tftp_send(void)
int len = 0;
ushort *s;
-#ifdef CONFIG_MCAST_TFTP
- /* Multicast TFTP.. non-MasterClients do not ACK data. */
- if (tftp_mcast_active && tftp_state == STATE_DATA &&
- tftp_mcast_master_client == 0)
- return;
-#endif
/*
* We will always be sending some sort of packet, so
* cobble together the packet headers now.
@@ -389,30 +346,10 @@ static void tftp_send(void)
/* try for more effic. blk size */
pkt += sprintf((char *)pkt, "blksize%c%d%c",
0, tftp_block_size_option, 0);
-#ifdef CONFIG_MCAST_TFTP
- /* Check all preconditions before even trying the option */
- if (!tftp_mcast_disabled) {
- tftp_mcast_bitmap = malloc(tftp_mcast_bitmap_size);
- if (tftp_mcast_bitmap && eth_get_dev()->mcast) {
- free(tftp_mcast_bitmap);
- tftp_mcast_bitmap = NULL;
- pkt += sprintf((char *)pkt, "multicast%c%c",
- 0, 0);
- }
- }
-#endif /* CONFIG_MCAST_TFTP */
len = pkt - xp;
break;
case STATE_OACK:
-#ifdef CONFIG_MCAST_TFTP
- /* My turn! Start at where I need blocks I missed. */
- if (tftp_mcast_active)
- tftp_cur_block = ext2_find_next_zero_bit(
- tftp_mcast_bitmap,
- tftp_mcast_bitmap_size * 8, 0);
- /* fall through */
-#endif
case STATE_RECV_WRQ:
case STATE_DATA:
@@ -482,10 +419,6 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
int i;
if (dest != tftp_our_port) {
-#ifdef CONFIG_MCAST_TFTP
- if (tftp_mcast_active &&
- (!tftp_mcast_port || dest != tftp_mcast_port))
-#endif
return;
}
if (tftp_state != STATE_SEND_RRQ && src != tftp_remote_port &&
@@ -566,12 +499,6 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
}
#endif
}
-#ifdef CONFIG_MCAST_TFTP
- parse_multicast_oack((char *)pkt, len - 1);
- if ((tftp_mcast_active) && (!tftp_mcast_master_client))
- tftp_state = STATE_DATA; /* passive.. */
- else
-#endif
#ifdef CONFIG_CMD_TFTPPUT
if (tftp_put_active) {
/* Get ready to send the first block */
@@ -599,11 +526,6 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
tftp_remote_port = src;
new_transfer();
-#ifdef CONFIG_MCAST_TFTP
- if (tftp_mcast_active) { /* start!=1 common if mcast */
- tftp_prev_block = tftp_cur_block - 1;
- } else
-#endif
if (tftp_cur_block != 1) { /* Assertion */
puts("\nTFTP error: ");
printf("First block is not block 1 (%ld)\n",
@@ -633,44 +555,8 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
* Acknowledge the block just received, which will prompt
* the remote for the next one.
*/
-#ifdef CONFIG_MCAST_TFTP
- /* if I am the MasterClient, actively calculate what my next
- * needed block is; else I'm passive; not ACKING
- */
- if (tftp_mcast_active) {
- if (len < tftp_block_size) {
- tftp_mcast_ending_block = tftp_cur_block;
- } else if (tftp_mcast_master_client) {
- tftp_mcast_prev_hole = ext2_find_next_zero_bit(
- tftp_mcast_bitmap,
- tftp_mcast_bitmap_size * 8,
- tftp_mcast_prev_hole);
- tftp_cur_block = tftp_mcast_prev_hole;
- if (tftp_cur_block >
- ((tftp_mcast_bitmap_size * 8) - 1)) {
- debug("tftpfile too big\n");
- /* try to double it and retry */
- tftp_mcast_bitmap_size <<= 1;
- mcast_cleanup();
- net_start_again();
- return;
- }
- tftp_prev_block = tftp_cur_block;
- }
- }
-#endif
tftp_send();
-#ifdef CONFIG_MCAST_TFTP
- if (tftp_mcast_active) {
- if (tftp_mcast_master_client &&
- (tftp_cur_block >= tftp_mcast_ending_block)) {
- puts("\nMulticast tftp done\n");
- mcast_cleanup();
- net_set_state(NETLOOP_SUCCESS);
- }
- } else
-#endif
if (len < tftp_block_size)
tftp_complete();
break;
@@ -693,9 +579,6 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
case TFTP_ERR_FILE_ALREADY_EXISTS:
default:
puts("Starting again\n\n");
-#ifdef CONFIG_MCAST_TFTP
- mcast_cleanup();
-#endif
net_start_again();
break;
}
@@ -873,9 +756,6 @@ void tftp_start(enum proto_t protocol)
memset(net_server_ethaddr, 0, 6);
/* Revert tftp_block_size to dflt */
tftp_block_size = TFTP_BLOCK_SIZE;
-#ifdef CONFIG_MCAST_TFTP
- mcast_cleanup();
-#endif
#ifdef CONFIG_TFTP_TSIZE
tftp_tsize = 0;
tftp_tsize_num_hash = 0;
@@ -924,102 +804,3 @@ void tftp_start_server(void)
}
#endif /* CONFIG_CMD_TFTPSRV */
-#ifdef CONFIG_MCAST_TFTP
-/*
- * Credits: atftp project.
- */
-
-/*
- * Pick up BcastAddr, Port, and whether I am [now] the master-client.
- * Frame:
- * +-------+-----------+---+-------~~-------+---+
- * | opc | multicast | 0 | addr, port, mc | 0 |
- * +-------+-----------+---+-------~~-------+---+
- * The multicast addr/port becomes what I listen to, and if 'mc' is '1' then
- * I am the new master-client so must send ACKs to DataBlocks. If I am not
- * master-client, I'm a passive client, gathering what DataBlocks I may and
- * making note of which ones I got in my bitmask.
- * In theory, I never go from master->passive..
- * .. this comes in with pkt already pointing just past opc
- */
-static void parse_multicast_oack(char *pkt, int len)
-{
- int i;
- struct in_addr addr;
- char *mc_adr;
- char *port;
- char *mc;
-
- mc_adr = NULL;
- port = NULL;
- mc = NULL;
- /* march along looking for 'multicast\0', which has to start at least
- * 14 bytes back from the end.
- */
- for (i = 0; i < len - 14; i++)
- if (strcmp(pkt + i, "multicast") == 0)
- break;
- if (i >= (len - 14)) /* non-Multicast OACK, ign. */
- return;
-
- i += 10; /* strlen multicast */
- mc_adr = pkt + i;
- for (; i < len; i++) {
- if (*(pkt + i) == ',') {
- *(pkt + i) = '\0';
- if (port) {
- mc = pkt + i + 1;
- break;
- } else {
- port = pkt + i + 1;
- }
- }
- }
- if (!port || !mc_adr || !mc)
- return;
- if (tftp_mcast_active && tftp_mcast_master_client) {
- printf("I got a OACK as master Client, WRONG!\n");
- return;
- }
- /* ..I now accept packets destined for this MCAST addr, port */
- if (!tftp_mcast_active) {
- if (tftp_mcast_bitmap) {
- printf("Internal failure! no mcast.\n");
- free(tftp_mcast_bitmap);
- tftp_mcast_bitmap = NULL;
- tftp_mcast_disabled = 1;
- return;
- }
- /* I malloc instead of pre-declare; so that if the file ends
- * up being too big for this bitmap I can retry
- */
- tftp_mcast_bitmap = malloc(tftp_mcast_bitmap_size);
- if (!tftp_mcast_bitmap) {
- printf("No bitmap, no multicast. Sorry.\n");
- tftp_mcast_disabled = 1;
- return;
- }
- memset(tftp_mcast_bitmap, 0, tftp_mcast_bitmap_size);
- tftp_mcast_prev_hole = 0;
- tftp_mcast_active = 1;
- }
- addr = string_to_ip(mc_adr);
- if (net_mcast_addr.s_addr != addr.s_addr) {
- if (net_mcast_addr.s_addr)
- eth_mcast_join(net_mcast_addr, 0);
- net_mcast_addr = addr;
- if (eth_mcast_join(net_mcast_addr, 1)) {
- printf("Fail to set mcast, revert to TFTP\n");
- tftp_mcast_disabled = 1;
- mcast_cleanup();
- net_start_again();
- }
- }
- tftp_mcast_master_client = simple_strtoul((char *)mc, NULL, 10);
- tftp_mcast_port = (unsigned short)simple_strtoul(port, NULL, 10);
- printf("Multicast: %s:%d [%d]\n", mc_adr, tftp_mcast_port,
- tftp_mcast_master_client);
- return;
-}
-
-#endif /* Multicast TFTP */