From patchwork Sun Aug 4 09:56:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 11074725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02322912 for ; Sun, 4 Aug 2019 09:57:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC44F2886C for ; Sun, 4 Aug 2019 09:57:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBF1928869; Sun, 4 Aug 2019 09:57:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C4C028869 for ; Sun, 4 Aug 2019 09:57:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726016AbfHDJ5J (ORCPT ); Sun, 4 Aug 2019 05:57:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:55410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfHDJ5J (ORCPT ); Sun, 4 Aug 2019 05:57:09 -0400 Received: from localhost.localdomain (unknown [180.111.32.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 454E720665; Sun, 4 Aug 2019 09:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564912629; bh=s1HN0HFWrzjCco1eavATf8vuBvGG9VhqmF59WM2sedc=; h=From:To:Cc:Subject:Date:From; b=qlHSPxQcEtXpsmJZiBR6c8s+/BOMOi2NbzqL7k7TVxG+4oV5iNnvXovD8aHza7/Is LV7LAqabdnpCLPQhb/PIanHegEoqShLKcHsjAgMB6mmeU+v/OzBRSt3ktEGXMytt4e iL/5bsVPQ8kfe4ojeZ56MH63Yz1vS6tCXA+Q/MHE= From: Chao Yu To: tytso@mit.edu, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, ebiggers@kernel.org, linux-fscrypt@vger.kernel.org, chao@kernel.org, Chao Yu Subject: [PATCH] ext4 crypto: fix to check feature status before get policy Date: Sun, 4 Aug 2019 17:56:43 +0800 Message-Id: <20190804095643.7393-1-chao@kernel.org> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Chao Yu When getting fscrypto policy via EXT4_IOC_GET_ENCRYPTION_POLICY, if encryption feature is off, it's better to return EOPNOTSUPP instead of ENODATA, so let's add ext4_has_feature_encrypt() to do the check for that. Signed-off-by: Chao Yu Signed-off-by: Chao Yu Signed-off-by: Eric Biggers --- fs/ext4/ioctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 442f7ef873fc..bf87835c1237 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -1112,9 +1112,11 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) return -EOPNOTSUPP; #endif } - case EXT4_IOC_GET_ENCRYPTION_POLICY: + case EXT4_IOC_GET_ENCRYPTION_POLICY: { + if (!ext4_has_feature_encrypt(sb)) + return -EOPNOTSUPP; return fscrypt_ioctl_get_policy(filp, (void __user *)arg); - + } case EXT4_IOC_FSGETXATTR: { struct fsxattr fa;