Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp385522yba; Fri, 12 Apr 2019 05:42:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqw86WZbrC2NphteALTgfZjY1M9DQFxw3Z7XmKqRqkHIrN5Q6xN53eA+zt/heXpWm6/dHM2Y X-Received: by 2002:a63:5953:: with SMTP id j19mr50589240pgm.260.1555072949760; Fri, 12 Apr 2019 05:42:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555072949; cv=none; d=google.com; s=arc-20160816; b=Q0k+fbo5HE8VK3htZqEGph9YDmT8Csy13zR/kXHznMIo/2jwGWjDxzZ8xLqexlh+IW iL7ccBxPC2Nvz1SoKshR7WjerlJyQZJK5Xm42QTViF4aWIoEKx1B9fDhIyKc41mkJ8mI VyN1+SSS3RldJBDCiC4H3vkbdofHA47wSgQ6+yfvtQOPk/pL9QDoQg1GBQ0/h/4Hg/Mv Fgj+Jn55Qlk75dYqvCMfclAo0GfVSiQxpIbebSQgUEO4dO6ojIBDOHOT4arv0tSoQzfV lIClC05A1HkH67WDRcgKvUVHaDxvJGqZVxHug8+3iS8YWiK3am7FY7AcPG3hxMNG0n9t MbKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=p52kOXmhLGjtcvgfeEttPUaATcwSZrXTsAytCT5CZmQ=; b=ocouNLSiF9OxQgjYaY1eKmLL4aOlEhhdDi2YIlLfQtdgW0k1yvlQrH/zdhYaYba4fL WJ5oeKHotwGMOzu1aSFoIklPJLP6XOVZucasRh/unBf02rMfyvlAiLb/kf/cjBQsN938 gQeTTEL3c0oJFCpAwkcwDILhrIk7auK2yIG+OwEpw+qdLvTbDktvLaRtq7Gd3aw4k1Hr ngv/vQGnwNVoxIkLt4Q8nj9tJG3dWuUzuQoYoeWUsRdH94Fyfi2se5b9xaQWVkT6z3/1 uCFAu3HSi7S62qnqk4MshG6U0+V3zP6hmab7iKSS6F5Vkg28k18swdqTP6LUUpSNnBBx kC3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pCGPDuwp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21si39139911pgj.513.2019.04.12.05.42.13; Fri, 12 Apr 2019 05:42:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pCGPDuwp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727826AbfDLMlh (ORCPT + 99 others); Fri, 12 Apr 2019 08:41:37 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:43874 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726714AbfDLMlg (ORCPT ); Fri, 12 Apr 2019 08:41:36 -0400 Received: by mail-ed1-f65.google.com with SMTP id w3so8186911edu.10; Fri, 12 Apr 2019 05:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p52kOXmhLGjtcvgfeEttPUaATcwSZrXTsAytCT5CZmQ=; b=pCGPDuwptJ2I02bpn583M+2mWoR5p0Bj85+dt6yO2eDZOc2c/27NsCieV1RbsVbZvW nVJYVpslVlrX0nAYFVH3fdkbIcnMppAEccBOoEGqF1Tgt0svQ81d2WhZGh4Xmb6cir04 YPnd4UYYwzzSF+ulH6Br046oszVKcxRdPL6D1/RuHvVNFz0H/7kG+L9k/UmMsSDBdJ5P YtCoiCWwt1T7QdO08F1kCl4YbRUfK2rwzhW5fwXn6ESPVJBs0v+lZsQLPyNgrvC4argd J86y00mn+9Peg8g9stLaHchC/QIVQxwaSttRn/Cc70cPiL/DQkLNixvs8Eji3nLVlnes mJBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=p52kOXmhLGjtcvgfeEttPUaATcwSZrXTsAytCT5CZmQ=; b=koItXI+E1KgqPxixBBO/AUTLmmUbai309t61JrD8k+drAIqOt/Lks8jIvBlI3UJB3q TXdYBwbIICQYMjKf0ZNKpPwZoAVku1Tq+o4V91Kj2f++Yo8pQfeeWv1ImkBvsJ3m9t4W b/sLzqBzqFtHE0e2a7JvzM7dBLllesL8/IAhtW+7KbE4W+VNupP9rEDccMitIa/Z9gwP o1QMUsgT8C9F6NBDlYmVOWHxq3jAWtCK8a2YGl6crzD0MHEs+pIMllZLvk2RUXF9ozTq hZd0YozSeLt3Y9UDuzClmiB5c7GAC+p9PYWa/v/bMRFbojhWoBjEan7U2nnyqJOgriPr VbHA== X-Gm-Message-State: APjAAAWotH0qJLtaGl9dF3q52EREnjpGNx1qAut51MvKv0F2AAj+Qt7O aCHyB+bDwP0Z8CgeSCND5LRE47Kstvc= X-Received: by 2002:a50:cb0a:: with SMTP id g10mr19987032edi.41.1555072894261; Fri, 12 Apr 2019 05:41:34 -0700 (PDT) Received: from neptune.fritz.box ([178.19.216.175]) by smtp.gmail.com with ESMTPSA id b3sm5070487ejp.80.2019.04.12.05.41.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2019 05:41:33 -0700 (PDT) From: Alban Crequy X-Google-Original-From: Alban Crequy To: ast@kernel.org, daniel@iogearbox.net Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, alban@kinvolk.io, iago@kinvolk.io Subject: [PATCH bpf v2] tools: bpftool: fix infinite loop in map create Date: Fri, 12 Apr 2019 14:40:50 +0200 Message-Id: <20190412124050.32120-1-alban@kinvolk.io> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alban Crequy "bpftool map create" has an infinite loop on "while (argc)". The error case is missing. Symptoms: when forgetting to type the keyword 'type' in front of 'hash': $ sudo bpftool map create /sys/fs/bpf/dir/foobar hash key 8 value 8 entries 128 (infinite loop, taking all the CPU) ^C After the patch: $ sudo bpftool map create /sys/fs/bpf/dir/foobar hash key 8 value 8 entries 128 Error: unknown arg hash Fixes: 0b592b5a01be ("tools: bpftool: add map create command") Signed-off-by: Alban Crequy --- Changes in v2: - Explain the cause of the bug in commitmsg - Add the "fixes" line in the commitmsg (Jakub's review) - Rebase on the bpf tree v1 was initially based on bpf-next and submitted on https://marc.info/?l=linux-kernel&m=155310327709613&w=2 --- tools/bpf/bpftool/map.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c index 05b029b934a6..1ccc38718458 100644 --- a/tools/bpf/bpftool/map.c +++ b/tools/bpf/bpftool/map.c @@ -1151,6 +1151,9 @@ static int do_create(int argc, char **argv) return -1; } NEXT_ARG(); + } else { + p_err("unknown arg %s", *argv); + return -1; } } -- 2.20.1