From patchwork Thu Mar 26 20:05:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 228741 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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=no 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 A220CC43331 for ; Thu, 26 Mar 2020 20:05:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77FDC20714 for ; Thu, 26 Mar 2020 20:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585253104; bh=0KCnYsuM4FCGda9+swhWI+aSCP2OsC5jlIXzqH+fkp0=; h=Date:From:To:Subject:List-ID:From; b=Q39SWyRW9pF3igcvgts1jQfZZ9E1S+Kxs1HfJC7Jj5fqXeyaM7yaQaQTWdr9nAbvB R86AXp6yahKAUyGTXeH7pk5ur4mWCZevRyKXwtRsQrbtdEN5GRr/IjWuyEh6HG72vX DcC4cU8altMRogr/QJXfs0lAr0DeOp9WqEIu0Fa0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727719AbgCZUFE (ORCPT ); Thu, 26 Mar 2020 16:05:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:35648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727612AbgCZUFD (ORCPT ); Thu, 26 Mar 2020 16:05:03 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (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 A6279206E6; Thu, 26 Mar 2020 20:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585253103; bh=0KCnYsuM4FCGda9+swhWI+aSCP2OsC5jlIXzqH+fkp0=; h=Date:From:To:Subject:From; b=Z8CtXW8Z0oCyZyGL/JBBG/HJ5uYjZdRpqFFLCwxfc/+oSZLq2YpH5uOvoafj+nZsP 8/ljqpSKv/L+juNJKBDW2wK4NWhROWeOd4aIQKYSalF2fDuajVFnAxjTIT0tduo9ZL Igj0X/K95D2d8uHfe961FlLnJX1nhpDFlLhqxxik= Date: Thu, 26 Mar 2020 13:05:02 -0700 From: akpm@linux-foundation.org To: bsingharora@gmail.com, davem@davemloft.net, dsahern@gmail.com, johannes@sipsolutions.net, laoar.shao@gmail.com, mm-commits@vger.kernel.org, stable@vger.kernel.org Subject: + kernel-taskstats-fix-wrong-nla-type-for-cgrouptaskstats-policy.patch added to -mm tree Message-ID: <20200326200502.2a5joA7oB%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch titled Subject: kernel/taskstats: fix wrong nla type for {cgroup,task}stats policy has been added to the -mm tree. Its filename is kernel-taskstats-fix-wrong-nla-type-for-cgrouptaskstats-policy.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/kernel-taskstats-fix-wrong-nla-type-for-cgrouptaskstats-policy.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/kernel-taskstats-fix-wrong-nla-type-for-cgrouptaskstats-policy.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Yafang Shao Subject: kernel/taskstats: fix wrong nla type for {cgroup,task}stats policy After our server is upgraded to a newer kernel, we found that it continuesly print a warning in the kernel message. The warning is, [832984.946322] netlink: 'irmas.lc': attribute type 1 has an invalid length. irmas.lc is one of our container monitor daemons, and it will use CGROUPSTATS_CMD_GET to get the cgroupstats, that is similar with tools/accounting/getdelays.c. We can also produce this warning with getdelays. For example, after running bellow command $ ./getdelays -C /sys/fs/cgroup/memory then you can find a warning in dmesg, [61607.229318] netlink: 'getdelays': attribute type 1 has an invalid length. This warning is introduced in commit 6e237d099fac ("netlink: Relax attr validation for fixed length types"), which is used to check whether attributes using types NLA_U* and NLA_S* have an exact length. Regarding this issue, the root cause is cgroupstats_cmd_get_policy defines a wrong type as NLA_U32, while it should be NLA_NESTED an its minimal length is NLA_HDRLEN. That is similar to taskstats_cmd_get_policy. As this behavior change really breaks our application, we'd better cc stable as well. Link: http://lkml.kernel.org/r/1585191042-9935-1-git-send-email-laoar.shao@gmail.com Signed-off-by: Yafang Shao Cc: Balbir Singh Cc: David Ahern Cc: David S. Miller Cc: Johannes Berg Cc: Signed-off-by: Andrew Morton --- kernel/taskstats.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/kernel/taskstats.c~kernel-taskstats-fix-wrong-nla-type-for-cgrouptaskstats-policy +++ a/kernel/taskstats.c @@ -35,8 +35,8 @@ struct kmem_cache *taskstats_cache; static struct genl_family family; static const struct nla_policy taskstats_cmd_get_policy[TASKSTATS_CMD_ATTR_MAX+1] = { - [TASKSTATS_CMD_ATTR_PID] = { .type = NLA_U32 }, - [TASKSTATS_CMD_ATTR_TGID] = { .type = NLA_U32 }, + [TASKSTATS_CMD_ATTR_PID] = { .type = NLA_NESTED }, + [TASKSTATS_CMD_ATTR_TGID] = { .type = NLA_NESTED }, [TASKSTATS_CMD_ATTR_REGISTER_CPUMASK] = { .type = NLA_STRING }, [TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK] = { .type = NLA_STRING },}; @@ -45,7 +45,7 @@ static const struct nla_policy taskstats * Make sure they are always aligned. */ static const struct nla_policy cgroupstats_cmd_get_policy[TASKSTATS_CMD_ATTR_MAX+1] = { - [CGROUPSTATS_CMD_ATTR_FD] = { .type = NLA_U32 }, + [CGROUPSTATS_CMD_ATTR_FD] = { .type = NLA_NESTED }, }; struct listener {