From patchwork Thu Jun 26 19:11:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4430191 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 38DBA9F402 for ; Thu, 26 Jun 2014 19:14:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65DBC201BB for ; Thu, 26 Jun 2014 19:13:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 928642024D for ; Thu, 26 Jun 2014 19:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751377AbaFZTN5 (ORCPT ); Thu, 26 Jun 2014 15:13:57 -0400 Received: from mail-qc0-f182.google.com ([209.85.216.182]:53362 "EHLO mail-qc0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750832AbaFZTN5 (ORCPT ); Thu, 26 Jun 2014 15:13:57 -0400 Received: by mail-qc0-f182.google.com with SMTP id m20so3516145qcx.41 for ; Thu, 26 Jun 2014 12:13:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=rvNy2QqLPVvRZgU58FNkkbLz2rs0nCEUn/2tnh910D0=; b=DUQXV82FXS4awfhiqzOopzbmGymymuiZ+FqcaOhCPZWG0n/6SHFEGej7ypu9bhlRsK aHVCzoBJIKmaHhkyxHmXG7Fq4+1bm035irbBFg0nr2FR8DewMoHrHcTvUNXcuBrugpkJ +BXh7yx9snjYPVTuK+O89vNmBi05XFc6Qlff5JffJka8edzuQ5BP7LIkDS5NsOO0Isd9 tefqUCmtq/69zFdhMwLIyAqpUECRBGJJ//SMNIo94DHhEhJDRBJMYT1fE6t7prRC75ub wEuzcJurTLfG7i4/FvBOUo5BhFBqsziFGEJAc66+68vXXS6toTqqCDrHzjP0NX3KcpjX bFcQ== X-Gm-Message-State: ALoCoQmtTytKVNDMXdkWArMFfHUF+TdnH2ngujzWBMu9WDQit8Q7Yw2pVbRv0t0YnLibI4s0Ujr4 X-Received: by 10.140.23.134 with SMTP id 6mr24694167qgp.84.1403810036666; Thu, 26 Jun 2014 12:13:56 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id 88sm4763039qgh.5.2014.06.26.12.13.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jun 2014 12:13:55 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 007/117] nfsd: properly handle embedded newlines in fault_injection input Date: Thu, 26 Jun 2014 15:11:47 -0400 Message-Id: <1403810017-16062-8-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403810017-16062-1-git-send-email-jlayton@primarydata.com> References: <1403810017-16062-1-git-send-email-jlayton@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently rpc_pton() fails to handle the case where you echo an address into the file, as it barfs on the newline. Ensure that we NULL out the first occurrence of any newline. Signed-off-by: Jeff Layton Reviewed-by: Christoph Hellwig --- fs/nfsd/fault_inject.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c index 2ed05c3cd43d..f1333fc35b33 100644 --- a/fs/nfsd/fault_inject.c +++ b/fs/nfsd/fault_inject.c @@ -115,11 +115,19 @@ static ssize_t fault_inject_write(struct file *file, const char __user *buf, struct net *net = current->nsproxy->net_ns; struct sockaddr_storage sa; u64 val; + char *nl; if (copy_from_user(write_buf, buf, size)) return -EFAULT; write_buf[size] = '\0'; + /* Deal with any embedded newlines in the string */ + nl = strchr(write_buf, '\n'); + if (nl) { + size = nl - write_buf; + *nl = '\0'; + } + size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa)); if (size > 0) nfsd_inject_set_client(file_inode(file)->i_private, &sa, size);