From patchwork Thu Apr 23 02:10:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bo YU X-Patchwork-Id: 1275495 X-Patchwork-Delegate: pabeni@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.01.org (client-ip=2001:19d0:306:5::1; helo=ml01.01.org; envelope-from=mptcp-bounces@lists.01.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=EW6lRhHm; dkim-atps=neutral Received: from ml01.01.org (ml01.01.org [IPv6:2001:19d0:306:5::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49713Z0P6zz9sSk for ; Thu, 23 Apr 2020 12:10:16 +1000 (AEST) Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A8DA410106322; Wed, 22 Apr 2020 19:09:51 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::1041; helo=mail-pj1-x1041.google.com; envelope-from=tsu.yubo@gmail.com; receiver= Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AF891100DCB9C for ; Wed, 22 Apr 2020 19:09:50 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id fu13so1213289pjb.5 for ; Wed, 22 Apr 2020 19:10:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=TqG0F1HlKv8ufJ0NHHqwMQ/0mnS4MGBjZrUPxYMzxJw=; b=EW6lRhHmAJmdnM7lv0tTtiN+KhgYCGm19XFMLBd2zMy/i3dYE9iH2VKp4E0MGlMzMK 7mmRBFCoJq5OxmJa2uTEJwGGSXTykX93xz+HAzqkzE2CnWdkPFK9QC5+Qy6QqPwA0Dff QzbVEB/ozW600DX2RDijBrgm7YyzzJNjO++pMrVnUqsn8V5mv/VK/R1ynXE28C17L2Ps O4JuNq1G7lwverf7kcrEq9xRVO9tVk5kQAPkabrMd2kpQBr+UGkv0h+AIp21PxjPjB3Y 2Vt12YbvkNh1qLkCS/GH4PyNTAvOMcQrBeD7GkiuvfF4qkomUMNZ9bfWpPtUR8Nd3fvO YYCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=TqG0F1HlKv8ufJ0NHHqwMQ/0mnS4MGBjZrUPxYMzxJw=; b=eImU1o1ht6dS6O+Fta5V4J10SyQk/TasipUCnAMId+15ufvkRkt1R6elbKDR8wK4H1 7eOWbVSwfyogaI3qwSXi8u74bIYXYN3lgQM0QbzfFrEhM2TpxgfMQKewfgOzg9e4RpA5 vfL7sxiwJ7947XY7cBm+kuqW0sNEsx3FpY3lfpk3UCkruAAb+bzJjfTLbE//p3QhvAlg rRSdOa6492jLK6S+iOOIxaXibkSd3I91xG+h7Mo+5etjhvjKfRZDseIzNs7WDvGfkbcS dk9TUADKZs+/QeJvtfgZCGSI414u3/RjY798WFasz4P0h0T+qC9uGKvCKs3xGhAo2Eld hCBA== X-Gm-Message-State: AGi0PuafCG+2dyAwP9wVIt46eVCcR7qdbmFAKuVuqU6kuf7sBqJ4H6py 0E83c/vcexZwJiO9IRPFfnA= X-Google-Smtp-Source: APiQypKN5FU1a0EMkWTkihNvcj3hMFxqTN3Jb1QVVKTKXlUGGMhOT+ZNag/ix7zU47OITaRXHAY/rA== X-Received: by 2002:a17:902:5983:: with SMTP id p3mr1698616pli.122.1587607811252; Wed, 22 Apr 2020 19:10:11 -0700 (PDT) Received: from debian.debian-2 ([154.223.71.61]) by smtp.gmail.com with ESMTPSA id f10sm553192pju.34.2020.04.22.19.10.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Apr 2020 19:10:10 -0700 (PDT) Date: Thu, 23 Apr 2020 10:10:03 +0800 From: Bo YU To: matthieu.baerts@tessares.net, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, mathew.j.martineau@linux.intel.com Message-ID: <20200423020957.g5ovpymbbp4nykbr@debian.debian-2> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Message-ID-Hash: ENSZG263NAJD5UFFCW6KSY5ITNSD5J5N X-Message-ID-Hash: ENSZG263NAJD5UFFCW6KSY5ITNSD5J5N X-MailFrom: tsu.yubo@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation CC: netdev@vger.kernel.org, mptcp@lists.01.org, tsu.yubo@gmail.com X-Mailman-Version: 3.1.1 Precedence: list Subject: [MPTCP] [PATCH V3 -next] mptcp/pm_netlink.c : add check for nla_put_in/6_addr List-Id: Discussions regarding MPTCP upstreaming Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Normal there should be checked for nla_put_in6_addr like other usage in net. Detected by CoverityScan, CID# 1461639 Fixes: 01cacb00b35c("mptcp: add netlink-based PM") Signed-off-by: Bo YU Acked-by: Paolo Abeni --- V3: fix code style, thanks for Paolo V2: Add check for nla_put_in_addr suggested by Paolo Abeni --- net/mptcp/pm_netlink.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.11.0 diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 86d61ab34c7c..b78edf237ba0 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -599,12 +599,14 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, nla_put_s32(skb, MPTCP_PM_ADDR_ATTR_IF_IDX, entry->ifindex)) goto nla_put_failure; - if (addr->family == AF_INET) - nla_put_in_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR4, - addr->addr.s_addr); + if (addr->family == AF_INET && + nla_put_in_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR4, + addr->addr.s_addr)) + goto nla_put_failure; #if IS_ENABLED(CONFIG_MPTCP_IPV6) - else if (addr->family == AF_INET6) - nla_put_in6_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR6, &addr->addr6); + else if (addr->family == AF_INET6 && + nla_put_in6_addr(skb, MPTCP_PM_ADDR_ATTR_ADDR6, &addr->addr6)) + goto nla_put_failure; #endif nla_nest_end(skb, attr); return 0;