Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1163321imm; Fri, 13 Jul 2018 12:42:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpexoekvHPqmHApLGaDLJ/hXix/LG9CvGWOjUm2TgozWhpNqXz+4YEXpvb1BIlzmvMh544Lv X-Received: by 2002:a63:ac57:: with SMTP id z23-v6mr7092528pgn.74.1531510977307; Fri, 13 Jul 2018 12:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531510977; cv=none; d=google.com; s=arc-20160816; b=yyyWr4JzoTs0rvBCkXnI3pA1xa3psjaCPKW+lO8tR/nu3dgyIHaqypVAljJ3/21GlT HQP7mF2MxkxyH+sx4gQJPiKlhr8XQqTMyBEVZzXLsvBqIJt2dG7g44jD8LqRPnWuEh54 0wTy1fUFHx/5D1WDOF09wLxnRqysYdYolVs+nAwT1PZnrctfX8ec5a7ezXaNfG3EFEu4 kJj/cm5YAQnRhdxCwXykGOgk6JyKOO20Risj5vH44cBoVzTJVBasVDYE4N5G7WPUq1xK gXfmQjVDdev33gkqIDJXWHXEAW55aQ09vC5AQvEojfCEj0pH++PLJWqe6xJFBgIbWiNq ojpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :arc-authentication-results; bh=4Lsi5GAdZP1wE3Hjf8KgvldXn+ptljenMCFMwiFsQLg=; b=ZyeE74PIRdcRnRWSOuJfBGJVMgYwp9qNtC6bD9ZHjA/ar6WUlZ5MFhejIgL2LT7rdr AXOto9emWlpQLee4b3CmBUlwP+dUGGjTqiV8Dj36HXgi2mNa3Qn7w9eoZoL6lU155KTj Cbt22DoSjGmTkXb2wcyBDgBgO8w3v1BFMxKfM4zS0FVKQAnuEuirKheIJx7/m3xQCrjN NyUQCd/noYHe025p9+CXhlHxa9U60uQ1kENF8oWm9AXpE7kKbcBZyXiqpu3KSoeUvkdV OVcB+X76Ld+8HgzwnnDHmto0QVJElythWhcAHSIAuLhjAbaWdxqHvaxjZOv+OIxyxL+j nbpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=qrPFMVsI; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=IcgAde+I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 71-v6si4416630pfl.220.2018.07.13.12.42.42; Fri, 13 Jul 2018 12:42:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=qrPFMVsI; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=IcgAde+I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731992AbeGMT6D (ORCPT + 99 others); Fri, 13 Jul 2018 15:58:03 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:39668 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731931AbeGMT6B (ORCPT ); Fri, 13 Jul 2018 15:58:01 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6DJcpc5013895; Fri, 13 Jul 2018 12:41:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=4Lsi5GAdZP1wE3Hjf8KgvldXn+ptljenMCFMwiFsQLg=; b=qrPFMVsIbv4TRzxyte9oCM4CvnAGkV+QLpPRj6QSua+Ws4wSC5WH72ziPEDr5fOpPnlU 89jy5j759+RhRijKfrsXHdf0HvazWEs7BQwK9dMFdqOjE1LCOi0G2HMP2Lp1AfI+nILW dr+9smgVDLWEBD05A1y7RUbYnjoPHJ98ImM= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2k7075rd26-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 13 Jul 2018 12:41:39 -0700 Received: from NAM01-BY2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.13) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 13 Jul 2018 12:41:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4Lsi5GAdZP1wE3Hjf8KgvldXn+ptljenMCFMwiFsQLg=; b=IcgAde+IVffUcCUDoHGHB5M0TILeHDjR+LZhnC9823Z8tmf7WdEq8XAuyYP53+lV1y1AGr7I+F+t4q5YqOJif+f32fA7coNQpjOoadx8ayCLKlsh8dox2ky4sGlL/kCaKCc/fbPCAcKdmfin0zM33DkhPH9AUYm4ObD4/BpdC5g= Received: from castle.thefacebook.com (2620:10d:c090:200::4:1cec) by CY1PR15MB0171.namprd15.prod.outlook.com (2a01:111:e400:58bb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.18; Fri, 13 Jul 2018 19:41:31 +0000 From: Roman Gushchin To: CC: , , Roman Gushchin , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH v2 bpf 3/5] bpf: bpf_prog_array_free() should take a generic non-rcu pointer Date: Fri, 13 Jul 2018 12:41:12 -0700 Message-ID: <20180713194114.2711-3-guro@fb.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180713194114.2711-1-guro@fb.com> References: <20180713194114.2711-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c090:200::4:1cec] X-ClientProxiedBy: MWHPR14CA0063.namprd14.prod.outlook.com (2603:10b6:300:81::25) To CY1PR15MB0171.namprd15.prod.outlook.com (2a01:111:e400:58bb::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d914f3c0-6c83-4bc6-73b1-08d5e8f8a290 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020);SRVR:CY1PR15MB0171; X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0171;3:ZcaHIGnt1fkQFWb+H5mO0FDoA93A3N1FC38VxsijcXE66f6SfgxCIdcjzZdZkvOMMeGklZCCkoWz43cHnaLTrMwOhRoSAEpJ0FrsD13AyeATmdUWY8N8JQd+gGPJ1Srk8ydbNzdQkgXJAva++thK071KYEL3+3LOOnrCWtscSAKqufWMuCmI61ubHuPGdQWE0qNlWVabx0mBvBuAxQM7yat3PKJcyY2LbmX0gPPu607i4GTTlJ/3VT988jYjuC4p;25:PTS6GXqpt2x1ChUFmM/c/uHnauT71AZ3XpA1iXBTD1yHGG6cg738iqOEkEa7qUjUIMZJ1+4Z+ODTkXzRkNCWim6QMy7wLt+wrJFbs2qJLq46poYNlcQ86m7IhUx1bO9sHfCX+VPRRMRSGdytVxEQy5SnGGL4uyG6jvIQJfhptTGDwn+Xr64GMmmWs1LHpCHV3QWJ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re82pfDCPLVIRbVMeKk8LJXPp7wo5IklzWpTCXowANyW6eHE7ew7U5mNNZb6ccaZyHFbQfN7sWekvk9CtiT3vlWRxMHnEk7o0iQeHohVVSdfchKs8oPOupex9yxqreU4a+XRiyC5zY1zdaFwF6SPzkjHfqwZy4O2zLxT2jbAQsrlHPEMVuX+Z4CtYtgf26pvrAt/6RpEx/lCl2gmAELvuR0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231311)(11241501184)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149027)(150027)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:CY1PR15MB0171;BCL:0;PCL:0;RULEID:;SRVR:CY1PR15MB0171; X-Forefront-PRVS: 07326CFBC4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(136003)(39860400002)(396003)(346002)(376002)(189003)(199004)(53416004)(52116002)(16526019)(6506007)(6916009)(14444005)(50466002)(48376002)(386003)(6666003)(1076002)(8676002)(46003)(186003)(86362001)(6116002)(575784001)(5660300001)(69596002)(8936002)(47776003)(6486002)(305945005)(2351001)(7736002)(478600001)(2361001)(81166006)(81156014)(105586002)(50226002)(76176011)(68736007)(106356001)(11346002)(54906003)(51416003)(476003)(52396003)(446003)(5024004)(2616005)(25786009)(16586007)(316002)(36756003)(4326008)(2906002)(97736004)(6512007)(486006)(53936002)(41533002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR15MB0171;H:castle.thefacebook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-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a/GzfsFvHEMgh2m+LTa2X9K1?= =?us-ascii?Q?buNzcaJlFnjPmTbLVfHBU/NWESJDR4s8n19OhaRa3ccRxXMS/OIliIxwC/QX?= =?us-ascii?Q?kk7EjFlD4jRy9QHCDLqIkTqjrRbnhR/oTahdYMufRDD6yG7zblx8e0sBQ9Kc?= =?us-ascii?Q?3ZBU5J3+la7Lo2DYQcw1msirxd21AblqNZxh4uoRK6j1fXgKcWjvGKDDxhH5?= =?us-ascii?Q?KNB92NG4/0KZQfnvHzPUF73Ug8anrcdrmyaQPfTdQypf0v2Grpox1hAsfzUJ?= =?us-ascii?Q?NFzqEz1O823UYyclVvwspu3nXculhuagsnk1bvnWzrlc+W/JNGoe6i6E9F/O?= =?us-ascii?Q?rKfHiLSwLjfvQ3bCM5gjtPmxfrRLh60yhdMz1xJ02zueTGCprdlnV3vqmxrh?= =?us-ascii?Q?WaCLOpKY3FpzjPARoJfuLcNUECq12fwTmLuIfoaD4KkL5kKTQF38SM0XzAQJ?= =?us-ascii?Q?IQZ5JxgkU+SsyGgSqyg4njEfJxz57l51UDTBS23lEClWpxJuTpM+iW0OW3mz?= =?us-ascii?Q?XcGaA=3D=3D?= X-Microsoft-Antispam-Message-Info: t9CF206BoM6MVUgUun8WuhcBFMxZ4qqOR5Ujevawb7qHF+VuJlsKNYH2e/0cgrk/xog+qRz8pdSyCmxHHe21vXN5e7x19PEJzFvODDZ1z1UHLXPiMKcgj0jRfiyyRiCVTtT7+l9riFtINd2pCDpJNLZXSL3BT2CwhprlZr5RssRCTDKrPa6IZO7G1vM2O8i+wUn979tgTbKDdtrJ/jo6ddwF8SJBO0ubo/+JYsQYRjjvq3y8xuTEWOxGmEpkFah3AhX1CrkhliT0xUuf2JPkq4W475FfHtjuDpObWbA9dSfEWAmVcJr8aP06XbjvHnWrTe/RmQOoO2BHNu6dNL7YKiVU/q0zcRsR+MzQPZc2xig= X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0171;6:w+xb2jOqyk0yPiMv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dlBlE3JIO+m0VtzWRq4AXOZF2Y+vc1H1JkZ+mkpNb2GLy5VRR1GuLau3MAPieaOwV5xc0H4QCyg8xwWSTrqYO+U8ii8TeJFcHoQpioxCuh1cGCE82ihKUbhI3tnEvDyRiM4Mxcwq9lij41YAoMly956BlFq1MS60n6BM= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2018 19:41:31.2396 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d914f3c0-6c83-4bc6-73b1-08d5e8f8a290 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR15MB0171 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-13_07:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org bpf_prog_array_free() should take a generic non-rcu pointer as an argument, as freeing the objects assumes that we're holding an exclusive rights on it. rcu_access_pointer() can be used to convert a __rcu pointer to a generic pointer before passing it to bpf_prog_array_free(), if necessary. This patch eliminates the following sparse warning: kernel/bpf/core.c:1556:9: warning: incorrect type in argument 1 (different address spaces) kernel/bpf/core.c:1556:9: expected struct callback_head *head kernel/bpf/core.c:1556:9: got struct callback_head [noderef] * Fixes: 324bda9e6c5a ("bpf: multi program support for cgroup+bpf") Signed-off-by: Roman Gushchin Cc: Alexei Starovoitov Cc: Daniel Borkmann --- drivers/media/rc/bpf-lirc.c | 6 +++--- include/linux/bpf.h | 2 +- kernel/bpf/cgroup.c | 11 ++++++----- kernel/bpf/core.c | 5 ++--- kernel/trace/bpf_trace.c | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/media/rc/bpf-lirc.c b/drivers/media/rc/bpf-lirc.c index fcfab6635f9c..509b262aa0dc 100644 --- a/drivers/media/rc/bpf-lirc.c +++ b/drivers/media/rc/bpf-lirc.c @@ -135,7 +135,7 @@ static int lirc_bpf_attach(struct rc_dev *rcdev, struct bpf_prog *prog) goto unlock; rcu_assign_pointer(raw->progs, new_array); - bpf_prog_array_free(old_array); + bpf_prog_array_free(rcu_access_pointer(old_array)); unlock: mutex_unlock(&ir_raw_handler_lock); @@ -173,7 +173,7 @@ static int lirc_bpf_detach(struct rc_dev *rcdev, struct bpf_prog *prog) goto unlock; rcu_assign_pointer(raw->progs, new_array); - bpf_prog_array_free(old_array); + bpf_prog_array_free(rcu_access_pointer(old_array)); unlock: mutex_unlock(&ir_raw_handler_lock); return ret; @@ -204,7 +204,7 @@ void lirc_bpf_free(struct rc_dev *rcdev) while (*progs) bpf_prog_put(*progs++); - bpf_prog_array_free(rcdev->raw->progs); + bpf_prog_array_free(rcu_access_pointer(rcdev->raw->progs)); } int lirc_prog_attach(const union bpf_attr *attr, struct bpf_prog *prog) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 943fb08d8287..329026baef6e 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -353,7 +353,7 @@ struct bpf_prog_array { }; struct bpf_prog_array *bpf_prog_array_alloc(u32 prog_cnt, gfp_t flags); -void bpf_prog_array_free(struct bpf_prog_array __rcu *progs); +void bpf_prog_array_free(struct bpf_prog_array *progs); int bpf_prog_array_length(struct bpf_prog_array __rcu *progs); int bpf_prog_array_copy_to_user(struct bpf_prog_array __rcu *progs, __u32 __user *prog_ids, u32 cnt); diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index badabb0b435c..9ac0c9b51d0d 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -37,7 +37,8 @@ void cgroup_bpf_put(struct cgroup *cgrp) kfree(pl); static_branch_dec(&cgroup_bpf_enabled_key); } - bpf_prog_array_free(cgrp->bpf.effective[type]); + bpf_prog_array_free(rcu_access_pointer( + cgrp->bpf.effective[type])); } } @@ -139,7 +140,7 @@ static void activate_effective_progs(struct cgroup *cgrp, /* free prog array after grace period, since __cgroup_bpf_run_*() * might be still walking the array */ - bpf_prog_array_free(old_array); + bpf_prog_array_free(rcu_access_pointer(old_array)); } /** @@ -168,7 +169,7 @@ int cgroup_bpf_inherit(struct cgroup *cgrp) return 0; cleanup: for (i = 0; i < NR; i++) - bpf_prog_array_free(arrays[i]); + bpf_prog_array_free(rcu_access_pointer(arrays[i])); return -ENOMEM; } @@ -270,7 +271,7 @@ int __cgroup_bpf_attach(struct cgroup *cgrp, struct bpf_prog *prog, css_for_each_descendant_pre(css, &cgrp->self) { struct cgroup *desc = container_of(css, struct cgroup, self); - bpf_prog_array_free(desc->bpf.inactive); + bpf_prog_array_free(rcu_access_pointer(desc->bpf.inactive)); desc->bpf.inactive = NULL; } @@ -372,7 +373,7 @@ int __cgroup_bpf_detach(struct cgroup *cgrp, struct bpf_prog *prog, css_for_each_descendant_pre(css, &cgrp->self) { struct cgroup *desc = container_of(css, struct cgroup, self); - bpf_prog_array_free(desc->bpf.inactive); + bpf_prog_array_free(rcu_access_pointer(desc->bpf.inactive)); desc->bpf.inactive = NULL; } diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 253aa8e79c7b..fdf961f70deb 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -1548,10 +1548,9 @@ struct bpf_prog_array *bpf_prog_array_alloc(u32 prog_cnt, gfp_t flags) return &empty_prog_array.hdr; } -void bpf_prog_array_free(struct bpf_prog_array __rcu *progs) +void bpf_prog_array_free(struct bpf_prog_array *progs) { - if (!progs || - progs == (struct bpf_prog_array __rcu *)&empty_prog_array.hdr) + if (!progs || progs == &empty_prog_array.hdr) return; kfree_rcu(progs, rcu); } diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 0ae6829804bc..5dace25d3088 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -995,8 +995,8 @@ int perf_event_attach_bpf_prog(struct perf_event *event, /* set the new array to event->tp_event and set event->prog */ event->prog = prog; - rcu_assign_pointer(event->tp_event->prog_array, new_array); - bpf_prog_array_free(old_array); + rcu_swap_protected(event->tp_event->prog_array, new_array, 1); + bpf_prog_array_free(new_array); unlock: mutex_unlock(&bpf_event_mutex); @@ -1021,8 +1021,8 @@ void perf_event_detach_bpf_prog(struct perf_event *event) if (ret < 0) { bpf_prog_array_delete_safe(old_array, event->prog); } else { - rcu_assign_pointer(event->tp_event->prog_array, new_array); - bpf_prog_array_free(old_array); + rcu_swap_protected(event->tp_event->prog_array, new_array, 1); + bpf_prog_array_free(new_array); } bpf_prog_put(event->prog); -- 2.14.4