Return-Path: Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j2148-0000C1-Rv for linux-um@lists.infradead.org; Wed, 12 Feb 2020 23:05:10 +0000 Received: by mail-pf1-x442.google.com with SMTP id j9so1972091pfa.8 for ; Wed, 12 Feb 2020 15:05:06 -0800 (PST) Date: Thu, 13 Feb 2020 08:05:02 +0900 Message-ID: From: Hajime Tazaki Subject: Re: [RFC v3 18/26] lkl tools: add test programs In-Reply-To: <20200212143229.3a557114@suse.de> References: <20200212143229.3a557114@suse.de> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-um" Errors-To: linux-um-bounces+geert=linux-m68k.org@lists.infradead.org To: ddiss@suse.de Cc: tavi.purdila@gmail.com, linux-kernel-library@freelists.org, linux-um@lists.infradead.org On Wed, 12 Feb 2020 22:32:29 +0900, David Disseldorp wrote: > Some minor comments on net-test... > > On Wed, 05 Feb 2020 23:46:39 +0900, Hajime Tazaki wrote: > > > +static int lkl_test_icmp(void) > > +{ > ... > > + icmp = malloc(sizeof(struct lkl_icmphdr *)); > > I think this should be sizeof(struct lkl_icmphdr) thanks, I'll fix this. > ... > > + 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. > > 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 linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um