From patchwork Thu Apr 16 11:43:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wuqixuan X-Patchwork-Id: 6225351 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7EBAF9F313 for ; Thu, 16 Apr 2015 11:44:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A72DA201BC for ; Thu, 16 Apr 2015 11:44:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE7842013D for ; Thu, 16 Apr 2015 11:44:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757180AbbDPLoL (ORCPT ); Thu, 16 Apr 2015 07:44:11 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:22306 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754754AbbDPLoL (ORCPT ); Thu, 16 Apr 2015 07:44:11 -0400 Received: from 172.24.2.119 (EHLO szxeml425-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CMF46764; Thu, 16 Apr 2015 19:44:07 +0800 (CST) Received: from [127.0.0.1] (10.66.68.134) by szxeml425-hub.china.huawei.com (10.82.67.180) with Microsoft SMTP Server id 14.3.158.1; Thu, 16 Apr 2015 19:43:52 +0800 Message-ID: <552FA066.3010905@huawei.com> Date: Thu, 16 Apr 2015 19:43:34 +0800 From: Wuqixuan User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: , , Subject: [PATCH] fs/sync.c : Add CAP_SYS_ADMIN checking before sync X-Originating-IP: [10.66.68.134] X-CFilter-Loop: Reflected Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The process, supposed in one container, can't flush the metadata and data of the all host's partitions without CAP_SYS_ADMIN capability, like sys_mount is doing. The checking will prevent some vicious programs impacting IO sequnces of those partitions, particularly, the ones which can't be accessed in the container. Signed-off-by: Last Wu --- fs/sync.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/sync.c b/fs/sync.c index fbc98ee..9f07909 100644 --- a/fs/sync.c +++ b/fs/sync.c @@ -103,6 +103,9 @@ SYSCALL_DEFINE0(sync) { int nowait = 0, wait = 1; + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + wakeup_flusher_threads(0, WB_REASON_SYNC); iterate_supers(sync_inodes_one_sb, NULL); iterate_supers(sync_fs_one_sb, &nowait);