Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2751840imj; Mon, 11 Feb 2019 07:58:40 -0800 (PST) X-Google-Smtp-Source: AHgI3IbsUnmd8Q7D5hHPJM1fsuNOenCkKoTVJTF/cjGrfTOYEFa/YcSrXQIKspbcqj1cUNflRKRj X-Received: by 2002:a63:e516:: with SMTP id r22mr29899228pgh.256.1549900720327; Mon, 11 Feb 2019 07:58:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900720; cv=none; d=google.com; s=arc-20160816; b=GKTpyc7LCtn62YfDWhhr0msdn9hkCGRufWCoy0cTDwAHS/Bo3ediO1NyP4Hcl19ud1 q7tHSFXdfJDJwXzRMcj2UlK6QncZhXB+MowHYyTuSzVtsaONGbxwJUbY78uS9F/n8x3n yo2mBLN9UMPQj1cyX72eL+CHK+OV6lz0+IGzUgQSslyJLWzA9DhFsDULyvSzmjpRCzfk 26tObXSaPFji7OfmE/+x4Z8H41zf66vVD9iJYveutfvn3nbvwxb4HZFrcDwo+71jI9wN yntXzYZqWieK5Z33fzAmEiqLFMRv20HzmFw8rWAM28b5S6WSNpj534oYv55U4rTSKrg9 Cx0A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pvUyStXP4qu1eqALljgaBjdVnlfzB62mOBjydpMU+to=; b=rtTT5zLwydU5guW1/Bkj6HSYv5xD42r6xKpTntXBzGFLmsRxzaDix7GoVbEm3vuok6 FXdYEJEtD7G1lIEWC2dzmpyNU2RsbVejf5HJjWjilrPCD+xdAsCcHbJFXPCU+Jl3FvEF EhKWGYM06ePxO7Uc4GHrW/6Vf6Q6XCrkjLrkRcyfIzrCAwEmObW9XEnVS7QfgHhGc26W +O0IAOYkbSx0D44v5jJoB6Cyih2aDL4tC0v/lpgIFzWxLyqtYbV2h1U4RfMQMvYKbA/P LAgNuTYE7blaps/Lg4/vU9uhdxfGBZqfVF9uwbtwLF7gxeMmCdKDY1gm9iZ3sCWwgn05 H9aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EJHYGCZs; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19si1353368pgh.564.2019.02.11.07.58.23; Mon, 11 Feb 2019 07:58: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=EJHYGCZs; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730668AbfBKOdg (ORCPT + 99 others); Mon, 11 Feb 2019 09:33:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:41262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730648AbfBKOda (ORCPT ); Mon, 11 Feb 2019 09:33:30 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 394C520844; Mon, 11 Feb 2019 14:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895609; bh=mtvvRI3wp9+pV9E1Y73ZMdakdEsymN7zWb1ePqQQc88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EJHYGCZsSUoT3jPtleyz682uylD2eP8AwRLdMv4bMRWFJRu1QIWwhOoKeqNbSt4EZ 9KhbrVE0hqDNJeR5vCP57ZO0iSkfPSTyu6cBc/B1YB31dt5VBKyVwtfDUVkVhsh/9S uhsdphheWZf6hdKn/WUYA0n9Fse8JzZN7ZGNHV1E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Smalley , Ondrej Mosnacek , Tejun Heo , Sasha Levin Subject: [PATCH 4.20 262/352] cgroup: fix parsing empty mount option string Date: Mon, 11 Feb 2019 15:18:09 +0100 Message-Id: <20190211141903.715636746@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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