From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A300C43387 for ; Wed, 16 Jan 2019 17:46:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D26A20657 for ; Wed, 16 Jan 2019 17:46:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="lw8rhdSz"; dkim=pass (1024-bit key) header.d=fb.onmicrosoft.com header.i=@fb.onmicrosoft.com header.b="XXnwWg+G" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727451AbfAPRqA (ORCPT ); Wed, 16 Jan 2019 12:46:00 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:36766 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726821AbfAPRp7 (ORCPT ); Wed, 16 Jan 2019 12:45:59 -0500 Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0GHc60e015392; Wed, 16 Jan 2019 09:45:33 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=ngju5ldJUsX7fxN9j8oeoeenFsm6HRgtlrNuPi4DMdI=; b=lw8rhdSzi41uVbZGXcJXl6DxEXC5DemG+VQGpge/3+TSW31gLi9JBioDsq+z9YlxLSFH dRIC2oVTfwATRqnLh9JqN6vFauk3TMv675OlZlUMm5BNMeMT/tWpsS2bnBDWBSo6DZJI Obnbo+iLUBjKkLWb+RZtORLR7oMYg2KKVhE= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2q29338280-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 16 Jan 2019 09:45:33 -0800 Received: from frc-mbx04.TheFacebook.com (2620:10d:c0a1:f82::28) by frc-hub06.TheFacebook.com (2620:10d:c021:18::176) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1531.3; Wed, 16 Jan 2019 09:45:32 -0800 Received: from frc-hub03.TheFacebook.com (2620:10d:c021:18::173) by frc-mbx04.TheFacebook.com (2620:10d:c0a1:f82::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1531.3; Wed, 16 Jan 2019 09:45:32 -0800 Received: from NAM05-DM3-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1531.3 via Frontend Transport; Wed, 16 Jan 2019 09:45:32 -0800 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=ngju5ldJUsX7fxN9j8oeoeenFsm6HRgtlrNuPi4DMdI=; b=XXnwWg+GWIGLdRCqT3SJaNzimvsfqE/hwIN9vQxhYyv3BXt9qD7NzLPksPCWYR58xRet8JehKTEODPgBO/OSbxPW8/SkBzOQH2+jl0sbKnsLphIy4wBUCJdD4HcJN2evZ91iF54UmQiYcqRj02JATSk23JMp9BhUUJb83X+1z+4= Received: from MWHPR15MB1165.namprd15.prod.outlook.com (10.175.2.19) by MWHPR15MB1533.namprd15.prod.outlook.com (10.173.235.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.19; Wed, 16 Jan 2019 17:45:30 +0000 Received: from MWHPR15MB1165.namprd15.prod.outlook.com ([fe80::ec0e:4a05:81f8:7df9]) by MWHPR15MB1165.namprd15.prod.outlook.com ([fe80::ec0e:4a05:81f8:7df9%4]) with mapi id 15.20.1537.018; Wed, 16 Jan 2019 17:45:30 +0000 From: Song Liu To: Stanislav Fomichev CC: Netdev , "davem@davemloft.net" , "ast@kernel.org" , "daniel@iogearbox.net" Subject: Re: [PATCH bpf 1/3] bpf: don't assume build-id length is always 20 bytes Thread-Topic: [PATCH bpf 1/3] bpf: don't assume build-id length is always 20 bytes Thread-Index: AQHUrSVbOkbfp53toEGhVNZgWfHl+KWyLD+A Date: Wed, 16 Jan 2019 17:45:30 +0000 Message-ID: <0FC05078-4DF7-453E-8F36-7C0F5AF81F69@fb.com> References: <20190115225447.245788-1-sdf@google.com> In-Reply-To: <20190115225447.245788-1-sdf@google.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3445.102.3) x-originating-ip: [2620:10d:c090:180::1:2ea9] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR15MB1533;20:PcN4LRD2NLnmJzbIBj9gg/51Mf4X9rqIdRTCfUkxIBVQ3IatpS9S3Yu6NAIwvdxIobUYj1k8AO2BNtSRcBlRWUJfF3fZPxTf++J7NjiHJz6DE4UR8Hyzc0KZv/4G9jgQZgmPElmZ3M5ECCsNbAX1Mdp29Rr4eCZHqQdXtXS3ims= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 56748924-b2fb-4317-674e-08d67bda6888 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(2017052603328)(7153060)(7193020);SRVR:MWHPR15MB1533; x-ms-traffictypediagnostic: MWHPR15MB1533: x-microsoft-antispam-prvs: x-forefront-prvs: 091949432C x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(136003)(366004)(396003)(51914003)(199004)(189003)(36756003)(25786009)(4326008)(71190400001)(83716004)(486006)(2906002)(82746002)(33656002)(53546011)(6506007)(76176011)(14454004)(478600001)(46003)(229853002)(6512007)(71200400001)(256004)(68736007)(53936002)(186003)(6246003)(97736004)(105586002)(5660300001)(316002)(106356001)(50226002)(54906003)(57306001)(81166006)(81156014)(6916009)(8936002)(2616005)(476003)(8676002)(99286004)(86362001)(6116002)(11346002)(102836004)(7736002)(446003)(6486002)(6436002)(305945005);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR15MB1533;H:MWHPR15MB1165.namprd15.prod.outlook.com;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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: vEl6pNaQexc+ldavnH0ErHKIFq9Rx2tZ7Vf7iudTv0nQMchgfA9zBnEGTG6kT+OaSRibskkiAk1jB9AB8YGAIS1xrpnWBTysNtOsdxHoBgmvzc/8Hx17HmZJKfmdXcVeFQmyMkFbWWNehCJQdO5kaNzIX5LneOn3nlkHFhOzdOgbIBWTUzlyCiR0wmJW/lFuYOgbwJ0UAxlg+qv8baeKHDPc0v0CaqO57OVvFWeau+Gna8Dd8oxGJwVzqBvGVNRmWfPQ80we/mR0C420IjYlAK2+ALZLBKeCJj2RsAH2L1xrzFy3r5kDugy3IR+Gvnq4SZoy7zOFwCWIqHthmI8P0t2rpN+UXKgtIErb83zwrl9fuhHe928YInrVpe8ITEy3pame6uoP/NFde+IKMq0WVzbHz6eKbBJzoz8XyX2w3pw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 56748924-b2fb-4317-674e-08d67bda6888 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jan 2019 17:45:30.3868 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1533 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-16_07:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org > On Jan 15, 2019, at 2:54 PM, Stanislav Fomichev wrote: >=20 > Build-id length is not fixed to 20, it can be (`man ld` /--build-id): > * 128-bit (uuid) > * 160-bit (sha1) > * any length specified in ld --build-id=3D0xhexstring >=20 > To fix the issue of missing BPF_STACK_BUILD_ID_VALID for shorter build-id= s, > assume that build-id is somewhere in the range of 1 .. 20. > Set the remaining bytes to zero. >=20 > Fixes: 615755a77b24 ("bpf: extend stackmap to save binary_build_id+offset= instead of address") > Signed-off-by: Stanislav Fomichev > --- > kernel/bpf/stackmap.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c > index d9e2483669d0..8975d1768dcb 100644 > --- a/kernel/bpf/stackmap.c > +++ b/kernel/bpf/stackmap.c > @@ -180,11 +180,15 @@ static inline int stack_map_parse_build_id(void *pa= ge_addr, >=20 > if (nhdr->n_type =3D=3D BPF_BUILD_ID && > nhdr->n_namesz =3D=3D sizeof("GNU") && > - nhdr->n_descsz =3D=3D BPF_BUILD_ID_SIZE) { > + nhdr->n_descsz > 0 && > + nhdr->n_descsz <=3D BPF_BUILD_ID_SIZE) { > + __u32 len =3D min_t(__u32, > + BPF_BUILD_ID_SIZE, nhdr->n_descsz); Given the check above, we only need len =3D nhdr->n_descsz, right? Other than this,=20 Acked-by: Song Liu Thanks for the fix! > memcpy(build_id, > note_start + note_offs + > ALIGN(sizeof("GNU"), 4) + sizeof(Elf32_Nhdr), > - BPF_BUILD_ID_SIZE); > + len); > + memset(build_id + len, 0, BPF_BUILD_ID_SIZE - len); > return 0; > } > new_offs =3D note_offs + sizeof(Elf32_Nhdr) + > --=20 > 2.20.1.97.g81188d93c3-goog >=20