All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Dan Carpenter <dan.carpenter@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Timur Tabi <timur@freescale.com>,
	Mihai Caraman <mihai.caraman@freescale.com>,
	Kumar Gala <galak@kernel.crashing.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 3.18 84/86] drivers/virt/fsl_hypervisor.c: dereferencing error pointers in ioctl
Date: Wed, 15 May 2019 12:56:01 +0200	[thread overview]
Message-ID: <20190515090656.106470070@linuxfoundation.org> (raw)
In-Reply-To: <20190515090642.339346723@linuxfoundation.org>

From: Dan Carpenter <dan.carpenter@oracle.com>

commit c8ea3663f7a8e6996d44500ee818c9330ac4fd88 upstream.

strndup_user() returns error pointers on error, and then in the error
handling we pass the error pointers to kfree().  It will cause an Oops.

Link: http://lkml.kernel.org/r/20181218082003.GD32567@kadam
Fixes: 6db7199407ca ("drivers/virt: introduce Freescale hypervisor management driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Timur Tabi <timur@freescale.com>
Cc: Mihai Caraman <mihai.caraman@freescale.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/virt/fsl_hypervisor.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -335,8 +335,8 @@ static long ioctl_dtprop(struct fsl_hv_i
 	struct fsl_hv_ioctl_prop param;
 	char __user *upath, *upropname;
 	void __user *upropval;
-	char *path = NULL, *propname = NULL;
-	void *propval = NULL;
+	char *path, *propname;
+	void *propval;
 	int ret = 0;
 
 	/* Get the parameters from the user. */
@@ -348,32 +348,30 @@ static long ioctl_dtprop(struct fsl_hv_i
 	upropval = (void __user *)(uintptr_t)param.propval;
 
 	path = strndup_user(upath, FH_DTPROP_MAX_PATHLEN);
-	if (IS_ERR(path)) {
-		ret = PTR_ERR(path);
-		goto out;
-	}
+	if (IS_ERR(path))
+		return PTR_ERR(path);
 
 	propname = strndup_user(upropname, FH_DTPROP_MAX_PATHLEN);
 	if (IS_ERR(propname)) {
 		ret = PTR_ERR(propname);
-		goto out;
+		goto err_free_path;
 	}
 
 	if (param.proplen > FH_DTPROP_MAX_PROPLEN) {
 		ret = -EINVAL;
-		goto out;
+		goto err_free_propname;
 	}
 
 	propval = kmalloc(param.proplen, GFP_KERNEL);
 	if (!propval) {
 		ret = -ENOMEM;
-		goto out;
+		goto err_free_propname;
 	}
 
 	if (set) {
 		if (copy_from_user(propval, upropval, param.proplen)) {
 			ret = -EFAULT;
-			goto out;
+			goto err_free_propval;
 		}
 
 		param.ret = fh_partition_set_dtprop(param.handle,
@@ -392,7 +390,7 @@ static long ioctl_dtprop(struct fsl_hv_i
 			if (copy_to_user(upropval, propval, param.proplen) ||
 			    put_user(param.proplen, &p->proplen)) {
 				ret = -EFAULT;
-				goto out;
+				goto err_free_propval;
 			}
 		}
 	}
@@ -400,10 +398,12 @@ static long ioctl_dtprop(struct fsl_hv_i
 	if (put_user(param.ret, &p->ret))
 		ret = -EFAULT;
 
-out:
-	kfree(path);
+err_free_propval:
 	kfree(propval);
+err_free_propname:
 	kfree(propname);
+err_free_path:
+	kfree(path);
 
 	return ret;
 }



  parent reply	other threads:[~2019-05-15 11:01 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15 10:54 [PATCH 3.18 00/86] 3.18.140-stable review Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 01/86] MIPS: scall64-o32: Fix indirect syscall number load Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 02/86] trace: Fix preempt_enable_no_resched() abuse Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 03/86] sched/numa: Fix a possible divide-by-zero Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 04/86] ceph: ensure d_name stability in ceph_dentry_hash() Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 05/86] sunrpc: dont mark uninitialised items as VALID Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 06/86] slip: make slhc_free() silently accept an error pointer Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 07/86] fs/proc/proc_sysctl.c: Fix a NULL pointer dereference Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 08/86] NFS: Forbid setting AF_INET6 to "struct sockaddr_in"->sin_family Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 09/86] netfilter: ebtables: CONFIG_COMPAT: drop a bogus WARN_ON Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 10/86] Revert "block/loop: Use global lock for ioctl() operation." Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 11/86] ipv4: add sanity checks in ipv4_link_failure() Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 12/86] team: fix possible recursive locking when add slaves Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 13/86] net: stmmac: move stmmac_check_ether_addr() to driver probe Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 14/86] qlcnic: Avoid potential NULL pointer dereference Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 15/86] usb: gadget: net2280: Fix overrun of OUT messages Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 16/86] usb: gadget: net2272: Fix net2272_dequeue() Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 17/86] net: ks8851: Dequeue RX packets explicitly Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 18/86] net: ks8851: Reassert reset pin if chip ID check fails Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 19/86] net: ks8851: Delay requesting IRQ until opened Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 20/86] net: ks8851: Set initial carrier state to down Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 21/86] net: ibm: fix possible object reference leak Greg Kroah-Hartman
2019-05-15 10:54 ` [PATCH 3.18 22/86] scsi: qla4xxx: fix a potential NULL pointer dereference Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 23/86] usb: u132-hcd: fix resource leak Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 24/86] ceph: fix use-after-free on symlink traversal Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 25/86] scsi: zfcp: reduce flood of fcrscn1 trace records on multi-element RSCN Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 26/86] libata: fix using DMA buffers on stack Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 27/86] kconfig/[mn]conf: handle backspace (^H) key Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 28/86] ipv4: ip_do_fragment: Preserve skb_iif during fragmentation Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 29/86] ipv6: invert flowlabel sharing check in process and user mode Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 30/86] packet: validate msg_namelen in send directly Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 31/86] ipv6/flowlabel: wait rcu grace period before put_pid() Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 32/86] USB: yurex: Fix protection fault after device removal Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 33/86] USB: w1 ds2490: Fix bug caused by improper use of altsetting array Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 34/86] USB: core: Fix unterminated string returned by usb_string() Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 35/86] USB: media: disable tlg2300 driver Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 36/86] USB: core: Fix bug caused by duplicate interface PM usage counter Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 37/86] HID: debug: fix race condition with between rdesc_show() and device removal Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 38/86] rtc: sh: Fix invalid alarm warning for non-enabled alarm Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 39/86] igb: Fix WARN_ONCE on runtime suspend Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 40/86] bonding: show full hw address in sysfs for slave entries Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 41/86] jffs2: fix use-after-free on symlink traversal Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 42/86] scsi: storvsc: Fix calculation of sub-channel count Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 43/86] hugetlbfs: fix memory leak for resv_map Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 44/86] xsysace: Fix error handling in ace_setup Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 45/86] ARM: orion: dont use using 64-bit DMA masks Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 46/86] ARM: iop: " Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 47/86] usb: usbip: fix isoc packet num validation in get_pipe Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 48/86] staging: iio: adt7316: allow adt751x to use internal vref for all dacs Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 49/86] staging: iio: adt7316: fix the dac read calculation Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 50/86] staging: iio: adt7316: fix the dac write calculation Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 51/86] media: v4l2: i2c: ov7670: Fix PLL bypass register values Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 52/86] scsi: libsas: fix a race condition when smp task timeout Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 53/86] ASoC:soc-pcm:fix a codec fixup issue in TDM case Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 54/86] ASoC: cs4270: Set auto-increment bit for register writes Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 55/86] ASoC: tlv320aic32x4: Fix Common Pins Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 56/86] scsi: csiostor: fix missing data copy in csio_scsi_err_handler() Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 57/86] iommu/amd: Set exclusion range correctly Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 58/86] genirq: Prevent use-after-free and work list corruption Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 59/86] scsi: qla2xxx: Fix incorrect region-size setting in optrom SYSFS routines Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 60/86] Bluetooth: hidp: fix buffer overflow Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 61/86] Bluetooth: Align minimum encryption key size for LE and BR/EDR connections Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 62/86] timer/debug: Change /proc/timer_stats from 0644 to 0600 Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 63/86] netfilter: compat: initialize all fields in xt_init Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 64/86] platform/x86: sony-laptop: Fix unintentional fall-through Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 65/86] iio: adc: xilinx: fix potential use-after-free on remove Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 66/86] HID: input: add mapping for keyboard Brightness Up/Down/Toggle keys Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 67/86] s390/dasd: Fix capacity calculation for large volumes Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 68/86] s390/3270: fix lockdep false positive on view->lock Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 69/86] KVM: x86: avoid misreporting level-triggered irqs as edge-triggered in tracing Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 70/86] tools lib traceevent: Fix missing equality check for strcmp Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 71/86] init: initialize jump labels before command line option parsing Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 72/86] s390: ctcm: fix ctcm_new_device error return code Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 73/86] selftests/net: correct the return value for run_netsocktests Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 74/86] gpu: ipu-v3: dp: fix CSC handling Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 75/86] Dont jump to compute_result state from check_result state Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 76/86] USB: serial: use variable for status Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 77/86] USB: serial: fix unthrottle races Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 78/86] bridge: Fix error path for kobject_init_and_add() Greg Kroah-Hartman
2019-05-15 20:48   ` Tobin C. Harding
2019-05-16  5:57     ` Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 79/86] net: ucc_geth - fix Oops when changing number of buffers in the ring Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 80/86] packet: Fix error path in packet_init Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 81/86] vlan: disable SIOCSHWTSTAMP in container Greg Kroah-Hartman
2019-05-15 10:55 ` [PATCH 3.18 82/86] ipv4: Fix raw socket lookup for local traffic Greg Kroah-Hartman
2019-05-15 10:56 ` [PATCH 3.18 83/86] bonding: fix arp_validate toggling in active-backup mode Greg Kroah-Hartman
2019-05-15 10:56 ` Greg Kroah-Hartman [this message]
2019-05-15 10:56 ` [PATCH 3.18 85/86] drivers/virt/fsl_hypervisor.c: prevent integer overflow in ioctl Greg Kroah-Hartman
2019-05-15 10:56 ` [PATCH 3.18 86/86] powerpc/booke64: set RI in default MSR Greg Kroah-Hartman
2019-05-15 15:07 ` [PATCH 3.18 00/86] 3.18.140-stable review kernelci.org bot
2019-05-16  3:33 ` Guenter Roeck
2019-05-16 14:27 ` shuah
2019-05-16 14:59   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190515090656.106470070@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=dan.carpenter@oracle.com \
    --cc=galak@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mihai.caraman@freescale.com \
    --cc=stable@vger.kernel.org \
    --cc=timur@freescale.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.