Skip to content

Commit 5fce5e0

Browse files
committed
userns: Convert drm to use kuid and kgid and struct pid where appropriate
Blink Blink this had not been converted to use struct pid ages ago? - On drm open capture the openers kuid and struct pid. - On drm close release the kuid and struct pid - When reporting the uid and pid convert the kuid and struct pid into values in the appropriate namespace. Cc: dri-devel@lists.freedesktop.org Acked-by: Dave Airlie <airlied@redhat.com> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
1 parent 1efdb69 commit 5fce5e0

5 files changed

Lines changed: 9 additions & 8 deletions

File tree

‎drivers/gpu/drm/drm_fops.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
251251
filp->private_data = priv;
252252
priv->filp = filp;
253253
priv->uid = current_euid();
254-
priv->pid = task_pid_nr(current);
254+
priv->pid = get_pid(task_pid(current));
255255
priv->minor = idr_find(&drm_minors_idr, minor_id);
256256
priv->ioctl_count = 0;
257257
/* for compatibility root is always authenticated */
@@ -524,6 +524,7 @@ int drm_release(struct inode *inode, struct file *filp)
524524
if (drm_core_check_feature(dev, DRIVER_PRIME))
525525
drm_prime_destroy_file_private(&file_priv->prime);
526526

527+
put_pid(file_priv->pid);
527528
kfree(file_priv);
528529

529530
/* ========================================================

‎drivers/gpu/drm/drm_info.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ int drm_clients_info(struct seq_file *m, void *data)
191191
seq_printf(m, "%c %3d %5d %5d %10u %10lu\n",
192192
priv->authenticated ? 'y' : 'n',
193193
priv->minor->index,
194-
priv->pid,
195-
priv->uid, priv->magic, priv->ioctl_count);
194+
pid_vnr(priv->pid),
195+
from_kuid_munged(seq_user_ns(m), priv->uid),
196+
priv->magic, priv->ioctl_count);
196197
}
197198
mutex_unlock(&dev->struct_mutex);
198199
return 0;

‎drivers/gpu/drm/drm_ioctl.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ int drm_getclient(struct drm_device *dev, void *data,
215215
list_for_each_entry(pt, &dev->filelist, lhead) {
216216
if (i++ >= idx) {
217217
client->auth = pt->authenticated;
218-
client->pid = pt->pid;
219-
client->uid = pt->uid;
218+
client->pid = pid_vnr(pt->pid);
219+
client->uid = from_kuid_munged(current_user_ns(), pt->uid);
220220
client->magic = pt->magic;
221221
client->iocs = pt->ioctl_count;
222222
mutex_unlock(&dev->struct_mutex);

‎include/drm/drmP.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ struct drm_prime_file_private {
426426
/** File private data */
427427
struct drm_file {
428428
int authenticated;
429-
pid_t pid;
430-
uid_t uid;
429+
struct pid *pid;
430+
kuid_t uid;
431431
drm_magic_t magic;
432432
unsigned long ioctl_count;
433433
struct list_head lhead;

‎init/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,6 @@ config UIDGID_CONVERTED
936936
depends on QUOTA = n
937937
depends on QUOTACTL = n
938938
depends on BSD_PROCESS_ACCT = n
939-
depends on DRM = n
940939

941940
# Networking
942941
depends on NET_9P = n

0 commit comments

Comments
 (0)