From: Florian Fainelli Subject: Re: [PATCH iproute2] xfrm: add option to hide keys in state output Date: Mon, 7 Jan 2019 14:23:39 -0800 Message-ID: <90a5e412-c57e-100d-085b-b6314451f075@gmail.com> References: <20190107213133.87000-1-benedictwong@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: nharold@google.com, lorenzo@google.com, maze@google.com To: Benedict Wong , netdev@vger.kernel.org Return-path: Received: from mail-yw1-f68.google.com ([209.85.161.68]:44867 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726833AbfAGWXt (ORCPT ); Mon, 7 Jan 2019 17:23:49 -0500 Received: by mail-yw1-f68.google.com with SMTP id b63so780219ywc.11 for ; Mon, 07 Jan 2019 14:23:48 -0800 (PST) In-Reply-To: <20190107213133.87000-1-benedictwong@google.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 1/7/19 1:31 PM, Benedict Wong wrote: > ip xfrm state show currently dumps keys unconditionally. This limits its > use in logging, as security information can be leaked. > > This patch adds a nokeys option to ip xfrm ( state show | monitor ), which > prevents the printing of keys. This allows ip xfrm state show to be used > in logging without exposing keys. I have not yet looked at the kernel side, but assuming the keys are stored on the kernel side as well (which is quite conceivably what is happening for software IPsec), would not it be better to not request the kernel not to dump the keys to begin with, that way a process ptracing iproute2 or whatever, would also not have a chance to ex-filtrate those keys? If this is not how this is implemented, apologies :) > > Signed-off-by: Benedict Wong > --- > ip/ipxfrm.c | 45 +++++++++++++++++++++++++-------------------- > ip/xfrm.h | 5 +++-- > ip/xfrm_monitor.c | 7 +++++-- > ip/xfrm_state.c | 27 ++++++++++++++++++++++----- > man/man8/ip-xfrm.8 | 15 ++++++++++++++- > 5 files changed, 69 insertions(+), 30 deletions(-) > > diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c > index 2dea4e37..1334ca9f 100644 > --- a/ip/ipxfrm.c > +++ b/ip/ipxfrm.c > @@ -497,7 +497,8 @@ void xfrm_selector_print(struct xfrm_selector *sel, __u16 family, > } > > static void __xfrm_algo_print(struct xfrm_algo *algo, int type, int len, > - FILE *fp, const char *prefix, int newline) > + FILE *fp, const char *prefix, int newline, > + bool nokeys) > { > int keylen; > int i; > @@ -521,7 +522,9 @@ static void __xfrm_algo_print(struct xfrm_algo *algo, int type, int len, > goto fin; > } > > - if (keylen > 0) { > + if (nokeys) > + fprintf(fp, "<