From patchwork Mon Sep 27 18:26:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 12537873 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B986EC433EF for ; Mon, 27 Sep 2021 18:27:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 934F060F6C for ; Mon, 27 Sep 2021 18:27:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236134AbhI0S2m (ORCPT ); Mon, 27 Sep 2021 14:28:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235991AbhI0S2m (ORCPT ); Mon, 27 Sep 2021 14:28:42 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16A31C061714 for ; Mon, 27 Sep 2021 11:27:03 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id k23-20020a17090a591700b001976d2db364so736702pji.2 for ; Mon, 27 Sep 2021 11:27:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cqZ/haXgFjIpSJHfI1VAsLg6naAL8kq0nI4pUX8OICI=; b=Ae/GnkZxx3AzOrnhpyQniuKHJ0wlNZWBFXL/PP1m5XyrATkGpzSqE3Uq9DuDZcHqBT 3/7Pw6GZqWYV5lFyBe6YWzOm62BJxOQ1gbk2uXzktlBWHR6jSykmBSNWR3rHP9Q44Ws4 uBBuE2m75g5Q8oX4OZxMmO0/NIOGZwIvpfmq4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cqZ/haXgFjIpSJHfI1VAsLg6naAL8kq0nI4pUX8OICI=; b=dk7enBkV1j6CgyxKBQZn76vcbeXUpb3gSpCtbRzWoC0vL3TQdy4moeDwy6bazaKyGK mw4IeomwbUXvJPsV0HbZ4XkKCmHh/1HXdrWDHLZLfK5uTCG/rcr5UCkIxcCe/Cn22Xo6 Ge9hvYkeFJPLagjmCgSqTBS36tBcsnyME7DASg6EqCwKqaV3+EPupne/hK5ee8K7M1fm 65XwBgmU3TD9OqF4rtxjMuNtP9n0FdfnsmJ66iL4l1ekiqiXyolPM8tN0KCCOYg70gZl Zz0GCmLEprBo3kLy+wmVhmH+FbrpkdMXVh2Ib5NK1uNgLvWF2s87q3Lk+SPlTYVSj3W6 6rVQ== X-Gm-Message-State: AOAM532/oj/uLDZD09/L5EBEbdi8ElXpXEvlTEcRYtabZoLZTt1fKv/j hqyvh3s0Qw6k/xtDabNzxtk15FlyL7SC7g== X-Google-Smtp-Source: ABdhPJywmhpBzovEAGLAlFReddqtfL+7gRfxRwqhTffp+Of1COtfe+1K/C/r12SNHYB9tQ7E7aOY9Q== X-Received: by 2002:a17:902:bd8d:b0:13a:8c8:a2b2 with SMTP id q13-20020a170902bd8d00b0013a08c8a2b2mr1103469pls.89.1632767223468; Mon, 27 Sep 2021 11:27:03 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id p26sm16995621pfw.137.2021.09.27.11.27.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 11:27:02 -0700 (PDT) From: Kees Cook To: Alexei Starovoitov Cc: Kees Cook , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH 0/2] bpf: Build with -Wcast-function-type Date: Mon, 27 Sep 2021 11:26:58 -0700 Message-Id: <20210927182700.2980499-1-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=813; h=from:subject; bh=MnT3y2POoh9krBGr+oM0LKIH9K7M9hDNGXXQn9PnoRw=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBhUgzzvGdW82BhK8YP1w6/r5Vk4Bo4qJhhkmiN8oKK zuSXBkqJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYVIM8wAKCRCJcvTf3G3AJhHyD/ 92lm82tkG/wPJiioqfs+Kxaa88GuCYKYWWP/IpncLQxmww37DgGOH/Wl/oJrhtTcw8GZZpOoNH3sse 7rn2JRT4QSEt5CzLLoD05pa6ceTWKIjkJ/d/VXCqNv+AfWepP3FacdWj60HKye/chGORzdj39B1tvC v62lA+y14QDzdx/r3AZ9MVzrnNaQFo4toGxCBRp7MnHFxL/mEv4cgPPAjFTfouI8vjnDy9GxHwlWnC xRONH7W48GvmgxCCtQg8Xmj380nJ/j3EImlyRlV0GulKQE8HUggfHnCp0BhmGL+RnuYJgfcpRkeO8F xI5c1r+1N6SZdUoRpQeXoaXu06lnFVybmVEa2qQwbq8zB0lCmpWH4moHHvk2EJ6lejNPCr8Tqbhyz7 2Sfh9Wzdb0IwASUho4vpo8yC3j3Z1EglOYMbTnM0yfx9K8vVmDNfJAi07mlFimGY/El21EE+vEb0Bb ZWJEP5ZsVJoI2H+wJXoNMM1rYE9WVWNJlCakhG7SJKxKbe85sJ6Z0/bPeukf+StZP+PhGG9uYGsygG kTPKuc45qiVI4IKKLnwhHm4B8BAg8WqCGUqePAvbi0tIopgbzqU37XmEc07HeCiwfr70U+YuVMs2wD x8/ZL4nbwMj00/sy7GZ/kgYZFPRtsLQ2djb0/g0c0gZAzlD9lQHeSbx4nrmA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Hi, In order to keep ahead of cases in the kernel where Control Flow Integrity (CFI) may trip over function call casts, enabling -Wcast-function-type is helpful. To that end, replace BPF_CAST_CALL() as it triggers warnings with this option and is now one of the last places in the kernel in need of fixing. Thanks, -Kees Kees Cook (2): bpf: Replace "want address" users of BPF_CAST_CALL with BPF_CALL_IMM bpf: Replace callers of BPF_CAST_CALL with proper function typedef include/linux/bpf.h | 4 +++- include/linux/filter.h | 7 +++---- kernel/bpf/arraymap.c | 7 +++---- kernel/bpf/hashtab.c | 13 ++++++------- kernel/bpf/helpers.c | 5 ++--- kernel/bpf/verifier.c | 26 +++++++++----------------- 6 files changed, 26 insertions(+), 36 deletions(-) Acked-by: Andrii Nakryiko