Received: by 10.192.165.148 with SMTP id m20csp4164848imm; Mon, 30 Apr 2018 13:01:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpGw5D7D+WxGRqvPQfO91aN+khYrLsCInEfXL4WuXYdgKYyk1yfG5RZP0GzG8A7wptuhYeC X-Received: by 2002:a65:60d1:: with SMTP id r17-v6mr6183461pgv.410.1525118481281; Mon, 30 Apr 2018 13:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525118481; cv=none; d=google.com; s=arc-20160816; b=V/9+McErh6xeMhXgpIFkh1uqzsYUc8Rl/OfKbceW4ycUrkb5b4sN+VMuLxbpBJRztD p6ohyt6EflvHsatqKEK5VAjh2zMwhk1ycj6Ffw5aPHvHRq3cdhZEYhq6Dzz0E/TfGsmt 046/oR75X83XMwES9eEEBsVzXLJ3sPoZHhIW4R8i8neAbMSJLuARl8hKwKWQTn0quBvd BIpFObx3vxVhNvAd2Lqug5N4s1tshcKcXCPJtWsFe4T5CysI+Xjl/PDWwMc0WMVhZBG0 CYq7/7hXDZsrffOBRqio5EhUezRPtSk8ew0bLq7MvZ4Q8OcFavHfMOkCSMvZAJF2Y1nc JyAQ== 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:dmarc-filter :arc-authentication-results; bh=7WKLn29I1xOx1NK3P7DKgkLOCc8T4NFEyx0rAbeGMo0=; b=St9aoukcBZ7F49SLy2HqYd9CbMzM0IkLt2LrXU2JTHDExHCphPqfWDjucD87nrER0M koflHwnPB42+1hP7fAd9EdmVjKuJe4TVcQTP0lgZ5611PWXXqEUXJKEyNDs9Jg/yQMym LgBTaTOwp6B5fk/ULKukkvLZVn+OVIlh9TWW3zDjluOlotparG32+ypUydbX/Mf0FMlj Pv/PKvlW3n/05gLT5i6aoJE9QY4Q19XZLWnAMFUfP2Hy6UqyQobYvw5NoPneKXX7ky5z 2B1hggkwbPJXEHoRPselwI+RtJKx2u8twvVY7Qv+zUmCdrnSevZeseVu9k5zxTaV86OI fGwQ== 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 a71-v6si6648745pge.159.2018.04.30.13.01.07; Mon, 30 Apr 2018 13:01:21 -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 S1755636AbeD3UA6 (ORCPT + 99 others); Mon, 30 Apr 2018 16:00:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:34532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932220AbeD3T1m (ORCPT ); Mon, 30 Apr 2018 15:27:42 -0400 Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9C22422E72; Mon, 30 Apr 2018 19:27:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C22422E72 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Todd Kjos Subject: [PATCH 4.14 66/91] ARM: amba: Dont read past the end of sysfs "driver_override" buffer Date: Mon, 30 Apr 2018 12:24:48 -0700 Message-Id: <20180430184007.599011308@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Geert Uytterhoeven commit d2ffed5185df9d8d9ccd150e4340e3b6f96a8381 upstream. When printing the driver_override parameter when it is 4095 and 4094 bytes long, the printing code would access invalid memory because we need count + 1 bytes for printing. Cfr. commits 4efe874aace57dba ("PCI: Don't read past the end of sysfs "driver_override" buffer") and bf563b01c2895a4b ("driver core: platform: Don't read past the end of "driver_override" buffer"). Fixes: 3cf385713460eb2b ("ARM: 8256/1: driver coamba: add device binding path 'driver_override'") Signed-off-by: Geert Uytterhoeven Reviewed-by: Todd Kjos Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/amba/bus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -84,7 +84,8 @@ static ssize_t driver_override_store(str struct amba_device *dev = to_amba_device(_dev); char *driver_override, *old, *cp; - if (count > PATH_MAX) + /* We need to keep extra room for a newline */ + if (count >= (PAGE_SIZE - 1)) return -EINVAL; driver_override = kstrndup(buf, count, GFP_KERNEL);