Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp996342ybt; Fri, 26 Jun 2020 17:31:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUtsvh8YnCjo7mV4qksxpojSoWkBsZl7qx6EcUXyPS4g1eQQx40vHfG8zV7DK/nr5P3rj3 X-Received: by 2002:a05:6402:706:: with SMTP id w6mr5959589edx.326.1593217912410; Fri, 26 Jun 2020 17:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593217912; cv=none; d=google.com; s=arc-20160816; b=sMhRqmnX0lcwAVoEWK3RkbPHHfe1c/q4moWArBsuUOD6QcVOn6/LbHGI0gimqE9lnn q2kIXk9eI5z61rqsvWaR544OnUD3dkk55Osss4T7y0njwGRDJ0pm5pQNiUMbil5b+kfK IQJAlvYEfBAQKUc6M3cvXgjM1WNmTWJ+uP2Sb8D/IC/hD60T10K5qcA2kQQOm4ObqsZN hUoxS4vmN3w55pwClTkDyCOlrtZCVddNU4WgKrqxKzUZuG3SyxuH1d3D27IxxWvWf6yv 8AOu9hnUGqf6eoiuMzJOPfa5j/2rDb2RQNqLFiO78BYmZY/ZlDachybslMDL4A393Fwr SNWA== 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:mime-version :references:in-reply-to:message-id:date:subject:smtp-origin-cluster :cc:to:smtp-origin-hostname:from:smtp-origin-hostprefix :dkim-signature; bh=PXwo5w25H1G3trFLqpf6ijaWoyxKihUhCvb9tnUjxmk=; b=NrHvPcoZYmg4G0WdWTmyDQxmCxjpV0DFCV+779VRAGL6Xy2W4ER9PUJS5FaDaMERKM EprjhaQzIy+Sm7l2QNV7gqec6whqLabKXOKr/yvC7qsJwU/OqRGTxs2G9EG1gIge/oTe Gc7ES1N4jbIiyMcZN2wUSSzPi4zyKha3n23BrY0MBl49jtuQyHa8Ivr0sgpWMaaKsclr AgFCB+Wr0ZaxAebFKQG2Nx91Nn0xDaXU7iC4oq903n2raDqUIUNTWZXlkYasQcddeWbT dKhMxIMnk1G4SRCAhV6d34Wk03MhpA1MqSV/Vm/mucOS5Dr2MiNpm90oioOFw2xpowmB KbOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=odF6NMD8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q7si17761438ejb.504.2020.06.26.17.31.29; Fri, 26 Jun 2020 17:31:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=odF6NMD8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726507AbgF0A3X (ORCPT + 99 others); Fri, 26 Jun 2020 20:29:23 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:8946 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726125AbgF0A3T (ORCPT ); Fri, 26 Jun 2020 20:29:19 -0400 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.42/8.16.0.42) with SMTP id 05R0FNvU023087 for ; Fri, 26 Jun 2020 17:29:17 -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-transfer-encoding : content-type; s=facebook; bh=PXwo5w25H1G3trFLqpf6ijaWoyxKihUhCvb9tnUjxmk=; b=odF6NMD8YIbMvoo09KZr6IoAUUDHIEYxGC47yE7Qf6eJMxfNO0KT6mRTMxT/2omjfJow 0U/bs5e6HT5aLNCrrchL+gLBGwelwpehyDIU3BdYjSYEdUF90n5b4fB4B7h0d30wR0nJ 1DfFD5iALLNNhaJLc1y5Yvm95tF+MEhZdCs= Received: from mail.thefacebook.com ([163.114.132.120]) by m0001303.ppops.net with ESMTP id 31wudn81g0-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 26 Jun 2020 17:29:17 -0700 Received: from intmgw005.03.ash8.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 26 Jun 2020 17:29:14 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id C4AAD62E4EB1; Fri, 26 Jun 2020 17:26:20 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Song Liu Smtp-Origin-Hostname: devbig006.ftw2.facebook.com To: , , CC: , , , , , , Song Liu , Yonghong Song Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH v3 bpf-next 3/4] bpf: allow %pB in bpf_seq_printf() and bpf_trace_printk() Date: Fri, 26 Jun 2020 17:26:08 -0700 Message-ID: <20200627002609.3222870-5-songliubraving@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200627002609.3222870-1-songliubraving@fb.com> References: <20200627002609.3222870-1-songliubraving@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-26_12:2020-06-26,2020-06-26 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 clxscore=1015 bulkscore=0 suspectscore=8 priorityscore=1501 phishscore=0 lowpriorityscore=0 cotscore=-2147483648 adultscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006270000 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This makes it easy to dump stack trace in text. Acked-by: Yonghong Song Signed-off-by: Song Liu --- kernel/trace/bpf_trace.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 977ba3b6f6c64..1d874d8e4384b 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -376,7 +376,7 @@ static void bpf_trace_copy_string(char *buf, void *un= safe_ptr, char fmt_ptype, =20 /* * Only limited trace_printk() conversion specifiers allowed: - * %d %i %u %x %ld %li %lu %lx %lld %lli %llu %llx %p %pks %pus %s + * %d %i %u %x %ld %li %lu %lx %lld %lli %llu %llx %p %pB %pks %pus %s */ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1, u64, arg2, u64, arg3) @@ -420,6 +420,11 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_s= ize, u64, arg1, goto fmt_str; } =20 + if (fmt[i + 1] =3D=3D 'B') { + i++; + goto fmt_next; + } + /* disallow any further format extensions */ if (fmt[i + 1] !=3D 0 && !isspace(fmt[i + 1]) && @@ -636,7 +641,8 @@ BPF_CALL_5(bpf_seq_printf, struct seq_file *, m, char= *, fmt, u32, fmt_size, if (fmt[i] =3D=3D 'p') { if (fmt[i + 1] =3D=3D 0 || fmt[i + 1] =3D=3D 'K' || - fmt[i + 1] =3D=3D 'x') { + fmt[i + 1] =3D=3D 'x' || + fmt[i + 1] =3D=3D 'B') { /* just kernel pointers */ params[fmt_cnt] =3D args[fmt_cnt]; fmt_cnt++; --=20 2.24.1