Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3635262imu; Mon, 28 Jan 2019 08:11:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN6zuQVWVz0N0vzxlYiixjo7Mn8Zcq0kaE10sqz1R+stk3MeM8sN5LmNYqLnPi/or0ij2TJj X-Received: by 2002:a17:902:ba8b:: with SMTP id k11mr22278395pls.177.1548691900938; Mon, 28 Jan 2019 08:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691900; cv=none; d=google.com; s=arc-20160816; b=LqnXB5HK2GQP+C2rJGWae2I/xbAVnzxiLLPP9F3rFSh8qMkfAZ5Sz+f99iLAtvMM5z /43g+f4vNca55I79nzntLNII8i74FYb/0TAZFm4ehlS5ZrA4r0jarrKJiQ81l+TghILm 12uusdMWgih8T8mb+wsR4PhndI3NzozZHb6CT3L02c+i6c5aZIwWrTLZtWwnUMl5Ixkk G9xNnlvPfRqcO1++Vstk49xxg79+62hhbswwgjW9O/SY1AGbcpnMnXI52MlzdX9FX7fY FGtNo4sVJZR9/u9wVuIFKfmuGLpmEhsHjJuoxcuDO/glMy4qiOukV3Ui/bZ21YpAL+fb NCnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d862hn5NyNNaOYxWYnj5vCWQfX8I55MCefbFzsSKYo4=; b=oMuNGGYQK8xsP1/1tDZplSo9i3TJUu858g+JOwQMDZRf14zEqZzj9WQbkhm6dazKWl fbDlv2m6k4aUH+L9RKRXgiAXRUsb2EOENEPSCuhxe4tIQHNNsIgDciSb/PQ/9Cf1LgBV hiyatJAr0565TieuLR2G41W9BmCgb/uogMVRanctNCRWcX3Sa8b+NKc8OFjJmB7Qhp/n qNV/YiVFFEa7wRqUjLtn3S4PtiseF3AY6QOah2U2cqvJ3QKqjWN7rW/EVPFItRdEZzkt nz9rlkgrCDznnYD7/v599Ad0dc+efs6pbhYR3eBRq7M8IUbm3BtYT6kJrGic/yEc+bX9 dh8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eR4SnWTY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2si16079666pgj.104.2019.01.28.08.11.25; Mon, 28 Jan 2019 08:11:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eR4SnWTY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732811AbfA1QKb (ORCPT + 99 others); Mon, 28 Jan 2019 11:10:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:36464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732345AbfA1QK3 (ORCPT ); Mon, 28 Jan 2019 11:10:29 -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 12B7921738; Mon, 28 Jan 2019 16:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691829; bh=KOsus9xJWb51QeK4RNQD+lzR12jV4nQQJ2SBBKX/baI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eR4SnWTYuasN0EpG/SdNfGVQeJUG0hJxi4p8bASp9qtTIVOxoyOV/CC4AgLW2DoAI T9P9NdYijv8kRHI21c3mKnSmqUhGf0L3HXHT50f4yrm3fk+kGjSW0fMvMsQaP/CiHq /uIHN2xu0N7hsO9pi3UOHru0GMFfdVyHslkrUcH0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ondrej Mosnacek , Tejun Heo , Sasha Levin Subject: [PATCH AUTOSEL 4.19 231/258] cgroup: fix parsing empty mount option string Date: Mon, 28 Jan 2019 10:58:57 -0500 Message-Id: <20190128155924.51521-231-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-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 1aa517908561..e578c3999970 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -1743,7 +1743,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