Received: by 10.192.165.148 with SMTP id m20csp4193364imm; Mon, 30 Apr 2018 13:34:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo2EOk3sQTTQacr8i3vbiQSUHed7K0IOolouRYQyvVkIVFRytk2jZQeRh+CehdhgxYh0kwB X-Received: by 2002:a17:902:887:: with SMTP id 7-v6mr14024999pll.319.1525120497003; Mon, 30 Apr 2018 13:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120496; cv=none; d=google.com; s=arc-20160816; b=wi4YdeEs+r0JY6sXVhEVBM/38VJEe8vu4xNeknAnB86EP2iEWmygMUbbwivoDA/C8G Cfe79g4Q6B+bexGCZJ5y+KxopyECvPhPCg0EgQw42aTAX6V+XUuvxPA8hB0JeO1avFZG kJvx3PVuGMT51yYvP61uymb3wNZKpNGsY2QPc5x8OdQTHbdR1zo0m0n1E+gjpe/CJzCi p4l06ulH+kfKwzwuXrTTUKEr+0kkRcezBlcWJL2SmsnhoyQdVj533ZorYjUK9e3agL0v BwcCn2pdn5kn0enHsg40HI31nvSkzMOPhH9aGXMTG8MkXO6UbYbRF+m7c0gwZzCvRv9F bV/g== 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=8QiN2xWEEIWWVgB7jMxzuVzl4qIql0k53d2EmIjZ0jk=; b=UsOTxVnv/ijCqPM/Y+l+Nbxj4CKTpcj+SRmxLKzJrcjR5WX1eXB+2W6RvIOy4+ZGbo FqSJ3DjAJvj7jIAuR7iqHOYhMip5HABOszzZenjW0LVJedFR9/1PIfunfuVWGsrJ1zoi GWS+H0tMRnmkEZUJwFL0BUoUqzMMrB31XlllQYOml/jdvQQp4gmvFhRbOFwFUvbXMNa8 gjCbm5UMIQ1K67x9KmI4snaaeSWNZ2Qaf4vLqd0GkxqJmnSVf9Wvkyo+z8CmAv1rEx7g XTZwKIk85Uv/6cEgN0P5+QxdRPGynZI/FFipVadSNbekgjBEjNv/thvmzg8RbDW4dCjd 952Q== 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 73si7807718pfb.204.2018.04.30.13.34.42; Mon, 30 Apr 2018 13:34:56 -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 S1755837AbeD3UdB (ORCPT + 99 others); Mon, 30 Apr 2018 16:33:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:59252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755491AbeD3T0D (ORCPT ); Mon, 30 Apr 2018 15:26:03 -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 03C2D22DCC; Mon, 30 Apr 2018 19:26:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03C2D22DCC 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.4 37/44] ARM: amba: Dont read past the end of sysfs "driver_override" buffer Date: Mon, 30 Apr 2018 12:24:48 -0700 Message-Id: <20180430190947.814524053@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430190946.093694747@linuxfoundation.org> References: <20180430190946.093694747@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.4-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 @@ -83,7 +83,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);