Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2303760rdb; Mon, 20 Nov 2023 07:33:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjnEOJb9UQvS3hsjSPt7mkYdwjfWB8i3Jr3DmOnY8keftxNBZMHIG2pO3oRnUlyc6mjgYf X-Received: by 2002:a17:90b:4f4e:b0:27c:f8bd:9a98 with SMTP id pj14-20020a17090b4f4e00b0027cf8bd9a98mr4626023pjb.40.1700494429447; Mon, 20 Nov 2023 07:33:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700494429; cv=none; d=google.com; s=arc-20160816; b=vyhWPEg9DTysICuQuZ8nm9TXnGUn/qpAzV8sSBrpIHLGIcVU5yVEcqmvU0rmc8ppEN QQfBzX6NOb0cT8K6uEW2b4YCMAgaWlpEJbTvb2mR56HPVzs4yg7neWjT0R3p120khpc2 ox4TmyJrvPBd2sWAtQB0bjYc3hqyLA5IQH00n2WXQWDJnwiSYrq0DY27+ooF3mkJNmVF i5GzJSLKKnhW0mvCPnOHPNpCD/5iISviR3foMLeD144O5Ms9eJ2cS9BD4J6B8wSD6p0A F6Bvy6YYqZBhJOCQDFhtB9GuFXzTTbQj1LUyp9O7hTwGRCX+c4tixvDxXA6+iJdDUgTg 31uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=c/vkPNph5u5OOrRSn6FR5rf84/Y5x7U2iw601QDwn1w=; fh=8E9PxrHR04CpFW5vHko+LFz9IF0fEBSuSmTBm54l9Os=; b=ndtSmEJDsmIKZjZdqd8/GdPtBSEz+vEKb6cVoJpliRHFN81BuRd1t3FZCai+JwUEHa VmoeyyJZhwEhxo+I7hUXS+CtVx0QgiwR5bEMogxtU7UqPlp1/4xSXMI0UmK3Et6beecR TB9I0kOv86DVcqXEejVLDwXEYx4066NVvbvJj1lw7W4KCy0O56rGPUOS26zyhEAO1XWc b4xsq3b9PNZgVmxNLaP8gzlVq9dcOC2XU7tqRo5YVC4iIzDXeaWztTfpAXGjnewfc5XP UY76l/BUegA3ZfSqRy4V2lrGcV3Et/Iu3CiDMeRgoqrTGLLwdUTaLI6TnjOnOr+woJ61 rMCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mojatatu-com.20230601.gappssmtp.com header.s=20230601 header.b=aZdT4nG3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id x3-20020a17090ab00300b0026d6ad52473si10728831pjq.34.2023.11.20.07.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 07:33:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@mojatatu-com.20230601.gappssmtp.com header.s=20230601 header.b=aZdT4nG3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9105780966F1; Mon, 20 Nov 2023 07:33:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234216AbjKTPdf (ORCPT + 99 others); Mon, 20 Nov 2023 10:33:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234062AbjKTPde (ORCPT ); Mon, 20 Nov 2023 10:33:34 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6D73B4 for ; Mon, 20 Nov 2023 07:33:30 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6b87c1edfd5so3570594b3a.1 for ; Mon, 20 Nov 2023 07:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1700494410; x=1701099210; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=c/vkPNph5u5OOrRSn6FR5rf84/Y5x7U2iw601QDwn1w=; b=aZdT4nG3nvtH4hK5HbpH/8dFyeH4vzz7mKT3IuUwrCXWFtDxiZq25X/8UNdVxq2ZM1 aDTsbkN4J3U00zRJwKv4akimkV6+37zdwvANSSGDyNsjUupOdT9FZyJqqk9C/DNAuC/W 7UODD+2NpIS3ifS1e0Qh+tlPENT28R0QXknGwMAx3BbC60M1fBoGKLt5WAOgTK3jPRDx d2Qcpz2zg8EVd/tQR0CO93BtJrqO1laIzOEuxlIs775FzSQ0afBB9hWAEbTyR1p8x8K0 nhIaqyybEMNJ+YnF5/kqtJlXxTArpSR7Xaeq4WRyS+jOR05e7+/TL+AlvKIzs8l8vTsC +qLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700494410; x=1701099210; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=c/vkPNph5u5OOrRSn6FR5rf84/Y5x7U2iw601QDwn1w=; b=XN97bJxvTEUGl4GsPbFQw6PwHrG3ja4b7aDJp4S3eL6+Ov9HqV+AIcPbReJsz2DYHZ Vvs9XbjIsQWxQ2tssuc3sPB12l9A3GkHlNU1+3kbeZGcYDhBgHDIqQ/0bUpX2KpSMRJ0 ocKiPwnCVmkwbGmT03SSn7IcpOkajlzkCRxFpX2XZLHt+EX0+Y69pVA9QKUEEY9e9LVW zkHrWU+BpCRINXjPYNcKs3n7CByx0LY5pSWhuAziGFjV5YG/+oMCd4ogBjDrttfRpd+o oYb5pLfQ5oiApjoAAOk0UJAJCBRycI/rOPPoTOUJWT2gEmTsijzkjHhem98Zjy0d9j4W 8gkw== X-Gm-Message-State: AOJu0YzppfsIMiCkloZhbbtVRLR7DW4oRKmxDYnFvGNG9HzEDtOcWgr3 hjl+MY+xsh2HpSNuCfhgiTe38Q== X-Received: by 2002:a05:6a20:8e10:b0:187:f6b3:3ca5 with SMTP id y16-20020a056a208e1000b00187f6b33ca5mr6106464pzj.52.1700494407205; Mon, 20 Nov 2023 07:33:27 -0800 (PST) Received: from [192.168.50.25] ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id p16-20020a056a000b5000b006cbb3512266sm1195791pfo.1.2023.11.20.07.33.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Nov 2023 07:33:26 -0800 (PST) Message-ID: <5e9c5ecb-c3c7-4e5f-ae9e-ff688f4c2e2f@mojatatu.com> Date: Mon, 20 Nov 2023 12:33:21 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] net: sched: Fix an endian bug in tcf_proto_create To: Simon Horman Cc: Kunwu Chan , jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, kunwu.chan@hotmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20231117093110.1842011-1-chentao@kylinos.cn> <16c758c6-479b-4c54-ad51-88c26a56b4c9@mojatatu.com> <20231120100417.GM186930@vergenet.net> Content-Language: en-US From: Pedro Tammela In-Reply-To: <20231120100417.GM186930@vergenet.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 20 Nov 2023 07:33:45 -0800 (PST) On 20/11/2023 07:04, Simon Horman wrote: > On Fri, Nov 17, 2023 at 09:06:45AM -0300, Pedro Tammela wrote: >> On 17/11/2023 06:31, Kunwu Chan wrote: >>> net/sched/cls_api.c:390:22: warning: incorrect type in assignment (different base types) >>> net/sched/cls_api.c:390:22: expected restricted __be16 [usertype] protocol >>> net/sched/cls_api.c:390:22: got unsigned int [usertype] protocol >>> >>> Fixes: 33a48927c193 ("sched: push TC filter protocol creation into a separate function") >>> >>> Signed-off-by: Kunwu Chan >>> --- >>> net/sched/cls_api.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c >>> index 1976bd163986..f73f39f61f66 100644 >>> --- a/net/sched/cls_api.c >>> +++ b/net/sched/cls_api.c >>> @@ -387,7 +387,7 @@ static struct tcf_proto *tcf_proto_create(const char *kind, u32 protocol, >>> goto errout; >>> } >>> tp->classify = tp->ops->classify; >>> - tp->protocol = protocol; >>> + tp->protocol = cpu_to_be16(protocol); >>> tp->prio = prio; >>> tp->chain = chain; >>> spin_lock_init(&tp->lock); >> I don't believe there's something to fix here either > > Hi Pedro and Kunwu, > > I suspect that updating the byte order of protocol isn't correct > here - else I'd assume we would have seen a user-visible bug on > little-endian systems buy now. > > But nonetheless I think there is a problem, which is that the appropriate > types aren't being used, which means the tooling isn't helping us wrt any > bugs that might subsequently be added or already lurking. So I think an > appropriate question is, what is the endien and width of protocol, and how > can we use an appropriate type throughout the call-path? Agreed and I'm all in for improving any tooling integration. I believe a better patch would be to have protocol as a be16 since it's creation everywhere. I looked quickly and it will be a "viral" change, meaning a couple of places will require a one line change.