Re: [PATCH 1/2] netlink: add NLA_REJECT policy type

4 messages, 3 authors, 2018-09-14 · open the first message on its own page

Re: [PATCH 1/2] netlink: add NLA_REJECT policy type

From: Johannes Berg <hidden>
Date: 2018-09-13 11:25:15

On Thu, 2018-09-13 at 12:49 +0200, Michal Kubecek wrote:
quoted
 		if (type > 0 && type <= maxtype) {
 			if (policy) {
-				err = validate_nla(nla, maxtype, policy);
+				err = validate_nla(nla, maxtype, policy,
+						   extack);
 				if (err < 0) {
-					NL_SET_ERR_MSG_ATTR(extack, nla,
-							    "Attribute failed policy validation");
+					NL_SET_BAD_ATTR(extack, nla);
+					if (extack && !extack->_msg)
+						NL_SET_ERR_MSG(extack,
+							       "Attribute failed policy validation");
 					goto errout;
 				}
 			}
-- 
Technically, this would change the outcome when nla_parse() is called
with extack->_msg already set nad validate_nla() fails on something else
than NLA_REJECT; it will preserve the previous message in such case.
But I don't think this is a serious problem.
Yes, that's true. I looked at quite a few of the setters just now (there
are ~500 already, wow!), and they all set & return, so this shouldn't be
an issue.

johannes

Re: [PATCH 1/2] netlink: add NLA_REJECT policy type

From: Michal Kubecek <hidden>
Date: 2018-09-13 17:15:06

On Thu, Sep 13, 2018 at 01:25:15PM +0200, Johannes Berg wrote:
On Thu, 2018-09-13 at 12:49 +0200, Michal Kubecek wrote:
quoted
quoted
 		if (type > 0 && type <= maxtype) {
 			if (policy) {
-				err = validate_nla(nla, maxtype, policy);
+				err = validate_nla(nla, maxtype, policy,
+						   extack);
 				if (err < 0) {
-					NL_SET_ERR_MSG_ATTR(extack, nla,
-							    "Attribute failed policy validation");
+					NL_SET_BAD_ATTR(extack, nla);
+					if (extack && !extack->_msg)
+						NL_SET_ERR_MSG(extack,
+							       "Attribute failed policy validation");
 					goto errout;
 				}
 			}
-- 
Technically, this would change the outcome when nla_parse() is called
with extack->_msg already set nad validate_nla() fails on something else
than NLA_REJECT; it will preserve the previous message in such case.
But I don't think this is a serious problem.
Yes, that's true. I looked at quite a few of the setters just now (there
are ~500 already, wow!), and they all set & return, so this shouldn't be
an issue.
In ethtool (work in progress) I sometimes use extack message for
non-fatal warnings but AFAICS never before parsing the userspace
request (actually always shortly before returning). So I don't have
a problem with it.

Michal Kubecek

Re: [PATCH 1/2] netlink: add NLA_REJECT policy type

From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Date: 2018-09-14 00:31:10

On Thu, Sep 13, 2018 at 02:05:54PM +0200, Michal Kubecek wrote:
On Thu, Sep 13, 2018 at 01:25:15PM +0200, Johannes Berg wrote:
quoted
On Thu, 2018-09-13 at 12:49 +0200, Michal Kubecek wrote:
quoted
quoted
 		if (type > 0 && type <= maxtype) {
 			if (policy) {
-				err = validate_nla(nla, maxtype, policy);
+				err = validate_nla(nla, maxtype, policy,
+						   extack);
 				if (err < 0) {
-					NL_SET_ERR_MSG_ATTR(extack, nla,
-							    "Attribute failed policy validation");
+					NL_SET_BAD_ATTR(extack, nla);
+					if (extack && !extack->_msg)
+						NL_SET_ERR_MSG(extack,
+							       "Attribute failed policy validation");
 					goto errout;
 				}
 			}
-- 
Technically, this would change the outcome when nla_parse() is called
with extack->_msg already set nad validate_nla() fails on something else
than NLA_REJECT; it will preserve the previous message in such case.
But I don't think this is a serious problem.
Yes, that's true. I looked at quite a few of the setters just now (there
are ~500 already, wow!), and they all set & return, so this shouldn't be
an issue.
In ethtool (work in progress) I sometimes use extack message for
non-fatal warnings but AFAICS never before parsing the userspace
request (actually always shortly before returning). So I don't have
a problem with it.
Considering we can only report 1 message, it should be okay to drop
the previous message in favor of the new one, which is either a
critical one or just another non-fatal one.

  Marcelo

Re: [PATCH 1/2] netlink: add NLA_REJECT policy type

From: Michal Kubecek <hidden>
Date: 2018-09-14 01:55:03

On Thu, Sep 13, 2018 at 04:20:14PM -0300, Marcelo Ricardo Leitner wrote:
On Thu, Sep 13, 2018 at 02:05:54PM +0200, Michal Kubecek wrote:
quoted
On Thu, Sep 13, 2018 at 01:25:15PM +0200, Johannes Berg wrote:
quoted
On Thu, 2018-09-13 at 12:49 +0200, Michal Kubecek wrote:
quoted
quoted
 		if (type > 0 && type <= maxtype) {
 			if (policy) {
-				err = validate_nla(nla, maxtype, policy);
+				err = validate_nla(nla, maxtype, policy,
+						   extack);
 				if (err < 0) {
-					NL_SET_ERR_MSG_ATTR(extack, nla,
-							    "Attribute failed policy validation");
+					NL_SET_BAD_ATTR(extack, nla);
+					if (extack && !extack->_msg)
+						NL_SET_ERR_MSG(extack,
+							       "Attribute failed policy validation");
 					goto errout;
 				}
 			}
-- 
Technically, this would change the outcome when nla_parse() is called
with extack->_msg already set nad validate_nla() fails on something else
than NLA_REJECT; it will preserve the previous message in such case.
But I don't think this is a serious problem.
Yes, that's true. I looked at quite a few of the setters just now (there
are ~500 already, wow!), and they all set & return, so this shouldn't be
an issue.
In ethtool (work in progress) I sometimes use extack message for
non-fatal warnings but AFAICS never before parsing the userspace
request (actually always shortly before returning). So I don't have
a problem with it.
Considering we can only report 1 message, it should be okay to drop
the previous message in favor of the new one, which is either a
critical one or just another non-fatal one.
What I wanted to point out is that the code above does not behave like
this. It does not distinguish between extack->_msg set by NLA_REJECT
branch and extack->_msg which had been set before nla_parse() was
called.

Michal Kubecek
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help