Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp842312imu; Tue, 11 Dec 2018 08:22:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/WJpB8mGliNVWFeaToC4Gdl5iYb1OuBFI2zExnJCy3Ol+qCWO1YNYRz0rLc4zxX/Zph+T1f X-Received: by 2002:a62:2b8b:: with SMTP id r133mr16911234pfr.246.1544545378646; Tue, 11 Dec 2018 08:22:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544545378; cv=none; d=google.com; s=arc-20160816; b=Nb+vprVQ7L7jZeGKVZLhpKLtp3YCI43Qc+Vk/IsriRofO2FX3pZchkEddJHRBjAbur xQcVOUmTblICp5SUMvBhoyIUZihRLVF4lAoH2lCgeWP3yUOCuH++hU3SCboFGMDwkmdA eWr4yG2iCr2IvgRP5RwLvHJZ00DKWD0gXCFK8iE8d2M3EoRLx4V9nUlPw67jaiW5o+E1 tf/HPV8oDnCrAigNxQ82f/E4yRtl36zO5BAzQ3hQYMQDKNxregb1zALD+MmM2Tr3dZZQ zYSyzK6TFY1iD0tCf+pVyVCHQoQ8zp430/IfjczOESCLssUAx5vaJkb0gn9lOHrvcLZg F/jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Zw/ByiiXlEX5TASqUKHTWllEpSNgfsTtuhLnokoi5zs=; b=H79j/FIrqbfYZ/l97AV8sWPAcRLaMJ0OnSxuSGXlqQiJy6bni3yvGD4a2ii3EiJ+79 x2EhCHOLEeyduChqJeTv0DfXGluE3V8YGgMS4VDLjfMInUR89uZDez5GyCShqKb2k5Ga azyzSmr0InfzqYhFZ3UPefyz1fKVto2siyCbxF6B/w2P5IBpDgZwe/rlSEWgtMnTngJN ACVYNgJplCwcpOyUhRy1+2Gf/w81DGWlAKWea7A8bYST7iqhx2SAz5UPYz9I9JfHDZw+ IB6Y8qbQZHyXFouPlPLSMlwbavHn3UhN9RSllaFU8tFciF3MX8clOF6RoQc0EKQZhbjp Sluw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jPDUHc+W; 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 x74si227547pfe.23.2018.12.11.08.22.43; Tue, 11 Dec 2018 08:22:58 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=jPDUHc+W; 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 S1728079AbeLKPpW (ORCPT + 99 others); Tue, 11 Dec 2018 10:45:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:33746 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728072AbeLKPpU (ORCPT ); Tue, 11 Dec 2018 10:45:20 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 D6A8D20870; Tue, 11 Dec 2018 15:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543119; bh=SIkK50BqF7lpxzTVb4B+qTp4nRS740r7O8/xmP1Jb4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jPDUHc+WiPgk1kmmuNGEDTu1ZiKGBwKxWHwUJD3SqOPn4uvQWv6e39VVHEcvK0hcC NGb4DKq2YZTNzmfZ/zbt6CjRUGSWGHXhYIzzCCvzuCOTtl47+rjz4aU04+4jsnf8Ny uJ9GoSQ9T5OzYMZl4UwgGJyYAXaezMhJZqbQIpXg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anand Jain , Filipe Manana , David Sterba Subject: [PATCH 4.4 09/91] Btrfs: ensure path name is null terminated at btrfs_control_ioctl Date: Tue, 11 Dec 2018 16:40:28 +0100 Message-Id: <20181211151606.720304800@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151606.026852373@linuxfoundation.org> References: <20181211151606.026852373@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Filipe Manana commit f505754fd6599230371cb01b9332754ddc104be1 upstream. We were using the path name received from user space without checking that it is null terminated. While btrfs-progs is well behaved and does proper validation and null termination, someone could call the ioctl and pass a non-null terminated patch, leading to buffer overrun problems in the kernel. The ioctl is protected by CAP_SYS_ADMIN. So just set the last byte of the path to a null character, similar to what we do in other ioctls (add/remove/resize device, snapshot creation, etc). CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Anand Jain Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/super.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2104,6 +2104,7 @@ static long btrfs_control_ioctl(struct f vol = memdup_user((void __user *)arg, sizeof(*vol)); if (IS_ERR(vol)) return PTR_ERR(vol); + vol->name[BTRFS_PATH_NAME_MAX] = '\0'; switch (cmd) { case BTRFS_IOC_SCAN_DEV: