From 804773eb22691c9f7675bb924eb358946f6f5e75 Mon Sep 17 00:00:00 2001 From: Lekensteyn Date: Wed, 29 Feb 2012 00:10:32 +0100 Subject: [PATCH 1/8] Fix misuse of sizeof which trims arguments/muid (GH-12) --- bbswitch.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bbswitch.c b/bbswitch.c index aa0f2a5..c1984f9 100644 --- a/bbswitch.c +++ b/bbswitch.c @@ -71,12 +71,12 @@ static struct notifier_block nb; /* whether the card was off before suspend or not; on: 0, off: 1 */ int dis_before_suspend_disabled; -static char *buffer_to_string(const char buffer[], char *target) { +static char *buffer_to_string(const char *buffer, size_t n, char *target) { int i; - for (i=0; i Date: Wed, 29 Feb 2012 00:30:14 +0100 Subject: [PATCH 2/8] Buffer overflow by one byte --- bbswitch.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bbswitch.c b/bbswitch.c index c1984f9..d17c05b 100644 --- a/bbswitch.c +++ b/bbswitch.c @@ -74,9 +74,8 @@ int dis_before_suspend_disabled; static char *buffer_to_string(const char *buffer, size_t n, char *target) { int i; for (i=0; i Date: Wed, 29 Feb 2012 00:49:34 +0100 Subject: [PATCH 3/8] Don't share buffer for muid/args, it'll be overwritten --- bbswitch.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bbswitch.c b/bbswitch.c index d17c05b..f0cd673 100644 --- a/bbswitch.c +++ b/bbswitch.c @@ -111,12 +111,13 @@ static int acpi_call_dsm(acpi_handle handle, const char muid[16], int revid, err = acpi_evaluate_object(handle, "_DSM", &input, &output); if (err) { - char tmp[5 * 16]; /* enough space for muid or args with separators */ + char muid_str[5 * 16]; + char args_str[5 * 4]; printk(KERN_WARNING "bbswitch: failed to evaluate _DSM {%s} %X %X" " {%s}: %s\n", - buffer_to_string(muid, 16, tmp), revid, func, - buffer_to_string(args, 4, tmp), acpi_format_exception(err)); + buffer_to_string(muid, 16, muid_str), revid, func, + buffer_to_string(args, 4, args_str), acpi_format_exception(err)); return err; } From e13e6ffc5468066ac780bfb098540ceffb8cf201 Mon Sep 17 00:00:00 2001 From: Lekensteyn Date: Thu, 1 Mar 2012 13:16:48 +0100 Subject: [PATCH 4/8] Fix null deref when ACPI method call failed (GH-12) --- bbswitch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bbswitch.c b/bbswitch.c index f0cd673..f1eb431 100644 --- a/bbswitch.c +++ b/bbswitch.c @@ -74,7 +74,7 @@ int dis_before_suspend_disabled; static char *buffer_to_string(const char *buffer, size_t n, char *target) { int i; for (i=0; i Date: Thu, 1 Mar 2012 21:53:52 +0100 Subject: [PATCH 5/8] Fix formatting of arguments on case of ACPI failure (GH-12) --- bbswitch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bbswitch.c b/bbswitch.c index f1eb431..0c55d98 100644 --- a/bbswitch.c +++ b/bbswitch.c @@ -74,7 +74,7 @@ int dis_before_suspend_disabled; static char *buffer_to_string(const char *buffer, size_t n, char *target) { int i; for (i=0; i Date: Thu, 26 Apr 2012 12:49:14 +0200 Subject: [PATCH 6/8] Fix documentation error (Closes GH-16) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 72e3d20..17bef18 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ The module has some options that control the behavior on loading and unloading: `load_state` and `unload_state`. Valid values are `-1`, `0` and `1` meaning "do not change the card state", "turn the card off" and "turn the card on" respectively. For example, if you want to have `bbswitch` disable the card -immediately when loading the module while disabling the card on unload, load the +immediately when loading the module while enabling the card on unload, load the module with: # modprobe bbswitch load_state=0 unload_state=1 From d12ce73a0d042fce3738aea800f55f8a23874e8c Mon Sep 17 00:00:00 2001 From: Lekensteyn Date: Thu, 26 Apr 2012 12:56:47 +0200 Subject: [PATCH 7/8] Update to version 0.4.2, update NEWS --- NEWS | 8 ++++++++ bbswitch.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 2f08c50..335e37e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +Version 0.4.2 - 26 April 2012 + +* Fixed a documentation error on unload_state. +* Added Makefile.dkms and documentation for easier installation using DKMS. +* Make /proc/acpi/bbswitch world-writable +* Fix NULL pointer dereference when reporting a failure during ACPI method + evaluation. + Version 0.4.1 - 16 January 2012 * Corrected a small error that yielded an confusing error message "The discrete diff --git a/bbswitch.c b/bbswitch.c index 0c55d98..ca79e0d 100644 --- a/bbswitch.c +++ b/bbswitch.c @@ -16,7 +16,7 @@ #include #include -#define BBSWITCH_VERSION "0.4.1" +#define BBSWITCH_VERSION "0.4.2" MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Toggle the discrete graphics card"); From 8ada8849f2944b679c659bf108ba3f25500c23fa Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sat, 7 Jul 2012 19:58:33 +0200 Subject: [PATCH 8/8] Compatibility with older DKMS versions (GH-25) --- Makefile.dkms | 6 +++--- NEWS | 2 ++ README.md | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile.dkms b/Makefile.dkms index 3a06762..b7c0d15 100644 --- a/Makefile.dkms +++ b/Makefile.dkms @@ -13,12 +13,12 @@ src_install: sed 's/#MODULE_VERSION#/$(modver)/' dkms/dkms.conf > '$(DKMS_DEST)/dkms.conf' build: src_install - $(DKMS) build 'bbswitch/$(modver)' + $(DKMS) build -m bbswitch -v $(modver) install: build - $(DKMS) install 'bbswitch/$(modver)' + $(DKMS) install -m bbswitch -v $(modver) uninstall: - $(DKMS) remove bbswitch/$(modver) --all + $(DKMS) remove -m bbswitch -v $(modver) --all .PHONY: all src_install build install uninstall diff --git a/NEWS b/NEWS index 335e37e..71252fd 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +* Improved compatibility with older DKMS versions. + Version 0.4.2 - 26 April 2012 * Fixed a documentation error on unload_state. diff --git a/README.md b/README.md index 17bef18..1f578e5 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ DKMS support If you have DKMS installed, you can install bbswitch in such a way that it survives kernel upgrades. It is recommended to remove older versions of bbswitch -by running `dkms remove bbswitch/OLDVERSION --all` as root. To install the new -version, simply run: +by running `dkms remove -m bbswitch -v OLDVERSION --all` as root. To install +the new version, simply run: # make -f Makefile.dkms