Skip to content

Commit 088e2ef

Browse files
committed
landlock: Simplify current_check_access_socket()
Remove the handled_access variable in current_check_access_socket() and update access_request instead. One up-to-date variable avoids picking the wrong one. Cc: Konstantin Meskhidze <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mickaël Salaün <[email protected]>
1 parent 782191c commit 088e2ef

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

security/landlock/net.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,11 @@ static const struct landlock_ruleset *get_current_net_domain(void)
6464
static int current_check_access_socket(struct socket *const sock,
6565
struct sockaddr *const address,
6666
const int addrlen,
67-
const access_mask_t access_request)
67+
access_mask_t access_request)
6868
{
6969
__be16 port;
7070
layer_mask_t layer_masks[LANDLOCK_NUM_ACCESS_NET] = {};
7171
const struct landlock_rule *rule;
72-
access_mask_t handled_access;
7372
struct landlock_id id = {
7473
.type = LANDLOCK_KEY_NET_PORT,
7574
};
@@ -164,9 +163,9 @@ static int current_check_access_socket(struct socket *const sock,
164163
BUILD_BUG_ON(sizeof(port) > sizeof(id.key.data));
165164

166165
rule = landlock_find_rule(dom, id);
167-
handled_access = landlock_init_layer_masks(
166+
access_request = landlock_init_layer_masks(
168167
dom, access_request, &layer_masks, LANDLOCK_KEY_NET_PORT);
169-
if (landlock_unmask_layers(rule, handled_access, &layer_masks,
168+
if (landlock_unmask_layers(rule, access_request, &layer_masks,
170169
ARRAY_SIZE(layer_masks)))
171170
return 0;
172171

0 commit comments

Comments
 (0)