From owner-svn-ports-all@freebsd.org Mon Nov 5 22:32:43 2018 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2F33F110DEDF; Mon, 5 Nov 2018 22:32:43 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6D21377AF2; Mon, 5 Nov 2018 22:32:42 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4E1151DC04; Mon, 5 Nov 2018 22:32:42 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wA5MWg4U078828; Mon, 5 Nov 2018 22:32:42 GMT (envelope-from dumbbell@FreeBSD.org) Received: (from dumbbell@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wA5MWg4l078827; Mon, 5 Nov 2018 22:32:42 GMT (envelope-from dumbbell@FreeBSD.org) Message-Id: <201811052232.wA5MWg4l078827@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dumbbell set sender to dumbbell@FreeBSD.org using -f From: =?UTF-8?Q?Jean-S=c3=a9bastien_P=c3=a9dron?= Date: Mon, 5 Nov 2018 22:32:42 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r484252 - in head/sysutils/acpi_call: . files X-SVN-Group: ports-head X-SVN-Commit-Author: dumbbell X-SVN-Commit-Paths: in head/sysutils/acpi_call: . files X-SVN-Commit-Revision: 484252 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6D21377AF2 X-Spamd-Result: default: False [-102.77 / 200.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.67)[-0.673,0]; ALLOW_DOMAIN_WHITELIST(-100.00)[FreeBSD.org]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-0.99)[-0.990,0]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; HAS_XAW(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; DMARC_NA(0.00)[FreeBSD.org]; RCVD_COUNT_THREE(0.00)[4]; MX_GOOD(-0.01)[cached: mx1.FreeBSD.org]; NEURAL_HAM_SHORT(-1.00)[-1.000,0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; RCVD_TLS_LAST(0.00)[] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Nov 2018 22:32:43 -0000 Author: dumbbell Date: Mon Nov 5 22:32:41 2018 New Revision: 484252 URL: https://svnweb.freebsd.org/changeset/ports/484252 Log: sysutils/acpi_call: Fix kernel panic since r336876 PR: 230993 Submitted by: D Scott Phillips Reported by: Theron Tarigo MFH: 2018Q4 Added: head/sysutils/acpi_call/files/patch-acpi__call.c (contents, props changed) Modified: head/sysutils/acpi_call/Makefile Modified: head/sysutils/acpi_call/Makefile ============================================================================== --- head/sysutils/acpi_call/Makefile Mon Nov 5 22:07:08 2018 (r484251) +++ head/sysutils/acpi_call/Makefile Mon Nov 5 22:32:41 2018 (r484252) @@ -3,6 +3,7 @@ PORTNAME= acpi_call PORTVERSION= 1.0.1 +PORTREVISION= 1 CATEGORIES= sysutils MASTER_SITES= http://projects.ukrweb.net/files/ \ http://imax.in.ua/files/ Added: head/sysutils/acpi_call/files/patch-acpi__call.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/acpi_call/files/patch-acpi__call.c Mon Nov 5 22:32:41 2018 (r484252) @@ -0,0 +1,138 @@ +--- acpi_call.c.orig 2011-11-07 05:35:10 UTC ++++ acpi_call.c +@@ -45,18 +45,97 @@ + + void acpi_call_fixup_pointers(ACPI_OBJECT *p, UINT8 *orig); + ++static void ++free_acpi_object_list(ACPI_OBJECT_LIST *list) ++{ ++ for (int i = 0; i < list->Count; i++) { ++ switch (list->Pointer[i].Type) { ++ case ACPI_TYPE_STRING: ++ AcpiOsFree(list->Pointer[i].String.Pointer); ++ break; ++ case ACPI_TYPE_BUFFER: ++ AcpiOsFree(list->Pointer[i].Buffer.Pointer); ++ break; ++ default: ++ break; ++ } ++ } ++ AcpiOsFree(list); ++} ++ ++static ACPI_OBJECT_LIST * ++copyin_acpi_object_list(ACPI_OBJECT_LIST *src) ++{ ++ ACPI_OBJECT_LIST *dest; ++ bool failed; ++ ++ if (src->Count > 7) ++ return NULL; ++ ++ dest = AcpiOsAllocate(sizeof(ACPI_OBJECT_LIST) + sizeof(ACPI_OBJECT) * src->Count); ++ if (!dest) ++ return NULL; ++ ++ dest->Count = src->Count; ++ dest->Pointer = (ACPI_OBJECT *)(dest + 1); ++ if (copyin(src->Pointer, dest->Pointer, sizeof(ACPI_OBJECT) * dest->Count)) { ++ AcpiOsFree(dest); ++ return NULL; ++ } ++ ++ failed = false; ++ ++ for (int i = 0; i < dest->Count; i++) { ++ switch (dest->Pointer[i].Type) { ++ case ACPI_TYPE_INTEGER: ++ break; ++ case ACPI_TYPE_STRING: { ++ void *v = AcpiOsAllocate(dest->Pointer[i].String.Length); ++ if (!v || copyin(dest->Pointer[i].String.Pointer, v, dest->Pointer[i].String.Length)) ++ failed = true; ++ dest->Pointer[i].String.Pointer = v; ++ break; ++ } ++ case ACPI_TYPE_BUFFER: { ++ void *v = AcpiOsAllocate(dest->Pointer[i].Buffer.Length); ++ if (!v || copyin(dest->Pointer[i].Buffer.Pointer, v, dest->Pointer[i].Buffer.Length)) ++ failed = true; ++ dest->Pointer[i].String.Pointer = v; ++ break; ++ } ++ default: ++ failed = true; ++ break; ++ } ++ } ++ ++ if (failed) { ++ free_acpi_object_list(dest); ++ dest = NULL; ++ } ++ ++ return dest; ++} ++ + static int + acpi_call_ioctl(u_long cmd, caddr_t addr, void *arg) + { + struct acpi_call_descr *params; ++ ACPI_OBJECT_LIST *args; + ACPI_BUFFER result; ++ char path[256]; + + result.Length = ACPI_ALLOCATE_BUFFER; + result.Pointer = NULL; + + if (cmd == ACPIIO_CALL) { + params = (struct acpi_call_descr*)addr; +- params->retval = AcpiEvaluateObject(NULL, params->path, ¶ms->args, &result); ++ args = copyin_acpi_object_list(¶ms->args); ++ if (!args) ++ return EINVAL; ++ if (copyinstr(params->path, path, sizeof(path), NULL)) ++ return EINVAL; ++ params->retval = AcpiEvaluateObject(NULL, path, args, &result); + if (ACPI_SUCCESS(params->retval)) + { + if (result.Pointer != NULL) +@@ -64,30 +143,31 @@ acpi_call_ioctl(u_long cmd, caddr_t addr, void *arg) + if (params->result.Pointer != NULL) + { + params->result.Length = min(params->result.Length, result.Length); ++ if (result.Length >= sizeof(ACPI_OBJECT)) ++ acpi_call_fixup_pointers((ACPI_OBJECT*)result.Pointer, params->result.Pointer); + copyout(result.Pointer, params->result.Pointer, + params->result.Length); + params->reslen = result.Length; +- if (result.Length >= sizeof(ACPI_OBJECT)) +- acpi_call_fixup_pointers((ACPI_OBJECT*)(params->result.Pointer), result.Pointer); + } + AcpiOsFree(result.Pointer); + } + } ++ free_acpi_object_list(args); + } + + return (0); + } + + void +-acpi_call_fixup_pointers(ACPI_OBJECT *p, UINT8 *orig) ++acpi_call_fixup_pointers(ACPI_OBJECT *p, UINT8 *dest) + { + switch (p->Type) + { + case ACPI_TYPE_STRING: +- p->String.Pointer = (char*)((UINT8*)(p->String.Pointer) - orig + (UINT8*)p); ++ p->String.Pointer += dest - (UINT8*)p; + break; + case ACPI_TYPE_BUFFER: +- p->Buffer.Pointer -= orig - (UINT8*)p; ++ p->Buffer.Pointer += dest - (UINT8*)p; + break; + } + }