Received: by 10.192.165.148 with SMTP id m20csp4180219imm; Mon, 30 Apr 2018 13:18:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZplBhqutXcKlQu8SrTwjJnadubKqfzA+h+kORydryzRGrRReBjd5ZNKn5aLR8vRFSFU+zPP X-Received: by 2002:a65:558c:: with SMTP id j12-v6mr11312214pgs.262.1525119532084; Mon, 30 Apr 2018 13:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119532; cv=none; d=google.com; s=arc-20160816; b=yYKjGnbXPDBBpTkie1enSu5ddJuTWimIZHP+k5DlJA4HASDHhQA8R7/yN32TUMj3Xq N5vmu9sYWsE6t/BkRxtbSQ/7GdKU8329klpfsENCAXRLQJYLOiIczrBUEe94vMOJzoui heeFSVUWvGNVnBdK+BjxckdzJVKEPugqJiEHS6eoh2QVbD4iokdcMJdw91cIHIQEVAGM YU6e9+gAlbaAFsg9q2BdGFIzYkKK/YR2xnac9d6YLWTiXya7Lwcwu5jDAqvV8mBDfncY Z6osfMea41dJ2k4EyWTqm15dlSGiF3PAHQXQzkiEkLdaRQ9Nwu+UXFHtPRtet+0X1FfC PdZQ== 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=jivmbtgVWs/C1eY0xQpYGguoV1B8XAA3lLghk9SLxe8=; b=BqpmM/1+v1IH+8+BGaWuhuOeBQJE8QctIcqdg4mLZqaaBzjJUYey4lOviDIXDNfnEK WoHpFoC3/AaKHOWcuFu/+0bbrJkfWSyk92C8h7A5W7zIv/+c00mEYwJc/6MdBSGRZ8l4 AgPVf882UyZn9D7JNnO6y8Q++BEM7EB9d01AzZMb+Q/+mLyG6vznh6vXXSWab1euycqa ljb47uwmTj2zhiWaRX4ZVbWJpF0LvgRcq3g0nMvUxxNpmmQqIfZBzhwGzOaJ1DbH264n 2HmzLWFBesaO2lCDguJmk3q1sMiXcElzYk3Pfboxwqz5VSlpTm2Ta51hYHDMjuprKZE9 4Fyw== 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 r10-v6si2316812pgv.499.2018.04.30.13.18.37; Mon, 30 Apr 2018 13:18:52 -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 S1755855AbeD3T06 (ORCPT + 99 others); Mon, 30 Apr 2018 15:26:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:60654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755755AbeD3T0w (ORCPT ); Mon, 30 Apr 2018 15:26:52 -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 E2C3122DAC; Mon, 30 Apr 2018 19:26:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2C3122DAC 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.9 46/61] ARM: amba: Dont read past the end of sysfs "driver_override" buffer Date: Mon, 30 Apr 2018 12:24:49 -0700 Message-Id: <20180430183955.253660569@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430183951.312721450@linuxfoundation.org> References: <20180430183951.312721450@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: 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);