Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3550167imm; Thu, 17 May 2018 10:28:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqcf4qEpO7ipq2/QitEzOx7vNIcm/VHC4Re75/BQX5JsfZykegFI/f49Y43tBBn+vS/kWRd X-Received: by 2002:a63:3d0a:: with SMTP id k10-v6mr4830565pga.11.1526578097966; Thu, 17 May 2018 10:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526578097; cv=none; d=google.com; s=arc-20160816; b=qx3Zlpn0oLvi6Ku/fLNUOR1B6bcHOvxtQb91ekzr3s9c1rva3Kc0QzFQP7D2s04VJa FFLqFoRm/6Ek/98IFifp3t1GBr5B3jhrqzR6JlVRX7ObnEdwh2ew6/xOjArpc8uuSZe/ niRHgSUwAlusyPFm6aW+acnvmxXVlncg/TRq4RY2eGTg9t9vA7nADBrPerUxf/awgRLu CVNVLuOmmxxZoEDRAblD/y8OiXHHMVW7rQ8MHVuWO+cCyhaJlpIHpv5YFWQNvHIqYqoV DR99Xeko3+8lLiG9iAb8gGVbAk2xa/Ecf1yAi7VtlLzHEP9bM39vYNpKRsY1NvAatpty Po0A== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=fotoYs79AxDj6bqjdm6R1mVuySxJsGky0a4JrKYN/eE=; b=lNxX4HA0YRvak2sG0wRvpPCgcRswcxBWlJv1FmWQJjnk9mtT684IEG3xOa5u13feU+ pj+KfdPg7PjgrgCQIbZvMsj2tk8pUpW5JsmrckeTOFcIQUHxlF1J3wLUztXx0Bz40XoN v3yZjT2dCEmq6q/id8v1TspeF2tf5+ECeChloyPrTyjT0JKei/l8xUGu5EGyLHyajPFS vzQULBK+cQ80EtRlVuac4VYpegqURTI0n7W2+uYxVULvk8ZV6gh0Qz4GGhHQS4Qp7cWf OJAB3+w4gwKh3z36EoArt6qIyuyfWe/yaglthx6DZ5NrIpYID90n1/ne8ijhkceoV0ql PQ2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E2JU6ZT/; 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=pass (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 91-v6si5533895plh.488.2018.05.17.10.28.02; Thu, 17 May 2018 10:28:17 -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=pass header.i=@gmail.com header.s=20161025 header.b=E2JU6ZT/; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752211AbeEQR1q (ORCPT + 99 others); Thu, 17 May 2018 13:27:46 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:35008 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750924AbeEQR1p (ORCPT ); Thu, 17 May 2018 13:27:45 -0400 Received: by mail-io0-f193.google.com with SMTP id g1-v6so2953721iob.2; Thu, 17 May 2018 10:27:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=fotoYs79AxDj6bqjdm6R1mVuySxJsGky0a4JrKYN/eE=; b=E2JU6ZT/KUrHyaSaWV9V9w8isKeeOsMkJ/Qw2IaVLOJFWZedeZszI/OVLdLRPJBddN coTMNMiwKulcjf25g4f+yHYdOfeMzR04uzTQwtdh96sO/HgQ6ht4J166P76M7ypjA4He yO7Vuo2NyZY4yINfaUFSOVUUENS076FkO468GQAWFj70GrukuP5pqzgU0G3gYUKS5MNX 4dhrlk+ZRPhDJNTFn1Yiz1WF7ZqHIFh8ghOMBHvrue1wsXVy7/moo7JVBjIZaiCX5Cif CvLRqYxwe3a+58ouOzKSxQzvv3wriouiz5mkReepsK7IUwL+obPAdnopRsG0lyCtCV+A R2EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fotoYs79AxDj6bqjdm6R1mVuySxJsGky0a4JrKYN/eE=; b=RAqB6J9BlFKm4/wfgpwqqQ/ltj7eKTZUMxYHOEMlU4CHBVgA7jSREnYywXNZLG8hQo L6Ahp2Uy0aemEkil16VF6b4G9zSHVDGRSdYZnqzCOaoGs7nTM8G65txQh2CkxwMSCW+q sy2nPrYiAuO4Etjo2iCyGNB4duVeiOsk8JtzxSEWWzbIphyCU8USYnrg+u7ULjbFQv93 RMMkYLNpS6XT9mGxwjYTj7/GdLZXzrdi/gM+cyUVxkXh/MfgFTXGx7SXI1X1ph/0VMb7 xFL6O7g9vWGJWMbFnEFivLH7+RcvQdCMLV9YosAJ0uFhb5eS0QxH8Q35KBeSJvbC7CJB EXWA== X-Gm-Message-State: ALKqPweecTYgHQn7neMOtnMvE/iQfXhRbZNIZ+iINswW2Ld7ExaSLrFc dX0yFqWwQoYbE/QDgMsfQvG932oB X-Received: by 2002:a6b:5009:: with SMTP id e9-v6mr6749836iob.5.1526578064278; Thu, 17 May 2018 10:27:44 -0700 (PDT) Received: from [192.168.86.24] ([184.63.162.180]) by smtp.gmail.com with ESMTPSA id t68-v6sm3000704iof.36.2018.05.17.10.27.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 May 2018 10:27:43 -0700 (PDT) Subject: Re: [PATCH 1/2] bpf: sockmap, fix uninitialized variable To: "Gustavo A. R. Silva" , Alexei Starovoitov , Daniel Borkmann Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <11073635016901e9e84c2f34f20d412073b26297.1526565461.git.gustavo@embeddedor.com> From: John Fastabend Message-ID: Date: Thu, 17 May 2018 10:27:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <11073635016901e9e84c2f34f20d412073b26297.1526565461.git.gustavo@embeddedor.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/17/2018 07:08 AM, Gustavo A. R. Silva wrote: > There is a potential execution path in which variable err is > returned without being properly initialized previously. > > Fix this by initializing variable err to 0. > > Addresses-Coverity-ID: 1468964 ("Uninitialized scalar variable") > Fixes: e5cd3abcb31a ("bpf: sockmap, refactor sockmap routines to work > with hashmap") > Signed-off-by: Gustavo A. R. Silva > --- > kernel/bpf/sockmap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c > index c6de139..41b41fc 100644 > --- a/kernel/bpf/sockmap.c > +++ b/kernel/bpf/sockmap.c > @@ -1713,7 +1713,7 @@ static int __sock_map_ctx_update_elem(struct bpf_map *map, > struct smap_psock_map_entry *e = NULL; > struct smap_psock *psock; > bool new = false; > - int err; > + int err = 0; > > /* 1. If sock map has BPF programs those will be inherited by the > * sock being added. If the sock is already attached to BPF programs > Thanks for catching this and the quick fix. The path to hit this case is to add a sock to a map (without a BPF program) where the sock already has been added to another map. I don't have any tests for the case with socks in multiple maps so I'll add some to the selftests so I remember this case. The alternative fix would be to always 'return 0' at the end of the function, but I think its probably better to init err here like above. Acked-by: John Fastabend