Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp670565img; Tue, 26 Feb 2019 06:45:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IaH7KqqkVgZyjSo8Z/gdEM3J4NhrYEXlO+xjBXxIP3bWTc8fMaiyVMAcjb1ORt23+EfVeSB X-Received: by 2002:a17:902:8e82:: with SMTP id bg2mr26532203plb.217.1551192321786; Tue, 26 Feb 2019 06:45:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551192321; cv=none; d=google.com; s=arc-20160816; b=I3O2+loUQtNNpZYFjA41QiWwEJW7JVoiEEFP8rkXZR+Aagl2vQnJ73dzIEHWh96kyI 6usbcVn8icUU8NvDfeOPmvyUXDG7QIYvjtXrf4pziyo5a1VGsUNzNvxJXZkfzLidHx7O RxPjUsZsNQFZk+sVtHFMcf0OtEND6rJ7Gmh2fOsMso2zYvIhwdUXDrzhvUhUPbyLa4Yj aH2l1XJ9heQpHyjxOmmWsB3wdrRQP1EPVm51wR8tbH4VpOQtdg/7lu6qHyS7oJ6upDej EIZWtiVa7LI2TdzsWAb9G+9jZiDJB0nzDRBXNTYV7RFqoOxDXA6YK5I8XdJQPuYyorX2 4Ecg== 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; bh=v1HW4fkQ/Q7IFEp/wTgiDVroKvtgcgeFLyd3KN+ewGo=; b=SKTN/zgYhvdWzmtgaol68WCju79CkRnzXA8JAPNBd/t0EM8AXoTt7rMo+C4uOgno26 LExZN1HO4HTpEI5SCcyXK9COi4O3mUZYexGNV5dsV+QWG9wzMrrGlEM5t44zUVQjjH+K 16Da/qbr8BPz8cgJt7kJcj8jrp3Wy4qOWgNx5lrb/aU8ujCYWH2jRJkAOzT6BXRHW4cq SdOWXwTY9vqzJDZOeplRhWx3IXL1zbIMG6A7PshLgGFmCnFuOO2Y0e8XwCwBz1yTv1NX 53iz4NDvm2EavWhhCOp9W4Z/RL4gTi0g8UgsD1Lu+XLDPflnLrLq/9o28q3E9WL93EUQ 8avw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si12293176pgf.247.2019.02.26.06.45.05; Tue, 26 Feb 2019 06:45:21 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727513AbfBZOon (ORCPT + 99 others); Tue, 26 Feb 2019 09:44:43 -0500 Received: from www62.your-server.de ([213.133.104.62]:35114 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbfBZOon (ORCPT ); Tue, 26 Feb 2019 09:44:43 -0500 Received: from [78.46.172.3] (helo=sslproxy06.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1gydyK-0000CQ-Id; Tue, 26 Feb 2019 15:44:40 +0100 Received: from [178.197.249.32] (helo=linux.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1gydyK-000IE6-BC; Tue, 26 Feb 2019 15:44:40 +0100 Subject: Re: [PATCH] bpf: decrease usercnt if bpf_map_new_fd() fails in bpf_map_get_fd_by_id() To: zerons , ast@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1551190537-28694-1-git-send-email-sironhide0null@gmail.com> From: Daniel Borkmann Message-ID: <564058e0-1432-676e-2f83-c8694911d8e5@iogearbox.net> Date: Tue, 26 Feb 2019 15:44:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1551190537-28694-1-git-send-email-sironhide0null@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.2/25372/Tue Feb 26 11:34:09 2019) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/26/2019 03:15 PM, zerons wrote: > [ Upstream commit c91951f15978f1a0c6b65f063d30f7ea7bc6fb42 ] Thanks for the fix! What do you mean by "upstream commit" above in this context? > In bpf/syscall.c, bpf_map_get_fd_by_id() use bpf_map_inc_not_zero() to increase > the refcount, both map->refcnt and map->usercnt. Then, if bpf_map_new_fd() fails, > should handle map->usercnt too. > > Signed-off-by: zerons > --- > kernel/bpf/syscall.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index cf5040f..db1ed12 100644 > --- a/kernel/bpf/syscall.c > +++ b/kernel/bpf/syscall.c > @@ -1966,7 +1966,7 @@ static int bpf_map_get_fd_by_id(const union bpf_attr *attr) > > fd = bpf_map_new_fd(map, f_flags); > if (fd < 0) > - bpf_map_put(map); > + bpf_map_put_with_uref(map); > > return fd; > } > -- > 2.7.4 >