Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1036730iob; Fri, 13 May 2022 20:33:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydNbkl0TP0iulgen28WaunDx3DoAmKNfg/Tjm/NjaQcUIOKrKY0IJ/Wc2+shgo3BzcVmG9 X-Received: by 2002:a5d:64ed:0:b0:20c:7407:681e with SMTP id g13-20020a5d64ed000000b0020c7407681emr6459225wri.408.1652499210605; Fri, 13 May 2022 20:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652499210; cv=none; d=google.com; s=arc-20160816; b=INrFBK3nIHwGG/XXapNOaTiadHpUdX1+RHK2cRKdSs5VF0q5Kq1DFjtH/nbiepbWhH v6ZYOs6U94eEIHS6MW6WBeNerMX3TaivI7C6Ima5IsVLVWxsMt/WUGuGnYGx6CJ3Qqm7 w9H1mkaGw62fv2PMDYfS6KMtbYbD2wOGfHpgYCyPQlDRdeVyru14TE7PD3+9Qn6pjTdh c+AdkXin91JCFDlilOqQtZwv7TosLqAUGXgepVuS9yOf68s+gZJSos/PNZVhTeOU0S8C rRQx6z3qbXlilvWkGnJj67FoabUwKKVLzZlZ6qPDH4wO2BemvmBpHn6x3mYFQk78kjmI YlAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=f7uUSDFA4nveMFnKca6XkX5fot8a0gngUc3fbjuqiDc=; b=cpfPqSYghTyDNQqFZzj+74Co9qjfBBmf76ILY1sORIYcYNV1E+fv+6pVbEYhAFD0xN GPej1O8Xsd8vmZIna6eGZ15Nu1UU/nNoqo977M/NlBe9e76OzvCteWuWS9xxeLDH8grD 4P7x2xL/cPg/I/iANxSvRBFzb/gA4/IBgWubPOfEUTD+dYuieKbLvd+NjYdsxrMfLo3t rtqfjJJz6dMcn1Juytbh5R4MyiwCk4g7AzN+tKdT8FV8C2uRWDYUl0JLAkMaUUwEcaga 8aIYKuj08lHuUEuw/UmspO8mOmeDQxIgYutXeIvHIBr4ZJj0FgHLyOGacCSH9QbhadgQ bIFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hvTJc3UD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v13-20020a056000162d00b0020c747a9be8si3920474wrb.362.2022.05.13.20.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:33:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hvTJc3UD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3B55C432809; Fri, 13 May 2022 17:09:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382210AbiEMPgx (ORCPT + 99 others); Fri, 13 May 2022 11:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382217AbiEMPgZ (ORCPT ); Fri, 13 May 2022 11:36:25 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD2A611177; Fri, 13 May 2022 08:36:23 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id bo5so7996025pfb.4; Fri, 13 May 2022 08:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f7uUSDFA4nveMFnKca6XkX5fot8a0gngUc3fbjuqiDc=; b=hvTJc3UDtG2aW5iVCKWiWROQFUI0X9RS6Yq3r92RXI+NPWzR46rXtgJbfNgLxXZFNI dCvp1AgllkksbOOaqv6OzhnnSVh+L83r/6s0kpVSwsuoDZ2/EXhYG/g9uxSe8+PBQP7/ gTP3pD3M1JopN8I0KxWPi51ff7WeOiJ0BXSmP/0YCIn8+6qeRY6khO9b7AC5kdEDA/6U GoYiXaupRMbYqNwiT6srPEgY/dN53zgBE+eQHf7m4dFETDibOdBVjK2yEeHYCfeUq3Rm IDgW5UUWw+vFhOtgh42DQ4lx5I50udUszoqEBLOIuGbvIhqIH0O0RgLtjyZK6l4Qii5g 5V1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=f7uUSDFA4nveMFnKca6XkX5fot8a0gngUc3fbjuqiDc=; b=51jGTpupujuzs+BbZ0p0E8zeJyelnGxOebpTC8sqIHS2jYjXhmUReW5UiGx81yPdLk GtoC00UTdpc339PYGYi1W04mTif6UqHDb3FUDoYYOFS2bTrL8Hrl2smmePK908NEtzL2 08ZJNIi0r0Yv5Wfb/oTSGpDii8Xzi36QKb31v1Ej/KFlP+3EHvq9MwwKeOmOWwH3btII sunYyXcNiOBcLRi3SZ6k5uDdezTL63FBObA4CoxHhalXmT5DF2Lev/3LrsiAuhXaF2oi vDEIbmu2jun9PdeOQ7faC4+BXtHd69odAVF8aY7pixafmX5NXgomqhJiKhhFnWEGzZZo aVxA== X-Gm-Message-State: AOAM533qPXRqX3MgfVHPQVkZoEGBm+AK+dyDm3JqRLrmH5bJSYseeBgc v0qhyAXEYtPmY+Mpz4Lywtk= X-Received: by 2002:a63:cd0b:0:b0:3c6:afc0:32a6 with SMTP id i11-20020a63cd0b000000b003c6afc032a6mr4420179pgg.436.1652456183258; Fri, 13 May 2022 08:36:23 -0700 (PDT) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id b10-20020a62a10a000000b0050dc762817dsm1942137pff.87.2022.05.13.08.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:36:22 -0700 (PDT) Sender: Vincent Mailhol From: Vincent Mailhol To: Marc Kleine-Budde Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, Max Staudt , Vincent Mailhol Subject: [PATCH v2 0/2] can: drop tx skb if the device is in listen only mode Date: Sat, 14 May 2022 00:36:04 +0900 Message-Id: <20220513153606.302464-1-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220513142355.250389-1-mailhol.vincent@wanadoo.fr> References: <20220513142355.250389-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In listen only mode, tx CAN frames can still reach the driver if injected via the packet socket. This series add a check toward CAN_CTRLMODE_LISTENONLY in can_dropped_invalid_skb() to discard such skb. The first patch does some preparation work and migrates can_dropped_invalid_skb() and can_skb_headroom_valid() from skb.h to skb.c. This preparation is needed because skb.h does not include linux/can/dev.h (for struct can_priv) and uapi/linux/can/netlink.h (for the definition of CAN_CTRLMODE_LISTEONLY) which we need for this change. The function being already big, better to de-inline them and move them to a .c file. The second and last patch is the actual change. * Changelog * v1 -> v2 * move can_dropped_invalid_skb() to skb.c instead of dev.h * also move can_skb_headroom_valid() to skb.c Vincent Mailhol (2): can: skb:: move can_dropped_invalid_skb and can_skb_headroom_valid to skb.c can: dev: drop tx skb if in listen only mode drivers/net/can/dev/skb.c | 65 +++++++++++++++++++++++++++++++++++++++ include/linux/can/skb.h | 59 +---------------------------------- 2 files changed, 66 insertions(+), 58 deletions(-) -- 2.35.1