Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9076447pxu; Mon, 28 Dec 2020 06:05:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZvdYsSQJ7kjdg75iHHZr0lmHyfRs8n60wK+67xwwW2l/3GriRxEPw+rq7p8rPfxB073Y3 X-Received: by 2002:aa7:d915:: with SMTP id a21mr41819320edr.251.1609164350885; Mon, 28 Dec 2020 06:05:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609164350; cv=none; d=google.com; s=arc-20160816; b=T2riXgAag9pJYFytfdWbcJGEUs9j+yINz1GBRTH1Bda9lYd+y8BynH6GpjHjI08tF8 vEeEMBejuso4ADKO7/jo6siojfuuX0c4esCfFPg8ACbbLCMONiyUsmTtST0GJJ8rDXfs jqZYgtHAwSkRSFZmsfX+fs4Ibx2RIldEMSNtBL79xbPJgP/PpH6mV3O39Os0ciEYBBD1 BxM4OyekeNkYcVPk/kqLIlpEVbFZQdelqgmh0CUBAc/7d+hzyPutMGbv8RYn9Pj7wZc0 mZJWQYfApQYFdj1ZMnbM1MHQvt1leGntVucR1/keVBStORN9YcpM5ku7GfYKJ4SUDdmi CqZA== 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=aYhf5r3Nn/aMwpLJNFn/b2cKtYBfbkOY5emd2ha7wRY=; b=GntDSBMY9p6fmvpZ3MR+dSlXkjec6Zu3xpzA3a5hIbUAZ9/XQ2s7XdimfHCBPZWV1a Vfd56fd6KVQEiHafYGcjkS3UcrxgTjPjTLkuJVr7PcL6O0fqCDVIARDXEny3MNHvuwQy HI9JNW57hFs1/12DiFx3OKay0A0XqrzWI5xy+IZLZ9mK2cq5d9trqYfkKpWGAcnYJE1P VRCZFZbKn28P0CFyoO9P4xjrlohzUsGOom6DEYJpUXSAXB3UO84sOZQ57wp66FqmLchF yUeo536Q0Z+QltyYz6UeV54W/WR8qRyULqKGWoPkiJmlUvhlHLkX+ZOWoOKbctoAET03 ASMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JsfnJK6B; 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 hh14si17922666ejb.457.2020.12.28.06.05.27; Mon, 28 Dec 2020 06:05:50 -0800 (PST) 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=JsfnJK6B; 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 S2436884AbgL1OCd (ORCPT + 99 others); Mon, 28 Dec 2020 09:02:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:36274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436862AbgL1OC2 (ORCPT ); Mon, 28 Dec 2020 09:02:28 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 51931206E5; Mon, 28 Dec 2020 14:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164107; bh=uAgkFiEy+IkBYMB+HdBGe/tfaQ+igclwfOexTpQJeLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JsfnJK6BNArCpd2HH5UTz9zMI+pbyBy+Z/BALqlfMTu6078YvB8BZo3VVyEPogMH8 8vmp/2twYKr0Ii5cHU+jhJRQ4asWWpJ7bVzkck0P8Cbs7iGL68fqLqsXWcBLoaTUbQ LzvD4wZXanl/qzyQEi3uOI4wIqih2XSvx93oQKqc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, KP Singh , Alexei Starovoitov , Song Liu , Sasha Levin Subject: [PATCH 5.10 062/717] bpf: Fix tests for local_storage Date: Mon, 28 Dec 2020 13:41:00 +0100 Message-Id: <20201228125023.967056310@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: KP Singh [ Upstream commit f0e5ba0bc481df77cf0afac2b33e420b33eeb463 ] The {inode,sk}_storage_result checking if the correct value was retrieved was being clobbered unconditionally by the return value of the bpf_{inode,sk}_storage_delete call. Also, consistently use the newly added BPF_LOCAL_STORAGE_GET_F_CREATE flag. Fixes: cd324d7abb3d ("bpf: Add selftests for local_storage") Signed-off-by: KP Singh Signed-off-by: Alexei Starovoitov Acked-by: Song Liu Link: https://lore.kernel.org/bpf/20201106103747.2780972-7-kpsingh@chromium.org Signed-off-by: Sasha Levin --- .../selftests/bpf/progs/local_storage.c | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/local_storage.c b/tools/testing/selftests/bpf/progs/local_storage.c index 0758ba229ae0e..09529e33be982 100644 --- a/tools/testing/selftests/bpf/progs/local_storage.c +++ b/tools/testing/selftests/bpf/progs/local_storage.c @@ -58,20 +58,22 @@ int BPF_PROG(unlink_hook, struct inode *dir, struct dentry *victim) { __u32 pid = bpf_get_current_pid_tgid() >> 32; struct dummy_storage *storage; + int err; if (pid != monitored_pid) return 0; storage = bpf_inode_storage_get(&inode_storage_map, victim->d_inode, 0, - BPF_SK_STORAGE_GET_F_CREATE); + BPF_LOCAL_STORAGE_GET_F_CREATE); if (!storage) return 0; - if (storage->value == DUMMY_STORAGE_VALUE) + if (storage->value != DUMMY_STORAGE_VALUE) inode_storage_result = -1; - inode_storage_result = - bpf_inode_storage_delete(&inode_storage_map, victim->d_inode); + err = bpf_inode_storage_delete(&inode_storage_map, victim->d_inode); + if (!err) + inode_storage_result = err; return 0; } @@ -82,19 +84,23 @@ int BPF_PROG(socket_bind, struct socket *sock, struct sockaddr *address, { __u32 pid = bpf_get_current_pid_tgid() >> 32; struct dummy_storage *storage; + int err; if (pid != monitored_pid) return 0; storage = bpf_sk_storage_get(&sk_storage_map, sock->sk, 0, - BPF_SK_STORAGE_GET_F_CREATE); + BPF_LOCAL_STORAGE_GET_F_CREATE); if (!storage) return 0; - if (storage->value == DUMMY_STORAGE_VALUE) + if (storage->value != DUMMY_STORAGE_VALUE) sk_storage_result = -1; - sk_storage_result = bpf_sk_storage_delete(&sk_storage_map, sock->sk); + err = bpf_sk_storage_delete(&sk_storage_map, sock->sk); + if (!err) + sk_storage_result = err; + return 0; } @@ -109,7 +115,7 @@ int BPF_PROG(socket_post_create, struct socket *sock, int family, int type, return 0; storage = bpf_sk_storage_get(&sk_storage_map, sock->sk, 0, - BPF_SK_STORAGE_GET_F_CREATE); + BPF_LOCAL_STORAGE_GET_F_CREATE); if (!storage) return 0; @@ -131,7 +137,7 @@ int BPF_PROG(file_open, struct file *file) return 0; storage = bpf_inode_storage_get(&inode_storage_map, file->f_inode, 0, - BPF_LOCAL_STORAGE_GET_F_CREATE); + BPF_LOCAL_STORAGE_GET_F_CREATE); if (!storage) return 0; -- 2.27.0