From patchwork Mon Nov 30 00:21:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 335075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D08BC64E7B for ; Mon, 30 Nov 2020 00:22:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 148832076C for ; Mon, 30 Nov 2020 00:22:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="iJz8meKP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728466AbgK3AWg (ORCPT ); Sun, 29 Nov 2020 19:22:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726470AbgK3AWg (ORCPT ); Sun, 29 Nov 2020 19:22:36 -0500 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76838C0613D2 for ; Sun, 29 Nov 2020 16:21:50 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id x15so5497899pll.2 for ; Sun, 29 Nov 2020 16:21:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tSQCaHe9eHAYQ8w7aCqFlbQul1fr8oCPecfQJAvAlxU=; b=iJz8meKPna7wJxCP5NIKE7tAyyXNq3bykaNzq2fFmlVlih1DfupvGcMvBVci3aJV74 OHCnNZeae1sARqJuM+GNq7tLpUGwtZu2er0s9Wnb5agof3izImPkhHIWv9timdtZw+vJ FknUkp2++FLxpDZ0VQ3OnUWMQyppItrOsOlQRuJtUDpor2kGo5WH60lXfWskBRTfBnG+ F7wkSm+6/SSJaFHBo2OK+DEemBaKabeSrrfPlLMvMCp6YIAjbsQ2olG2T9043s4HddH3 fXsl/m+3fvLKoD+PY3uqMJiZoVHlrAaRYlX/mjRwDa7AijbHuK8ZLWWPPZKkppfU5+zj sy6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tSQCaHe9eHAYQ8w7aCqFlbQul1fr8oCPecfQJAvAlxU=; b=O/2hLue7LqCDjXc4wdxPq0yZQNtzf+bvrVIrXntkHgpZiEXE2YYTyE1dqAz1Pup24o rAvwL3/CwSAeIcmPbfDWcgjRqwlpyKTE+kfHZLjR42Cy7VLKRGuEIFYy1DrLqxY8/xeK FpQj4onBBpEl1joA5CQ4xmWpigZWBf7X+X89WwuhpopylCrsf+aDkbNvPB1Y/sNeQYsq Lwcs4Q80T7n7ECxc2CUP5A95l/J75Gep0foWwwMBcKrytexClcwmpRYNyi9FRiUAO2E1 Pd4wlJJyzdKiBQG2W+UA440SPPXET70FDqcmYHl9KICyIGifyOdphj03JGUCaE9qHesv Hs3w== X-Gm-Message-State: AOAM531bBk6O8uxF7EOM7JwYl8ygkrYy2izgcEtnL33B2ddnCrswdBNP fEOaYQGt5iZ+dCU1WAAoFOIEh/Hdl8ep9a9X X-Google-Smtp-Source: ABdhPJzH00LHTn//hPtaXRYXjy7Q4gros1gHEWSqOjnyHGB0DTQxXMVZ/sh7OlEoEp5TltGo3cvjKQ== X-Received: by 2002:a17:902:c104:b029:da:5206:8b9b with SMTP id 4-20020a170902c104b02900da52068b9bmr11106990pli.46.1606695709630; Sun, 29 Nov 2020 16:21:49 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id d3sm20746129pji.26.2020.11.29.16.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 16:21:48 -0800 (PST) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger , shalomt@mellanox.com Subject: [PATCH 1/5] devlink: fix uninitialized warning Date: Sun, 29 Nov 2020 16:21:31 -0800 Message-Id: <20201130002135.6537-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201130002135.6537-1-stephen@networkplumber.org> References: <20201130002135.6537-1-stephen@networkplumber.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org GCC-10 complains about uninitialized variable. devlink.c: In function ‘cmd_dev’: devlink.c:2803:12: warning: ‘val_u32’ may be used uninitialized in this function [-Wmaybe-uninitialized] 2803 | val_u16 = val_u32; | ~~~~~~~~^~~~~~~~~ devlink.c:2747:11: note: ‘val_u32’ was declared here 2747 | uint32_t val_u32; | ^~~~~~~ This is a false positive because it can't figure out the control flow when the parse returns error. Fixes: 2557dca2b028 ("devlink: Add string to uint{8,16,32} conversion for generic parameters") Cc: shalomt@mellanox.com Signed-off-by: Stephen Hemminger --- devlink/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 1ff865bc5c22..ca99732efd00 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -2744,7 +2744,7 @@ static int cmd_dev_param_set(struct dl *dl) struct param_ctx ctx = {}; struct nlmsghdr *nlh; bool conv_exists; - uint32_t val_u32; + uint32_t val_u32 = 0; uint16_t val_u16; uint8_t val_u8; bool val_bool; From patchwork Mon Nov 30 00:21:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 335073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DF05C64E7D for ; Mon, 30 Nov 2020 00:22:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3629D2073C for ; Mon, 30 Nov 2020 00:22:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="e4z8twir" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728537AbgK3AWi (ORCPT ); Sun, 29 Nov 2020 19:22:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726470AbgK3AWi (ORCPT ); Sun, 29 Nov 2020 19:22:38 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23C4CC0613D3 for ; Sun, 29 Nov 2020 16:21:52 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id u2so5476204pls.10 for ; Sun, 29 Nov 2020 16:21:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fKMan7oWGvWyjqMhG7qMLjXbclAI34cwErrXXBHsZqg=; b=e4z8twirx+GIHIP3GV6Nd2w33uGii2KiSZiH37qGJSBmqifDHgfZhQcdI12WJUDT46 k0zWaJtXn4WKVa6+n6xnJVWMjWmpeEQEXgEuWga0DeppUgSaNRVvzNeFXzZHywtAOaWV Uii9oedA5NQDuVPa6KEkMDNok9WhzETeRxcgWhnfWHSuVZ8rz3cJZgSXrNKfUKdxrGON 93oOm1d6Rxgehm0QkcXGB8pKB+APeQhPk8l0IQtdb+sBITEp7sCxffRuO8CSuXQzyzdo LOQvZiXpcaAZaZfMAwJtxrItYVVjaXxonWdKVTO4c0qqOTSAO3D9SCICgqXHbXZYY7Yi 1P3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fKMan7oWGvWyjqMhG7qMLjXbclAI34cwErrXXBHsZqg=; b=qS4xYq8FSrcqfaTQF8lpon7iDlCIktNdmn5/nV83MqFf8ArZZGNFX02lW6RlfhVmlB zwmJlg6y9/aO6n0al38dVBhIvt4EUW4hri/aMt+b1WfSBLFqf9jmeDgnQO54ASNnD2sQ pa65ihBsJ5VZlIMLcIYJU99dgINtKictlBIDP1Tprf30aA6nTbzVleyKPPqB0ueE7cIo bdFHTVPRuyvx43kBbG/+r8d8OgD/byIUaBZ/gFOu4IJWXgcQOIIMxCYhcJCmXCk0S4xD 2vQSlRTQTnrk2XPrqoxZGfNIhr6T/eZs1YzAHu9rzfh3lkcWV3JIC2odjs26faYtPNmp odAg== X-Gm-Message-State: AOAM531xFQPPs2Zdf2uAaGofjwKhehPx7XmTgkqexSaRiOITqDfKU1Fy 2GySfG8dZNj1oIhp/cr9v+SNpPA9okDXumKc X-Google-Smtp-Source: ABdhPJyqJ2m2lMIcuckfrHh43XYHph7ECe2ig3XckhHLGVp7j/QHOkuM3Y4UhOwGQf5LgIvb1yKKPw== X-Received: by 2002:a17:902:eb53:b029:d9:e57a:e402 with SMTP id i19-20020a170902eb53b02900d9e57ae402mr16398047pli.85.1606695711236; Sun, 29 Nov 2020 16:21:51 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id d3sm20746129pji.26.2020.11.29.16.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 16:21:50 -0800 (PST) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger , nikolay@cumulusnetworks.com Subject: [PATCH 2/5] bridge: fix string length warning Date: Sun, 29 Nov 2020 16:21:32 -0800 Message-Id: <20201130002135.6537-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201130002135.6537-1-stephen@networkplumber.org> References: <20201130002135.6537-1-stephen@networkplumber.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Gcc-10 complains about possible string length overflow. This can't happen Ethernet address format is always limited to 18 characters or less. Just resize the temp buffer. Fixes: 70dfb0b8836d ("iplink: bridge: export bridge_id and designated_root") Cc: nikolay@cumulusnetworks.com Signed-off-by: Stephen Hemminger --- ip/iplink_bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c index 3e81aa059cb3..d12fd0558f7d 100644 --- a/ip/iplink_bridge.c +++ b/ip/iplink_bridge.c @@ -74,7 +74,7 @@ static void explain(void) void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf, size_t len) { - char eaddr[32]; + char eaddr[18]; ether_ntoa_r((const struct ether_addr *)id->addr, eaddr); snprintf(buf, len, "%.2x%.2x.%s", id->prio[0], id->prio[1], eaddr); From patchwork Mon Nov 30 00:21:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 335715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D096FC64E90 for ; Mon, 30 Nov 2020 00:22:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 858B221973 for ; Mon, 30 Nov 2020 00:22:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="j1/t0Gwc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728598AbgK3AWk (ORCPT ); Sun, 29 Nov 2020 19:22:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726470AbgK3AWj (ORCPT ); Sun, 29 Nov 2020 19:22:39 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70DC3C0613D4 for ; Sun, 29 Nov 2020 16:21:53 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id l17so9038555pgk.1 for ; Sun, 29 Nov 2020 16:21:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EkhG6AFxavZ5abglJ6kOnkEVdmyu4algVumO7xanA0Q=; b=j1/t0Gwc3huo4y0dlJdRRybuJmjeDfsOR36i+hsRhdeIK5/Q2CCr1jQZCnaAd5YbB9 dCVdPb+rkBkiLIVRHJyyd6zrHP141RpwCir+UvbxPnVIzuX8GI5FNZY2u/0f+lZJ4juj p48Y3vLi9J6WmnwucVAK+u1f6bSIZw7d1cZh1oAKkgcLf3ZZoKYQkKSOympnbOpG7W8e sx+UFo4R9q6nj5AcccApUmBWXrzBE6BggRa4LvvhJyB+U535yhaFcWOvxueXfWCIfd0y /FOZ+mL9mQce/s4k2AjS/OLfaSRn5gOJJ81uGq1tXRDlRUBMLdeYRzJ6jvxrHLWVoVXt +uAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EkhG6AFxavZ5abglJ6kOnkEVdmyu4algVumO7xanA0Q=; b=Piq3205pt2cjDs9XNv4qdHTvzBWxRYJTsN6tp2cqAp3Ozwyqjx3Bv+n3XaoF774nBX +mCPAOUZH8Fzy/UVOloQN/RGbZWxErjbzSC0zh4PgLGPYvID9vszDN6BH+Wf34fMX2o8 nLTp+4CVKaaAjya0QyUJ3FI8e0SqArp2vP6iSDluPK8ULSy3e9nHMzPQoNDbgQ2JnO4P oPz76bX/sJXlSgoW8Z3F2+SXIz0iavwmQ+t7gNa0m+nsF51LgkRlP45QIUx/sEdP2FeY uPvSb/B6uNvASx9mEHT5ar2Zcdu+V6ElsuiVzSHpOJr2yDDqWLFpI3/ZI3gvsaeVe3Po ixRQ== X-Gm-Message-State: AOAM533wtAQdISuNu3z8NcuDN8Hx61DpFHSN13osNRgAmO1mJFZrxIK1 Vsy+GVRT1xhse6gVVeKbsFsnLSFmk+0+7XlI X-Google-Smtp-Source: ABdhPJx8GT8BJbot0A6yeIkmZ3Uc8weLLnW02ru3sse13V9T5/WAkruE0l3BKUJ5DenXO4u2eIYsHA== X-Received: by 2002:a62:188a:0:b029:19a:cdab:9841 with SMTP id 132-20020a62188a0000b029019acdab9841mr5860089pfy.12.1606695712563; Sun, 29 Nov 2020 16:21:52 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id d3sm20746129pji.26.2020.11.29.16.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 16:21:51 -0800 (PST) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger , petrm@mellanox.com Subject: [PATCH 3/5] tc: fix compiler warnings in ip6 pedit Date: Sun, 29 Nov 2020 16:21:33 -0800 Message-Id: <20201130002135.6537-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201130002135.6537-1-stephen@networkplumber.org> References: <20201130002135.6537-1-stephen@networkplumber.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Gcc-10 complains about referencing a zero size array. This occurs because the array of keys is actually in the following structure which is part of the overall selector. The original code was safe, but better to just use the key array directly. Fixes: 2d9a8dc439ee ("tc: p_ip6: Support pedit of IPv6 dsfield") Cc: petrm@mellanox.com Signed-off-by: Stephen Hemminger --- tc/p_ip6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tc/p_ip6.c b/tc/p_ip6.c index 71660c610c82..83a6ae8183a7 100644 --- a/tc/p_ip6.c +++ b/tc/p_ip6.c @@ -82,7 +82,7 @@ parse_ip6(int *argc_p, char ***argv_p, /* Shift the field by 4 bits on success. */ if (!res) { int nkeys = sel->sel.nkeys; - struct tc_pedit_key *key = &sel->sel.keys[nkeys - 1]; + struct tc_pedit_key *key = &sel->keys[nkeys - 1]; key->mask = htonl(ntohl(key->mask) << 4 | 0xf); key->val = htonl(ntohl(key->val) << 4); From patchwork Mon Nov 30 00:21:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 335716 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28DC8C3E8C5 for ; Mon, 30 Nov 2020 00:22:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4F932073C for ; Mon, 30 Nov 2020 00:22:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="plkbj/W2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728350AbgK3AWg (ORCPT ); Sun, 29 Nov 2020 19:22:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbgK3AWe (ORCPT ); Sun, 29 Nov 2020 19:22:34 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0DDCC0617A6 for ; Sun, 29 Nov 2020 16:21:54 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id s63so9011064pgc.8 for ; Sun, 29 Nov 2020 16:21:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d+CBUwikwpql5D28/Ydzn/tkpCccjAYgynX4fCid50M=; b=plkbj/W22smzmlJa5fUkgT54RGF02gbentES9oiGQ44dlffUxV+aQBvQjEdiNdOP+4 TAcjqzmzQAhrW8FMhzU10Pc8FwPacEq8+odkH7WUrBIJiFWFqClkOzg83BGS3RHhFzPu g/sZ3qzttmJM+bpPckrnIUcatjzKcdHNYkc9lfFpGYfZRZo5cprdI1YqjUcN+A11Fwae HRlgq9l1id+tJrrx5ZXgnPFVjdFdhuRHjAjte3ieAzAsJDJdIyPj4Fra9LOt9E+Bypec 5vDjppdWEBZxQXq3uyvI72iN+9SxjaX3P2/6RNi1oayAtNREu8rOhz6t5DznUHDTqZS4 O8SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d+CBUwikwpql5D28/Ydzn/tkpCccjAYgynX4fCid50M=; b=P4FRHwLQKEXpK92aernePRbXObHoS4ke+KycejNrO5Oi+mvOeU9hTzZ0GLUSUd2+P2 KVGAFldvHbG35f7EEVKnRntljMPOumLmzLPRoMkGlixmQ67SokG552JyOyVIW3hgbqyp ZlvZ2Xta8rOCG7sWb5l9/bbb1SDboICYc2zpisQs+h+zLC/eHl/9mEx6eBjc1xdvqjOW 24CvCmqNUq5a3Xb+F9BzIR77yYnFDROHowYjq6GSL0ZT5RNl+hjqJSpQAXF/pRwyJOPh gQF9lcqxYN8z4o41QS5OL2gxcU4wJJt23XeZ0opf5gg8iHZpLY7+XX8KTgmthr3VsyBy LmlA== X-Gm-Message-State: AOAM533lWANvs//Q39rPxYk6oH5kafViDT2fq0b+4sH7DbmPWsi3Dq+V d0qMJVIG9AssjJ1ssaUDPaag/Gq6+2CrHgzS X-Google-Smtp-Source: ABdhPJzU3ch2l08S6Q1ii/zd+QeeDFWM7fcS2B9W/mIDk5z6bSdEeE8LC9XWM/A8s2UmqSHqx3tK/g== X-Received: by 2002:a63:f158:: with SMTP id o24mr1985859pgk.281.1606695713809; Sun, 29 Nov 2020 16:21:53 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id d3sm20746129pji.26.2020.11.29.16.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 16:21:53 -0800 (PST) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [PATCH 4/5] misc: fix compiler warning in ifstat and nstat Date: Sun, 29 Nov 2020 16:21:34 -0800 Message-Id: <20201130002135.6537-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201130002135.6537-1-stephen@networkplumber.org> References: <20201130002135.6537-1-stephen@networkplumber.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The code here was doing strncpy() in a way that causes gcc 10 warning about possible string overflow. Just use strlcpy() which will null terminate and bound the string as expected. This has existed since start of git era so no Fixes tag. Signed-off-by: Stephen Hemminger --- misc/ifstat.c | 2 +- misc/nstat.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/misc/ifstat.c b/misc/ifstat.c index c05183d79a13..d4a33429dc50 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -251,7 +251,7 @@ static void load_raw_table(FILE *fp) buf[strlen(buf)-1] = 0; if (info_source[0] && strcmp(info_source, buf+1)) source_mismatch = 1; - strncpy(info_source, buf+1, sizeof(info_source)-1); + strlcpy(info_source, buf+1, sizeof(info_source)); continue; } if ((n = malloc(sizeof(*n))) == NULL) diff --git a/misc/nstat.c b/misc/nstat.c index 6fdd316cce84..ecdd4ce8266d 100644 --- a/misc/nstat.c +++ b/misc/nstat.c @@ -136,8 +136,7 @@ static void load_good_table(FILE *fp) buf[strlen(buf)-1] = 0; if (info_source[0] && strcmp(info_source, buf+1)) source_mismatch = 1; - info_source[0] = 0; - strncat(info_source, buf+1, sizeof(info_source)-1); + strlcpy(info_source, buf + 1, sizeof(info_source)); continue; } /* idbuf is as big as buf, so this is safe */ From patchwork Mon Nov 30 00:21:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 335714 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20D76C3E8C5 for ; Mon, 30 Nov 2020 00:23:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7E5420757 for ; Mon, 30 Nov 2020 00:23:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="vlIoijCe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728627AbgK3AXK (ORCPT ); Sun, 29 Nov 2020 19:23:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726470AbgK3AXJ (ORCPT ); Sun, 29 Nov 2020 19:23:09 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD57CC0617A7 for ; Sun, 29 Nov 2020 16:21:56 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id l1so5498481pld.5 for ; Sun, 29 Nov 2020 16:21:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i/b3F1OiqGDBMwbHm3iD7dfFR9hiS2R0OKWSeitmuMk=; b=vlIoijCeUukxQ9A7L2qOSEglAx6kuV5A539p8wicOhJWQIY30UQkUHOqgTYFZG53yI +Lc2S1USCywTK2kkQLHNIL7gpnUywyWccztjcsUBAeGGRKyYN7Ta5qi/18EEeAjxIJSJ FP0UoGInexrL3pc+Hqzxf5vTQyf25lvhwPkZJOckZEczCQX3w+QE2yEA+A9N84SU37Z0 Iy7kXifztOTugNNSolVXgyEAYF8Y+PtZtru52DpH545vgyC/B2xRkckuWR/F31N3lfrk 1jEpVZGI4BgTcKalFr/D7f5hdRDL7oo583fs/7NAJbkANXnhayhbKvUUE3wZTSQHVY6B x5CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i/b3F1OiqGDBMwbHm3iD7dfFR9hiS2R0OKWSeitmuMk=; b=siwnD6OWI214Scs9MbEgCOkGmk8Jrm+5Ly/CoLBPJAds2SdV8r9QZhsK0G2ZwZWAaZ Uxr2L+kcOYqlyzQ4I545S8pZ/1pSOyKI12QvbLsLvWZv/TRYuMUswssaU9koXCb74XMd Bh+3qDM+jABuFJkYlI0S+rSBCu5lydN+0nin1zk3w8XMdziVyUO4mEnmC8W+jbo1fDvE oDvfJEaJPIAQlkc4Swd1/cTAWpt4pZUFeTuEqfX+mZcsFqUhQGtwjl/jCl8aJXfBH+/9 642u99NfAx3HpTTXQ6yxYE6vCKe0rUSkCTwOW3+6/edQaS7hM3MTc+97NtfyTYTn7HIC psNA== X-Gm-Message-State: AOAM5318dV+ewUqRrpg7Hwdq1MghAzWs6Q5v0cwMVDx9hDmu7f+ymObR 47ACiIz/EXQM5R3VRQQbZ71jujDmn11W4pev X-Google-Smtp-Source: ABdhPJxAQtQYys2wwJI+5uatLVqomub9iU5xr3PUUzJiWtnxMTUoCEYSBoIatf9denxicfZYlVcmXQ== X-Received: by 2002:a17:90a:2941:: with SMTP id x1mr22627396pjf.25.1606695715889; Sun, 29 Nov 2020 16:21:55 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id d3sm20746129pji.26.2020.11.29.16.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 16:21:54 -0800 (PST) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [PATCH 5/5] f_u32: fix compiler gcc-10 compiler warning Date: Sun, 29 Nov 2020 16:21:35 -0800 Message-Id: <20201130002135.6537-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201130002135.6537-1-stephen@networkplumber.org> References: <20201130002135.6537-1-stephen@networkplumber.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org With gcc-10 it complains about array subscript error. f_u32.c: In function ‘u32_parse_opt’: f_u32.c:1113:24: warning: array subscript 0 is outside the bounds of an interior zero-length array ‘struct tc_u32_key[0]’ [-Wzero-length-bounds] 1113 | hash = sel2.sel.keys[0].val & sel2.sel.keys[0].mask; | ~~~~~~~~~~~~~^~~ In file included from tc_util.h:11, from f_u32.c:26: ../include/uapi/linux/pkt_cls.h:253:20: note: while referencing ‘keys’ 253 | struct tc_u32_key keys[0]; | This is because the keys are actually allocated in the second element of the parent structure. Simplest way to address the warning is to assign directly to the keys in the containing structure. This has always been in iproute2 (pre-git) so no Fixes. Signed-off-by: Stephen Hemminger --- tc/f_u32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tc/f_u32.c b/tc/f_u32.c index e0a322d5a11c..2ed5254a40d5 100644 --- a/tc/f_u32.c +++ b/tc/f_u32.c @@ -1110,7 +1110,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle, } NEXT_ARG(); } - hash = sel2.sel.keys[0].val & sel2.sel.keys[0].mask; + hash = sel2.keys[0].val & sel2.keys[0].mask; hash ^= hash >> 16; hash ^= hash >> 8; htid = ((hash % divisor) << 12) | (htid & 0xFFF00000);