From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753092AbcFIVcc (ORCPT ); Thu, 9 Jun 2016 17:32:32 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:51481 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932311AbcFIVUN (ORCPT ); Thu, 9 Jun 2016 17:20:13 -0400 From: Kamal Mostafa To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Cc: Nicolas Dichtel , "David S . Miller" , Kamal Mostafa Subject: [PATCH 4.2.y-ckt 170/206] taskstats: fix nl parsing in accounting/getdelays.c Date: Thu, 9 Jun 2016 14:16:19 -0700 Message-Id: <1465507015-23052-171-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1465507015-23052-1-git-send-email-kamal@canonical.com> References: <1465507015-23052-1-git-send-email-kamal@canonical.com> X-Extended-Stable: 4.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.2.8-ckt12 -stable review patch. If anyone has any objections, please let me know. ---8<------------------------------------------------------------ From: Nicolas Dichtel commit 570d8e9398011a63590c281a36cdce311196608e upstream. The type TASKSTATS_TYPE_NULL should always be ignored. When jumping to the next attribute, only the length of the current attribute should be added, not the length of all nested attributes. This last bug was not visible before commit 80df554275c2, because the kernel didn't put more than two nested attributes. Fixes: a3baf649ca9c ("[PATCH] per-task-delay-accounting: documentation") Fixes: 80df554275c2 ("taskstats: use the libnl API to align nlattr on 64-bit") Signed-off-by: Nicolas Dichtel Signed-off-by: David S. Miller Signed-off-by: Kamal Mostafa --- Documentation/accounting/getdelays.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c index f405780..9497d20 100644 --- a/Documentation/accounting/getdelays.c +++ b/Documentation/accounting/getdelays.c @@ -504,6 +504,8 @@ int main(int argc, char *argv[]) if (!loop) goto done; break; + case TASKSTATS_TYPE_NULL: + break; default: fprintf(stderr, "Unknown nested" " nla_type %d\n", @@ -511,7 +513,8 @@ int main(int argc, char *argv[]) break; } len2 += NLA_ALIGN(na->nla_len); - na = (struct nlattr *) ((char *) na + len2); + na = (struct nlattr *)((char *)na + + NLA_ALIGN(na->nla_len)); } break; -- 2.7.4