From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:54276 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754823AbdIHHYJ (ORCPT ); Fri, 8 Sep 2017 03:24:09 -0400 Subject: Patch "of/device: Prevent buffer overflow in of_device_modalias()" has been added to the 4.12-stable tree To: bjorn.andersson@linaro.org, gregkh@linuxfoundation.org, robh@kernel.org Cc: , From: Date: Fri, 08 Sep 2017 09:24:06 +0200 Message-ID: <1504855446208212@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled of/device: Prevent buffer overflow in of_device_modalias() to the 4.12-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: of-device-prevent-buffer-overflow-in-of_device_modalias.patch and it can be found in the queue-4.12 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From 08ab58d9de3eb8498ae0585001d0975e46217a39 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Wed, 23 Aug 2017 18:04:04 -0700 Subject: of/device: Prevent buffer overflow in of_device_modalias() From: Bjorn Andersson commit 08ab58d9de3eb8498ae0585001d0975e46217a39 upstream. As of_device_get_modalias() returns the number of bytes that would have been written to the target string, regardless of how much did fit in the buffer, it's possible that the returned index points beyond the buffer passed to of_device_modalias() - causing memory beyond the buffer to be null terminated. Fixes: 0634c2958927 ("of: Add function for generating a DT modalias with a newline") Cc: Rob Herring Signed-off-by: Bjorn Andersson Signed-off-by: Rob Herring Signed-off-by: Greg Kroah-Hartman --- drivers/of/device.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -274,6 +274,8 @@ ssize_t of_device_modalias(struct device ssize_t sl = of_device_get_modalias(dev, str, len - 2); if (sl < 0) return sl; + if (sl > len - 2) + return -ENOMEM; str[sl++] = '\n'; str[sl] = 0; Patches currently in stable-queue which might be from bjorn.andersson@linaro.org are queue-4.12/of-device-prevent-buffer-overflow-in-of_device_modalias.patch