summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov2007-12-05 08:45:24 +0100
committerLinus Torvalds2007-12-05 18:21:20 +0100
commitf1dad166e88a5ddca0acf8f11dea0e2bd92d8bf3 (patch)
treee907d1de7ee3bad49b101336a0b1640e8d05bd51
parentBlackfin SPI driver: reconfigure speed_hz and bits_per_word in each spi transfer (diff)
downloadkernel-qcow2-linux-f1dad166e88a5ddca0acf8f11dea0e2bd92d8bf3.tar.gz
kernel-qcow2-linux-f1dad166e88a5ddca0acf8f11dea0e2bd92d8bf3.tar.xz
kernel-qcow2-linux-f1dad166e88a5ddca0acf8f11dea0e2bd92d8bf3.zip
Avoid potential NULL dereference in unregister_sysctl_table
register_sysctl_table() can return NULL sometimes, e.g. when kmalloc() returns NULL or when sysctl check fails. I've also noticed, that many (most?) code in the kernel doesn't check for the return value from register_sysctl_table() and later simply calls the unregister_sysctl_table() with potentially NULL argument. This is unlikely on a common kernel configuration, but in case we're dealing with modules and/or fault-injection support, there's a slight possibility of an OOPS. Changing all the users to check for return code from the registering does not look like a good solution - there are too many code doing this and failure in sysctl tables registration is not a good reason to abort module loading (in most of the cases). So I think, that we can just have this check in unregister_sysctl_table just to avoid accidental OOPS-es (actually, the unregister_sysctl_table() did exactly this, before the start_unregistering() appeared). Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/sysctl.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 0deed82a6156..8ac51714b08c 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1588,6 +1588,10 @@ struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
void unregister_sysctl_table(struct ctl_table_header * header)
{
might_sleep();
+
+ if (header == NULL)
+ return;
+
spin_lock(&sysctl_lock);
start_unregistering(header);
spin_unlock(&sysctl_lock);
highlight'>|\ | * x86/CPU/AMD: Don't force the CPB cap when running under a hypervisorFrank van der Linden2019-05-241-2/+5 | * x86/boot: Provide KASAN compatible aliases for string routinesArd Biesheuvel2019-05-241-4/+10 * | Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/ke...Linus Torvalds2019-06-0223-124/+547 |\ \ | * \ Merge tag 'perf-urgent-for-mingo-5.2-20190528' of git://git.kernel.org/pub/sc...Ingo Molnar2019-05-28124-558/+1455 | |\ \ | | * | tools headers UAPI: Sync kvm.h headers with the kernel sourcesArnaldo Carvalho de Melo2019-05-284-3/+105 | | * | perf record: Fix s390 missing module symbol and warning for non-root usersThomas Richter2019-05-281-3/+6 | | * | perf machine: Read also the end of the kernelJiri Olsa2019-05-281-9/+18 | | * | perf test vmlinux-kallsyms: Ignore aliases to _etext when searching on kallsymsArnaldo Carvalho de Melo2019-05-281-1/+8 | | * | perf session: Add missing swap ops for namespace eventsNamhyung Kim2019-05-281-0/+21 | | * | perf namespace: Protect reading thread's namespaceNamhyung Kim2019-05-281-2/+13 | | * | tools headers UAPI: Sync drm/drm.h with the kernelArnaldo Carvalho de Melo2019-05-281-0/+37 | | * | tools headers UAPI: Sync drm/i915_drm.h with the kernelArnaldo Carvalho de Melo2019-05-281-73/+181 | | * | tools headers UAPI: Sync linux/fs.h with the kernelArnaldo Carvalho de Melo2019-05-281-0/+3 | | * | tools headers UAPI: Sync linux/sched.h with the kernelArnaldo Carvalho de Melo2019-05-281-0/+1 | | * | tools arch x86: Sync asm/cpufeatures.h with the with the kernelArnaldo Carvalho de Melo2019-05-281-0/+3 | | * | tools include UAPI: Update copy of files related to new fspick, fsmount, fsco...Arnaldo Carvalho de Melo2019-05-284-1/+83 | | * | perf arm64: Fix mksyscalltbl when system kernel headers are ahead of the kernelVitaly Chikunov2019-05-281-1/+1 | | * | perf data: Fix 'strncat may truncate' build failure with recent gccShawn Landden2019-05-281-1/+1 | * | | perf/ring-buffer: Use regular variables for nestingPeter Zijlstra2019-05-242-17/+28 | * | | perf/ring-buffer: Always use {READ,WRITE}_ONCE() for rb->user_page dataPeter Zijlstra2019-05-241-3/+3 | * | | perf/ring_buffer: Add ordering to rb->nest incrementPeter Zijlstra2019-05-241-0/+9 | * | | perf/ring_buffer: Fix exposing a temporarily decreased data_headYabin Cui2019-05-241-4/+20 | * | | perf/x86/intel/ds: Fix EVENT vs. UEVENT PEBS constraintsStephane Eranian2019-05-211-14/+14 * | | | Merge branch 'efi-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/ker...Linus Torvalds2019-06-024-3/+14 |\ \ \ \ | * | | | efi: Allow the number of EFI configuration tables entries to be zeroRob Bradford2019-05-252-0/+6 | * | | | efi/x86/Add missing error handling to old_memmap 1:1 mapping codeGen Zhang2019-05-252-3/+8 * | | | | Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/ke...Linus Torvalds2019-06-021-1/+1 |\ \ \ \ \ | * | | | | stacktrace: Unbreak stack_trace_save_tsk_reliable()Joe Lawrence2019-05-191-1/+1 * | | | | | Merge tag 'spdx-5.2-rc3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/g...Linus Torvalds2019-06-026-6/+6 |\ \ \ \ \ \ | * | | | | | treewide: fix typos of SPDX-License-IdentifierMasahiro Yamada2019-06-015-5/+5 | * | | | | | crypto: ux500 - fix license comment syntax errorAlex Xu (Hello71)2019-06-011-1/+1 * | | | | | | Merge tag 'powerpc-5.2-3' of git://git.kernel.org/pub/scm/linux/kernel/git/po...Linus Torvalds2019-06-025-3/+19 |\ \ \ \ \ \ \ | * | | | | | | powerpc/kexec: Fix loading of kernel + initramfs with kexec_file_load()Thiago Jung Bauermann2019-05-231-1/+5 | * | | | | | | powerpc/perf: Fix MMCRA corruption by bhrb_filterRavi Bangoria2019-05-223-2/+10 | * | | | | | | powerpc/powernv: Return for invalid IMC domainAnju T Sudhakar2019-05-22