compat: drm updates for next-20120926
cover compat: drm updates for next-20120926
From: "Luis R. Rodriguez" <[email protected]>
I've decided to enable DRM drivers by default starting with i915. Turns out that to enable that there were a slew of a few more collatera evolutions which required backporting as well as some other changes to compat-drivers. This and the compat-drivers series addresses those changes.
Luis R. Rodriguez (3):
compat: backport uidgid.h kuid_t and kgid_t addition
compat: backport definition of VM_NODUMP and VM_DONTDUMP
compat: backport seq_file's user namespace addition
compat/Makefile | 3 + compat/compat-3.5.c | 30 +++++++ compat/user_namespace.c | 68 +++++++++++++++ include/linux/compat-2.6.h | 1 + include/linux/compat-3.4.h | 11 +++ include/linux/compat-3.7.h | 30 +++++++ include/linux/uidgid.h | 205 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 348 insertions(+) create mode 100644 compat/compat-3.5.c create mode 100644 compat/user_namespace.c create mode 100644 include/linux/uidgid.h
Signature · 1 line
1.7.10.4
PATCH 1/3 compat: backport uidgid.h kuid_t and kgid_t addition
From: "Luis R. Rodriguez" <[email protected]>
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains \ 7a4e7408c5cadb240e068a662251754a562355e3
v3.5-rc1~107^2~33
This backports:
commit 7a4e7408c5cadb240e068a662251754a562355e3
Author: Eric W. Biederman <[email protected]> Date: Mon Nov 14 14:29:51 2011 -0800
userns: Add kuid_t and kgid_t and associated infrastructure in uidgid.h
Start distinguishing between internal kernel uids and gids and values that userspace can use. This is done by introducing two new types: kuid_t and kgid_t. These types and their associated functions are infrastructure are declared in the new header uidgid.h.
Ultimately there will be a different implementation of the mapping functions for use with user namespaces. But to keep it simple we introduce the mapping functions first to separate the meat from the mechanical code conversions.
Export overflowuid and overflowgid so we can use from_kuid_munged and from_kgid_munged in modular code.
The uidgid.h header file is provided for older kernels and for newer kernels we use include_next trick. The only difference here is that compat-3.5.c now exports overflowuid and overflowgid in the case that CONFIG_UID16 was not defined given that on older kernels these were not exported although linux/highuid.h always has historically provided the extern declaration for them.
Apart from all this we also force inclusion of uidgid.h within the compat framework now given that in newer kernels its expected to be included by many header files and modules without them having included it in upstream code already.
mcgrof@garbanzo ~/compat (git::master)$ time ckmake Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK]
real 1m0.411s
user 3m18.060s
sys 0m30.686s
--- compat/Makefile | 3 + compat/compat-3.5.c | 30 +++++++ compat/user_namespace.c | 68 +++++++++++++++ include/linux/compat-2.6.h | 1 + include/linux/uidgid.h | 205 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 307 insertions(+) create mode 100644 compat/compat-3.5.c create mode 100644 compat/user_namespace.c create mode 100644 include/linux/uidgid.h
compat/Makefile +3 -0
@@ -45,6 +45,9 @@ compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_KERNEL_3_3) += \ compat-3.3.o compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o +compat-$(CONFIG_COMPAT_KERNEL_3_5) += \ + compat-3.5.o \ + user_namespace.o compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o
compat/compat-3.5.c new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Copyright 2012 Luis R. Rodriguez <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Compatibility file for Linux wireless for kernels 3.5. +*/ + +#include <linux/module.h> +#include <linux/highuid.h> + +/* +* Commit 7a4e7408c5cadb240e068a662251754a562355e3 +* exported overflowuid and overflowgid for all +* kernel configurations, prior to that we only +* had it exported when CONFIG_UID16 was enabled. +* We are technically redefining it here but +* nothing seems to be changing it, except +* kernel/ code does epose it via sysctl and +* proc... if required later we can add that here. +*/ +#ifndef CONFIG_UID16 +int overflowuid =DEFAULT_OVERFLOWUID ; +int overflowgid =DEFAULT_OVERFLOWGID ; + +EXPORT_SYMBOL (overflowuid); +EXPORT_SYMBOL (overflowgid); +#endif
compat/user_namespace.c new file +68 -0
68 lines not on this page · raw message
include/linux/compat-2.6.h +1 -0
@@ -11,6 +11,7 @@#endif #include <linux/compat_autoconf.h> #include <linux/init.h> +#include <linux/uidgid.h> /* * The define overwriting module_init is based on the original module_init
include/linux/uidgid.h new file +205 -0
205 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH 1/3] compat: backport uidgid.h kuid_t and kgid_t addition
I don't know the discipline you keep for the compat backports.
However I e=
xpect you can simplify this bit considerably by removing the USER_NS case a= s it will never be true, except in 3.5 where this code already in exists.
=
You can further simplify things by leaving out the overflowuid and overflow= gid cases from from_kuid_munged, as for a backport I doubt anyon will care = if the value is -1 or overflowuid.
Eric
PATCH 2/3 compat: backport definition of VM_NODUMP and VM_DONTDUMP
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
Commit accb61fe defined and added VM_NODUMP so we backport that but later VM_NODUMP was renamed to VM_DONTDUMP via commit cdaaa7003. We backport that definition declaration as well. Note though that commit 909af768e removed the usage of the same bit field and it was used previously for VM_ALWAYSDUMP... given that we want to backport support for it but we can't we make this flag now a no-op for older kernels.
Usage of VM_NODUMP or VM_DONTDUMP on older kernels will simply yield in a no-op for memory regions.
mcgrof@frijol ~/linux-next (git::master)$ git describe --contains \ 909af768e88867016f427264ae39d27a57b6a8ed
v3.4-rc1~109^2~7
commit 909af768e88867016f427264ae39d27a57b6a8ed
Author: Jason Baron <[email protected]> Date: Fri Mar 23 15:02:51 2012 -0700
coredump: remove VM_ALWAYSDUMP flag
The motivation for this patchset was that I was looking at a way for a qemu-kvm process, to exclude the guest memory from its core dump, which can be quite large. There are already a number of filter flags in /proc/<pid>/coredump_filter, however, these allow one to specify 'types' of kernel memory, not specific address ranges (which is needed in this case).
Since there are no more vma flags available, the first patch eliminates the need for the 'VM_ALWAYSDUMP' flag. The flag is used internally by the kernel to mark vdso and vsyscall pages. However, it is simple enough to check if a vma covers a vdso or vsyscall page without the need for this flag.
The second patch then replaces the 'VM_ALWAYSDUMP' flag with a new 'VM_NODUMP' flag, which can be set by userspace using new madvise flags:
'MADV_DONTDUMP', and unset via 'MADV_DODUMP'. The core dump filters continue to work the same as before unless 'MADV_DONTDUMP' is set on the region.
The qemu code which implements this features is at:
http://people.redhat.com/~jbaron/qemu-dump/qemu-dump.patch
In my testing the qemu core dump shrunk from 383MB -> 13MB with this patch.
I also believe that the 'MADV_DONTDUMP' flag might be useful for security sensitive apps, which might want to select which areas are dumped.
This patch:
The VM_ALWAYSDUMP flag is currently used by the coredump code to indicate that a vma is part of a vsyscall or vdso section. However, we can determine if a vma is in one these sections by checking it against the gate_vma and checking for a non-NULL return value from arch_vma_name(). Thus, freeing a valuable vma bit.
mcgrof@frijol ~/linux-next (git::master)$ git describe --contains accb61fe v3.4-rc1~109^2~6
commit accb61fe7bb0f5c2a4102239e4981650f9048519
Author: Jason Baron <[email protected]> Date: Fri Mar 23 15:02:51 2012 -0700
coredump: add VM_NODUMP, MADV_NODUMP, MADV_CLEAR_NODUMP
Since we no longer need the VM_ALWAYSDUMP flag, let's use the freed bit for 'VM_NODUMP' flag. The idea is is to add a new madvise() flag:
MADV_DONTDUMP, which can be set by applications to specifically request memory regions which should not dump core.
The specific application I have in mind is qemu: we can add a flag there that wouldn't dump all of guest memory when qemu dumps core. This flag might also be useful for security sensitive apps that want to absolutely make sure that parts of memory are not dumped. To clear the flag use:
MADV_DODUMP.
VM_NODUMP was renamed to VM_DONTDUMP so for older kernels just use the old declaration. This commit is not yet on Linus' tree so in linux-next we trust it will be on v3.7-rc1.
commit cdaaa7003e855fb50be3a566ac8ef96c6ff138cd
Author: Konstantin Khlebnikov <[email protected]> Date: Wed Sep 26 11:33:12 2012 +1000
mm: prepare VM_DONTDUMP for using in drivers
Rename VM_NODUMP into VM_DONTDUMP: this name matches other negative flags:
VM_DONTEXPAND, VM_DONTCOPY. Currently this flag used only for sys_madvise. The next patch will use it for replacing the outdated flag VM_RESERVED.
Also forbid madvise(MADV_DODUMP) for special kernel mappings VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_RESERVED | VM_PFNMAP)
--- include/linux/compat-3.4.h | 11 +++++++++++ include/linux/compat-3.7.h | 3 +++ 2 files changed, 14 insertions(+)
include/linux/compat-3.4.h +11 -0
@@ -5,6 +5,17 @@#if (LINUX_VERSION_CODE <KERNEL_VERSION (3 ,4 ,0 )) +/* +* defined here to allow things to compile but technically +* using this for memory regions will yield in a no-op on newer +* kernels but on older kernels (v3.3 and older) this bit was used +* for VM_ALWAYSDUMP. The goal was to remove this bit moving forward +* and since we can't skip the core dump on old kernels we just make +* this bit name now a no-op. +* +* For details see commits: 909af7 accb61fe cdaaa7003 +*/ +#define VM_NODUMP 0x0/* This backports: *
include/linux/compat-3.7.h +3 -0
@@ -9,6 +9,9 @@#include <linux/tty.h> #include <linux/pci.h> #include <linux/pci_regs.h> +#include <linux/mm.h> + +#define VM_DONTDUMP VM_NODUMP#define netlink_notify_portid (__notify) (__notify->pid)#define genl_info_snd_portid (__genl_info) (__genl_info->snd_pid)
Signature · 1 line
1.7.10.4
Re: [PATCH 2/3] compat: backport definition of VM_NODUMP and VM_DONTDUMP
This was in my patches to be sent but i am really busy these days so you have fixed it before me. Sorry and thank you :)
Ozan Caglayan
PATCH 3/3 compat: backport seq_file's user namespace addition
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
Commit adb37c4, which as per linux-next may get to v3.7-rc1, introduced adding a user namespace to a struct seq_file. For older kernels with CONFIG_USER_NS support just access the user_name space via the struct file. For kernels without CONFIG_USER_NS pass the init_user_ns. There is a special case to handle for kernels with CONFIG_USER_NS prior to v2.6.38 -- see commit 47a150ed which added a struct user_namespace to struct cred.
This backports:
commit adb37c4c67f807f16beb222028fb3ce9a354dc2b
Author: Eric W. Biederman <[email protected]> Date: Wed May 23 18:01:20 2012 -0600
userns: Make seq_file's user namespace accessible
struct file already has a user namespace associated with it in file->f_cred->user_ns, unfortunately because struct seq_file has no struct file backpointer associated with it, it is difficult to get at the user namespace in seq_file context. Therefore add a helper function seq_user_ns to return the associated user namespace and a user_ns field to struct seq_file to be used in implementing seq_user_ns.
And for kernels older than v2.6.38 this is relevant to review:
commit 47a150edc2ae734c0f4bf50aa19499e23b9a46f8
Author: Serge E. Hallyn <[email protected]> Date: Fri May 13 04:27:54 2011 +0100
Cache user_ns in struct cred
If !CONFIG_USERNS, have current_user_ns() defined to (&init_user_ns).
Get rid of _current_user_ns. This requires nsown_capable() to be defined in capability.c rather than as static inline in capability.h, so do that.
Request_key needs init_user_ns defined at current_user_ns if !CONFIG_USERNS, so forward-declare that in cred.h if !CONFIG_USERNS at current_user_ns() define.
Compile-tested with and without CONFIG_USERNS.
[ This makes a huge performance difference for acl_permission_check(),
up to 30%. And that is one of the hottest kernel functions for loads that are pathname-lookup heavy. ]
mcgrof@garbanzo ~/compat (git::master)$ time ckmake Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK]
real 1m1.219s
user 3m19.912s
sys 0m31.102s
--- include/linux/compat-3.7.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
include/linux/compat-3.7.h +27 -0
@@ -10,9 +10,36 @@#include <linux/pci.h> #include <linux/pci_regs.h> #include <linux/mm.h> +#include <linux/user_namespace.h> +#include <linux/file.h> +#include <linux/seq_file.h> #define VM_DONTDUMP VM_NODUMP +#ifdef CONFIG_USER_NS + +#if (LINUX_VERSION_CODE >KERNEL_VERSION (2 ,6 ,38 )) +static inline struct user_namespace *seq_user_ns (struct seq_file *seq) +{ + struct file *f = container_of((void *) seq, struct file, private_data); + +return f->f_cred->user_ns; +} +#else +static inline struct user_namespace *seq_user_ns (struct seq_file *seq) +{ +return current_user_ns (); +} +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) */ + +#else +static inline struct user_namespace *seq_user_ns (struct seq_file *seq) +{ +extern struct user_namespace init_user_ns; +return &init_user_ns; +} +#endif /* CONFIG_USER_NS */ +#define netlink_notify_portid (__notify) (__notify->pid)#define genl_info_snd_portid (__genl_info) (__genl_info->snd_pid)#define NETLINK_CB_PORTID (__skb) NETLINK_CB(cb->skb).pid
Signature · 1 line
1.7.10.4