Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3953721pxb; Tue, 2 Nov 2021 01:13:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU1afeDaGBrKFyL34PqoCcad5k/0hhlI6sGDLymUY9BkHXZhKOYJcPC3Uo7xWcRYCEedyc X-Received: by 2002:a17:906:5054:: with SMTP id e20mr40989658ejk.449.1635840781613; Tue, 02 Nov 2021 01:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635840781; cv=none; d=google.com; s=arc-20160816; b=zLKQhKAi5fG3CComo5wXRUTeUDd8BGbfah/fKQPpxmI2f+2TWX8JTsSPzQVmKEMMur 9Q5bOydXTAHDhgIC0gA+Eg+nv9Ykx9IISWyE1XJlCqbdX7JF/Yk+5n5mDiz+CN5modJG LEOWDiJWii0BXc/Nv3dRzz7UDfGQB3aDob9sol/Ai63fnJ8B/xJ3dWXkZ2kU8sUNUC+r ok7pc6taUA62A785R2hRuJAt0R8UsolEr7ARk99NdjfVYOI/s7puSBTKpsexuZ2jxJPG maZMCxoSXrZVbcIDHFeaeIZJeDKdTu77U0ruNPZQjvaadkupUVwanfkU5k2Tdh74XXG1 a94A== 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 :message-id:date:subject:cc:to:from; bh=JkPOe5yJgCLXPHA4dkQmlkFysjbeJ8crsomrAVpxNt0=; b=KLMNtG2jeWlZp2HkRXLsvDOGbb0YNVegXJLxgfUx3u0HbZefNaZJ1xB0jLGGULf8FP JM6fQjzB7Hd5+c5w4I7pc3s2YUkfHdw/TCxW+kkqFeFuiFoc5sYKtHf7RrUwnvTqTjmz KUShhYvlnXnnJsmDrqoAG/JMRbbteCwNm4q6ECbjAvTyt2SLBl0QkcOwuk8x5tgODoAj B9BgkFPwq+w2rwUcR0c2XRner2TuN/0v9foCt/X7PRMHK53K+JNf9vP9FMhMq75n+Pfl YKeovNlzVoyIqaqTAbVGTDvdrU+UyneZjcSIVDv/SY7pdz5nvR0hBrOkpzjbaYZ0MUND mptw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si22936718edv.219.2021.11.02.01.12.37; Tue, 02 Nov 2021 01:13:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229505AbhKBIN0 (ORCPT + 99 others); Tue, 2 Nov 2021 04:13:26 -0400 Received: from spam.zju.edu.cn ([61.164.42.155]:60706 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229497AbhKBINM (ORCPT ); Tue, 2 Nov 2021 04:13:12 -0400 Received: from localhost.localdomain (unknown [222.205.7.222]) by mail-app2 (Coremail) with SMTP id by_KCgA3q_Z18oBhxp9fAA--.22102S4; Tue, 02 Nov 2021 16:10:29 +0800 (CST) From: Lin Ma To: krzysztof.kozlowski@canonical.com Cc: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lin Ma Subject: [PATCH] NFC: add necessary privilege flags in netlink layer Date: Tue, 2 Nov 2021 16:10:21 +0800 Message-Id: <20211102081021.32237-1-linma@zju.edu.cn> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: by_KCgA3q_Z18oBhxp9fAA--.22102S4 X-Coremail-Antispam: 1UD129KBjvJXoWxGF4fWF45uryfC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ailing-List: linux-kernel@vger.kernel.org The CAP_NET_ADMIN checks are needed to prevent attackers faking a device under NCIUARTSETDRIVER and exploit privileged commands. This patch add GENL_ADMIN_PERM flags in genl_ops to fulfill the check. Except for commands like NFC_CMD_GET_DEVICE, NFC_CMD_GET_TARGET, NFC_CMD_LLC_GET_PARAMS, and NFC_CMD_GET_SE, which are mainly information- read operations. Signed-off-by: Lin Ma --- net/nfc/netlink.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 49089c50872e..334f63c9529e 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1664,31 +1664,37 @@ static const struct genl_ops nfc_genl_ops[] = { .cmd = NFC_CMD_DEV_UP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_dev_up, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_DEV_DOWN, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_dev_down, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_START_POLL, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_start_poll, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_STOP_POLL, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_stop_poll, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_DEP_LINK_UP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_dep_link_up, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_DEP_LINK_DOWN, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_dep_link_down, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_GET_TARGET, @@ -1706,26 +1712,31 @@ static const struct genl_ops nfc_genl_ops[] = { .cmd = NFC_CMD_LLC_SET_PARAMS, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_llc_set_params, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_LLC_SDREQ, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_llc_sdreq, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_FW_DOWNLOAD, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_fw_download, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_ENABLE_SE, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_enable_se, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_DISABLE_SE, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_disable_se, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_GET_SE, @@ -1737,21 +1748,25 @@ static const struct genl_ops nfc_genl_ops[] = { .cmd = NFC_CMD_SE_IO, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_se_io, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_ACTIVATE_TARGET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_activate_target, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_VENDOR, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_vendor_cmd, + .flags = GENL_ADMIN_PERM, }, { .cmd = NFC_CMD_DEACTIVATE_TARGET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .doit = nfc_genl_deactivate_target, + .flags = GENL_ADMIN_PERM, }, }; -- 2.33.1