mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Security: Replace dac_mmap_min_addr to mmap_min_addr in cap_file_mmap()
@ 2010-04-14  2:48 wzt.wzt
  2010-04-14  3:02 ` Eric Paris
  0 siblings, 1 reply; 4+ messages in thread
From: wzt.wzt @ 2010-04-14  2:48 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-security-module, jmorris

cap_file_mmap() comments said "If the process is attempting to map 
memory below mmap_min_addr", if CONFIG_LSM_MMAP_MIN_ADDR is set, 
dac_mmap_min_addr is not equal mmap_min_addr, so replace dac_mmap_min_addr
to mmap_min_addr seems to be better.

Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>

---
 include/linux/security.h |    1 +
 security/commoncap.c     |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/linux/security.h b/include/linux/security.h
index 233d20b..61fd9e7 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -101,6 +101,7 @@ void reset_security_ops(void);
 extern unsigned long mmap_min_addr;
 extern unsigned long dac_mmap_min_addr;
 #else
+#define mmap_min_addr		0UL
 #define dac_mmap_min_addr	0UL
 #endif
 
diff --git a/security/commoncap.c b/security/commoncap.c
index 6166973..878cf89 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -942,7 +942,7 @@ int cap_file_mmap(struct file *file, unsigned long reqprot,
 {
 	int ret = 0;
 
-	if (addr < dac_mmap_min_addr) {
+	if (addr < mmap_min_addr) {
 		ret = cap_capable(current, current_cred(), CAP_SYS_RAWIO,
 				  SECURITY_CAP_AUDIT);
 		/* set PF_SUPERPRIV if it turns out we allow the low mmap */
-- 
1.6.5.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Security: Replace dac_mmap_min_addr to mmap_min_addr in  cap_file_mmap()
  2010-04-14  2:48 Security: Replace dac_mmap_min_addr to mmap_min_addr in cap_file_mmap() wzt.wzt
@ 2010-04-14  3:02 ` Eric Paris
  2010-04-14  5:50   ` wzt wzt
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Paris @ 2010-04-14  3:02 UTC (permalink / raw)
  To: wzt.wzt; +Cc: linux-kernel, linux-security-module, jmorris

NAK NAK NAK

go back and reread the whole purpose for the separation.

-Eric

On Tue, Apr 13, 2010 at 10:48 PM,  <wzt.wzt@gmail.com> wrote:
> cap_file_mmap() comments said "If the process is attempting to map
> memory below mmap_min_addr", if CONFIG_LSM_MMAP_MIN_ADDR is set,
> dac_mmap_min_addr is not equal mmap_min_addr, so replace dac_mmap_min_addr
> to mmap_min_addr seems to be better.
>
> Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
>
> ---
>  include/linux/security.h |    1 +
>  security/commoncap.c     |    2 +-
>  2 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/security.h b/include/linux/security.h
> index 233d20b..61fd9e7 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -101,6 +101,7 @@ void reset_security_ops(void);
>  extern unsigned long mmap_min_addr;
>  extern unsigned long dac_mmap_min_addr;
>  #else
> +#define mmap_min_addr          0UL
>  #define dac_mmap_min_addr      0UL
>  #endif
>
> diff --git a/security/commoncap.c b/security/commoncap.c
> index 6166973..878cf89 100644
> --- a/security/commoncap.c
> +++ b/security/commoncap.c
> @@ -942,7 +942,7 @@ int cap_file_mmap(struct file *file, unsigned long reqprot,
>  {
>        int ret = 0;
>
> -       if (addr < dac_mmap_min_addr) {
> +       if (addr < mmap_min_addr) {
>                ret = cap_capable(current, current_cred(), CAP_SYS_RAWIO,
>                                  SECURITY_CAP_AUDIT);
>                /* set PF_SUPERPRIV if it turns out we allow the low mmap */
> --
> 1.6.5.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Security: Replace dac_mmap_min_addr to mmap_min_addr in  cap_file_mmap()
  2010-04-14  3:02 ` Eric Paris
@ 2010-04-14  5:50   ` wzt wzt
  2010-04-14  7:35     ` Amerigo Wang
  0 siblings, 1 reply; 4+ messages in thread
From: wzt wzt @ 2010-04-14  5:50 UTC (permalink / raw)
  To: Eric Paris; +Cc: linux-kernel, linux-security-module, jmorris

still not understand,  if CONFIG_LSM_MMAP_MIN_ADDR is not set,
mmap_min_addr is equal dac_mmap_min_addr, right?
if not, mmap_min_addr is set as CONFIG_LSM_MMAP_MIN_ADDR.  what's the
effect of mmap_min_addr?  except round_hint_to_min() will use
mmap_min_addr, any other functions will call it?
Anyway, the comments need change mmap_min_addr as dac_mmap_min_addr,
right? If i'm wrong, please point it, thanks.
/*
 * If the process is attempting to map memory below mmap_min_addr they need   |{
 * CAP_SYS_RAWIO.
 */

On Wed, Apr 14, 2010 at 11:02 AM, Eric Paris <eparis@parisplace.org> wrote:
> NAK NAK NAK
>
> go back and reread the whole purpose for the separation.
>
> -Eric
>
> On Tue, Apr 13, 2010 at 10:48 PM,  <wzt.wzt@gmail.com> wrote:
>> cap_file_mmap() comments said "If the process is attempting to map
>> memory below mmap_min_addr", if CONFIG_LSM_MMAP_MIN_ADDR is set,
>> dac_mmap_min_addr is not equal mmap_min_addr, so replace dac_mmap_min_addr
>> to mmap_min_addr seems to be better.
>>
>> Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
>>
>> ---
>>  include/linux/security.h |    1 +
>>  security/commoncap.c     |    2 +-
>>  2 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/include/linux/security.h b/include/linux/security.h
>> index 233d20b..61fd9e7 100644
>> --- a/include/linux/security.h
>> +++ b/include/linux/security.h
>> @@ -101,6 +101,7 @@ void reset_security_ops(void);
>>  extern unsigned long mmap_min_addr;
>>  extern unsigned long dac_mmap_min_addr;
>>  #else
>> +#define mmap_min_addr          0UL
>>  #define dac_mmap_min_addr      0UL
>>  #endif
>>
>> diff --git a/security/commoncap.c b/security/commoncap.c
>> index 6166973..878cf89 100644
>> --- a/security/commoncap.c
>> +++ b/security/commoncap.c
>> @@ -942,7 +942,7 @@ int cap_file_mmap(struct file *file, unsigned long reqprot,
>>  {
>>        int ret = 0;
>>
>> -       if (addr < dac_mmap_min_addr) {
>> +       if (addr < mmap_min_addr) {
>>                ret = cap_capable(current, current_cred(), CAP_SYS_RAWIO,
>>                                  SECURITY_CAP_AUDIT);
>>                /* set PF_SUPERPRIV if it turns out we allow the low mmap */
>> --
>> 1.6.5.3
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Security: Replace dac_mmap_min_addr to mmap_min_addr in cap_file_mmap()
  2010-04-14  5:50   ` wzt wzt
@ 2010-04-14  7:35     ` Amerigo Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Amerigo Wang @ 2010-04-14  7:35 UTC (permalink / raw)
  To: wzt wzt; +Cc: Eric Paris, linux-kernel, linux-security-module, jmorris

On Wed, Apr 14, 2010 at 01:50:40PM +0800, wzt wzt wrote:
>still not understand,  if CONFIG_LSM_MMAP_MIN_ADDR is not set,
>mmap_min_addr is equal dac_mmap_min_addr, right?
>if not, mmap_min_addr is set as CONFIG_LSM_MMAP_MIN_ADDR.  what's the
>effect of mmap_min_addr?  except round_hint_to_min() will use
>mmap_min_addr, any other functions will call it?

round_hint_to_min() will be called by mmap().

As the names tell you, mmap_min_addr will be checked by mmap(),
dac_mmap_min_addr will be checked for CAP_SYS_RAWIO.

Please check commit 788084ab, as Eric suggested.

>Anyway, the comments need change mmap_min_addr as dac_mmap_min_addr,
>right? If i'm wrong, please point it, thanks.
>/*
> * If the process is attempting to map memory below mmap_min_addr they need   |{
> * CAP_SYS_RAWIO.
> */
>

Yes, I think the comment needs to be fixed.

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-14  7:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-14  2:48 Security: Replace dac_mmap_min_addr to mmap_min_addr in cap_file_mmap() wzt.wzt
2010-04-14  3:02 ` Eric Paris
2010-04-14  5:50   ` wzt wzt
2010-04-14  7:35     ` Amerigo Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®