Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp706077yba; Thu, 18 Apr 2019 08:15:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzW2k2nblwY0JWh4qUG5b36YGBT2oEF8w9FCYn4u82M1aaufze51tKWzcOw9oYbxUmSNNU X-Received: by 2002:a63:5846:: with SMTP id i6mr6126658pgm.423.1555600551274; Thu, 18 Apr 2019 08:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555600551; cv=none; d=google.com; s=arc-20160816; b=ZB4CMbR2AZFidQr1K1ToJhFeZ8Qc9iukHTrbnAZenK4ze4daAISBte2d9FosTGQxae K2EZM2zWX3PAj60ncvzRPni5nUIkXmwqfCVAY35Lq79s8+488HJWR1Kif+X8cvmQOora OfdlFQuiBeTjJWqCPqApENIFy8FcTDzJAw9ep6LqMBNgrJR2GADy9eLJY4EBHH0bPy2i wsUmOoF++pD7ffHN4ciQvuLDyMo/v+e0OEBeido+BHTUgxv5DWVov2MD9anmnsl1A8B8 qOX5Gs/wuue7xrN455wkfT7LI9M6oUe9dJkuoz6+sVkkHnIiWyYX6rW/M5Gx1m81PR5m CUpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=Ja2XnzNSnNoq3rGy2qbSA/3XbMrlUk2CB7PPcq7e1xc=; b=JrqcbrPhTJxrHZ4HqOHo5NNrmM2pbifmuyMp1Bp3sVdXcRh1Nk9CJP87rWS6PFuova Wg4c8FOL7Bn4S+MlQwrwm/8qJS0pnEmONaH8Wx2ScyHRsYU5HYOX4u03CSl82LgE/yMK XkOUwLaIfX8dQLWWmx7ajdB5c6qOHIjN5WPZ6MhJFZnKhoz0H1FWtsLe7OjuphHa5LEB SsZGvuiIk6jUv+RLWhGel8E4Q+Ep2CSd7x1Z+ePKtLFl8OU1w+7ovZbeEys61E7VVc3o uodCpRESRBTmcs28v+04tk3q7jW0r+mA7PbNSDVW/H7GJMbPOLs1kKNtlqYAaM/gifgz YxVA== 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 c1si2419103pla.240.2019.04.18.08.15.36; Thu, 18 Apr 2019 08:15:51 -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 S2389456AbfDRPOm (ORCPT + 99 others); Thu, 18 Apr 2019 11:14:42 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:43244 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731317AbfDRPOm (ORCPT ); Thu, 18 Apr 2019 11:14:42 -0400 Received: by mail-lf1-f66.google.com with SMTP id i68so1909892lfi.10; Thu, 18 Apr 2019 08:14:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ja2XnzNSnNoq3rGy2qbSA/3XbMrlUk2CB7PPcq7e1xc=; b=s17nwBS4/9P9n0JWOXhTI+JJB34UxE5ls/JwCE16cniZy4AHvKK1vsSDXZ4pZeQJ3c 1BjRhNAW+X6TMj3mqkbs6n2FrO/JSZ/fNGOfrXGjazw8XWh1MaToUupm7iFVcPSXlkyo rHHvkobnqFIrtDU5nHeWgGzAmlr5rYy20dSOZ078Y+s82/cDPcha+ZMLBFjmJdwwBGYI kx+wXhrMAU6TvWB4xjnl/IzVFX34oPDeQPL1pGWAzTI35JUVNkdijumV4Xae8l+6taQW kPYuxMPSJOvCvri5gRWoDRaj04cdth0svzgA4AjSgz175Lty6Fxl0z/r44QKzpcMfPRk k4XQ== X-Gm-Message-State: APjAAAXWoBJ3LOvWimXextsw3TPR9hG0Wk9jRG0rGS6NmpptJuTBx1wQ kdc0hMeYRCIl3V/Q9Nrh0PMdfBDYZvMVO4tGA7Y= X-Received: by 2002:ac2:420b:: with SMTP id y11mr53081771lfh.104.1555600479501; Thu, 18 Apr 2019 08:14:39 -0700 (PDT) MIME-Version: 1.0 References: <20190416202013.4034148-1-arnd@arndb.de> <20190416202013.4034148-3-arnd@arndb.de> <20190417211303.GU2217@ZenIV.linux.org.uk> <20190417235300.GB2217@ZenIV.linux.org.uk> In-Reply-To: <20190417235300.GB2217@ZenIV.linux.org.uk> From: Arnd Bergmann Date: Thu, 18 Apr 2019 17:14:21 +0200 Message-ID: Subject: Re: [PATCH v3 02/26] compat_ioctl: move simple ppp command handling into driver To: Al Viro Cc: Linux FS-devel Mailing List , y2038 Mailman List , Linux Kernel Mailing List , Paul Mackerras , "David S. Miller" , Michal Ostrowski , Dmitry Kozlov , James Chapman , linux-ppp@vger.kernel.org, Networking Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 18, 2019 at 1:53 AM Al Viro wrote: > On Thu, Apr 18, 2019 at 12:03:07AM +0200, Arnd Bergmann wrote: > > On Wed, Apr 17, 2019 at 11:13 PM Al Viro wrote: > > > > > > On Tue, Apr 16, 2019 at 10:19:40PM +0200, Arnd Bergmann wrote: > > > > diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c > > > > index c708400fff4a..04252c3492ee 100644 _ptr(arg) to ppp_ioctl() and be done with that > > > } > > > > > > with BPF-related bits (both compat and native) taken to e.g. net/core/bpf-ppp.c, > > > picked by both generic and isdn? IDGI... > > > > I was trying to unify the native and compat code paths as much > > as possible here. Handling the four PPPIO*32 commands in > > compat_ppp_ioctl would either require duplicating large chunks > > of ppp_ioctl, or keeping the extra compat_alloc_user_space() > > copy from the existing implementation. > > > > I'll try to come up with a different way to structure the patches. > > Huh? Instead of > case PPPIOCSCOMPRESS: > err = ppp_set_compress(ppp, arg); > break; > in native, have > struct ppp_option_data data; > ... > case PPPIOCSCOMPRESS: > if (copy_from_user(&data, argp, sizeof(data))) > err = -EFAULT; > else > err = ppp_set_compress(ppp, &data); > break; Right, I ended up with something similar before I saw your message. > in native and similar in compat, with get_bpf_ppp() replaced > with call of compat_get_bpf_ppp() and ioctl numbers obviously > adjusted. All there is to it... Helpers obviously shared > with isdn and yes, all crap gone from fs/compat_ioctl.c... I would still leave the ISDN side alone, aside from adding the 64-bit time_t support. > Why would you want to duplicate large chunks of anything? > The above is not even compile-tested, but... I can put > together a patch if you wish. Or am I missing something > here? I expected that the ppp_compat_ioctl() function would end up fairly complex, to duplicate the logic before the switch()/case. What I have now is static long ppp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct ppp_file *pf; struct ppp *ppp; int err = -ENOIOCTLCMD; struct ppp_option_data32 data32; struct ppp_option_data data; void __user *argp = compat_ptr(arg); mutex_lock(&ppp_mutex); pf = file->private_data; if (!pf || pf->kind != INTERFACE) goto out; ppp = PF_TO_PPP(pf); switch (cmd) { case PPPIOCSCOMPRESS32: if (copy_from_user(&data32, argp, sizeof(data32))) { err = -EFAULT; goto out; } data.ptr = compat_ptr(data32.ptr); data.length = data32.length; data.transmit = data32.transmit; err = ppp_set_compress(ppp, &data); break; #ifdef CONFIG_PPP_FILTER case PPPIOCSPASS32: err = compat_get_sock_fprog(&uprog, argp); if (err) break; err = ppp_set_filter(ppp, &uprog, &ppp->pass_filter); break; case PPPIOCSACTIVE32: err = compat_get_sock_fprog(&uprog, argp); if (err) break; err = ppp_set_filter(ppp, &uprog, &ppp->active_filter); break; #endif /* CONFIG_PPP_FILTER */ default: break; } out: mutex_unlock(&ppp_mutex); if (err == -ENOIOCTLCMD) err = ppp_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); return err; } Which doesn't look nearly as bad as I had feared, but still is a larger change to the existing code than what I had before, so there is a bigger risk that I screwed up somewhere new. Arnd