Skip to contentSkip to conversation

lkl tools: add test programs

RFC Hajime Tazaki 1 participant 1 message Feb 12, 2020 1 message not in the archive User-mode Linux (UML)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 10 lines · David Disseldorp

Some minor comments on net-test...

Quoted 2 lines · Hajime Tazaki
(quoted diff) +2 -0
+static int lkl_test_icmp(void)
+{

...

Review

Quoted 1 line
(quoted diff) +1 -0
+	icmp = malloc(sizeof(struct lkl_icmphdr *));

I think this should be sizeof(struct lkl_icmphdr)

thanks, I'll fix this.

Quoted 13 lines

...

Review

Quoted 8 lines
(quoted diff) +8 -0
+	ret = lkl_sys_recv(sock, buf, sizeof(buf), LKL_MSG_DONTWAIT);
+	if (ret < 0) {
+		lkl_test_logf("recv error (%s)\n", lkl_strerror(ret));
+		return TEST_FAILURE;
+	}
+
+	iph = (struct lkl_iphdr *)buf;
+	icmp = (struct lkl_icmphdr *)(buf + iph->ihl * 4);

I realise this is test code, but IMO it still makes sense to do bounds checking here, e.g.

Quoted 10 lines
  pkt_len = ret;
  if (pkt_len < sizeof(struct lkl_iphdr)) {
          return TEST_FAILURE;
  }

  iph = (struct lkl_iphdr *)buf;
  icmphdr_off = iph->ihl * 4;
  if (pkt_len < icmphdr_off + sizeof(struct lkl_icmphdr)) {
          return TEST_FAILURE;
  }

thanks, I will fix this too in the next round.

-- Hajime

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um