From patchwork Thu Apr 2 04:02:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 228270 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 15DA9C43331 for ; Thu, 2 Apr 2020 04:02:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D04B62074D for ; Thu, 2 Apr 2020 04:02:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585800147; bh=yEANSQNTDEg3s6+T/qARwfi+FDj8BcnZWcHkBnUGGoc=; h=Date:From:To:Subject:In-Reply-To:List-ID:From; b=TmhdVMEzpcWDE1E4XqFV8ckla8yt3NSHvGpH/7OjhPXQNkkY4cIdsgKIerC9zCjrI fzxk7oG9hTa1sY+hgXwFeJF/KdEY5VG/AUae/AD8RtFGMJxw6NeomWpvsyDMap1KyE 6bsqYNhSGNSPcTNPiljO35BroYIoJJeOlSd/HoH8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727746AbgDBEC1 (ORCPT ); Thu, 2 Apr 2020 00:02:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:45562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727734AbgDBEC1 (ORCPT ); Thu, 2 Apr 2020 00:02:27 -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 2EFE4206E9; Thu, 2 Apr 2020 04:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585800146; bh=yEANSQNTDEg3s6+T/qARwfi+FDj8BcnZWcHkBnUGGoc=; h=Date:From:To:Subject:In-Reply-To:From; b=ZctaS9Q18US50tNh3+0RJhcFMHFN1AUNshtzEwAl+e3RPbfuIR/mZlb6a//aFm4Ab 10SeDC0jOavpEYd8z8n+HPBUPxHFTrm1Tpeltv4Soz1LtsuAJ4EG129cFgwptNH/mf m6MP6wepRAm2OHJsyMdHZI1Kx2YssFyb9dm9+vrM= Date: Wed, 01 Apr 2020 21:02:25 -0700 From: Andrew Morton To: akpm@linux-foundation.org, dsahern@kernel.org, johannes@sipsolutions.net, laoar.shao@gmail.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, nagar@watson.ibm.com, stable@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 001/155] tools/accounting/getdelays.c: fix netlink attribute length Message-ID: <20200402040225.favho3pCV%akpm@linux-foundation.org> In-Reply-To: <20200401210155.09e3b9742e1c6e732f5a7250@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 From: David Ahern Subject: tools/accounting/getdelays.c: fix netlink attribute length A recent change to the netlink code: 6e237d099fac ("netlink: Relax attr validation for fixed length types") logs a warning when programs send messages with invalid attributes (e.g., wrong length for a u32). Yafang reported this error message for tools/accounting/getdelays.c. send_cmd() is wrongly adding 1 to the attribute length. As noted in include/uapi/linux/netlink.h nla_len should be NLA_HDRLEN + payload length, so drop the +1. Link: http://lkml.kernel.org/r/20200327173111.63922-1-dsahern@kernel.org Fixes: 9e06d3f9f6b1 ("per task delay accounting taskstats interface: documentation fix") Signed-off-by: David Ahern Reported-by: Yafang Shao Tested-by: Yafang Shao Cc: Johannes Berg Cc: Shailabh Nagar Cc: Signed-off-by: Andrew Morton --- tools/accounting/getdelays.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/accounting/getdelays.c~getdelays-fix-netlink-attribute-length +++ a/tools/accounting/getdelays.c @@ -136,7 +136,7 @@ static int send_cmd(int sd, __u16 nlmsg_ msg.g.version = 0x1; na = (struct nlattr *) GENLMSG_DATA(&msg); na->nla_type = nla_type; - na->nla_len = nla_len + 1 + NLA_HDRLEN; + na->nla_len = nla_len + NLA_HDRLEN; memcpy(NLA_DATA(na), nla_data, nla_len); msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len);