From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757227AbbDPLoX (ORCPT ); Thu, 16 Apr 2015 07:44:23 -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 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 Content-Type: text/plain; charset="GB2312" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.66.68.134] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) 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); -- 1.9.1