Received: by 10.213.65.68 with SMTP id h4csp1771646imn; Mon, 19 Mar 2018 12:50:24 -0700 (PDT) X-Google-Smtp-Source: AG47ELtuDqY01ySZ1GuUvWoCNQubiCLYUFizU2V8xJG63Ux+ng1SNzrmE7RlUuCwCWOxP1/xudeH X-Received: by 10.99.124.68 with SMTP id l4mr9973589pgn.225.1521489024282; Mon, 19 Mar 2018 12:50:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521489024; cv=none; d=google.com; s=arc-20160816; b=kpNPGCD6pxkMq2K3WS9NHzFfGsUrvNT9OWcR8b94Thv1gctG/XqRv/Oy8EZXeesgeu nOMl1pEehz6496UO5JxDJwJLLa8OqMz6UnNYVcHUWVe/AD9fLtv/6s3rGBNpuzfYo2EV c1ucHAv3WBAQR3NrVKN4UFQqvHBsWLk6vPEN5Cy0zx7N0OZB1VSmVEKBHJxIz/kCF3CQ TFU9lxhAUI/m2sJzFCI1E124nk/v2SMEz3liaKPJKtmnIdJfyUslnnZsl+0fqam7hYAT /k6cX4/27In2b7YLX0It4Qpu1A2AhiPQN1AsQ63cjP/1ZRbRodKc0vZnnMK54Gbgy+Pm mC9Q== 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=Gcpt9v0NUAcomxSGzaUfPdCftsUyFjfB1AqKclmUM8s=; b=QFUOH8J4gO+b9nQG88jvqQ/uaj8zm9B7EH+bpSiZR5CT2WyIZ0T0bcGSKqJgNg+zg/ l0O/H85sebAwxqU6HaNxyT73Dy/p7W/nUjlNwtGQCqDWt9xfPvx7X05sLW2yADBhmEp6 x7fw9RxpTHNFkKN+MLXFoTnOEXog7c/uo9lN5N3V4Jn+cY3XsR76zk3i41JDPjkjqGwl 7bif6JfhfXgTVJFJ+fMc57nzzYniboYtwuw4osqcr9kQqIMX8M0w0ahcJ/QjgLOM6P0p 4PE0/ajb7wePH11SHnTle+ggh5oPS1o4Q2FQqKLJn4WzyoB0nUIoy3A838nP4bDQ/3Sk a7Zw== 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 f3si416676pgn.787.2018.03.19.12.50.09; Mon, 19 Mar 2018 12:50:24 -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 S969518AbeCSSUT (ORCPT + 99 others); Mon, 19 Mar 2018 14:20:19 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47510 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030972AbeCSSUI (ORCPT ); Mon, 19 Mar 2018 14:20:08 -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 481ED1090; Mon, 19 Mar 2018 18:20:07 +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.9 050/241] of: fix of_device_get_modalias returned length when truncating buffers Date: Mon, 19 Mar 2018 19:05:15 +0100 Message-Id: <20180319180753.285714415@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@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.9-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);