Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1669779imm; Wed, 1 Aug 2018 22:00:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfM70p4MDWanB3mbmDs1VuyB0cG+oaJm8B2zNX6h44+lNTNOxCv3rGjNgPovx3sDTLML6GE X-Received: by 2002:a65:58c8:: with SMTP id e8-v6mr1207324pgu.96.1533186044156; Wed, 01 Aug 2018 22:00:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533186044; cv=none; d=google.com; s=arc-20160816; b=ExDgiCgylGQItmsvUPYFHH9EgQZi6vA0AWVob3OlEmgEwCIFS5RaeLiG8a9rEK4cM9 hpUyqvdwyVlYSsQcq4T5u0jTOVKljePuf3ii2XDKTyr+TIjGY86ctoUkQx0voPPBc2kj KPqvVJWEKqK9PZYaUwGeu4VwtJbxDEWC07mtRFl12sLPosOlAbvz5kZYdolsqCUxhfw6 sRdv8ItrVDxIeGQF2/Fxq8KWZGggE13GgToonN0dkp0Dw4z3b9fC+WtdCKkBycxNG8Qs zoBnYtkJhvfgUEWhSfH7RC+X5Ee3a/0d17a6Js8O9Mv7v0vrnPH7lv4UjBbS+/qRQ+nv 5Zdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=L6LlUGZEsLl+bZS+Ynb7BKlcbbHPj7DppLL/novD/lw=; b=G8/Ml1jl6Fbex68bFKpmO7Tg85nsM8n02bEmpxlVUYqRenDDs0PT8pSGEQ87LOsyd9 QAvZFB1bNkpCrqZPZSVlDPMy+j3IfDsc2EEJyLW9J7EZ+dHPS3VjCJig1DqfUOqznHNo 5MVT89CaYCu6r1fsMeNdABXadULd/3fcQ2/EhhSAUvrkWWJdO0V29I57PjzgG/SqVLl1 GkZfhEXPIpOjBrb3e4+r07a0YupJM7ffbYXQLpPy9/gNSSPSRc3P2++ipQ5C3M2uNTMf tX8GSpqbUdcDManY252aMo778Ud2wzQn8/fd3ikzsqJbyTTqUmVSGgqAB0VSR2i52a0n 9oOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i18-v6si1062610pgk.595.2018.08.01.22.00.29; Wed, 01 Aug 2018 22:00:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727362AbeHBGsZ (ORCPT + 99 others); Thu, 2 Aug 2018 02:48:25 -0400 Received: from nautica.notk.org ([91.121.71.147]:50752 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727223AbeHBGsZ (ORCPT ); Thu, 2 Aug 2018 02:48:25 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id BF190C009; Thu, 2 Aug 2018 06:59:06 +0200 (CEST) Date: Thu, 2 Aug 2018 06:58:51 +0200 From: Dominique Martinet To: v9fs-developer@lists.sourceforge.net Cc: Dominique Martinet , linux-kernel@vger.kernel.org, Matthew Wilcox , Greg Kurz , linux-fsdevel@vger.kernel.org Subject: Re: [V9fs-developer] [PATCH v2 2/2] net/9p: add a per-client fcall kmem_cache Message-ID: <20180802045851.GA15564@nautica> References: <1532943263-24378-1-git-send-email-asmadeus@codewreck.org> <1533177452-2165-1-git-send-email-asmadeus@codewreck.org> <1533177452-2165-2-git-send-email-asmadeus@codewreck.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1533177452-2165-2-git-send-email-asmadeus@codewreck.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dominique Martinet wrote on Thu, Aug 02, 2018: > [...] > + clnt->fcall_cache = kmem_cache_create("9p-fcall-cache", clnt->msize, > + 0, 0, NULL); Well, my gut feeling that I'd need a v3 was right, after a bit more time testing (slightly different setup), I got this warning: Bad or missing usercopy whitelist? Kernel memory overwrite attempt detected to SLUB object '9p-fcall-cache' (offset 23, size 55078)! So this kmem_cache_create needs to change to kmem_cache_create_usercopy, but I'm not sure how to best specify the range -- this warning was about writing data to the buffer so a TWRITE: size[4] Twrite tag[2] fid[4] offset[8] count[4] data[count] (the data[count] part comes from user - this matches 4+1+2+4+8+4 = 23) Similarily RREAD has data that can be copied to userspace, which has a similar check: size[4] Rread tag[2] count[4] data[count] So I could hardcode offset = 4+1+2+4=11, usercopy size = msize - 11... We have some P9_*HDR*SZ macros but none are really appropriate: --- /* ample room for Twrite/Rread header */ #define P9_IOHDRSZ 24 /* Room for readdir header */ #define P9_READDIRHDRSZ 24 /* size of header for zero copy read/write */ #define P9_ZC_HDR_SZ 4096 --- It's actually been bugging me for a while that I see hardcoded '7's for 9p main header size (len + msg type + tag) everywhere, I could add a first P9_HDRSZ of 7 and use that + 4? -- Dominique