tlshd: probe the attributes with correct attribute length#141
tlshd: probe the attributes with correct attribute length#141chucklever merged 1 commit intooracle:mainfrom
Conversation
chucklever
left a comment
There was a problem hiding this comment.
The diagnosis is correct — nla_put_string() sends a NUL-terminated string for HANDSHAKE_A_DONE_REMOTE_AUTH, but the kernel policy expects an s32 (4 bytes), so the attribute length validation fails before the probe can determine whether the attribute is supported.
A couple of concerns with the fix as proposed:
-
attr_len=1forHANDSHAKE_A_DONE_TAGis suspect. This attribute is a string —nla_put_string()is used at line 814 when actually sending it. A 1-byte raw payload vianla_put()has no NUL terminator, so a kernel withNLA_NUL_STRINGpolicy may reject it for a different reason. The originalnla_put_string()call was already correct for this attribute. -
Raw length parameter pushes type knowledge to the caller. Each call site must know the wire size of the attribute, which is fragile if more probed attributes are added later.
A cleaner approach would be to dispatch on the attribute's actual type rather than adding a generic length parameter. For example, the probe function could use nla_put_s32(msg, attr_type, 0) for integer attributes and keep nla_put_string(msg, attr_type, "__probe__") for string attributes. This could be a switch on attr_type inside tlshd_probe_attr(), or two separate helper calls in tlshd_detect_kernel_caps().
aeea17a to
dc7de47
Compare
|
Thank you for the elaborate review, you're right, this seems like the most effective way - I've now pushed the updated code. |
|
Thanks for the update — the switch-on-attr_type approach looks right. One thing to tighten up: the default:
tlshd_log_error("Attribute %d not supported", attr_type);
nlmsg_free(msg);
return false;With that fix, this looks good to me. |
During probing of attributes, kernel can validate attribute length or other things, (null termination of a string e.g.) which triggers warning: netlink: 'tlshd': attribute type 3 has an invalid length. Probing should take attribute data type into account.
|
I see, pushed. Thank you for the guidance. |
During probing of attributes, kernel can validate attribute length, which triggers warning:
netlink: 'tlshd': attribute type 3 has an invalid length.
Probing should send appropriate attribute length. This is a minimal way to do it, certainly not perfect.
Closes: #140