From patchwork Wed Dec 4 20:13:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11273517 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B81B8159A for ; Wed, 4 Dec 2019 20:14:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A82E207DD for ; Wed, 4 Dec 2019 20:14:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ointL4y1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728060AbfLDUOA (ORCPT ); Wed, 4 Dec 2019 15:14:00 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:40152 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727033AbfLDUN7 (ORCPT ); Wed, 4 Dec 2019 15:13:59 -0500 Received: by mail-yw1-f67.google.com with SMTP id i126so239934ywe.7 for ; Wed, 04 Dec 2019 12:13:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rRaJqBMw2JaW2HjFrmxgGVunQOxyxkDl+7LN3gRpOHI=; b=ointL4y1KsYc/kePdaCgPTA6kC73zJZiys40A3EMgatjCxTq4ofOUQqSmSkGGCcC2/ J4TxLTTpPL0k5acDZHb/H+nkh9G14nlR7i4gvbiJcam1y2JPHfvdPXHkZlHkik5f+ear zStYyrWzL1k/VN7wLGobRaY+SuXSQ2jDGySDkgiYBwhPgIg0cSjbMYdbpgZIkmJPny69 SIWREIENLdqqg8SIaV0gZZq+N2DBrrtzxGJOUKIDT1R9veJPBBbp7D/CsR5Pl6lq5xwq 5u9prj/Q96V6Jf66LzjhePBPE8NrdFbeDqpN4/P/Gwah6r+ykjJrr4/Cw1Ga2Dmu1fse ryRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rRaJqBMw2JaW2HjFrmxgGVunQOxyxkDl+7LN3gRpOHI=; b=Mf5HO9k58VfTp2bZyYewxiINgwlfr+/7wCyN6pgFxufe9TemTr9m0H/5R7m2e6VN9W Bt+E5b54L4gMg+W+rcVBa+H8cvte1ydpGAO+7bZLazyD+n4h8iacmkk9fiOwZ+JdN44i fN2+vZaln9ayGgPebK6SIdFJ/vBiYuAXg2quGd4Sb0KMvh5zg+MfdN3d/L+y2swRuHQL m+UkLh3VwNB0XOpJbFQF6xVm4yi6v070DuxQdYREKzhmkRlye0efrPpwxWs6a1NC63Oh WMIJZ5toJsko+gTrzdDJQa4rzo6UTIAcGa7ofcnljSrTGGsU3Bhe1KXx1isv7chI6pRe z2jg== X-Gm-Message-State: APjAAAWKbopLl1uvqnr06iI6cCYSQts9fHtfVJx/DCJN43GaRSfyvbR2 5J2/NQRJsGGe710XM8mLs/ia5yMz X-Google-Smtp-Source: APXvYqycMmq3BlwfHRpLnwW0oJR1mAdtZ6itCPmkSxq76cVN++MNQhWjRaSIp2zkbDXrBiLfwhMX3A== X-Received: by 2002:a81:9301:: with SMTP id k1mr3306238ywg.143.1575490438848; Wed, 04 Dec 2019 12:13:58 -0800 (PST) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id o69sm3496446ywd.38.2019.12.04.12.13.57 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 04 Dec 2019 12:13:58 -0800 (PST) From: Olga Kornievskaia To: bfields@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/3] NFSD fix mismatching type in nfsd4_set_netaddr Date: Wed, 4 Dec 2019 15:13:52 -0500 Message-Id: <20191204201354.17557-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20191204201354.17557-1-olga.kornievskaia@gmail.com> References: <20191204201354.17557-1-olga.kornievskaia@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Fix __be32 and u32 mismatch in return and assignment. Reported-by: kbuild test robot Fixes: dbd4c2dd8f13 ("NFSD add COPY_NOTIFY operation") Signed-off-by: Olga Kornievskaia --- fs/nfsd/nfsd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 0ff6ef9..c679afd 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -388,7 +388,7 @@ static inline bool nfsd4_spo_must_allow(struct svc_rqst *rqstp) extern const u32 nfsd_suppattrs[3][3]; -static inline u32 nfsd4_set_netaddr(struct sockaddr *addr, +static inline __be32 nfsd4_set_netaddr(struct sockaddr *addr, struct nfs42_netaddr *netaddr) { struct sockaddr_in *sin = (struct sockaddr_in *)addr; From patchwork Wed Dec 4 20:13:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11273519 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 172CB138C for ; Wed, 4 Dec 2019 20:14:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E951B20803 for ; Wed, 4 Dec 2019 20:14:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CGHtzPh6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728031AbfLDUOB (ORCPT ); Wed, 4 Dec 2019 15:14:01 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:33370 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727033AbfLDUOB (ORCPT ); Wed, 4 Dec 2019 15:14:01 -0500 Received: by mail-yw1-f68.google.com with SMTP id 192so265986ywy.0 for ; Wed, 04 Dec 2019 12:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3Mpgs98QEWEfBR0zDtL1zQxUobXF+5kk2R/iSUk7+KU=; b=CGHtzPh6vroJ7cYO9k+jY22pCngjZyw+owcv8idd7weey0DAsiKms0ahomBpEHZF6t jWzfBsl6c+JBDlX0wnbmUFoJEfTU3Ri4ZBGjuwdxajhnPLEU3mFWknN4JYVx0ow3jo71 eNdiXq76slh3y5S9BTNrjp+t4oRRmBRojFQRV13b1koibkoDpaHtCdOf56erOMIL9iRc A2EO17QJowjZ/v12BJSVXGPrxlTvcXG5CBGNXgl5Z6tkUVS1U0VyAFYsJxEOxESXuQZh b8knRAEqIUmHTwh0k1JF23CWt+Nx3So0+SH7VSc/SizuFK+yMRaDSdixXaKNIn5K+64y v7fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3Mpgs98QEWEfBR0zDtL1zQxUobXF+5kk2R/iSUk7+KU=; b=dfuVexd8j43GBlOcEaTkyhb83c85DVzO4VfFd1RJoPtfA21irHIaVad9qVlkpP6ziV y732CQXgAqwErE2JIdehPoOPpRKCruWXbGU2JLa7tlDtQecBmgIsTlIPfk6lHWENR3HQ uyEOSG3TWNJHhsOhsc57Fa/yGnozU/puN3PQb7o+XsGU+vyGR//zVeMNzA/9amEc9kUC 4aUW9rAfL9bi3ba9IZLDcw0hxAnkWDXtnTs2PNuFF+qg+ODP438LMGarhrpE8sZ0HyZ3 EzQ7kbgqEV9dMVtXIs4X7grGInDiLd63pkpGtD8/m9lRTS/CoyyUs8n8NTf/figkwgp3 /THg== X-Gm-Message-State: APjAAAXE4Ah1XLsqSudFZyFTF9zLntTaXGOZnY0JDngYexreJtItCkzn IeyMtr4DDC+d+DUdY0XYFCs= X-Google-Smtp-Source: APXvYqyV3MkUNNW8/IeN6rW6CfIdqiRYjtpS26Fuf3NvJ/QUfCApeAsz9+8lFCfx2/Ls1I5sYt77Jw== X-Received: by 2002:a81:18c5:: with SMTP id 188mr3275228ywy.258.1575490440107; Wed, 04 Dec 2019 12:14:00 -0800 (PST) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id o69sm3496446ywd.38.2019.12.04.12.13.59 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 04 Dec 2019 12:13:59 -0800 (PST) From: Olga Kornievskaia To: bfields@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/3] NFSD fix nfserro errno mismatch Date: Wed, 4 Dec 2019 15:13:53 -0500 Message-Id: <20191204201354.17557-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20191204201354.17557-1-olga.kornievskaia@gmail.com> References: <20191204201354.17557-1-olga.kornievskaia@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org There is mismatch between __be32 and u32 in nfserr and errno. Reported-by: kbuild test robot Fixes: d5e54eeb0e3d ("NFSD add nfs4 inter ssc to nfsd4_copy") Signed-off-by: Olga Kornievskaia --- fs/nfsd/nfs4proc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index ec4f79c8..187cef6 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1169,7 +1169,8 @@ extern struct file *nfs42_ssc_open(struct vfsmount *ss_mnt, size_t tmp_addrlen, match_netid_len = 3; char *startsep = "", *endsep = "", *match_netid = "tcp"; char *ipaddr, *dev_name, *raw_data; - int len, raw_len, status = -EINVAL; + int len, raw_len; + __be32 status = nfserr_inval; naddr = &nss->u.nl4_addr; tmp_addrlen = rpc_uaddr2sockaddr(SVC_NET(rqstp), naddr->addr, @@ -1207,7 +1208,7 @@ extern struct file *nfs42_ssc_open(struct vfsmount *ss_mnt, snprintf(raw_data, raw_len, NFSD42_INTERSSC_MOUNTOPS, ipaddr); - status = -ENODEV; + status = nfserr_nodev; type = get_fs_type("nfs"); if (!type) goto out_free_rawdata; @@ -1253,8 +1254,6 @@ extern struct file *nfs42_ssc_open(struct vfsmount *ss_mnt, * Called with COPY cstate: * SAVED_FH: source filehandle * CURRENT_FH: destination filehandle - * - * Returns errno (not nfserrxxx) */ static __be32 nfsd4_setup_inter_ssc(struct svc_rqst *rqstp, @@ -1263,7 +1262,7 @@ extern struct file *nfs42_ssc_open(struct vfsmount *ss_mnt, { struct svc_fh *s_fh = NULL; stateid_t *s_stid = ©->cp_src_stateid; - __be32 status = -EINVAL; + __be32 status = nfserr_inval; /* Verify the destination stateid and set dst struct file*/ status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, @@ -1280,7 +1279,7 @@ extern struct file *nfs42_ssc_open(struct vfsmount *ss_mnt, copy->c_fh.size = s_fh->fh_handle.fh_size; memcpy(copy->c_fh.data, &s_fh->fh_handle.fh_base, copy->c_fh.size); - copy->stateid.seqid = s_stid->si_generation; + copy->stateid.seqid = cpu_to_be32(s_stid->si_generation); memcpy(copy->stateid.other, (void *)&s_stid->si_opaque, sizeof(stateid_opaque_t)); @@ -1308,7 +1307,7 @@ extern struct file *nfs42_ssc_open(struct vfsmount *ss_mnt, struct vfsmount **mount) { *mount = NULL; - return -EINVAL; + return nfserr_inval; } static void From patchwork Wed Dec 4 20:13:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11273521 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 32623159A for ; Wed, 4 Dec 2019 20:14:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1048920803 for ; Wed, 4 Dec 2019 20:14:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O6wRL5TV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728068AbfLDUOC (ORCPT ); Wed, 4 Dec 2019 15:14:02 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:34839 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727033AbfLDUOC (ORCPT ); Wed, 4 Dec 2019 15:14:02 -0500 Received: by mail-yw1-f68.google.com with SMTP id i190so258504ywc.2 for ; Wed, 04 Dec 2019 12:14:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mEvf+peCGVw75eQ2JbDVrUErRePsnis5N3Fg/DZCN7A=; b=O6wRL5TVgKQEYbF95MvAIDCu2s6OmxHTLzfKfvqi4ZrWeuKF/1Lqk1drczZFqADVLP kEPQxcHpB3mb8OzULlIW1557lpS7L2WRL++v+pPxCBGB/CgrdHBbZUWyjNYWZwERCTKd /9CcO3kfDZ4CeaKiDbwpqOIm/pqnRQU6mYILASWV5fu0hlBKsMV3pPt+ahchGfRmshFJ j9BC0JqeEDb2ZXiPPOIqlNqCrRL3cWdXywIsO+GrABztvXz3IJT7ne0s44tEyO9PfSfp uRlI74r/TKA2Fl6IoDvzGtGBqT+xkspMARSZ209L+OPBHLotHHxgYgIsfq6V20rcQub0 /2uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mEvf+peCGVw75eQ2JbDVrUErRePsnis5N3Fg/DZCN7A=; b=lp/DFHZfRnW7ECNg+nMd/TdQ9GsxzjANkDd7x/wderfU9zQhxkiNQ2qer/0dPmMoLy q9Qxbnv/V7CYwfF2DyddrcXqY+SRkY53dSWzUdEX7E2jUQV52tkfaThalUub1ocpL702 z93Ec0mrziKSaSghxmtUD3oT9pcTbrkSe2HuyWqqQJ/WzUQa2Os5vGlJh4Znl+FUepFW fWfDKK9duccgduwui0jMR4tOEsYmUcMgRpGvabXeY/pjyhdslTwZgz15ZQzpMTfSkT97 ZqbInXZZ7vWtsYSD/orWRCeGxtQwowjCX3D1mNSkd9qEAouekRsMq0VCsyu2jdfdZtvv 7F/Q== X-Gm-Message-State: APjAAAVUMoV+tXYhecwjbZ/4WyWBNXri1tgfKzbL7a/ZwojlRUUdT2h2 gvjVDj/jjEIs3VZNUUu/2ykzGqqm X-Google-Smtp-Source: APXvYqxQ0LhbD+ttdHVCwb2hOP9wSGAVSACZX+Z2/ZKWTLaAWvgE+ytUbiOFgD8cVszLIfkvLXHiGA== X-Received: by 2002:a0d:d516:: with SMTP id x22mr3477924ywd.257.1575490441371; Wed, 04 Dec 2019 12:14:01 -0800 (PST) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id o69sm3496446ywd.38.2019.12.04.12.14.00 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 04 Dec 2019 12:14:00 -0800 (PST) From: Olga Kornievskaia To: bfields@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 3/3] NFSD fixing possible null pointer derefering in copy offload Date: Wed, 4 Dec 2019 15:13:54 -0500 Message-Id: <20191204201354.17557-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20191204201354.17557-1-olga.kornievskaia@gmail.com> References: <20191204201354.17557-1-olga.kornievskaia@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Static checker revealed possible error path leading to possible NULL pointer dereferencing. Reported-by: Dan Carpenter Fixes: e0639dc5805a: ("NFSD introduce async copy feature") Signed-off-by: Olga Kornievskaia --- fs/nfsd/nfs4proc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 187cef6..d33c39c 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1446,7 +1446,8 @@ static void cleanup_async_copy(struct nfsd4_copy *copy) { nfs4_free_copy_state(copy); nfsd_file_put(copy->nf_dst); - nfsd_file_put(copy->nf_src); + if (copy->cp_intra) + nfsd_file_put(copy->nf_src); spin_lock(©->cp_clp->async_lock); list_del(©->copies); spin_unlock(©->cp_clp->async_lock); @@ -1551,7 +1552,8 @@ static int nfsd4_do_async_copy(void *data) out: return status; out_err: - cleanup_async_copy(async_copy); + if (async_copy) + cleanup_async_copy(async_copy); status = nfserrno(-ENOMEM); if (!copy->cp_intra) nfsd4_interssc_disconnect(copy->ss_mnt);