Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3421552pxf; Mon, 29 Mar 2021 01:34:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGOLMFXVSKxp9phGcKMyLEMXxh5PXsmrtZFhZ/7O6FILsKpZm33yptUUvmqHu6TN8rhV0X X-Received: by 2002:a05:6402:11c9:: with SMTP id j9mr27424874edw.348.1617006899306; Mon, 29 Mar 2021 01:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617006899; cv=none; d=google.com; s=arc-20160816; b=ov3uo4FYCoOWEUc21DvHGybvhEhIuGdU2Qb3qvj3rGABEKYR97Hw7/U+uAAGtDgbPK +u4wiKzfbfo8C5/Oh52yndfIE4LV+U7N5Rx82C0V7tX74c3nM0NhymXko/N3seNP/udf Y7gtcw0KNoEDk+RhO5umVAqn5UsB8IgWLZu24Z8KmrSsdyTmdnn0R2hFHgRrzPYjRk0v Rs0yvnCAUxYs4MQGITNLgA0BPF6IdQbwBOQbkTCXNlBpoWYwCNS1ceJz7K/sgzmvR9RJ QOp/uQ5KalnRFb3QkcAYJe5k29Uhv5UUvOidzJ8v6YTGwXxOa+IF2UK6rZCt3ar/xv68 uzBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SX5VD6YhcbZs6Ck43uxhTMkvSzT/0NwetJ+yy3Ohc0g=; b=oAjA1gJ7jJTA51Y9T8357X39+D9RWVrdMCsVEGdfRV6Nny/Y8+Z/5KzyDlxaiHcTVS zr9rqVdCJgb+ngJ2gnIk3+F8elUqe2PU4Sl24MF7MT2WburuItpNZbDxpp1JIaarwqVf 8sW94pzrFL1XnZXN3+YZvZ/1ypwqdnRWsswYWgfVZ4Y8y4oSg4ZeW4Pu647fZaefFHKa 7Dkp0pBSMSpe0I9J+VkZ5q1QYjNI73YFYIoERfYqEqUOsxkItAaseVGJfQ/9tv9moZ8M rpfJsW2kWlSKBVaL2YcIh0XChyo3UAPYqbc/mKw5Jh7t8zaFmG57wsDdxAvCgl6VNVUy BOCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qSTScNiy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq17si12824544ejb.679.2021.03.29.01.34.36; Mon, 29 Mar 2021 01:34:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qSTScNiy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234798AbhC2Idh (ORCPT + 99 others); Mon, 29 Mar 2021 04:33:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:36736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233366AbhC2IUx (ORCPT ); Mon, 29 Mar 2021 04:20:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8AAEA61554; Mon, 29 Mar 2021 08:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006041; bh=vTiQ4lbdj/zsCApx9tl3LVRNY6OLYz9huurQkgXcsIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qSTScNiyC/E72thRdC3eujDg+KBovqj3ajev4kZKE19kgt3z45nzfo+9jqWP3t5mE ai1CbEklbXzYv893snmOU/KEX7pO5T1mbTd37p1gng8ArLKhfh3+ZoCoelWAnfZRb+ 7nRhyOlCMD8R9Xtdg1r7EKNDxsugBWkmxhXAYvkc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tal Lossos , Daniel Borkmann , Yonghong Song , KP Singh , Sasha Levin Subject: [PATCH 5.10 095/221] bpf: Change inode_storages lookup_elem return value from NULL to -EBADF Date: Mon, 29 Mar 2021 09:57:06 +0200 Message-Id: <20210329075632.374491687@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tal Lossos [ Upstream commit 769c18b254ca191b45047e1fcb3b2ce56fada0b6 ] bpf_fd_inode_storage_lookup_elem() returned NULL when getting a bad FD, which caused -ENOENT in bpf_map_copy_value. -EBADF error is better than -ENOENT for a bad FD behaviour. The patch was partially contributed by CyberArk Software, Inc. Fixes: 8ea636848aca ("bpf: Implement bpf_local_storage for inodes") Signed-off-by: Tal Lossos Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song Acked-by: KP Singh Link: https://lore.kernel.org/bpf/20210307120948.61414-1-tallossos@gmail.com Signed-off-by: Sasha Levin --- kernel/bpf/bpf_inode_storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/bpf_inode_storage.c b/kernel/bpf/bpf_inode_storage.c index c2a501cd90eb..a4ac48c7dada 100644 --- a/kernel/bpf/bpf_inode_storage.c +++ b/kernel/bpf/bpf_inode_storage.c @@ -109,7 +109,7 @@ static void *bpf_fd_inode_storage_lookup_elem(struct bpf_map *map, void *key) fd = *(int *)key; f = fget_raw(fd); if (!f) - return NULL; + return ERR_PTR(-EBADF); sdata = inode_storage_lookup(f->f_inode, map, true); fput(f); -- 2.30.1