Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3006357imm; Sun, 1 Jul 2018 10:09:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIIJwyCg2yZY0QXps8jVZ/j30it7nEc+Wnp8Kih7O3TmfnEJ8zCwJWoucb+1cUc5x/yqqr4 X-Received: by 2002:a63:3e0a:: with SMTP id l10-v6mr19472283pga.355.1530464958698; Sun, 01 Jul 2018 10:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464958; cv=none; d=google.com; s=arc-20160816; b=GbXGZgTWNA5bpccq15B5Cndjy2XK4lVnzRdiYDwGjCstJfc7bWPHuyNoF68MuoUU+s k3w4vcw108+wfvZAKrJjWlveWeHx2eNsoeIRpq6XsdqHYKMNPpWPpRY3OPizXSfvkZV9 tyhXjeyEdsMa0sfY4PqFcoV9kyslfY+EhdIbqSwpuTQ2Pgy+6eQNp8WuBRaWzzvyJZ5s LPyKmajIDaH/Zz7M4oxj37bCMMubj8VO+IQQDFurrlYH5kVY9p47TG5HgCiKcPBDbRhN nvLyYnSoH94GJ887PUPuKWlV7PGUhCD5KI7wbFmGdotntvXBlBQxKH4YDgBGwrvik97/ cWjg== 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=P/5Q0R6eAVd8xXGJuesptqchm0N+UFnnvX6qfwTRjYw=; b=0yFsLZQ22mpo6uSPj++2Ib770PN0hnJ/C3V4a9EmLuB6Ewape8CDTCsUNIjb83DuTj +tZ3apvCbk7iew/XSsqF0f7jnmhgGDZPiKSRIHgy/zgISv8vgZeqrXVr/qCRloakrgen kKegL7i0OvNVOXFGY2DByQmglsZlWl8uCbpTN/5Y2TZJRxsFuRNdbqRaQk5FYc/CdPPX bxplZGc1sf3ZtxqVjadwRkFdFM3tDEB6o7XUJynhv32oyzJSRRCz40xnweGFWEekuBzZ McNglVKUYxQevHNhfaANAIbiEQ8vbfy42xIPyMaekLYp+gaYROLXQoResrApU7CfHx/O O/qQ== 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 d35-v6si15046786pla.116.2018.07.01.10.09.04; Sun, 01 Jul 2018 10:09:18 -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 S1032121AbeGAQl6 (ORCPT + 99 others); Sun, 1 Jul 2018 12:41:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37432 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031342AbeGAQlp (ORCPT ); Sun, 1 Jul 2018 12:41:45 -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 A0ACAAA6; Sun, 1 Jul 2018 16:41:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Frank Rowand , Rob Herring Subject: [PATCH 4.17 078/220] of: overlay: validate offset from property fixups Date: Sun, 1 Jul 2018 18:21:42 +0200 Message-Id: <20180701160911.704332946@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@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.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Frank Rowand commit 482137bf2aecd887ebfa8756456764a2f6a0e545 upstream. The smatch static checker marks the data in offset as untrusted, leading it to warn: drivers/of/resolver.c:125 update_usages_of_a_phandle_reference() error: buffer underflow 'prop->value' 's32min-s32max' Add check to verify that offset is within the property data. Reported-by: Dan Carpenter Signed-off-by: Frank Rowand Cc: Signed-off-by: Rob Herring Signed-off-by: Greg Kroah-Hartman --- drivers/of/resolver.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c @@ -122,6 +122,11 @@ static int update_usages_of_a_phandle_re goto err_fail; } + if (offset < 0 || offset + sizeof(__be32) > prop->length) { + err = -EINVAL; + goto err_fail; + } + *(__be32 *)(prop->value + offset) = cpu_to_be32(phandle); }