Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7182230yba; Thu, 2 May 2019 05:49:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7be4WLZ2JoGT73Bh7LEVvQn6EijXx2/rqxzF6hQSv+DGBZfB22tMHV7tsVetNzCR862mi X-Received: by 2002:a17:902:2827:: with SMTP id e36mr3478982plb.45.1556801364800; Thu, 02 May 2019 05:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556801364; cv=none; d=google.com; s=arc-20160816; b=oFlR9Wzugp7KyjYPEj8W5CmbMLAGcxyDs5Lsh/zIaCWGvRkqTRGvtlCnIEmzg9ZTgi Cw16koBQ31dGDEguyNbvOPs7AuvpOhQSn1hafOuFg7bHoO3nkjjxGRTMPj+tLAiBWtox yW+HxMdj/xWOMJrh7sqU4ah6oRtXW/HsG6RCfjMYgm2MM7o7hJkLKpPmhiI/cztfoiMY KO2lOFCDH49fXsfeRtcr6Suna2ziMGXspArVL0OVNgHxO8P21uG05P/LsxWTBMowtyBe OtpOuNYbKF0o7fI1tIKWyvO0AsuNDQpKl1lSmqyqA2Y2o4oK3YDSbXToghQhqPduGu0n pOTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=ocPtUm+KzQlrnXH6GpmUYwjwYLcKWHFQsnK06wEC2hY=; b=v/9aL23ARhzVQfRhPrUCZmsgIO8BnDIFGx/Bx2Jd63gxGeX9L7IcBMZbpoWclpBZHH xmrC3vWZGICSgg+NbV4/1hmpWUNwDyeZykkTYNzwx721knjHMZxlBGngmIB0J6VCOe9S jPlV7FMpiyoMQNbXsChZFgyTWXoBcP/CwaFFzP3AxkCWhYcvA2Vkugt9NXmvSw8GXDNR a7hUpXor8WQszvKGO2rBusyZHy3swhH4KDC639cfKr/fsXETSDq7PX0y7yXYFnEgSXs+ P3ap3LqFUY9GHuMQeIWZyOqY4rlEydUNi2VWkA8ROkmfuYtijuctUXgFCEjNNdKU1Xfe 9E2Q== ARC-Authentication-Results: i=1; mx.google.com; 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 c13si15609866plo.175.2019.05.02.05.49.08; Thu, 02 May 2019 05:49:24 -0700 (PDT) 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; 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 S1726595AbfEBMsH (ORCPT + 99 others); Thu, 2 May 2019 08:48:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:33946 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726383AbfEBMsC (ORCPT ); Thu, 2 May 2019 08:48:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0874DAEDB; Thu, 2 May 2019 12:48:00 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 63222E0156; Thu, 2 May 2019 14:48:00 +0200 (CEST) Message-Id: In-Reply-To: References: From: Michal Kubecek Subject: [PATCH net-next 2/3] netlink: set bad attribute also on maxtype check To: "David S. Miller" Cc: netdev@vger.kernel.org, Johannes Berg , David Ahern , linux-kernel@vger.kernel.org Date: Thu, 2 May 2019 14:48:00 +0200 (CEST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The check that attribute type is within 0...maxtype range in __nla_validate_parse() sets only error message but not bad_attr in extack. Set also bad_attr to tell userspace which attribute failed validation. Signed-off-by: Michal Kubecek --- lib/nlattr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/nlattr.c b/lib/nlattr.c index 29f6336e2422..adc919b32bf9 100644 --- a/lib/nlattr.c +++ b/lib/nlattr.c @@ -356,7 +356,8 @@ static int __nla_validate_parse(const struct nlattr *head, int len, int maxtype, if (type == 0 || type > maxtype) { if (validate & NL_VALIDATE_MAXTYPE) { - NL_SET_ERR_MSG(extack, "Unknown attribute type"); + NL_SET_ERR_MSG_ATTR(extack, nla, + "Unknown attribute type"); return -EINVAL; } continue; -- 2.21.0