diff mbox series

[net,1/1] net/sched: taprio: Check if socket flags are valid

Message ID 20220318142532.313226-2-b.spranger@linutronix.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net/sched: taprio: Check if sk_flags are valid | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers fail 1 blamed authors not CCed: vedang.patel@intel.com; 2 maintainers not CCed: vedang.patel@intel.com pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Benedikt Spranger March 18, 2022, 2:25 p.m. UTC
A user may set the SO_TXTIME socket option to ensure a packet is send
at a given time. The taprio scheduler has to confirm, that it is allowed
to send a packet at that given time, by a check against the packet time
schedule. The scheduler drop the packet, if the gates are closed at the
given send time.

The check, if SO_TXTIME is set, may fail since sk_flags are part of an
union and the union is used otherwise. This happen, if a socket is not
a full socket, like a request socket for example.

Add a check to verify, if the union is used for sk_flags.

Fixes: 4cfd5779bd6e ("taprio: Add support for txtime-assist mode")
Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de>
Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 net/sched/sch_taprio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Vinicius Costa Gomes March 19, 2022, 1:11 a.m. UTC | #1
Benedikt Spranger <b.spranger@linutronix.de> writes:

> A user may set the SO_TXTIME socket option to ensure a packet is send
> at a given time. The taprio scheduler has to confirm, that it is allowed
> to send a packet at that given time, by a check against the packet time
> schedule. The scheduler drop the packet, if the gates are closed at the
> given send time.
>
> The check, if SO_TXTIME is set, may fail since sk_flags are part of an
> union and the union is used otherwise. This happen, if a socket is not
> a full socket, like a request socket for example.
>
> Add a check to verify, if the union is used for sk_flags.
>
> Fixes: 4cfd5779bd6e ("taprio: Add support for txtime-assist mode")
> Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de>
> Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---

>  net/sched/sch_taprio.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
> index 1ce6416b4810..86911a61e739 100644
> --- a/net/sched/sch_taprio.c
> +++ b/net/sched/sch_taprio.c
> @@ -419,7 +419,8 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch,
>  {
>  	struct taprio_sched *q = qdisc_priv(sch);
>  
> -	if (skb->sk && sock_flag(skb->sk, SOCK_TXTIME)) {
> +	/* sk_flags are only save to use on full sockets. */


A very minor nitpick: it should have been "safe to use".

Apart from that,

Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>

> +	if (skb->sk && sk_fullsock(skb->sk) && sock_flag(skb->sk, SOCK_TXTIME)) {
>  		if (!is_valid_interval(skb, sch))
>  			return qdisc_drop(skb, sch, to_free);
>  	} else if (TXTIME_ASSIST_IS_ENABLED(q->flags)) {
> -- 
> 2.20.1
>


Cheers,
diff mbox series

Patch

diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 1ce6416b4810..86911a61e739 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -419,7 +419,8 @@  static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch,
 {
 	struct taprio_sched *q = qdisc_priv(sch);
 
-	if (skb->sk && sock_flag(skb->sk, SOCK_TXTIME)) {
+	/* sk_flags are only save to use on full sockets. */
+	if (skb->sk && sk_fullsock(skb->sk) && sock_flag(skb->sk, SOCK_TXTIME)) {
 		if (!is_valid_interval(skb, sch))
 			return qdisc_drop(skb, sch, to_free);
 	} else if (TXTIME_ASSIST_IS_ENABLED(q->flags)) {