From patchwork Mon Nov 9 12:54:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 322587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF583C388F7 for ; Mon, 9 Nov 2020 13:42:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEB60206B2 for ; Mon, 9 Nov 2020 13:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604929345; bh=99OUfKmhEX8Y8oEVWQie1vocVS/5EWsoArtu+G30j/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qoezZg8mCjpiouDKPBRqd4RNq3ywE4yn6OOA5z7db1r/zO5rJ6fyn+D0hceUksmSo olUXQwSHAsmA8vxi5EhFPk2nWW8dASo5beMBuxOQKEu+IlcyuB4eCptT0Me2uKnut3 jS9L8tLjtH6MFN2/mTfX6nvmIbD/6MmGiGtWZ0jQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730009AbgKINmI (ORCPT ); Mon, 9 Nov 2020 08:42:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:55188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730549AbgKINBI (ORCPT ); Mon, 9 Nov 2020 08:01:08 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 A8FDA20789; Mon, 9 Nov 2020 13:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604926867; bh=99OUfKmhEX8Y8oEVWQie1vocVS/5EWsoArtu+G30j/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Y5bfnbkrO3Bdp5PnVCU7K16yod3ChG8IH5au2GKYLV1Nkujy1ACEynEyMJxGrcXd PqN58xz54LdTntuvIoOoaJoIA6NIJdtfopSBpGNLQofTjc3OBGPRxNjBo9wEVtopf3 GAuN/p+KsQP4Vytm+dn8Q9soOsNzbo+tqAFeifgs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Theodore Tso Subject: [PATCH 4.9 014/117] fscrypt: use EEXIST when file already uses different policy Date: Mon, 9 Nov 2020 13:54:00 +0100 Message-Id: <20201109125026.326180094@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125025.630721781@linuxfoundation.org> References: <20201109125025.630721781@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Eric Biggers commit 8488cd96ff88966ccb076e4f3654f59d84ba686d upstream. As part of an effort to clean up fscrypt-related error codes, make FS_IOC_SET_ENCRYPTION_POLICY fail with EEXIST when the file already uses a different encryption policy. This is more descriptive than EINVAL, which was ambiguous with some of the other error cases. I am not aware of any users who might be relying on the previous error code of EINVAL, which was never documented anywhere. This failure case will be exercised by an xfstest. Signed-off-by: Eric Biggers Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/crypto/policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -131,7 +131,7 @@ int fscrypt_ioctl_set_policy(struct file printk(KERN_WARNING "%s: Policy inconsistent with encryption context\n", __func__); - ret = -EINVAL; + ret = -EEXIST; } inode_unlock(inode);