Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8100808imu; Tue, 4 Dec 2018 03:01:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/X/I1vw7DuVwn8BdFgSRRcZ0eshKua15Dh2QFqWq3EH8GQ0SjsDlpE0vMP9/zvG/vQA18Pv X-Received: by 2002:a63:7c13:: with SMTP id x19mr16140871pgc.45.1543921310173; Tue, 04 Dec 2018 03:01:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543921310; cv=none; d=google.com; s=arc-20160816; b=Kp1zwaP1TQH9l1nkrfCBfkCGtBJTzKCK+8gnzFJ51t18uaWNJj/WH2bFKXFYPx/t6f vjxRq7wrI2/dGGbersSi5lpT8h0jEh/+OO/muuvisNr2RumpeOC0P7vtUzuNocNTsQyi mD2Fe06fFBEA/lje2ta9JI9WlmP0XFnxN00PID3TLvkfXih5Y35EQVqn5UvmRWnNy2vP fXTYISqjf7dp5vxJ3rl/Moe8MDMmCGk97r2FyWMoKjEFfXS4H0iUAiDHyrXuRU3RrHn3 n6WUtSCKPj8wx6XAyzEHDer2+KNk9Cuyfgm+Jsa2KsHaBus/LuzVA3yL9KrnyxrkOdSE nbng== 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=cGSJCd25bPjJf+Ivp5ni61kJsOUaA++flF7ZzP2iLxA=; b=gz2fRQb+IrADZ8D5LkMg93743x243ETRVu2YS3czKzsXWCBlZQ0l6LQ5CH6qygm7Ul vdQgD6pxRB3xoMjX8VZj43scQFM7kElwG968hxM1mTxTBC6tJhHgCni+g4kwicrC3jk/ m1O1n7rc82vsHmNV/lEdLZyZ5KU4hwAXj1MxeH+qUUeb0RkoTjkP5pBqIscLT9M7KLcf 9Iy39oSBmy+5pGsNmPDNOIVNssjrOIjkeX0QahKcMnvxU5OvHCi9dym6odHNEWl2laMQ u5v3+N1erJjTMFlTwF9oSMLLq/6F+z9eZ8EuieLAWgACR701wXozAu0PDOTMX572DJ/S vvNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="qGMVgVM/"; 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 d23si14834639pgj.558.2018.12.04.03.01.33; Tue, 04 Dec 2018 03:01:50 -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="qGMVgVM/"; 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 S1727048AbeLDK6w (ORCPT + 99 others); Tue, 4 Dec 2018 05:58:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:43396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbeLDK6u (ORCPT ); Tue, 4 Dec 2018 05:58:50 -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 9BE4020878; Tue, 4 Dec 2018 10:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921130; bh=4AdDbPfadk49x3wuhaFAXMJNfhqhPKdzIlSeenvNwR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qGMVgVM/0dD8WADoUKAsjapvCRswyOMOwn4N+sqyL4DlbR40G2wa4E5PCNqfKHIwh nspM0mrbK5S4Y4eLbyAc04YzCGdehtbol6jrmaeiOQSGR9KoPZLKYAThlmr6MYeiTY HHcp8YFdovolNOWiRNEuwJ+9SE/MTJyB3O/Nd5Mk= 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.19 075/139] Btrfs: ensure path name is null terminated at btrfs_control_ioctl Date: Tue, 4 Dec 2018 11:49:16 +0100 Message-Id: <20181204103653.198863469@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103649.950154335@linuxfoundation.org> References: <20181204103649.950154335@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.19-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 @@ -2235,6 +2235,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: