Skip to content

Commit 3301f6a

Browse files
committed
Merge branch 'for-5.7-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup fixes from Tejun Heo: - Reverted stricter synchronization for cgroup recursive stats which was prepping it for event counter usage which never got merged. The change was causing performation regressions in some cases. - Restore bpf-based device-cgroup operation even when cgroup1 device cgroup is disabled. - An out-param init fix. * 'for-5.7-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: device_cgroup: Cleanup cgroup eBPF device filter code xattr: fix uninitialized out-param Revert "cgroup: Add memory barriers to plug cgroup_rstat_updated() race window"
2 parents 006f38a + eec8fd0 commit 3301f6a

File tree

6 files changed

+29
-30
lines changed

6 files changed

+29
-30
lines changed

drivers/gpu/drm/amd/amdkfd/kfd_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ void kfd_dec_compute_active(struct kfd_dev *dev);
10501050
/* Check with device cgroup if @kfd device is accessible */
10511051
static inline int kfd_devcgroup_check_permission(struct kfd_dev *kfd)
10521052
{
1053-
#if defined(CONFIG_CGROUP_DEVICE)
1053+
#if defined(CONFIG_CGROUP_DEVICE) || defined(CONFIG_CGROUP_BPF)
10541054
struct drm_device *ddev = kfd->ddev;
10551055

10561056
return devcgroup_check_permission(DEVCG_DEV_CHAR, ddev->driver->major,

fs/xattr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,9 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
876876
struct simple_xattr *new_xattr = NULL;
877877
int err = 0;
878878

879+
if (removed_size)
880+
*removed_size = -1;
881+
879882
/* value == NULL means remove */
880883
if (value) {
881884
new_xattr = simple_xattr_alloc(value, size);
@@ -914,9 +917,6 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
914917
list_add(&new_xattr->list, &xattrs->head);
915918
xattr = NULL;
916919
}
917-
918-
if (removed_size)
919-
*removed_size = -1;
920920
out:
921921
spin_unlock(&xattrs->lock);
922922
if (xattr) {

include/linux/device_cgroup.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
#include <linux/fs.h>
3-
#include <linux/bpf-cgroup.h>
43

54
#define DEVCG_ACC_MKNOD 1
65
#define DEVCG_ACC_READ 2
@@ -11,16 +10,10 @@
1110
#define DEVCG_DEV_CHAR 2
1211
#define DEVCG_DEV_ALL 4 /* this represents all devices */
1312

14-
#ifdef CONFIG_CGROUP_DEVICE
15-
int devcgroup_check_permission(short type, u32 major, u32 minor,
16-
short access);
17-
#else
18-
static inline int devcgroup_check_permission(short type, u32 major, u32 minor,
19-
short access)
20-
{ return 0; }
21-
#endif
2213

2314
#if defined(CONFIG_CGROUP_DEVICE) || defined(CONFIG_CGROUP_BPF)
15+
int devcgroup_check_permission(short type, u32 major, u32 minor,
16+
short access);
2417
static inline int devcgroup_inode_permission(struct inode *inode, int mask)
2518
{
2619
short type, access = 0;
@@ -61,6 +54,9 @@ static inline int devcgroup_inode_mknod(int mode, dev_t dev)
6154
}
6255

6356
#else
57+
static inline int devcgroup_check_permission(short type, u32 major, u32 minor,
58+
short access)
59+
{ return 0; }
6460
static inline int devcgroup_inode_permission(struct inode *inode, int mask)
6561
{ return 0; }
6662
static inline int devcgroup_inode_mknod(int mode, dev_t dev)

kernel/cgroup/rstat.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@ void cgroup_rstat_updated(struct cgroup *cgrp, int cpu)
3333
return;
3434

3535
/*
36-
* Paired with the one in cgroup_rstat_cpu_pop_updated(). Either we
37-
* see NULL updated_next or they see our updated stat.
38-
*/
39-
smp_mb();
40-
41-
/*
36+
* Speculative already-on-list test. This may race leading to
37+
* temporary inaccuracies, which is fine.
38+
*
4239
* Because @parent's updated_children is terminated with @parent
4340
* instead of NULL, we can tell whether @cgrp is on the list by
4441
* testing the next pointer for NULL.
@@ -134,13 +131,6 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct cgroup *pos,
134131
*nextp = rstatc->updated_next;
135132
rstatc->updated_next = NULL;
136133

137-
/*
138-
* Paired with the one in cgroup_rstat_cpu_updated().
139-
* Either they see NULL updated_next or we see their
140-
* updated stat.
141-
*/
142-
smp_mb();
143-
144134
return pos;
145135
}
146136

security/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ obj-$(CONFIG_SECURITY_YAMA) += yama/
3030
obj-$(CONFIG_SECURITY_LOADPIN) += loadpin/
3131
obj-$(CONFIG_SECURITY_SAFESETID) += safesetid/
3232
obj-$(CONFIG_SECURITY_LOCKDOWN_LSM) += lockdown/
33-
obj-$(CONFIG_CGROUP_DEVICE) += device_cgroup.o
33+
obj-$(CONFIG_CGROUPS) += device_cgroup.o
3434
obj-$(CONFIG_BPF_LSM) += bpf/
3535

3636
# Object integrity file lists

security/device_cgroup.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <linux/rcupdate.h>
1616
#include <linux/mutex.h>
1717

18+
#ifdef CONFIG_CGROUP_DEVICE
19+
1820
static DEFINE_MUTEX(devcgroup_mutex);
1921

2022
enum devcg_behavior {
@@ -792,7 +794,7 @@ struct cgroup_subsys devices_cgrp_subsys = {
792794
};
793795

794796
/**
795-
* __devcgroup_check_permission - checks if an inode operation is permitted
797+
* devcgroup_legacy_check_permission - checks if an inode operation is permitted
796798
* @dev_cgroup: the dev cgroup to be tested against
797799
* @type: device type
798800
* @major: device major number
@@ -801,7 +803,7 @@ struct cgroup_subsys devices_cgrp_subsys = {
801803
*
802804
* returns 0 on success, -EPERM case the operation is not permitted
803805
*/
804-
static int __devcgroup_check_permission(short type, u32 major, u32 minor,
806+
static int devcgroup_legacy_check_permission(short type, u32 major, u32 minor,
805807
short access)
806808
{
807809
struct dev_cgroup *dev_cgroup;
@@ -825,13 +827,24 @@ static int __devcgroup_check_permission(short type, u32 major, u32 minor,
825827
return 0;
826828
}
827829

830+
#endif /* CONFIG_CGROUP_DEVICE */
831+
832+
#if defined(CONFIG_CGROUP_DEVICE) || defined(CONFIG_CGROUP_BPF)
833+
828834
int devcgroup_check_permission(short type, u32 major, u32 minor, short access)
829835
{
830836
int rc = BPF_CGROUP_RUN_PROG_DEVICE_CGROUP(type, major, minor, access);
831837

832838
if (rc)
833839
return -EPERM;
834840

835-
return __devcgroup_check_permission(type, major, minor, access);
841+
#ifdef CONFIG_CGROUP_DEVICE
842+
return devcgroup_legacy_check_permission(type, major, minor, access);
843+
844+
#else /* CONFIG_CGROUP_DEVICE */
845+
return 0;
846+
847+
#endif /* CONFIG_CGROUP_DEVICE */
836848
}
837849
EXPORT_SYMBOL(devcgroup_check_permission);
850+
#endif /* defined(CONFIG_CGROUP_DEVICE) || defined(CONFIG_CGROUP_BPF) */

0 commit comments

Comments
 (0)