Received: by 10.223.185.116 with SMTP id b49csp1076838wrg; Sat, 3 Mar 2018 14:55:14 -0800 (PST) X-Google-Smtp-Source: AG47ELtmAgkZsMEukPTHhV9Wx6NQWoDT9O/IwVP9LCk5npaN27KLeWFoR1Jul/v+MGLkC6Wxhi48 X-Received: by 2002:a17:902:5481:: with SMTP id e1-v6mr8895564pli.300.1520117713992; Sat, 03 Mar 2018 14:55:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520117713; cv=none; d=google.com; s=arc-20160816; b=Jik1eTcXxSBC7aEnYv0BIoOt7TP//id/Zat4FqtJxotcJ+KzsUEgZWps8LmRMRe+Y/ WFk2HM0fLuk/cYsA9+3BIw3/IglHU4VTrfhOrGRvwehehKbBy26Qz5nSc1VHmUWnpG8v gx0lozJObTs5oCs5qYQQ4oHF7j8X6uJPgwP/7GCxZvH2dib94ZpLTsfwElL12sqyn7QS HG42575BzHxfdLRe99uTSH2MVwVPvfQtD3WXoFVcGLnpHBZmrrmUfcsAyqf4ReUA0/yH 0qz+p/MERr66M6Hjvf6nkosdTSc3d+9N/p3RQsTq9NcwE71RMgUP1eurdch+7SkDBeWs epiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=9WBEYOFvPJ/tU8dhpMcTEYEKRO2hNP7DwtjwXiRXTmg=; b=lWURdWytCiKtTgXi9L9td6pYlYOEUPSYMuICK/yV2E3RSew2J4UFLhtoZZGJNd1VXg 4bYT86ySj1JIRLJIG1lUG2kszs2YryomaIpJJYWTrFVJdHeq7ONzbeduTSTHLXqB4ryC PnfCKjxl+H2gReKJ+0Efow0KLH1rA/z5ZbqsdejTHBolOHOjNw+5IPLtSvVbxZlurqzO Ob25fhHScseN1bsPcbGcSh+E/dce/043N9WzUAWWrLWmx1WifHFm5J0g36gDK8hYiF3y cyhO6G1T7L7KK6KZzh3txTp2d06iD5wQT/g4ETH2kuVAe3pfR9w6IkNy8sJcvoJzyUNF NdKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=hjuq9DXf; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m87si7358850pfk.383.2018.03.03.14.54.59; Sat, 03 Mar 2018 14:55:13 -0800 (PST) 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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=hjuq9DXf; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935229AbeCCWyY (ORCPT + 99 others); Sat, 3 Mar 2018 17:54:24 -0500 Received: from mail-by2nam01on0095.outbound.protection.outlook.com ([104.47.34.95]:48488 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934409AbeCCWlD (ORCPT ); Sat, 3 Mar 2018 17:41:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=9WBEYOFvPJ/tU8dhpMcTEYEKRO2hNP7DwtjwXiRXTmg=; b=hjuq9DXffn8IEl7RuXGWImpZJm9CpGYJ3HjdljAjVQ+V2qrxwYJ6ubx0XGzC3NWtEq9QB7bvSZCdB6YRaveM1xz4Y+ELoBOZG6iEFhpJJkZgNJ0S8pkgFrdswdRFGkI8PUSPLrgSpwDvy7FmtY6dULMmrRf2kiPVM0moqhvOxik= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB0940.namprd21.prod.outlook.com (52.132.146.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.5; Sat, 3 Mar 2018 22:41:01 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:41:01 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Rob Herring , Frank Rowand , Sasha Levin Subject: [PATCH AUTOSEL for 3.18 14/63] of: fix of_device_get_modalias returned length when truncating buffers Thread-Topic: [PATCH AUTOSEL for 3.18 14/63] of: fix of_device_get_modalias returned length when truncating buffers Thread-Index: AQHTsz+fzAgnDqwc0USYiZtYz0Dmgg== Date: Sat, 3 Mar 2018 22:33:17 +0000 Message-ID: <20180303223228.27323-14-alexander.levin@microsoft.com> References: <20180303223228.27323-1-alexander.levin@microsoft.com> In-Reply-To: <20180303223228.27323-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB0940;7:1QzGh44WxJsaaaSloeKNzp6QXHaf1/L4KHU4Mw+rKvOwHaqtG6AllZbGOxJ8RpeFpgSG/LqIuql9RM9a27RxQGXt+3NSJRb+0MmgbA4XWx6/9cIX3cTbkdr7l11qtTMtm7MHF5tS686NH0Vtg0eqKpTNYIcYE4zodew8O1k2GgsZ77UXlK0MmpXRtgFT8+adDXqqze/F+LqLYNFTWyuFzXvyMtOmOg91EKQrsEWpAZK6reDPIW9QJRL5tEKk9tdr x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 76d297b3-13bb-4579-16cc-08d58157d6fc x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020);SRVR:MW2PR2101MB0940; x-ms-traffictypediagnostic: MW2PR2101MB0940: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231220)(944501244)(52105095)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB0940;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB0940; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(39380400002)(346002)(366004)(39860400002)(396003)(199004)(189003)(106356001)(68736007)(6486002)(25786009)(22452003)(6436002)(186003)(2906002)(81156014)(81166006)(10090500001)(66066001)(8676002)(36756003)(6512007)(39060400002)(2900100001)(316002)(97736004)(59450400001)(102836004)(53936002)(6506007)(3280700002)(26005)(4326008)(5250100002)(305945005)(2501003)(76176011)(2950100002)(86362001)(99286004)(3846002)(72206003)(14454004)(3660700001)(478600001)(1076002)(5660300001)(10290500003)(6666003)(6116002)(7736002)(86612001)(107886003)(110136005)(54906003)(105586002)(8936002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB0940;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: jD+XL4aQ8rS1xgoMcBg0QI/1uUfF4PsU/5MfCvRnCp3QJQ5ri9GTGBRww3mNCWsiuZd9aN0NB5YHQLEAG+MGC0Qnc5D4i2NZrc5pYnPvP1OPQBkvlqcgNfWtGxC6uEjAJ/xtRCLgDXBJLC+BgBBuUVPsJA7jv+h3KyLcmGDG3dw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76d297b3-13bb-4579-16cc-08d58157d6fc X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:33:17.0909 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB0940 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/of/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index de20165bad48..2ef5ca45a136 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -126,7 +126,7 @@ ssize_t of_device_get_modalias(struct device *dev, char= *str, ssize_t len) str[i] =3D '_'; } =20 - return tsize; + return repend; } EXPORT_SYMBOL_GPL(of_device_get_modalias); =20 --=20 2.14.1