diff options
| author | Dmitry Torokhov <[email protected]> | 2023-05-01 15:20:08 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2023-05-01 15:20:08 -0700 | 
| commit | 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e (patch) | |
| tree | d57f3a63479a07b4e0cece029886e76e04feb984 /kernel/bpf/hashtab.c | |
| parent | 5dc63e56a9cf8df0b59c234a505a1653f1bdf885 (diff) | |
| parent | 53bea86b5712c7491bb3dae12e271666df0a308c (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.4 merge window.
Diffstat (limited to 'kernel/bpf/hashtab.c')
| -rw-r--r-- | kernel/bpf/hashtab.c | 8 | 
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c index 5aa2b5525f79..5dfcb5ad0d06 100644 --- a/kernel/bpf/hashtab.c +++ b/kernel/bpf/hashtab.c @@ -152,7 +152,7 @@ static inline int htab_lock_bucket(const struct bpf_htab *htab,  {  	unsigned long flags; -	hash = hash & HASHTAB_MAP_LOCK_MASK; +	hash = hash & min_t(u32, HASHTAB_MAP_LOCK_MASK, htab->n_buckets - 1);  	preempt_disable();  	if (unlikely(__this_cpu_inc_return(*(htab->map_locked[hash])) != 1)) { @@ -171,7 +171,7 @@ static inline void htab_unlock_bucket(const struct bpf_htab *htab,  				      struct bucket *b, u32 hash,  				      unsigned long flags)  { -	hash = hash & HASHTAB_MAP_LOCK_MASK; +	hash = hash & min_t(u32, HASHTAB_MAP_LOCK_MASK, htab->n_buckets - 1);  	raw_spin_unlock_irqrestore(&b->raw_lock, flags);  	__this_cpu_dec(*(htab->map_locked[hash]));  	preempt_enable(); @@ -1004,8 +1004,6 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,  			l_new = ERR_PTR(-ENOMEM);  			goto dec_count;  		} -		check_and_init_map_value(&htab->map, -					 l_new->key + round_up(key_size, 8));  	}  	memcpy(l_new->key, key, key_size); @@ -1592,6 +1590,7 @@ static int __htab_map_lookup_and_delete_elem(struct bpf_map *map, void *key,  			else  				copy_map_value(map, value, l->key +  					       roundup_key_size); +			/* Zeroing special fields in the temp buffer */  			check_and_init_map_value(map, value);  		} @@ -1792,6 +1791,7 @@ again_nocopy:  						      true);  			else  				copy_map_value(map, dst_val, value); +			/* Zeroing special fields in the temp buffer */  			check_and_init_map_value(map, dst_val);  		}  		if (do_delete) {  |