Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp67822imm; Wed, 5 Sep 2018 15:07:39 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbwIydjQqxctKf26DM8k6zC3cG/oaYa0prHBClY+bbTZhI69fmtO9mk45qCJGGpgOaRQJLF X-Received: by 2002:a17:902:f209:: with SMTP id gn9mr18287099plb.173.1536185259775; Wed, 05 Sep 2018 15:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536185259; cv=none; d=google.com; s=arc-20160816; b=xSrO2a36cTLecBI0jyDx8hMDuWZGjTyuNBjhwUA+VFBhdhM96FXDoPsoCJlq6juxuV zPJGNOat9o2mf51JRnVxy9wcGr3ROJy6eaBuq+CGL0CxPM9HSY0XgHGGtLzqKTlrLSO+ 0y/57pQUhsosk3k73NABH8Ws6QDW7JZf9xB4yZHqeNKAeK1wjHVjKNgcPwMBY/cTQ6jH Z3BMRxzEIyReHGfLzI+E6BnrAqQD879PSk9djbN5/oXYwN5ru3FobPjR/iFygpeOmZtx hcMuoBTSn/9m4fuwYB/giRTQ+BEeifRN+xTBHiJiJBBQdPtolIPihag6ZlXzyUziqyNB Ni7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=MRP10B/u9BAggWceKspLZcdl4jB7SW3JoZbABT9WGCE=; b=RwTWyQ7/cdrFbHGjApn03hlUD8LfnZRUx6nFRdIUfvLqsK02mL6axb4gRdgNT9dT9+ wU/wmSEiW+W+rzUN4yxgSA3LMIbnvX8xTH9bBrn2Ak3XWGVL0y3j+5/7KsmtwcwWUa71 FnHdKjejgt9p9sg2blbodj4KMvAgB64Rq5fIZi1jxBCFr3EZKRqOrtaCWhUHVc+IlKps cyl5MOSEVuVAZ831BpqMt9ZiCseXavOQLbt+MnRRonztWGSHxAQfh7W96GVbc4nis2km LjW2bBpJxGOei7PkRuxlL1c5L15a0TjEC7agChqSTtir1qdzIofjad6buu4ubUKRryYe KAIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AEoW242G; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z16-v6si3285464pgi.252.2018.09.05.15.07.24; Wed, 05 Sep 2018 15:07:39 -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=@kernel.org header.s=default header.b=AEoW242G; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728260AbeIFChp (ORCPT + 99 others); Wed, 5 Sep 2018 22:37:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:51996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727518AbeIFCho (ORCPT ); Wed, 5 Sep 2018 22:37:44 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C8E722073D; Wed, 5 Sep 2018 22:05:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536185133; bh=nnaSol8PjHTgHNMe4LHQtUuf5KuQcsHtsDHGnZGssUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AEoW242GzcUjq37xJKx/P3oJs5I1p8fToj5/exLyu3S7Jc9vdBiMLY6mQHEHNbV5T EdOEIWg+Ii60l7zxx62fJeq9agFO2X9opWH6rmjFIpaWML7+FgXfQaRdXQTWrzdxMT 9EzLPPvNvSjlUgnNWyITSnSgE1H6ZH/mp+qgMgxs= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Jiri Olsa , Namhyung Kim , Wang Nan Subject: [PATCH 15/77] perf trace augmented_syscalls: Add augmented_sockaddr_syscall_enter() Date: Wed, 5 Sep 2018 19:03:38 -0300 Message-Id: <20180905220440.20256-16-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180905220440.20256-1-acme@kernel.org> References: <20180905220440.20256-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo From the one for 'connect', so that we can use it with sendto and others that receive a 'struct sockaddr'. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-8bdqv1q0ndcjl1nqns5r5je2@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/examples/bpf/augmented_syscalls.c | 46 ++++++++++++++++------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/tools/perf/examples/bpf/augmented_syscalls.c b/tools/perf/examples/bpf/augmented_syscalls.c index 6dfead0be74e..5f417e528419 100644 --- a/tools/perf/examples/bpf/augmented_syscalls.c +++ b/tools/perf/examples/bpf/augmented_syscalls.c @@ -95,6 +95,31 @@ struct syscall_enter_newstat_args { augmented_filename_syscall_enter(newstat); +#ifndef _K_SS_MAXSIZE +#define _K_SS_MAXSIZE 128 +#endif + +#define augmented_sockaddr_syscall_enter(syscall) \ +struct augmented_enter_##syscall##_args { \ + struct syscall_enter_##syscall##_args args; \ + struct sockaddr_storage addr; \ +}; \ +int syscall_enter(syscall)(struct syscall_enter_##syscall##_args *args) \ +{ \ + struct augmented_enter_##syscall##_args augmented_args; \ + unsigned long addrlen = sizeof(augmented_args.addr); \ + probe_read(&augmented_args.args, sizeof(augmented_args.args), args); \ +/* FIXME_CLANG_OPTIMIZATION_THAT_ACCESSES_USER_CONTROLLED_ADDRLEN_DESPITE_THIS_CHECK */ \ +/* if (addrlen > augmented_args.args.addrlen) */ \ +/* addrlen = augmented_args.args.addrlen; */ \ +/* */ \ + probe_read(&augmented_args.addr, addrlen, args->addr_ptr); \ + perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, \ + &augmented_args, \ + sizeof(augmented_args) - sizeof(augmented_args.addr) + addrlen); \ + return 0; \ +} + struct sockaddr; struct syscall_enter_connect_args { @@ -105,25 +130,6 @@ struct syscall_enter_connect_args { unsigned long addrlen; }; -struct augmented_enter_connect_args { - struct syscall_enter_connect_args args; - struct sockaddr_storage addr; -}; - -int syscall_enter(connect)(struct syscall_enter_connect_args *args) -{ - struct augmented_enter_connect_args augmented_args; - unsigned long addrlen = sizeof(augmented_args.addr); - - probe_read(&augmented_args.args, sizeof(augmented_args.args), args); -#ifdef FIXME_CLANG_OPTIMIZATION_THAT_ACCESSES_USER_CONTROLLED_ADDRLEN_DESPITE_THIS_CHECK - if (addrlen > augmented_args.args.addrlen) - addrlen = augmented_args.args.addrlen; -#endif - probe_read(&augmented_args.addr, addrlen, args->addr_ptr); - perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, &augmented_args, - sizeof(augmented_args) - sizeof(augmented_args.addr) + addrlen); - return 0; -} +augmented_sockaddr_syscall_enter(connect); license(GPL); -- 2.14.4