From mboxrd@z Thu Jan 1 00:00:00 1970 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.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 8C11EC282CD for ; Mon, 28 Jan 2019 17:32:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5AABB2147A for ; Mon, 28 Jan 2019 17:32:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548696741; bh=deLd/TLG65eT0LwrJMQh3Zpq9hycuwPGr95Q8zxpuww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TJDWdLLbCz7wXBVXyRqe+g9i78zHZKBzZCbleLmvjFg1k+7lcwZkycInG1y4FIPEh gh+DwAViCWAHQ+oQbGRxLLSfnT2pl1woUlEJcNN6HHyRGpct6elRfHvqIxikVW0F9Z mx+fJ/w1rtsB/2fGohy1F84LPrmbrhRQSoBddy5k= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728363AbfA1P5h (ORCPT ); Mon, 28 Jan 2019 10:57:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:43012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729669AbfA1P5c (ORCPT ); Mon, 28 Jan 2019 10:57:32 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C53CC2183F; Mon, 28 Jan 2019 15:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691051; bh=deLd/TLG65eT0LwrJMQh3Zpq9hycuwPGr95Q8zxpuww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cAWZybxKE6TsIi4XBIyo/NboARKm9i+GRmxXrqmK+ya9PwIvVuCfMoLinTzpLq+qU Ch29JD7kT8STQlm2wJ3OvKZACbC0bVpsH2eXhpMFoub3n8pryyHJREp8H6V83aeiAx 42mGP5p8XyUWvuPZhUkan2QwKCMRuPR9QtATi/dM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ondrej Mosnacek , Tejun Heo , Sasha Levin Subject: [PATCH AUTOSEL 4.20 274/304] cgroup: fix parsing empty mount option string Date: Mon, 28 Jan 2019 10:43:11 -0500 Message-Id: <20190128154341.47195-274-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128154341.47195-1-sashal@kernel.org> References: <20190128154341.47195-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ondrej Mosnacek [ Upstream commit e250d91d65750a0c0c62483ac4f9f357e7317617 ] This fixes the case where all mount options specified are consumed by an LSM and all that's left is an empty string. In this case cgroupfs should accept the string and not fail. How to reproduce (with SELinux enabled): # umount /sys/fs/cgroup/unified # mount -o context=system_u:object_r:cgroup_t:s0 -t cgroup2 cgroup2 /sys/fs/cgroup/unified mount: /sys/fs/cgroup/unified: wrong fs type, bad option, bad superblock on cgroup2, missing codepage or helper program, or other error. # dmesg | tail -n 1 [ 31.575952] cgroup: cgroup2: unknown option "" Fixes: 67e9c74b8a87 ("cgroup: replace __DEVEL__sane_behavior with cgroup2 fs type") [NOTE: should apply on top of commit 5136f6365ce3 ("cgroup: implement "nsdelegate" mount option"), older versions need manual rebase] Suggested-by: Stephen Smalley Signed-off-by: Ondrej Mosnacek Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin --- kernel/cgroup/cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 1f84977fab47..498c6bcf992a 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -1744,7 +1744,7 @@ static int parse_cgroup_root_flags(char *data, unsigned int *root_flags) *root_flags = 0; - if (!data) + if (!data || *data == '\0') return 0; while ((token = strsep(&data, ",")) != NULL) { -- 2.19.1