Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4750913pxj; Wed, 12 May 2021 12:23:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH5Z0xQofC9298U8QOnkf7tAWmX/Js3qMM82YD9lGq8di1aF6qzFCukpMTz95BFfn/jKE0 X-Received: by 2002:a17:906:594c:: with SMTP id g12mr11520201ejr.267.1620847386495; Wed, 12 May 2021 12:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620847386; cv=none; d=google.com; s=arc-20160816; b=mUYHVYOfKEdljmRMEeqhLyPwHV/CRnDnUn+M3Nnl00AF+UZopaxBZmVOjEFCQbfRs2 mAqszQyOzTMcBSjHeolCBjLtdbAAZioU/FAHtmg3JvdESKlBzewwP5hQqtwNMXSxrpvt S2Hm9spogMzLn/VcbWgf3OzcjgWGfPHvHWAeSKB/s+gi5oo7Yl4aIzAUG4RAoWYSXDYN AkANTW1ORZkrV3RyPuWVjn5RHMoqIOGHkFKR7j/JSCDSOrBk8ttATr9aFoFzxFCXs2XH dbdyNxac66ZXGiR/NW9S9AAdYLvf9/MGQHOah26l8MzPQF1ooK1cViToROi0HF1vMNAB jE4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9Udn60b8EXtnhpykkzUiLZ5EgfVRjS/v0Jn+uXSJbhc=; b=B5Mnjs8RpWr6xU+kGvnVbzgZ0rFyRhzRyiAPJ7gVXNtwimeEPD5yBAv+pTTAdFjU+k Lew8IbjMBmfE9erNh6la4Pfj9fjZk6p7ROwOoAZnva73MDon1hj8jTuZiAWyWzu+CjlG BKGkpsRT/AwI2tB0kV1Ydm5kUlf4dGzEp86n3ceaVFfJDZ7KV2h42Dv5t2tuRvoqGdXu 47wOhII/ynVD+Qm6uJrfiQTqH1xxHOeoIhj7/tfKdS8tlot0EuikpwukgLZ0hJEmSgDj Y5QYr6WeR28XFWelt3HAgP9H8R1tl3RCYasFj73D9BhbbEmssIBk0ZfVLoOGrReNPTbs JoSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pueee3rX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs9si614734ejc.643.2021.05.12.12.22.42; Wed, 12 May 2021 12:23:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pueee3rX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376739AbhELTPh (ORCPT + 99 others); Wed, 12 May 2021 15:15:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:42358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244436AbhELQqD (ORCPT ); Wed, 12 May 2021 12:46:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7F06F61E72; Wed, 12 May 2021 16:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620836089; bh=wldFpXk7J5dSO2jDrGOR0jFyaXmfUj1pKOG5pOMLCfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pueee3rXoouFBynRAhHaDyoQyRCNidqkSvWdEC9mYxg1bZUuC0VjIgCM2eAeOHorG tGng53ld9RrtqhvHFm8/Qs9LVB9LLiH5N76M4VQS3SXokUhPgF5zDblq90aBKM4ll2 yBeIwMP7xbQwZGgIKoY3YUbdymTZoQDD3nsVFw7k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Alessio Balsini , Miklos Szeredi , Sasha Levin Subject: [PATCH 5.12 570/677] fuse: fix matching of FUSE_DEV_IOC_CLONE command Date: Wed, 12 May 2021 16:50:16 +0200 Message-Id: <20210512144856.333623127@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alessio Balsini [ Upstream commit 6076f5f341e612152879bfda99f0b76c1953bf0b ] With commit f8425c939663 ("fuse: 32-bit user space ioctl compat for fuse device") the matching constraints for the FUSE_DEV_IOC_CLONE ioctl command are relaxed, limited to the testing of command type and number. As Arnd noticed, this is wrong as it wouldn't ensure the correctness of the data size or direction for the received FUSE device ioctl. Fix by bringing back the comparison of the ioctl received by the FUSE device to the originally generated FUSE_DEV_IOC_CLONE. Fixes: f8425c939663 ("fuse: 32-bit user space ioctl compat for fuse device") Reported-by: Arnd Bergmann Signed-off-by: Alessio Balsini Signed-off-by: Miklos Szeredi Signed-off-by: Sasha Levin --- fs/fuse/dev.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index c0fee830a34e..a5ceccc5ef00 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2233,11 +2233,8 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd, int oldfd; struct fuse_dev *fud = NULL; - if (_IOC_TYPE(cmd) != FUSE_DEV_IOC_MAGIC) - return -ENOTTY; - - switch (_IOC_NR(cmd)) { - case _IOC_NR(FUSE_DEV_IOC_CLONE): + switch (cmd) { + case FUSE_DEV_IOC_CLONE: res = -EFAULT; if (!get_user(oldfd, (__u32 __user *)arg)) { struct file *old = fget(oldfd); -- 2.30.2