lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 11 Feb 2022 12:11:43 +0000
From:   Yafang Shao <laoar.shao@...il.com>
To:     ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
        kafai@...com, songliubraving@...com, yhs@...com,
        john.fastabend@...il.com, kpsingh@...nel.org
Cc:     netdev@...r.kernel.org, bpf@...r.kernel.org,
        Yafang Shao <laoar.shao@...il.com>
Subject: [PATCH 2/4] bpf: Add pin_name into struct bpf_map

A new member pin_name is added into struct bpf_map, which will set when
the map is pinned and cleared when the pinned file is removed.

Signed-off-by: Yafang Shao <laoar.shao@...il.com>
---
 include/linux/bpf.h | 1 +
 kernel/bpf/inode.c  | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 9cf8055..220de69 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -182,6 +182,7 @@ struct bpf_map {
 	struct mem_cgroup *memcg;
 #endif
 	char name[BPF_OBJ_NAME_LEN];
+	char pin_name[BPF_PIN_NAME_LEN];
 	bool bypass_spec_v1;
 	bool frozen; /* write-once; write-protected by freeze_mutex */
 	/* 14 bytes hole */
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index f1a8811..586adef 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -440,6 +440,7 @@ static int bpf_obj_do_pin(const char __user *pathname, void *raw,
 	struct bpf_prog_aux *aux;
 	struct bpf_prog *prog;
 	struct dentry *dentry;
+	struct bpf_map *map;
 	struct inode *dir;
 	struct path path;
 	umode_t mode;
@@ -470,6 +471,9 @@ static int bpf_obj_do_pin(const char __user *pathname, void *raw,
 		ret = vfs_mkobj(dentry, mode, bpf_mkprog, raw);
 		break;
 	case BPF_TYPE_MAP:
+		map = raw;
+		(void) strncpy_from_user(map->pin_name, pathname, BPF_PIN_NAME_LEN);
+		map->pin_name[BPF_PIN_NAME_LEN - 1] = '\0';
 		ret = vfs_mkobj(dentry, mode, bpf_mkmap, raw);
 		break;
 	case BPF_TYPE_LINK:
@@ -619,6 +623,7 @@ static void bpf_free_inode(struct inode *inode)
 {
 	struct bpf_prog_aux *aux;
 	struct bpf_prog *prog;
+	struct bpf_map *map;
 	enum bpf_type type;
 
 	if (S_ISLNK(inode->i_mode))
@@ -630,6 +635,10 @@ static void bpf_free_inode(struct inode *inode)
 			aux = prog->aux;
 			aux->pin_name[0] = '\0';
 			break;
+		case BPF_TYPE_MAP:
+			map = inode->i_private;
+			map->pin_name[0] = '\0';
+			break;
 		default:
 			break;
 		}
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ