Received: by 10.192.165.148 with SMTP id m20csp4149411imm; Mon, 30 Apr 2018 12:41:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrM3gNve2HOZqP4HjztIi8aSGLUQ7I17VxngBK4BWKRTCq1blIiCF1JvNr9wy5D1tqz/Qw8 X-Received: by 2002:a63:7d13:: with SMTP id y19-v6mr10969938pgc.160.1525117304208; Mon, 30 Apr 2018 12:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525117304; cv=none; d=google.com; s=arc-20160816; b=vkxkI3yeFw/6xv9UVnAcb4YerqmZ0jOWqWFKUdDl1HkpKoVd2rsOQ2WfqFJeFTq7vj K6Z2l9VZcMW4isHv+3pf07pR/N1sGjiX6K9YX6Ts3RLX/9flXWYb72iAEdZX9gdSLyHp YAFIBDyEh4vHwmx053s+sxYDzteWIyVHNNYe2zAjVMQI1aTnbC8gHq3wB1HB5xybZV1W d1sFgNKBd+0GmUmd8lfqFPxCrji8X+ZN3vEVUeEUqbfjnBox9rUunuTPdd8mvpdjr/i4 FRMZPlJZjyoihrvOA2ssrmS13X2th/jYGB/4hp9x46f9LlSI8P+NeJZmNAm8KgxoScut o4KQ== 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=JLVorw3+OY1MOOYDwKvE7wctnvK8uTTuHBmFeVhzF0U=; b=PVPqpMd33yfUBlWGPHUujJ2mtVczKzXP6C4gkelfTGfa8vGxHrxXoMePR3KXPuVZqF ezsN4uQlOJwGuyxfS7F1C8k7mCxeCafgpsQvd2z3hizODPLQpXG6EpeAW9ACMZHyX4Fi qQPsFpOPFvM9N1PU2/ir+G4NO+gaJUZKt8VIjJJyCXukDOWwaXaxaQrcMKBc0XZBVPl8 UKuB75Bjniroi7EuO8jH7zSX+uQCxA1LhGltNMWUNXVcXZSE54MFes42ijS+p/WLp5CC 33VEdJJbiPAEKrzkC21WZyjS2ku+zlzd5UDo+Jz65CTp/CFhsYpPRmAuwsqpjYOZ3lvx kR3g== 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 1-v6si7941719ply.464.2018.04.30.12.40.59; Mon, 30 Apr 2018 12:41:44 -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 S932371AbeD3Tg7 (ORCPT + 99 others); Mon, 30 Apr 2018 15:36:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:36686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756374AbeD3T2o (ORCPT ); Mon, 30 Apr 2018 15:28:44 -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 3D57E22DAC; Mon, 30 Apr 2018 19:28:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D57E22DAC 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.16 075/113] ARM: amba: Dont read past the end of sysfs "driver_override" buffer Date: Mon, 30 Apr 2018 12:24:46 -0700 Message-Id: <20180430184018.368730183@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@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.16-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);