Received: by 10.213.65.68 with SMTP id h4csp1715305imn; Mon, 19 Mar 2018 11:15:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELvNeudq18zzQqckd0fYsQiQSMiu7ewtmOdjgu6hwWPIcShUTWyZUV1cFPnUFpvECEOkTFW4 X-Received: by 10.167.131.86 with SMTP id z22mr11028041pfm.185.1521483333345; Mon, 19 Mar 2018 11:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521483333; cv=none; d=google.com; s=arc-20160816; b=touJjd3O3DHNExhm0jJxB/nhRK83jF31TWISi2aawCEHHaejfo7m31jJuYNSR3S3tp hqe1v7EXbmNDF7lXHGftb7g9uytGz+QCljh4BoOEv6KafUHV+7Msq2oy5J16Qa15EGTg wuFxgxsWtXVqj9ZDP7QJXcna0Xy5J+T3i/VIS9iqs0wDsh6TOALXbkxGxDTA8jjvAiyL rQSKnUkZNzOGf2y0lq0TxuipZ7V7oRPfyzqKoeHqkRhz+nlXTQrg/oWe/GUg0Y4f7ASu o4Ci5jnieHPtUnn+18DqarU48JZ5w/jAMxiMyMDXrQgN9gtsSM7xPk8ly8K+wV+G7iKm uSfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=inUBFEgRYgrEdFnyQ7JX/+3oX8VWxNkTQXV9i6EdfhM=; b=H7fvrRNEBhYEG+/jeTClh41Aujdcdh3Ky4dMOovTJUw80ikFlXhGaw5GGaoYv3XXE+ 0OO7ADV0dUI/B3QbO0eXMtYbDDfxLs8dawa55cjKsEl7Rxis6ukQ4qrPvhPcuk7fIVFF ZDKimpBTP5TQgCTh+lviMDi8006zEs8ofWN7kS4FpB7IjrUPCb3GGxYSltAAsBQesasW EZm7MxkZHqXJTXmVWoyeSrqJroz8M1NVT1evW0N2U37qvbtbF17MJpSUhKLSyixrW8/B HZ0dwsCmtlMYokeGk4jFe83f3x+tm6sTGFQmpxGD/cTRzKbjKjz52pz3VrXnkc8md3UF sQnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5si303798pfn.386.2018.03.19.11.15.18; Mon, 19 Mar 2018 11:15:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030482AbeCSSNA (ORCPT + 99 others); Mon, 19 Mar 2018 14:13:00 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42902 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935657AbeCSSMr (ORCPT ); Mon, 19 Mar 2018 14:12:47 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 009851206; Mon, 19 Mar 2018 18:12:45 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rob Herring , Frank Rowand , Sasha Levin Subject: [PATCH 4.4 023/134] of: fix of_device_get_modalias returned length when truncating buffers Date: Mon, 19 Mar 2018 19:05:06 +0100 Message-Id: <20180319171852.535241779@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rob Herring [ Upstream commit bcf54d5385abaea9c8026aae6f4eeb348671a52d ] If the length of the modalias is greater than the buffer size, then the modalias is truncated. However the untruncated length is returned which will cause an error. Fix this to return the truncated length. If an error in the case was desired, then then we should just return -ENOMEM. The reality is no device will ever have 4KB of compatible strings to hit this case. Signed-off-by: Rob Herring Cc: Frank Rowand Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/of/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -223,7 +223,7 @@ ssize_t of_device_get_modalias(struct de str[i] = '_'; } - return tsize; + return repend; } EXPORT_SYMBOL_GPL(of_device_get_modalias);