Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7278990yba; Thu, 2 May 2019 07:19:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDDnu7UcVh1tPG1elkvQpaS936Tp9QRUA17bKvYMRccbZfH2qYI5jv4xSl8mNnFwsGrcUt X-Received: by 2002:a17:902:bb96:: with SMTP id m22mr4027993pls.185.1556806768065; Thu, 02 May 2019 07:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556806768; cv=none; d=google.com; s=arc-20160816; b=wNLcW0iHel6IsfdY0QMUPyiMKVmI/ce14wHgSMIcPRQ1IlISi0esoN0nT5T0yTwJal R4AAi7Y6M4VGxV9M6qw54Y70ubBcw/3YzLhNFBxVYbpSl/U7lqTrBypwCtGii4dMYnUC El259sYuf9JfyWWZqA7scTUPx8tGE+ubQSqOwt3ha02RDbJyTP4wpPSTbUzXvPQmX4mt 6LoFylMK8lxGrHpqlqAk9x1oYOJEeeSUa3KYg/ReXgk9It9ez56C5MGTh+sE5JXcVkUi bMib5kT5kn63/RbK5WVgOHhsfWBxi7JaiHma/2BdtiyFfIYYsAR4H11jr2xHIvxNhU2q jKYg== 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=/Pl7O7DA11ZmwofiFnYS1dR7GXgUOCPP7CmZlKTbgIY=; b=tWw8DIYTm6XAPE8UFhactOmVKViWlgKNt3QD7SIiw/098x5xBn161LUwW6pcftmtvo LgAh6vEyxKIlq8GvlIVNJ69QSUx/6AsZLhF3HoOQ5xEOrjc+ErCIUB+QdMHh7XN+lrGb tVAnTqkm2FdeTPeUzOGdY1kycGz+qzWg6QAiNKMJ5lL9m9JQhpcOMsfEkjsI2juNGSqG 0+AHDD/WInZXSILiJ3R0QJp+0jEeTKc0U1PMkOAndpeRER5m0PCwF8WrgBa+1ODcm6y1 8aHun75NpgjRlfF0/+4yMESX7Wbqi0wHetl1OV5dDL0hRA2Nbl3pknhZuQri8TgDscUN GsNA== 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 102si33367961plc.239.2019.05.02.07.19.12; Thu, 02 May 2019 07:19:28 -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 S1726549AbfEBOPm (ORCPT + 99 others); Thu, 2 May 2019 10:15:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:51402 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726327AbfEBOPM (ORCPT ); Thu, 2 May 2019 10:15:12 -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 82947AD9F; Thu, 2 May 2019 14:15:11 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id CF641E0156; Thu, 2 May 2019 16:15:10 +0200 (CEST) Message-Id: In-Reply-To: References: From: Michal Kubecek Subject: [PATCH net-next v2 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 16:15:10 +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 Reviewed-by: Johannes Berg Reviewed-by: David Ahern --- 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