From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C0F8C433EF for ; Wed, 22 Sep 2021 15:45:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F95F610A1 for ; Wed, 22 Sep 2021 15:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232571AbhIVPrV (ORCPT ); Wed, 22 Sep 2021 11:47:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232318AbhIVPrV (ORCPT ); Wed, 22 Sep 2021 11:47:21 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C0BEC061574 for ; Wed, 22 Sep 2021 08:45:51 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 997E77027; Wed, 22 Sep 2021 11:45:49 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 997E77027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1632325549; bh=LFTo6NPpYxw6/I3pnfZQGuPQrfymygTY8Jrs7pPLph4=; h=Date:To:Cc:Subject:References:In-Reply-To:From:From; b=m9nSojEXJRcmSXk+6yAZbNl/uhXB9Nsbbq6BR3mq2aIAeQf+9OBPi03R1k7XLBiFe 7uYovKPZUrSMC2bAath6Az/XJonSM+O2azlQnvLlGMaI6EpkeNHYUgKgUAU9WqkMS6 8fViBosi243u7feNnF4kPWJgId5OJLixWWarFb48= Date: Wed, 22 Sep 2021 11:45:49 -0400 To: Chuck Lever Cc: dai.ngo@oracle.com, linux-nfs@vger.kernel.org Subject: Re: [PATCH] NLM: Remove svcxdr_encode_owner() Message-ID: <20210922154549.GB22937@fieldses.org> References: <163181894199.1110.356714948732645250.stgit@bazille.1015granger.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <163181894199.1110.356714948732645250.stgit@bazille.1015granger.net> User-Agent: Mutt/1.5.21 (2010-09-15) From: bfields@fieldses.org (J. Bruce Fields) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, Sep 16, 2021 at 03:03:32PM -0400, Chuck Lever wrote: > Dai Ngo reports that, since the XDR overhaul, the NLM server crashes > when the TEST procedure wants to return NLM_DENIED. There is a bug > in svcxdr_encode_owner() that none of our standard test cases found. > > Replace the open-coded function with a call to an appropriate > pre-fabricated XDR helper. Makes sense to me. I assume you're taking this for 5.15.--b. > > Reported-by: Dai Ngo > Signed-off-by: Chuck Lever > --- > fs/lockd/svcxdr.h | 13 ++----------- > 1 file changed, 2 insertions(+), 11 deletions(-) > > This might be a little better for the long term. Comments? > > diff --git a/fs/lockd/svcxdr.h b/fs/lockd/svcxdr.h > index c69a0bb76c94..805fb19144d7 100644 > --- a/fs/lockd/svcxdr.h > +++ b/fs/lockd/svcxdr.h > @@ -134,18 +134,9 @@ svcxdr_decode_owner(struct xdr_stream *xdr, struct xdr_netobj *obj) > static inline bool > svcxdr_encode_owner(struct xdr_stream *xdr, const struct xdr_netobj *obj) > { > - unsigned int quadlen = XDR_QUADLEN(obj->len); > - __be32 *p; > - > - if (xdr_stream_encode_u32(xdr, obj->len) < 0) > - return false; > - p = xdr_reserve_space(xdr, obj->len); > - if (!p) > + if (unlikely(obj->len > XDR_MAX_NETOBJ)) > return false; > - p[quadlen - 1] = 0; /* XDR pad */ > - memcpy(p, obj->data, obj->len); > - > - return true; > + return xdr_stream_encode_opaque(xdr, obj->data, obj->len) > 0; > } > > #endif /* _LOCKD_SVCXDR_H_ */ >