From patchwork Sat Oct 21 13:28:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Belouin X-Patchwork-Id: 10021417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ECF9A60234 for ; Sat, 21 Oct 2017 14:00:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4C51285A4 for ; Sat, 21 Oct 2017 14:00:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8F3428BCD; Sat, 21 Oct 2017 14:00:47 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 135AC285A4 for ; Sat, 21 Oct 2017 14:00:46 +0000 (UTC) Received: (qmail 9377 invoked by uid 550); 21 Oct 2017 14:00:42 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 15832 invoked from network); 21 Oct 2017 13:30:32 -0000 From: Nicolas Belouin To: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: Nicolas Belouin Date: Sat, 21 Oct 2017 15:28:06 +0200 Message-Id: <20171021132806.18086-1-nicolas@belouin.fr> X-Mailer: git-send-email 2.14.2 X-Antivirus: Dr.Web (R) for Unix mail servers drweb plugin ver.6.0.2.8 X-Antivirus-Code: 0x100000 Subject: [kernel-hardening] [PATCH] fs: Use CAP_DAC_OVERRIDE to allow for file dedupe X-Virus-Scanned: ClamAV using ClamSMTP In its current implementation the check is against CAP_SYS_ADMIN, however this capability is bloated and inapropriate for this use. Indeed the check aims to avoid dedupe against non writable files, falling directly in the use case of CAP_DAC_OVERRIDE. Signed-off-by: Nicolas Belouin --- fs/read_write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/read_write.c b/fs/read_write.c index f0d4b16873e8..43cc7e84e29e 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1965,7 +1965,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) u64 len; int i; int ret; - bool is_admin = capable(CAP_SYS_ADMIN); + bool is_admin = capable(CAP_SYS_ADMIN) || capable(CAP_DAC_OVERRIDE); u16 count = same->dest_count; struct file *dst_file; loff_t dst_off;