From patchwork Fri Jan 18 19:12:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benedict Wong X-Patchwork-Id: 1027707 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="lLz0uktg"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43h9Z52hknz9sD9 for ; Sat, 19 Jan 2019 06:12:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729332AbfARTMn (ORCPT ); Fri, 18 Jan 2019 14:12:43 -0500 Received: from mail-pf1-f202.google.com ([209.85.210.202]:45406 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729115AbfARTMn (ORCPT ); Fri, 18 Jan 2019 14:12:43 -0500 Received: by mail-pf1-f202.google.com with SMTP id 74so10755026pfk.12 for ; Fri, 18 Jan 2019 11:12:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=qUj8rDMFx34nb1IOqurLEsscY8sl1R9szKuAG+KLGc8=; b=lLz0uktghayp/dE88jmjhPN6GQh9fukHeUpcInEIUwmIlG6fsOq6YjQFutdo1iB2gz SoIVi7t4xc/Ge2TAjkHzVGxoMfVIckTaAypg0XbGogGs8sssYvUFEJQCMzQlc62OlswP 5Bbwwim4UD+aER8xsmSQnr6e+NX4DHqQw7P5BtY1tEpsqR/vnpdVMupnsr9xkg8KzmC0 OzmOxSMLaDjbzhKAPj/eMO3ZlVHmjqKExgJi+ncvP22ddtdpX1gzCymj3mgSq1n55qiR M9t5zUFuaOpadN9q9CbkgRUf7rbP9SAUFhPwZmKVhu692tB73mQb9G4q4DzzbCU1CVwF +ang== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qUj8rDMFx34nb1IOqurLEsscY8sl1R9szKuAG+KLGc8=; b=aARAdlLcCSmcfusqF/crx016QjHcECyvY3P3sFSwXQasPgnrIgcdqnw3OxSPLJaLS3 ZFYFeqk6frlARejG1STyp+rVfVrZid0tn7EvZRfFiw3GkPAbKomnyvS+CfzPuWopf2dp 8AHwSUoVhIinDbQtYYW/gzYz/Y45XVjohXJ7C9nAbHyt+9qaMvY/w+HVTualTrSU551V EdNr+feQmNOrzL8UA+k+VR1OBkFZ0IEVZ/5hZkOEmM4YEi3B/RXZIEuBU6mIpYbFP6Np 2mecWuiYU5k4QeZ46iQf2i/yUf1YyVAuOopZT51h7quXf3HafgAtd+Y+ZfUinSpdSCdc O6/w== X-Gm-Message-State: AJcUukeZh01oUrkB891IUuk4n/uFJVpCYxPAVzoyESqYkrn7lofFysgB oogSUIYIRNuxTVThm25t9ShH7OuLI5rvZInWLWGbTMOqlX/H5ntmeOEyJ7n0wEiDl9UKDT1tjRR hlmryyGug/pONB4phGXjCkjA2iBCFbiZHrLG5a4xM+b2RAroOZcKn+Ko46dojdtdoCLv5fHN+2o Wnzw== X-Google-Smtp-Source: ALg8bN65WWNFWZYNSD+ueTGia3+MnmLsMob605psmQGzEnbYxvPmVO2lWgfnP8JJO4nl2aLz85CODl045J4P0WBP7yg= X-Received: by 2002:a17:902:9045:: with SMTP id w5mr6561213plz.109.1547838761778; Fri, 18 Jan 2019 11:12:41 -0800 (PST) Date: Fri, 18 Jan 2019 11:12:17 -0800 In-Reply-To: <20190118191217.131649-1-benedictwong@google.com> Message-Id: <20190118191217.131649-2-benedictwong@google.com> Mime-Version: 1.0 References: <20190118191217.131649-1-benedictwong@google.com> X-Mailer: git-send-email 2.20.1.321.g9e740568ce-goog Subject: [PATCH v2 iproute2 1/1] xfrm: add option to hide keys in state output From: Benedict Wong To: netdev@vger.kernel.org Cc: nharold@google.com, benedictwong@google.com, lorenzo@google.com, maze@google.com, dsahern@gmail.com Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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. Signed-off-by: Benedict Wong --- ip/ipxfrm.c | 49 +++++++++++++++++++++++++--------------------- ip/xfrm.h | 5 +++-- ip/xfrm_monitor.c | 7 +++++-- ip/xfrm_state.c | 27 ++++++++++++++++++++----- man/man8/ip-xfrm.8 | 15 +++++++++++++- 5 files changed, 71 insertions(+), 32 deletions(-) diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c index 2dea4e37..b153b863 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, "<