From owner-freebsd-hackers@freebsd.org Fri Jul 29 16:49:59 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 78045BA7C33 for ; Fri, 29 Jul 2016 16:49:59 +0000 (UTC) (envelope-from starak.adam@gmail.com) Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0C9FF1362; Fri, 29 Jul 2016 16:49:59 +0000 (UTC) (envelope-from starak.adam@gmail.com) Received: by mail-wm0-x22f.google.com with SMTP id o80so160228737wme.1; Fri, 29 Jul 2016 09:49:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=3z0pheZ5eF0z69R6nqVkcCcFIybTg2iPwIqax6JFmNc=; b=Yq8X1M7KbY33dGT3GztS1KnwGJYQC2HYRNBiYMSaMqlZO4IPdu7Lmm7P670gvEy/XG fMezxgWIXUDYB/VUn6IVwKLFurdZdLRyTVEaJc5YYb2KLRqbEw5X5c03xGRhoi/hQNbv wTBeVYlYvDQP7KXikApNpNfKJbj2lhlTBEH9mpVNi7Ts7Hq66KuVeGFW9e+qGZu/se2n cwcrhN2iZ3+hhRFRJOrlm5E8uvCFAUml+cgc7Id2BWa6TDkbA1luwnaN4tQSqJ6gUG6W tDXALU7iAx8Ul17k1OtDAM203AQFMhf5Y9pa8br4A+lZAQ8QKSc3zSqF8lQZFpoVswil 0Gww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=3z0pheZ5eF0z69R6nqVkcCcFIybTg2iPwIqax6JFmNc=; b=grMzgoy94P7z5AmeDVWKP5vm/fwIyf/c/lt4ynfDS0quhN2i0CXD/3xjuk9AvvezZh bSDFcFqadt3NP9les2OWvF3lX+Dnp4xPAvJPoYJOnjIZ3w++fEs69S7FJOseS0fPtG13 XiQy3MYaKjkJCLI8jvfyw7JLwDtyxKuwXi+zaCQQQNPeXpMYqbZaRNQsf8E3QAK6Qh6q bNLH4/I7rCt7VugSBGuTPQICxoyB2SLk8h4Hsz1T6JOFnKxTN2+j25pDnQGt2xbzBXL0 +g2hC6bDrRFqX/zEHrbiX81/z0fqmJjiSGdHZbch/9+TRmzFZ/96TsWUoXrDSVgq6EFX xA9w== X-Gm-Message-State: AEkoouuRvd04GmQ3RcGFSWli6Sk3kPC4g99QwTlY5YbrV/rBMdTuRIDWpOZEbNmluR+Nsg== X-Received: by 10.28.100.70 with SMTP id y67mr2078845wmb.23.1469810997055; Fri, 29 Jul 2016 09:49:57 -0700 (PDT) Received: from [100.84.96.220] (188.146.71.199.nat.umts.dynamic.t-mobile.pl. [188.146.71.199]) by smtp.gmail.com with ESMTPSA id q187sm3845498wma.17.2016.07.29.09.49.55 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jul 2016 09:49:56 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: Modify user space from kernel. From: Adam Starak X-Mailer: iPhone Mail (13G34) In-Reply-To: Date: Fri, 29 Jul 2016 18:49:55 +0200 Cc: FreeBSD Hackers Content-Transfer-Encoding: quoted-printable Message-Id: <00058592-A469-440C-884E-5C057DAE2AB6@gmail.com> References: To: cem@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jul 2016 16:49:59 -0000 My project is focused on nvlist. I'm improving and expanding its usage. Nvli= st can be used in userland as well as in kernel. My goal is to establish com= munications between them via nvlist. That's why setting a fixed size or loop= ing doesn't satisfy me. It'll be some kind of IPC, not only for sysctl ofc.=20= Best regards, Adam Starak Dnia 29.07.2016 o godz. 18:05 Conrad Meyer napisa=C5=82(a)= : >> On Fri, Jul 29, 2016 at 6:11 AM, Adam Starak wrot= e: >> Hello! >>=20 >> My name is Adam. I participate in Google Summer of Code this year. I came= >> up with a big problem, which doesn't allow me to go further in my project= . >>=20 >> I made a new syscall, which is going to retrieve sysctl data and put it >> inside the nvlist. And here my problem is. I need to move somehow this da= ta >> (packed nvlist) into the user space. Is there any chance to pass data fro= m >> kernel to user space without knowing the size of it? >>=20 >> Right now, the implementation of __sysctl() function requests void pointe= r >> and size in order to get data. If allocated memory is too low, it returns= >> ENOMEM and you need to realloc the data. I wanted to avoid this situation= . >=20 > Hey Adam, >=20 > That is the usual way to do it. Just curious =E2=80=94 why do you want to= > avoid that situation? >=20 > Your other option might be to put an upper limit on the size of the > result, and pass a buffer of that size in from userspace. But then > you are artificially limited to some arbitrary size and must > preallocate a large buffer even in the case that the output is small. >=20 > Best, > Conrad