Received: by 10.213.65.68 with SMTP id h4csp497833imn; Wed, 4 Apr 2018 02:05:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/PmRnoBqBOxzftlm8wq4vQLBv/ZuW3sGKR51pC3+hTrWUj1qCtzjIg/p5Tly49msoRg2lX X-Received: by 2002:a17:902:36a:: with SMTP id 97-v6mr17445342pld.186.1522832735868; Wed, 04 Apr 2018 02:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522832735; cv=none; d=google.com; s=arc-20160816; b=HjUbF4jvcBGBO5GlgSbHbx/d8K97ynXVFKR6FwNAGzT6Dq5M6/JKRYwpkcaXLU1E4e N/Aqx7IBDWuoInXWc414hS89TsQh730n5WUJM6+FFA4liQfa/+L+P8N3FSvK9D40XLv+ o/UlEZA+jOmwsDKGy1sgn10uW/W56shHi1gYTjnZqWknpygYKWJ9R9qujF1zyU4BQjdg IC08dcjSzxTS5jQ4d3Zdo7TRH/l49Z+wXnvHqj9AMIOo2l9RPC7xE4Ea/eqOy9OdvFAb enbxq4HGx5c2tVX2NdKyZgU4laeYep38yldHruppa7D1DcoCqq6P97xXA2x+9JxCcvLr qgHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:mime-version:dkim-signature :arc-authentication-results; bh=n7p39y2tGXloBl1/N3Uf/lxJK3PG4o9dIt4VQnttz2w=; b=EtwKjB8rdqlytMrDMXsU3ZfHngtdjhxdC5UTJ70hRyFPXZSb+WNmpPcZnqigfGmSpZ aFyR5aNzrWmrwttWaqAiilI3q+H7NrjqSOW/gx2sC6sSfyJL3q+eIbq5qMwKc2LgZ1i4 JrmmlU9Jd5UurYRzswM50zT4igHKWxBFOT4CHNKGpJp5Hp2aeJ/leUM9aINpM/q1MOiu R0AETD56tJVQL22xXeh9Hc9KY0nBJ7aS+xB10w2YcC0AdvAiDDCErdJfPPeDHn9oAnlF 8xGLWmr5ig3LEHQzfpVdgjYgf+rHXmwICSqTQgNOlJ3Ksc7G4kPMzNbhsYNVpF68ne1z 0NIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=YPPi7Fy1; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cloudflare.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x24si3400436pgc.780.2018.04.04.02.05.21; Wed, 04 Apr 2018 02:05:35 -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=@cloudflare.com header.s=google header.b=YPPi7Fy1; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751368AbeDDJEK (ORCPT + 99 others); Wed, 4 Apr 2018 05:04:10 -0400 Received: from mail-ot0-f179.google.com ([74.125.82.179]:33248 "EHLO mail-ot0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750852AbeDDJEJ (ORCPT ); Wed, 4 Apr 2018 05:04:09 -0400 Received: by mail-ot0-f179.google.com with SMTP id 23-v6so22544449otj.0 for ; Wed, 04 Apr 2018 02:04:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=mime-version:from:date:message-id:subject:to:cc :content-transfer-encoding; bh=n7p39y2tGXloBl1/N3Uf/lxJK3PG4o9dIt4VQnttz2w=; b=YPPi7Fy1XUmtj/4NoWdUKZvu1NY/Z2gq8GkohPmbWdUAu+Tpnz94yKBJ1PijXsHbiQ hyDlaSDvt54dSzrkvyABawnYN1rNldDowxT4xvIRSlI3ldGGI3csNK8vAnc6DYTQ9F71 rME1iB1tiH6f2omIMvbqSdTwJZvmC+vjLtJ6E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc :content-transfer-encoding; bh=n7p39y2tGXloBl1/N3Uf/lxJK3PG4o9dIt4VQnttz2w=; b=dU6AGwp/wg+vEuHUnHt6xt+dY9orchSkdbyDjI39e1SXtSuspRzUH7u5pBNP8rj4LE 3/xSU+aRfQEokBDyNC1f9MZ4U3AFKdjs7f/INYls/kpCU1P5ZEbM2f9+GqnDFZhXSi/V JMuu+bVrbAnhIqUB0I438MKIvJpsNy9Rr7NPbxXwpK5mtiTYx7kOkNtFpTyUdBuwht03 gUQZtsMhDdnopux3IX3taA+o0d9/ZZv4cAAijqmnYuYO0Zn3s6/kt/8i4/uLgkzHnBl4 4mDDRXrBFhBMtel5gTKg95+ownmkpeiUFvtK3KkyduvgBmTb0FzaoGb7bLHTgZWPh6RT 21Qw== X-Gm-Message-State: ALQs6tDzhoSViv0C8ap136PHSysHbk6oM0qEpHVCSDFDyvtMzs/rjDVa NY/yqp97BTq2wH/1vxME4dev5+Sa97C7lXKwelsO8Q== X-Received: by 2002:a9d:be1:: with SMTP id 88-v6mr9719318oth.285.1522832648580; Wed, 04 Apr 2018 02:04:08 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:101b:0:0:0:0:0 with HTTP; Wed, 4 Apr 2018 02:04:08 -0700 (PDT) From: Lorenz Bauer Date: Wed, 4 Apr 2018 11:04:08 +0200 Message-ID: Subject: PROBLEM: Using BPF_PROG_TEST_RUN with data_out != NULL is unsafe To: ast@kernel.org, daniel@iogearbox.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, I=E2=80=99ve encountered an issue when using BPF_PROG_TEST_RUN and capturin= g the output. The kernel copies data into user space without checking the length of the destination buffer. In bpf_test_finish(), size is the amount of data in the XDP buffer / skb after the program is run. This can be larger than data_size_in due to bpf_xdp_adjust_head() and friends. bpf_test_finish doesn=E2=80=99t clamp size to data_size_out, which is what = I was expecting. What is the correct way to use this interface? Best, Lorenz --=20 Lorenz Bauer | Systems Engineer 25 Lavington St., London SE1 0NZ www.cloudflare.com