Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1751067pxf; Fri, 19 Mar 2021 15:09:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypNef2lOsMnbVJH1P/W28582Rx/YDrcsEZ2fl5Rda3PIIAIxYm2Vs+PjFmRxfTFd5Dk+gG X-Received: by 2002:a50:eb97:: with SMTP id y23mr12296589edr.170.1616191776950; Fri, 19 Mar 2021 15:09:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616191776; cv=none; d=google.com; s=arc-20160816; b=qrJrl/dNO0JTM71bY/y3jj+kTW7FczH0ci41SQ+G1Kt6d/EU2SNygSeDt+xFsNokUr hYVgDyg5MA6Qg6LebGhj4kKagmc/zbzqLL2LkXzf9bGtcHXMSE5DaPzJV1mzVefiNJEm QoroefPn+XCDI1awbrMtrxyGY4P8XPXGP/Kk3ghoTXw3T7WG92gh1p8aBrOEqPUa9Ur8 ZVh8d/h26WqsSL20m+iOZL+LX8BUIsyPjxjyqfE2tnj8/0UjS/A726j2P1NKkNK+MIwt oQWk+E6JOgu1G62r0Eqr8aAonXbWOBpCVHvRlz7LRGODO6PUNaXZtrj7AJWx4H7CjVH+ XJ9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Tpb6lNNIMtiqOobkkz7pgbvgA0UyB0HXjyiq4zy5RJI=; b=FSclMob7uY/2aq/TKZN9pucdREr8e6+UqxMZQRUmMrQsL6smwjuNbdmhJ/4uWALojn 6ndr04g8LOvZ/BkgeROTBV7FczYAGRkgCvbSxaLYD3CjTklb6Gq6rwWXJMl2gQhUF96z E4xhWfKqnjbzAitHa+QO3y5R8LF2yZ5abcSwe4GBOFCpAweL3kSIOMp0Rg0RkqZf30zc v0FYZthcncimmjUZPfa0Y5XrarV4DpT3OcQbzz4KmeCoXBk4KTwD/0YAjDK99BI0nYoD BG+IqNNdE84WgNdrLovn9a4ZfAL3gvNhFLvMinUfTwQzrjMpMM5z0y417CvSnne6PHKf 066g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QgrjJL4J; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si5215582ejy.263.2021.03.19.15.09.03; Fri, 19 Mar 2021 15:09:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@redhat.com header.s=mimecast20190719 header.b=QgrjJL4J; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230490AbhCSWIa (ORCPT + 99 others); Fri, 19 Mar 2021 18:08:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45842 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhCSWIN (ORCPT ); Fri, 19 Mar 2021 18:08:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616191693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Tpb6lNNIMtiqOobkkz7pgbvgA0UyB0HXjyiq4zy5RJI=; b=QgrjJL4JDVaqQh4cfN31vkfHfDYgvGk6zTPnUzZ01ifHdflqIMGA/p50MrfYbHgesjO7bv ce/R4NeOPSBpTdtTmp/yHw5VGoWQ/Jy85ckiubX0uZNwoxhFDAQ744Y/BI1E0+lpJ12ytC ZSVegVgc8kOWzXm9LICMjQNNH6k1bwo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-291-1i-LpwZ-PzyJX1vF6tfYUA-1; Fri, 19 Mar 2021 18:08:09 -0400 X-MC-Unique: 1i-LpwZ-PzyJX1vF6tfYUA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3346A9113F; Fri, 19 Mar 2021 22:08:07 +0000 (UTC) Received: from pick.fieldses.org (ovpn-115-237.rdu2.redhat.com [10.10.115.237]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C17745D72F; Fri, 19 Mar 2021 22:08:06 +0000 (UTC) Received: by pick.fieldses.org (Postfix, from userid 2815) id 4EBF4121007; Fri, 19 Mar 2021 18:08:05 -0400 (EDT) Date: Fri, 19 Mar 2021 18:08:05 -0400 From: "J. Bruce Fields" To: Chuck Lever III Cc: Chris Down , Linux NFS Mailing List , Linux-Net , LKML , Trond Myklebust , "David S. Miller" Subject: Re: [PATCH] SUNRPC: Output oversized frag reclen as ASCII if printable Message-ID: References: <3844BF67-8820-4D6C-95BA-8BA0B0956BD0@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3844BF67-8820-4D6C-95BA-8BA0B0956BD0@oracle.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, Mar 19, 2021 at 02:58:14PM +0000, Chuck Lever III wrote: > Hi Chris- > > > On Mar 19, 2021, at 10:54 AM, Chris Down wrote: > > > > The reclen is taken directly from the first four bytes of the message > > with the highest bit stripped, which makes it ripe for protocol mixups. > > For example, if someone tries to send a HTTP GET request to us, we'll > > interpret it as a 1195725856-sized fragment (ie. (u32)'GET '), and print > > a ratelimited KERN_NOTICE with that number verbatim. > > > > This can be confusing for downstream users, who don't know what messages > > like "fragment too large: 1195725856" actually mean, or that they > > indicate some misconfigured infrastructure elsewhere. > > One wonders whether that error message is actually useful at all. > We could, for example, turn this into a tracepoint, or just get > rid of it. Just going on vague memories here, but: I think we've seen both spurious and real bugs reported based on this. I'm inclined to go with a dprintk or tracepoint but not removing it entirely. --b. > > > > To allow users to more easily understand and debug these cases, add the > > number interpreted as ASCII if all characters are printable: > > > > RPC: fragment too large: 1195725856 (ASCII "GET ") > > > > If demand grows elsewhere, a new printk format that takes a number and > > outputs it in various formats is also a possible solution. For now, it > > seems reasonable to put this here since this particular code path is the > > one that has repeatedly come up in production. > > > > Signed-off-by: Chris Down > > Cc: Chuck Lever > > Cc: J. Bruce Fields > > Cc: Trond Myklebust > > Cc: David S. Miller > > --- > > net/sunrpc/svcsock.c | 39 +++++++++++++++++++++++++++++++++++++-- > > 1 file changed, 37 insertions(+), 2 deletions(-) > > > > diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c > > index 2e2f007dfc9f..046b1d104340 100644 > > --- a/net/sunrpc/svcsock.c > > +++ b/net/sunrpc/svcsock.c > > @@ -46,6 +46,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -863,6 +864,34 @@ static void svc_tcp_clear_pages(struct svc_sock *svsk) > > svsk->sk_datalen = 0; > > } > > > > +/* The reclen is taken directly from the first four bytes of the message with > > + * the highest bit stripped, which makes it ripe for protocol mixups. For > > + * example, if someone tries to send a HTTP GET request to us, we'll interpret > > + * it as a 1195725856-sized fragment (ie. (u32)'GET '), and print a ratelimited > > + * KERN_NOTICE with that number verbatim. > > + * > > + * To allow users to more easily understand and debug these cases, this > > + * function decodes the purported length as ASCII, and returns it if all > > + * characters were printable. Otherwise, we return NULL. > > + * > > + * WARNING: Since we reuse the u32 directly, the return value is not null > > + * terminated, and must be printed using %.*s with > > + * sizeof(svc_sock_reclen(svsk)). > > + */ > > +static char *svc_sock_reclen_ascii(struct svc_sock *svsk) > > +{ > > + u32 len_be = cpu_to_be32(svc_sock_reclen(svsk)); > > + char *len_be_ascii = (char *)&len_be; > > + size_t i; > > + > > + for (i = 0; i < sizeof(len_be); i++) { > > + if (!isprint(len_be_ascii[i])) > > + return NULL; > > + } > > + > > + return len_be_ascii; > > +} > > + > > /* > > * Receive fragment record header into sk_marker. > > */ > > @@ -870,6 +899,7 @@ static ssize_t svc_tcp_read_marker(struct svc_sock *svsk, > > struct svc_rqst *rqstp) > > { > > ssize_t want, len; > > + char *reclen_ascii; > > > > /* If we haven't gotten the record length yet, > > * get the next four bytes. > > @@ -898,9 +928,14 @@ static ssize_t svc_tcp_read_marker(struct svc_sock *svsk, > > return svc_sock_reclen(svsk); > > > > err_too_large: > > - net_notice_ratelimited("svc: %s %s RPC fragment too large: %d\n", > > + reclen_ascii = svc_sock_reclen_ascii(svsk); > > + net_notice_ratelimited("svc: %s %s RPC fragment too large: %d%s%.*s%s\n", > > __func__, svsk->sk_xprt.xpt_server->sv_name, > > - svc_sock_reclen(svsk)); > > + svc_sock_reclen(svsk), > > + reclen_ascii ? " (ASCII \"" : "", > > + (int)sizeof(u32), > > + reclen_ascii ?: "", > > + reclen_ascii ? "\")" : ""); > > set_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags); > > err_short: > > return -EAGAIN; > > -- > > 2.30.2 > > > > -- > Chuck Lever > > >