Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2659219pxj; Mon, 14 Jun 2021 04:15:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLk7ch66Bz81BMGzvjhMsQyH9WIe5IInzFnOL2xS9dwq3yZtNzQbQ57N6E7SorENTDTXKh X-Received: by 2002:aa7:c04e:: with SMTP id k14mr15842666edo.157.1623669317618; Mon, 14 Jun 2021 04:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623669317; cv=none; d=google.com; s=arc-20160816; b=OVbvJzfJO9VO+LGT1sHKwAe89si6ODfNQ8EMLj/s5zZWGa0A9hilh94hK0erK+4VlH gyQ68m2HKQ+zrSJQlV47MDqdFfG67jZrSVzTW37qzBfbvlJHqRMqnsIFn7FqYbY8kDJe fFUYuq4wVtHyY26JAAo5Tzl/UCodrw+CsT59lsjgUu5pG2tyUpykGElaCPz00l4OoU6i DdjgWCxIRlVp6Pz/M7s0WgKvk8sRFYrIMophmIZa1qw3bLHSmpGdpaoIspBSPe6CTUGI E0qqzJJvhWlFq2mvczmzv+OGiexwNqa0Bplg23PAfpBAtJytj+SrXC845MnTN55jrElV IxMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MIAvBb+ZQ4zO1I6rQAy13z+fFHngswNH5P1LFZbhfMM=; b=gcM6Oit8V6Lfi7OuvqnIi1EF2O1nc+A/h70StsKJVTXbrflinnQjq/IDHyhCXlhNo2 CT/ajE96SsfyKGNNMIjwCLncT/0dcnn0KDg8occfF6jbfS6FosJSUQKnfPFuptfcOO4m zAvxyCsR/z1YYTE05+LllG4PooXdMpCows1NKIP6XRpZ1YZSQl0UODEqcizHgVFNuHFC uVBbq82wBvFhONMnYrsDOywdDwumkVATRcmLSIaeQtEj+QUvUE+LcC3vQLu9S1VEKMz9 ddOjo18Dr4EprXVC7NhQLEY2k9iqnv4PkCHHSbgdZPyajYS5Cga6zmpa1+TgU+MiwrZ2 +JKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jLtpg7YP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si11280187edv.293.2021.06.14.04.14.55; Mon, 14 Jun 2021 04:15:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jLtpg7YP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235433AbhFNLOC (ORCPT + 99 others); Mon, 14 Jun 2021 07:14:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:36434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234453AbhFNLB6 (ORCPT ); Mon, 14 Jun 2021 07:01:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7C8C0617ED; Mon, 14 Jun 2021 10:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623667419; bh=KRjCISm4yquNeegIJ6KbpYAovwB+TTjR6etMae6EviM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jLtpg7YPw89V+iMaRAXlfcaGNuVi0/EoL/lpBlmUVs/AK29ai2sLbJagqNZ7f8sMG DvB6X4jK7u5UBnVOSNxF7Tgki2iZaPHNIadPDGO+h94jpiV3BnHZsoyuxnnj6tFZO6 HknY7DuQ5EZfzu+T7NjgrYmSrs/QX86ktOme0n8U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Kuznetsov , Andrey Krasichkov , Dmitry Yakunin , Tejun Heo Subject: [PATCH 5.10 063/131] cgroup1: dont allow \n in renaming Date: Mon, 14 Jun 2021 12:27:04 +0200 Message-Id: <20210614102655.164161071@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102652.964395392@linuxfoundation.org> References: <20210614102652.964395392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Kuznetsov commit b7e24eb1caa5f8da20d405d262dba67943aedc42 upstream. cgroup_mkdir() have restriction on newline usage in names: $ mkdir $'/sys/fs/cgroup/cpu/test\ntest2' mkdir: cannot create directory '/sys/fs/cgroup/cpu/test\ntest2': Invalid argument But in cgroup1_rename() such check is missed. This allows us to make /proc//cgroup unparsable: $ mkdir /sys/fs/cgroup/cpu/test $ mv /sys/fs/cgroup/cpu/test $'/sys/fs/cgroup/cpu/test\ntest2' $ echo $$ > $'/sys/fs/cgroup/cpu/test\ntest2' $ cat /proc/self/cgroup 11:pids:/ 10:freezer:/ 9:hugetlb:/ 8:cpuset:/ 7:blkio:/user.slice 6:memory:/user.slice 5:net_cls,net_prio:/ 4:perf_event:/ 3:devices:/user.slice 2:cpu,cpuacct:/test test2 1:name=systemd:/ 0::/ Signed-off-by: Alexander Kuznetsov Reported-by: Andrey Krasichkov Acked-by: Dmitry Yakunin Cc: stable@vger.kernel.org Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- kernel/cgroup/cgroup-v1.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -820,6 +820,10 @@ static int cgroup1_rename(struct kernfs_ struct cgroup *cgrp = kn->priv; int ret; + /* do not accept '\n' to prevent making /proc//cgroup unparsable */ + if (strchr(new_name_str, '\n')) + return -EINVAL; + if (kernfs_type(kn) != KERNFS_DIR) return -ENOTDIR; if (kn->parent != new_parent)