From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01B6BC433EF for ; Mon, 18 Apr 2022 13:18:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243573AbiDRNUm (ORCPT ); Mon, 18 Apr 2022 09:20:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241216AbiDRNCz (ORCPT ); Mon, 18 Apr 2022 09:02:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE30432EC9; Mon, 18 Apr 2022 05:43:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 45DD96101A; Mon, 18 Apr 2022 12:43:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52044C385A1; Mon, 18 Apr 2022 12:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650285780; bh=pYN5YaqPMVrIYNkemgBBg6Hg5c93OoTRnwHTBkHfFdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=stvaRkrki0/fU+ND/sedBQv43jsIWMkynl2ftq2HKUrBj+rfHR7oG8goAjb/F6S8S VPNPdGLkB+dIdGm18nxdzDGlK82kob+/0h3Juee3UHUuiXxPiAEZceFpjJ1KxdG18y xxADT4A06pf0Q6NSbXWsLfHGNzi9T7djYDB99/YM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benedikt Spranger , Kurt Kanzenbach , Vinicius Costa Gomes , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 08/63] net/sched: taprio: Check if socket flags are valid Date: Mon, 18 Apr 2022 14:13:05 +0200 Message-Id: <20220418121134.709843105@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121134.149115109@linuxfoundation.org> References: <20220418121134.149115109@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benedikt Spranger [ Upstream commit e8a64bbaaad1f6548cec5508297bc6d45e8ab69e ] 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 Reviewed-by: Kurt Kanzenbach Acked-by: Vinicius Costa Gomes Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 b268e6130451..4c26f7fb32b3 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -427,7 +427,8 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch, if (unlikely(!child)) return qdisc_drop(skb, sch, to_free); - if (skb->sk && sock_flag(skb->sk, SOCK_TXTIME)) { + /* sk_flags are only safe 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)) { -- 2.35.1