Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1717199ybg; Sat, 19 Oct 2019 01:00:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeaP0egq5ahvURgGmagh4vrkMQAjMHs2HJM6yalzjvPlj3/WkO6SVtwcUfhg6JzB0jva7M X-Received: by 2002:a50:ace1:: with SMTP id x88mr14092752edc.132.1571472015152; Sat, 19 Oct 2019 01:00:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571472015; cv=none; d=google.com; s=arc-20160816; b=q+nT8KxOLE5blSgcjyzHzNqHvdCtgVYcK7MafWf1MPP9sz8A24owTnCuHKfVL1G+Vy WqTQ2fBd/jHPdakQcC3QxsqafbAbZmSkeSqGSuNjKByIDLvyJho8Uo8hm1BGBTpMYUSa yBYQdrtfRci4me4RQ+KjiQkO/dInBJqFL/zn5qXuQeBehPoziM4KVB1U+gmZb6MS9lYj N6OR9HsjcW6yFsKVcOUUjzhw0ATYs1aGFprr9rhuAhZ8uqRQ4QxwnZiCqBfi04Q1nbG1 URRxhbFPalwUbm0htfEwNXGkThLcUeKIDtH9TvgrbdWL+vnYF2nqa0SKCJqy2JokGgi6 05/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=M3S4yTtVgaNC9BkQRuSaEuAlwVVJJ6jYNkihyhEpRi8=; b=wrLRUUkS0frk+RNnkwIdAj7A0In7DNs7Zbojn/Xnx6ev6YiRSwOdxGk7LLZSTl76NM f74Zi7EBXT5dsiLJHzg2fWU78D8ksVEfku5K4+Xn1YVhTE3gFD+0vJODAaoROgNxofVb 8bO5HkyIWVgLMcOdCyfN816xJoHINwhKtVZuHYR99E4U+B1Y1MnpD6ryZpBh4SaJO2wK lJ+oBsGuyIdPNvfM+XTC7hR3McUwZobwfT3sIGlod6dHmZii+HtHh14RmH6hnQIqWTRJ RA9C+XwaR3nzuSslombGasZBR27cPEQPJiIbXDRoAPRutVTsxY2tAZJgXdz3kGg4ymYd 1YGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=idopb+em; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si4970880edv.182.2019.10.19.00.59.51; Sat, 19 Oct 2019 01:00:15 -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=fail header.i=@gmail.com header.s=20161025 header.b=idopb+em; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2442185AbfJRIQD (ORCPT + 99 others); Fri, 18 Oct 2019 04:16:03 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44371 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731008AbfJRIQC (ORCPT ); Fri, 18 Oct 2019 04:16:02 -0400 Received: by mail-pl1-f196.google.com with SMTP id q15so2471812pll.11; Fri, 18 Oct 2019 01:16:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=M3S4yTtVgaNC9BkQRuSaEuAlwVVJJ6jYNkihyhEpRi8=; b=idopb+em4RetH9GiUvFvJK761YLj4h6/AlCEqA6bzDqYMWGLNUahqbQH6A69wIQsDT hGUNY4MnXEekB51MQ8sI59BW/kyjexIGJ27cjEtI5itCrGT05nVYV1OaFaEroBFeGMaG eJ22SaHega6SqNDS+lIcWSOr1k5ibLmeJaJgDUIVnz2whel16FRvcsc3ELS39qvMbq4t MR6mf+Egztb99o9k/MJeOkKYfNR/6m2xs+Lk93ZwnZ8ivpWphIuUT6XJoRLZGrCQjR/2 2KJ7MUOXFIZHIi0TTCDKvTHAniMnSSF061ZM/nRfh5OLP1gEuyhNu6XRAt129699POlC qQ1w== 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:mime-version :content-transfer-encoding; bh=M3S4yTtVgaNC9BkQRuSaEuAlwVVJJ6jYNkihyhEpRi8=; b=NKpuxb/t14ngqbPUwZUUxiu0AXo7xLpDVOQLJ5WHN7ml0FcoZWDetjifI9V1xJ/4po /0KGV5Vf90WvFJ55ueFE/hWmEYgcCzyV8t8Pdo+ytVlu1KG1A/ylDwn+IV4Gn3hzAZjE r9LeuMm4+DMwASGlUDgCoXuM6SLkeZhyJV77BUkuk+KqvIcTaN7oF1/7D4D459Dw1U+s 2Ec4rgBUSAQzoD9rqG22E3jLFEpibGZdNVufRiSdhRP8hix1cP6rTzbilp5KK996jdrD DiVHlLXhY8tLntnMBnnU0Woh2khNCTi/6i8LBMb954rwaRfuwg5JzpiMIu9JjSLkzUBM PY+w== X-Gm-Message-State: APjAAAVdkhABs725Hn2+3XkiGrGOXb9DPKWCMHvqhwoc2M2tiTWYNXTH 6aEcyrmCyjq3+izxw49qaw7/EOEc6NQ= X-Received: by 2002:a17:902:bc41:: with SMTP id t1mr8649031plz.34.1571386561943; Fri, 18 Oct 2019 01:16:01 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id e10sm7216574pfh.77.2019.10.18.01.15.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2019 01:16:01 -0700 (PDT) From: Chuhong Yuan Cc: Doug Ledford , Jason Gunthorpe , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH] IB/uverbs: Add a check for uverbs_attr_get Date: Fri, 18 Oct 2019 16:15:34 +0800 Message-Id: <20191018081533.8544-1-hslester96@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Only uverbs_copy_to_struct_or_zero in uverbs_ioctl.c does not have a check for uverbs_attr_get. Although its usage in uverbs_response has a check for attr's validity, UVERBS_HANDLER does not. Therefore, it is better to add a check like other functions in uverbs_ioctl.c. Signed-off-by: Chuhong Yuan --- drivers/infiniband/core/uverbs_ioctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/core/uverbs_ioctl.c b/drivers/infiniband/core/uverbs_ioctl.c index 61758201d9b2..269938f59d3f 100644 --- a/drivers/infiniband/core/uverbs_ioctl.c +++ b/drivers/infiniband/core/uverbs_ioctl.c @@ -795,6 +795,9 @@ int uverbs_copy_to_struct_or_zero(const struct uverbs_attr_bundle *bundle, { const struct uverbs_attr *attr = uverbs_attr_get(bundle, idx); + if (IS_ERR(attr)) + return PTR_ERR(attr); + if (size < attr->ptr_attr.len) { if (clear_user(u64_to_user_ptr(attr->ptr_attr.data) + size, attr->ptr_attr.len - size)) -- 2.20.1