Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4018357ybi; Tue, 18 Jun 2019 10:17:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqy37PI4jtZCdcL292wpc4rafDFOqoq2WiWn64zfoyxOhM6oSPei2XK+nLtmrf5h+NZqtLt/ X-Received: by 2002:a65:64d5:: with SMTP id t21mr3714920pgv.310.1560878237531; Tue, 18 Jun 2019 10:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560878237; cv=none; d=google.com; s=arc-20160816; b=YVN7LJWBauR2hXMsVxH8Bvqw0BIkyiu5DzEzcjCMNReJbrHKuBRGGRBz/5lyzVOmsX puW8aRyNKuc8+cF5KuTkRYOs/WpG2K6bwmoYkagIipnMwy6YDCcmk3bLi/UkGmIM3uwx A8Db+pk98aWxeK4EfniYIkkUNXd/IiMkEyUNElDx1VDDjlF7YRduhL8M9STUEEg5PBzR 3Ttq8R6wS7quOUv/9K6ovVvehrhjRANp73SLCh1pjloDuxRDuB/uqE4SMrTVTFqMCLJW PZqBPyW7KEJ6+Ulr1ADJ7ijn80JGk0wqZ3ZbSgNtKX1mN0L58F0wjVDNYRAKiHmgQ08v 5CNQ== 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:dkim-signature; bh=5HdOkeGTOimtUzxYuQ63HUqEs40RoAuiCtdWAjPZDM0=; b=AXfGmL42d4OnyHTsa6DFaIpVa11VqOVMMEPwM+FBjIuE0qH1rCm1U2q6eoSj/sLsRE /fWMBXIOjkwdYGLpTwj/iuA5tHMVVMnxaBBk0cYvgRx1/E5rtKMbyhZpQwqA3mrVOsez jxBsrFQHFGsT3noC47F83NgdfPK47gOGUeNgRQp/ICWiLU0nm69NsGShMAeXpZWl4ZWe 3i4uIglxckR+D/N552wakjAyvhbhUvY8JXc0m2KA1Zd+VMNYrCe4L7B+xwDM6QRlin2s yS+kTkqO1zQ45foGs6wqLeMBSU3ItWdwNIsbJMAY5j6xq0v4JDUk+adhxYT8l1cQjz11 2ESA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@poorly.run header.s=google header.b=OaDtkN5H; 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 f187si13949399pfb.265.2019.06.18.10.17.01; Tue, 18 Jun 2019 10:17:17 -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; dkim=pass header.i=@poorly.run header.s=google header.b=OaDtkN5H; 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 S1730162AbfFRRQc (ORCPT + 99 others); Tue, 18 Jun 2019 13:16:32 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:43983 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729435AbfFRRQc (ORCPT ); Tue, 18 Jun 2019 13:16:32 -0400 Received: by mail-qt1-f193.google.com with SMTP id w17so9889854qto.10 for ; Tue, 18 Jun 2019 10:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=5HdOkeGTOimtUzxYuQ63HUqEs40RoAuiCtdWAjPZDM0=; b=OaDtkN5HFpjGr/oGrGRtE6pafVhMmdq/+VJSFcdz1WobXMuZUUKApbaDiA9vnXK2j3 M1ZG9xkYjtUHKnUSxIWDICD7d9IOcd3cpxqHPwMwqOnwjKwahWRc8XwbX0PJfKH98415 37Tsyp4Yhxud4rCL+Rw1GCax0qVqIuAdhttJfj9MfV0epKELmBAAIwOXbAonPiJugOsp EhKXuX5lRWnE12UtILOB1cW4SFsisYFxR1LSJ3zLUupulctUeP/CFusTIdpSZD8JLC4E dlPL2W1HH03olfJL/RXjzT2piEGtlzgdSpRKJfjApX6sjAnrlenIcMgVNTGyGbpx++rF yzsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=5HdOkeGTOimtUzxYuQ63HUqEs40RoAuiCtdWAjPZDM0=; b=CasmBIQSJa3VLxZHylyjYpKtegMdDGiCtNPR3930xUo9ypNMOmKDc6hq04it7DlPeX 9+CdkXCwf5ftM8ZUeNpufk8c0fXL7QN/SHoEC3qOfMMxumsxoli2/mbLurcokjPHXmzT whgaTrVA39RNa9Mj/dAV26iLvDuxCQxXTtd818vqFNBqrbH4EkFLMuTgv2NoMFdV3ac1 boBFT8tv6u48zvmJi7FVX3uy3iN1DfyB/BLSa4u9XyNCN6PZ2bTxaPM2KeI4cY0CdCYJ VxwutpWfVLrDTbYGu3W98prLrG0ujxgNDW+hVtSQKmR6YINj1zuJJU9ZZo0s8ZBosDdo z1Gg== X-Gm-Message-State: APjAAAWkwcA/Pot+MGhVMRIz6rMmCq2gyA1xtZ6zv5X7RWXuf4Yk3q27 muugMr/nRvrv6+CNf9/a4wQoVg== X-Received: by 2002:ac8:2bb3:: with SMTP id m48mr98945689qtm.218.1560878191074; Tue, 18 Jun 2019 10:16:31 -0700 (PDT) Received: from localhost ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id o71sm8278024qke.18.2019.06.18.10.16.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 10:16:30 -0700 (PDT) Date: Tue, 18 Jun 2019 13:16:29 -0400 From: Sean Paul To: Dan Carpenter Cc: Al Viro , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH v2] drm: return -EFAULT if copy_to_user() fails Message-ID: <20190618171629.GB25413@art_vandelay> References: <20190618125623.GA24896@mwanda> <20190618131843.GA29463@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190618131843.GA29463@mwanda> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 18, 2019 at 04:18:43PM +0300, Dan Carpenter wrote: > The copy_from_user() function returns the number of bytes remaining > to be copied but we want to return a negative error code. Otherwise > the callers treat it as a successful copy. > > Signed-off-by: Dan Carpenter Thanks Dan, I've applied this to drm-misc-fixes. Sean > --- > v2: The first version was missing a chunk > > drivers/gpu/drm/drm_bufs.c | 5 ++++- > drivers/gpu/drm/drm_ioc32.c | 5 ++++- > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c > index 68dacf8422c6..8ce9d73fab4f 100644 > --- a/drivers/gpu/drm/drm_bufs.c > +++ b/drivers/gpu/drm/drm_bufs.c > @@ -1351,7 +1351,10 @@ static int copy_one_buf(void *data, int count, struct drm_buf_entry *from) > .size = from->buf_size, > .low_mark = from->low_mark, > .high_mark = from->high_mark}; > - return copy_to_user(to, &v, offsetof(struct drm_buf_desc, flags)); > + > + if (copy_to_user(to, &v, offsetof(struct drm_buf_desc, flags))) > + return -EFAULT; > + return 0; > } > > int drm_legacy_infobufs(struct drm_device *dev, void *data, > diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c > index 586aa28024c5..a16b6dc2fa47 100644 > --- a/drivers/gpu/drm/drm_ioc32.c > +++ b/drivers/gpu/drm/drm_ioc32.c > @@ -378,7 +378,10 @@ static int copy_one_buf32(void *data, int count, struct drm_buf_entry *from) > .size = from->buf_size, > .low_mark = from->low_mark, > .high_mark = from->high_mark}; > - return copy_to_user(to + count, &v, offsetof(drm_buf_desc32_t, flags)); > + > + if (copy_to_user(to + count, &v, offsetof(drm_buf_desc32_t, flags))) > + return -EFAULT; > + return 0; > } > > static int drm_legacy_infobufs32(struct drm_device *dev, void *data, > -- > 2.20.1 > -- Sean Paul, Software Engineer, Google / Chromium OS