Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp769450imm; Fri, 28 Sep 2018 06:35:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV607xmvHYFdQS+vvmf/awC8KF70E0kBwg9e8tH+Xzz5zi8h/Yu00Qz4NUL5UyVYStdsoKlDU X-Received: by 2002:a17:902:b287:: with SMTP id u7-v6mr16115582plr.123.1538141713031; Fri, 28 Sep 2018 06:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538141713; cv=none; d=google.com; s=arc-20160816; b=cR0rKoKUDe0quHxSmtBkESS/u4w2cXEMEYaM4Ybo7DxUmfrtT95Aed1CISE5Aefa5C 3a30i15YJzacNipP8UCRq2/YIiPONnKd+OlRaloAESkeu2yLgFeIo8uDjffOQIEn8/4j bwBj0s9GdvXH4ahAk9aR+5mA3v4pZr5wMod8zA+w1UfqTsmHcCKlwNClqzwZWjn+/neF 6EVjjukm1gIUxdIbzahE1kmCxxPPJ4I1TH382g63nF6jtU+CiDqdhGjBKav6hp/WyEyj lTeZj85vyxiZt5i8DjCI/WB5+pll71EPK/ojIC74loyELSw1zg0ZLTEv8f2hanZJylQ9 1FFA== 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:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=JAltMuVBR78ZMFN03uQFYFrclIm5hJbSUPpMBFpRLOA=; b=PVp2ffFHoy3SAan/AGOej+1u5sPrGyHdwBSWgccJKK/jpgjLVDrGGsxM9wdF8uAHdg KD6VUDtG5wBvip5Yle/9s/72/l4ZJ1uOcoUnpl28Jvv4MdyAnAu2ZtohcBv3zYWSoSRc HV5rVn3Zfcw37BwmRyNY9omrB8nw2PN95WZDhEBi3V3LS9038JTZligaF9Uwq7Qhf0M1 HwUZRWIDPo8BrJGPx6Q16DxUKD6CTenftPhAG/eR5ZcscmNHKwIBaS3oYeUFPzP2wbzG Ou2ilImuDAUttK569E6iiYbAC8wLLPPlNL03Czb0JV1MiMYHTEDndgWiO4Prp92TLZ3m kS4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=ZikFhqGH; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=ImCThyHx; 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 e17-v6si4308703pgv.54.2018.09.28.06.34.56; Fri, 28 Sep 2018 06:35:13 -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=ZikFhqGH; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=ImCThyHx; 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 S1729093AbeI1T6T (ORCPT + 99 others); Fri, 28 Sep 2018 15:58:19 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:3339 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726349AbeI1T6T (ORCPT ); Fri, 28 Sep 2018 15:58:19 -0400 Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8SDWnT0008834; Fri, 28 Sep 2018 06:34:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=JAltMuVBR78ZMFN03uQFYFrclIm5hJbSUPpMBFpRLOA=; b=ZikFhqGHzE3kOc5Yjwc7pwL9Q7xlj1sAh8U+F8ruiSLPqVbndKnWktS51KB3DMowlDnm vW5O6nwJHz1M6NGTyWA4oz/cCFBsTUtv4UTH2rsNJg1YAq9uOgEaqW2N5zwEritc1Rqx /ixWyOmZNc2+0PJ3RfP7ijN0NTV0COyLQg0= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2msmnn847g-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 28 Sep 2018 06:34:09 -0700 Received: from PRN-CHUB02.TheFacebook.com (2620:10d:c081:35::11) by PRN-CHUB16.TheFacebook.com (2620:10d:c081:35::28) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 28 Sep 2018 06:34:07 -0700 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.12) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 28 Sep 2018 06:34:07 -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=JAltMuVBR78ZMFN03uQFYFrclIm5hJbSUPpMBFpRLOA=; b=ImCThyHx3zYx9673+mfC7osI+kjcVvtmMiAsBTjB53qu6m6EBQLrCQFhh3ip0ByFOE0mVMobG2XChd1L8fYDu0xZDqzV0Y6gkLbecfRBG98IYPBTr5Md3yeTz216oxEGhRATGIBwG9qyA0fMSL7vIeOVHrOYkh8isURnJ5iFh2Q= Received: from castle.tfbnw.net (2620:10d:c092:180::1:baa) by BLUPR15MB0164.namprd15.prod.outlook.com (2a01:111:e400:5249::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.22; Fri, 28 Sep 2018 13:34:02 +0000 From: Roman Gushchin To: CC: , , Roman Gushchin , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH bpf] bpf: harden flags check in cgroup_storage_update_elem() Date: Fri, 28 Sep 2018 14:33:21 +0100 Message-ID: <20180928133321.31121-1-guro@fb.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:180::1:baa] X-ClientProxiedBy: AM5P190CA0003.EURP190.PROD.OUTLOOK.COM (2603:10a6:206:14::16) To BLUPR15MB0164.namprd15.prod.outlook.com (2a01:111:e400:5249::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a47ab09b-5edc-4ea5-3113-08d625470eee X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:BLUPR15MB0164; X-Microsoft-Exchange-Diagnostics: 1;BLUPR15MB0164;3:dtXxGhJ2abR7vuu1lbnki04mGZesFSw/DzF98OdQpbpr+gpYL+qVX7LTd98dYF1+FQiPo9rYITCY0xpdiE9A3MVnZPEo1ebVhW/+6iE1jN+Bi5iiJnUlVW2qCcR3lWcmPzZoPEey0UerEiNpnfBjb+VRH0IUeM5Cz1PJ1wxzmFS8YcwNr5Ya1grpydCczdH+W/5TknLUSUnaWJMmJkI4CHbiVKlekczfNbYESwabb+YHNd5TE+88KK8pqpnS0ILa;25:RLxawtfAs0fGWQR6Sd4jmrcPh9bVukNIJ7iDU4TuNJJETE/SP5Z0UdabYeyvNqr6ofcqGDVbjrYMboIjhjUwF5iF8F/i9krSXhEjutei1DPK4UW2GWcifniIwoce0zlR+ej1wR7M4m9NI0acSRzkcPhUHrWgUFeAMKJ9qA3CE172p4z67t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mNq+WykzfC+cLCc7yC8HyERmMof/uA0XvJr44nkni/7w+AEmSXOQ5Fd1BGRNIgrjpPEd+bLZ1RzYOU74EHayaoqVc1ek+Tzg3/xILi4VAPFxqKTMRcsR2inJGQzaxxmrhfYOiiUjDAvKOHIRb7pM3XvCo5BwbJo9o6iYUau8poTYWDsnZwgn8RWMxqoxA3we/n9uEPEOmQ6pkInPX0zyi61syubSA92EepWaO7h 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)(823301075)(3002001)(10201501046)(93006095)(93001095)(3231355)(11241501184)(944501410)(52105095)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051);SRVR:BLUPR15MB0164;BCL:0;PCL:0;RULEID:;SRVR:BLUPR15MB0164; X-Forefront-PRVS: 0809C12563 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(376002)(396003)(136003)(366004)(39860400002)(346002)(199004)(189003)(68736007)(2351001)(478600001)(53416004)(2361001)(106356001)(105586002)(6486002)(8676002)(81166006)(6506007)(386003)(81156014)(6512007)(2906002)(36756003)(52116002)(6116002)(51416003)(52396003)(50226002)(50466002)(48376002)(486006)(54906003)(16586007)(8936002)(316002)(1076002)(5660300001)(16526019)(186003)(2616005)(69596002)(476003)(25786009)(46003)(4326008)(6916009)(34290500001)(47776003)(14444005)(7736002)(86362001)(53936002)(97736004)(305945005)(6666003)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR15MB0164;H:castle.tfbnw.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL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yR0Jzv2xGPLG0Q/aTOeue?= =?us-ascii?Q?5vifb7BZ2bLqxGRbY2pU1ExKRS/xin4H8yh++s1WxPchaFTQs6PrZ0KeXzMM?= =?us-ascii?Q?FEFS5tuu7YyAZYUYgrPazqcT+lyns9lOybKiWdfaMYVA8WmouOsppkCAqf0Y?= =?us-ascii?Q?LWwZzI1wET9b54LJXrl0zbMfTiUhokSkExoaATAhG4MWiaf5YvYQxOzSgwIG?= =?us-ascii?Q?tG0MMfqfiyhWMLzTob+weNkuHofn272bOYeOv0fW7VENzUNwF4c62RQ5U664?= =?us-ascii?Q?srFfosER4SwYZ0wwyzCEQgW58R+jt+hNt9j5gDW6YzUx29IMhPB2q/ES43AM?= =?us-ascii?Q?hrwIlLSpAV6bF+X0cP30SbQltGvFHIcIch+HGczb1TgGjHskW2AMj/Ej8GTh?= =?us-ascii?Q?tppB8ow+GjIAtzqgGT3R8zB+eE+TJGK7OZ7cclY?= X-Microsoft-Antispam-Message-Info: e3BwoqV9jhrmQfn4cAO1L5ZFa6axsyJeFykjk4QPU0U8LFX/nTNimGr1t1QpnQJzzbrF8hqKmUhMvrVw2p7SuVT15dgLlnBf0Y+WcjudwJw9N9oeU5LfIIwcsaufrgxLowoE32qwKbFu7DS3w8Nne+tv/RI//olArSMf8cFTL0MfbLkhRbvHLa+ky7tlMbR4u/mBlg9SWY9mzY8YJXBpCDvEgH96RVD4jqYZak4mSvMgv+tljHIpB+cFiLFLfoXzeIrc2W0IqiSwgg0TrUTivvv40IQpM/TnZAqEX+ngEVBWl/VfYNIl+XxRSaHy9vpy6JntWAGgSXD8Nvmb62wmtDiAP35jITc/bNfeHCiUnAU= X-Microsoft-Exchange-Diagnostics: 1;BLUPR15MB0164;6:5efiey9l9bwwVTwnstUusi2Fj3JSndMLbbep5x3MKp1F/eRtQCYc6/K4KichOR3GVQcORITSjgsq+GRDZpmesrZEaWdA/mTjdXlisOBUFarRu3V03rXUYcq9c209H6pzjcTzDs1aOro/WZOgZaMsmKuNqBvxow94GJ0uo6xZKmQfP3UQ/F+3vGAn0FjnbRJovdRnyUopMhOo1StdQQXmt8Q6iOZ7ARsTbJ7xgXaXdxDm/qsofvC6ocAf2d7Yrx7iyEalP1rEqpEkp7G1QRK60GtmjYhyp2GsWFJOrQwc00qBA/nm+YAlXbXDCNR4NFlQ3N7K9nMA4e+Rd7OgD77vhFmeH39hSFOS/MGD6y2nhU7XrXo9NNKkT2yanY5FTDilDjAOEOyckbSmNWg8jOEKKcS62R/65T3eL+91IAvg3Kmfw7kO0mkNPxWUXiTC5isesWX7IZZ8x5aJz2W6d+G5gg==;5:5jD6UdgrP1TX/DnlhYYvMZGEgc3ZUcb5kqnNXGvmSzmRbQR/lp5tTBmtuu8MA3e50dAyRIpq+hF7NIJ1O55sfb0pofU55SZJETx/D4LwnD3U4qdaZIl4nVAmCVVUmARl+d4wv0eVlKtCkdM8iOw64kpJz3PAetmD0BDghGzRnYY=;7:XJVHITO1asCBlx+d3EKkbbC9ElNoihAflFfGiZBIQ/iRIYmWNG8iYYnNinLQleeeunRWnwb5o91+i4TfxEZljGCxZULGVdn91ndALGp5kSBbwYkYrlspHMzD3iv5LJAo0RplQYVKyzT5ns9lNHV7XERzeHtObezzyo0QXwlMPJWP13yasboBfYi1veyCdGZFX8ooPxHtAzIuuHlOEmxQnHwJcQl6NIU18XX8pjG2SJTBZuHluFse1IIIhK2VtGru SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BLUPR15MB0164;20:+fCSDgWDhcjjzdoWzKmpesE9e+LzgeZlDtctcHI09EXkqeJSIjh136mLucNQf/ahrglinIWnJcslv38FPKQV960V0lxfqtrPpXTdX9lMHlqqZlel6TNtXetwXv04X2de0xwqXEQV1CiWlUb/BhuGmwgDQuO+zW/pdJ4yLS4+g38= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2018 13:34:02.7546 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a47ab09b-5edc-4ea5-3113-08d625470eee X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR15MB0164 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-28_06:,, 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 cgroup_storage_update_elem() shouldn't accept any flags argument values except BPF_ANY and BPF_EXIST to guarantee the backward compatibility, had a new flag value been added. Fixes: de9cbbaadba5 ("bpf: introduce cgroup storage maps") Signed-off-by: Roman Gushchin Cc: Alexei Starovoitov Cc: Daniel Borkmann --- kernel/bpf/local_storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/local_storage.c b/kernel/bpf/local_storage.c index f8746e6a9a35..2a7680106320 100644 --- a/kernel/bpf/local_storage.c +++ b/kernel/bpf/local_storage.c @@ -130,7 +130,7 @@ static int cgroup_storage_update_elem(struct bpf_map *map, void *_key, struct bpf_cgroup_storage *storage; struct bpf_storage_buffer *new; - if (flags & BPF_NOEXIST) + if (flags != BPF_ANY && flags != BPF_EXIST) return -EINVAL; storage = cgroup_storage_lookup((struct bpf_cgroup_storage_map *)map, -- 2.17.1