diff mbox series

[RFC,v1,08/10] net: qrtr: Drop remote {NEW|DEL}_LOOKUP messages

Message ID 20241018181842.1368394-9-denkenz@gmail.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series QRTR Multi-endpoint support | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/source_inline success Was 0 now: 0

Commit Message

Denis Kenzior Oct. 18, 2024, 6:18 p.m. UTC
These messages are explicitly filtered out by the in-kernel name
service (ns.c).  Filter them out even earlier to save some CPU cycles.

Signed-off-by: Denis Kenzior <denkenz@gmail.com>
Reviewed-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: Andy Gross <agross@kernel.org>
---
 net/qrtr/af_qrtr.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Chris Lew Oct. 23, 2024, 12:36 a.m. UTC | #1
On 10/18/2024 11:18 AM, Denis Kenzior wrote:
> These messages are explicitly filtered out by the in-kernel name
> service (ns.c).  Filter them out even earlier to save some CPU cycles.
> 
> Signed-off-by: Denis Kenzior <denkenz@gmail.com>
> Reviewed-by: Marcel Holtmann <marcel@holtmann.org>
> Reviewed-by: Andy Gross <agross@kernel.org>
> ---
>   net/qrtr/af_qrtr.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/net/qrtr/af_qrtr.c b/net/qrtr/af_qrtr.c
> index b2f9c25ba8f8..95c9679725ee 100644
> --- a/net/qrtr/af_qrtr.c
> +++ b/net/qrtr/af_qrtr.c
> @@ -560,6 +560,11 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)
>   	if (!size || len != ALIGN(size, 4) + hdrlen)
>   		goto err;
>   
> +	/* Don't allow remote lookups */
> +	if (cb->type == QRTR_TYPE_NEW_LOOKUP ||
> +	    cb->type == QRTR_TYPE_DEL_LOOKUP)
> +		goto err;
> +

Just curious, was this case observed? I thought we blocked clients from 
sending this control message to remotes and I didnt think the ns 
broadcasts it either.

>   	if ((cb->type == QRTR_TYPE_NEW_SERVER ||
>   	     cb->type == QRTR_TYPE_RESUME_TX) &&
>   	    size < sizeof(struct qrtr_ctrl_pkt))
Denis Kenzior Oct. 24, 2024, 6:03 p.m. UTC | #2
Hi Chris,

>> @@ -560,6 +560,11 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const 
>> void *data, size_t len)
>>       if (!size || len != ALIGN(size, 4) + hdrlen)
>>           goto err;
>> +    /* Don't allow remote lookups */
>> +    if (cb->type == QRTR_TYPE_NEW_LOOKUP ||
>> +        cb->type == QRTR_TYPE_DEL_LOOKUP)
>> +        goto err;
>> +
> 
> Just curious, was this case observed? I thought we blocked clients from sending 
> this control message to remotes and I didnt think the ns broadcasts it either.

No I didn't see this in practice, so this patch is not strictly necessary.

One thing I thought about originally was to remove the check in ns.c in order to 
extend struct qrtr_lookup with the endpoint id: an application interested only 
in services on a certain endpoint could send NEW_LOOKUP with the endpoint id 
included as a CMSG header.  It made the proposal more complicated though and I 
didn't think it was really needed since QRTR_BIND_ENDPOINT was the better tool 
for this kind of use case.

Regards,
-Denis
diff mbox series

Patch

diff --git a/net/qrtr/af_qrtr.c b/net/qrtr/af_qrtr.c
index b2f9c25ba8f8..95c9679725ee 100644
--- a/net/qrtr/af_qrtr.c
+++ b/net/qrtr/af_qrtr.c
@@ -560,6 +560,11 @@  int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)
 	if (!size || len != ALIGN(size, 4) + hdrlen)
 		goto err;
 
+	/* Don't allow remote lookups */
+	if (cb->type == QRTR_TYPE_NEW_LOOKUP ||
+	    cb->type == QRTR_TYPE_DEL_LOOKUP)
+		goto err;
+
 	if ((cb->type == QRTR_TYPE_NEW_SERVER ||
 	     cb->type == QRTR_TYPE_RESUME_TX) &&
 	    size < sizeof(struct qrtr_ctrl_pkt))