Skip to content

Commit

Permalink
net: remove CONFIG_MCAST_TFTP
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Chris Packham <[email protected]>
Acked-by: Joe Hershberger <[email protected]>
  • Loading branch information
cpackham authored and jhershbe committed Jan 24, 2019
1 parent 1a4af5c commit 67bb984
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 273 deletions.
9 changes: 0 additions & 9 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -1429,15 +1429,6 @@ The following options need to be configured:
forwarded through a router.
(Environment variable "netmask")

- Multicast TFTP Mode:
CONFIG_MCAST_TFTP

Defines whether you want to support multicast TFTP as per
rfc-2090; for example to work with atftp. Lets lots of targets
tftp down the same boot image concurrently. Note: the Ethernet
driver in use must provide a function: mcast() to join/leave a
multicast group.

- BOOTP Recovery Mode:
CONFIG_BOOTP_RANDOM_DELAY

Expand Down
6 changes: 1 addition & 5 deletions drivers/net/rtl8139.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,10 @@ static void rtl_reset(struct eth_device *dev);
static int rtl_transmit(struct eth_device *dev, void *packet, int length);
static int rtl_poll(struct eth_device *dev);
static void rtl_disable(struct eth_device *dev);
#ifdef CONFIG_MCAST_TFTP/* This driver already accepts all b/mcast */
static int rtl_bcast_addr(struct eth_device *dev, const u8 *bcast_mac, u8 set)
static int rtl_bcast_addr(struct eth_device *dev, const u8 *bcast_mac, int join)
{
return (0);
}
#endif

static struct pci_device_id supported[] = {
{PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139},
Expand Down Expand Up @@ -229,9 +227,7 @@ int rtl8139_initialize(bd_t *bis)
dev->halt = rtl_disable;
dev->send = rtl_transmit;
dev->recv = rtl_poll;
#ifdef CONFIG_MCAST_TFTP
dev->mcast = rtl_bcast_addr;
#endif

eth_register (dev);

Expand Down
14 changes: 4 additions & 10 deletions drivers/net/tsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ static void tsec_configure_serdes(struct tsec_private *priv)
0, TBI_CR, CONFIG_TSEC_TBICR_SETTINGS);
}

#ifdef CONFIG_MCAST_TFTP

/* the 'way' for ethernet-CRC-32. Spliced in from Linux lib/crc32.c
* and this is the ethernet-crc method needed for TSEC -- and perhaps
* some other adapter -- hash tables
Expand Down Expand Up @@ -124,9 +122,10 @@ static u32 ether_crc(size_t len, unsigned char const *p)
* the entry.
*/
#ifndef CONFIG_DM_ETH
static int tsec_mcast_addr(struct eth_device *dev, const u8 *mcast_mac, u8 set)
static int tsec_mcast_addr(struct eth_device *dev, const u8 *mcast_mac,
int join)
#else
static int tsec_mcast_addr(struct udevice *dev, const u8 *mcast_mac, int set)
static int tsec_mcast_addr(struct udevice *dev, const u8 *mcast_mac, int join)
#endif
{
struct tsec_private *priv = (struct tsec_private *)dev->priv;
Expand All @@ -140,14 +139,13 @@ static int tsec_mcast_addr(struct udevice *dev, const u8 *mcast_mac, int set)

value = BIT(31 - whichbit);

if (set)
if (join)
setbits_be32(&regs->hash.gaddr0 + whichreg, value);
else
clrbits_be32(&regs->hash.gaddr0 + whichreg, value);

return 0;
}
#endif /* Multicast TFTP ? */

/*
* Initialized required registers to appropriate values, zeroing
Expand Down Expand Up @@ -745,9 +743,7 @@ static int tsec_initialize(bd_t *bis, struct tsec_info_struct *tsec_info)
dev->halt = tsec_halt;
dev->send = tsec_send;
dev->recv = tsec_recv;
#ifdef CONFIG_MCAST_TFTP
dev->mcast = tsec_mcast_addr;
#endif

/* Tell U-Boot to get the addr from the env */
for (i = 0; i < 6; i++)
Expand Down Expand Up @@ -887,9 +883,7 @@ static const struct eth_ops tsec_ops = {
.recv = tsec_recv,
.free_pkt = tsec_free_pkt,
.stop = tsec_halt,
#ifdef CONFIG_MCAST_TFTP
.mcast = tsec_mcast_addr,
#endif
};

static const struct udevice_id tsec_ids[] = {
Expand Down
3 changes: 0 additions & 3 deletions drivers/usb/gadget/ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -2579,9 +2579,6 @@ int usb_eth_initialize(bd_t *bi)
netdev->halt = usb_eth_halt;
netdev->priv = l_priv;

#ifdef CONFIG_MCAST_TFTP
#error not supported
#endif
eth_register(netdev);
return 0;
}
Expand Down
14 changes: 1 addition & 13 deletions include/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ struct eth_ops {
int (*recv)(struct udevice *dev, int flags, uchar **packetp);
int (*free_pkt)(struct udevice *dev, uchar *packet, int length);
void (*stop)(struct udevice *dev);
#ifdef CONFIG_MCAST_TFTP
int (*mcast)(struct udevice *dev, const u8 *enetaddr, int join);
#endif
int (*write_hwaddr)(struct udevice *dev);
int (*read_rom_hwaddr)(struct udevice *dev);
};
Expand Down Expand Up @@ -175,9 +173,7 @@ struct eth_device {
int (*send)(struct eth_device *, void *packet, int length);
int (*recv)(struct eth_device *);
void (*halt)(struct eth_device *);
#ifdef CONFIG_MCAST_TFTP
int (*mcast)(struct eth_device *, const u8 *enetaddr, u8 set);
#endif
int (*mcast)(struct eth_device *, const u8 *enetaddr, int join);
int (*write_hwaddr)(struct eth_device *);
struct eth_device *next;
int index;
Expand Down Expand Up @@ -286,11 +282,7 @@ extern void (*push_packet)(void *packet, int length);
int eth_rx(void); /* Check for received packets */
void eth_halt(void); /* stop SCC */
const char *eth_get_name(void); /* get name of current device */

#ifdef CONFIG_MCAST_TFTP
int eth_mcast_join(struct in_addr mcast_addr, int join);
#endif


/**********************************************************************/
/*
Expand Down Expand Up @@ -577,10 +569,6 @@ extern struct in_addr net_ntp_server; /* the ip address to NTP */
extern int net_ntp_time_offset; /* offset time from UTC */
#endif

#if defined(CONFIG_MCAST_TFTP)
extern struct in_addr net_mcast_addr;
#endif

/* Initialize the network adapter */
void net_init(void);
int net_loop(enum proto_t);
Expand Down
2 changes: 0 additions & 2 deletions net/eth-uclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions net/eth_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down
7 changes: 0 additions & 7 deletions net/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
Loading

0 comments on commit 67bb984

Please sign in to comment.